⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gamedata.java

📁 国外人写的操作感挺好的一款滑雪游戏.结构也比较清楚
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
//#ifdef _MULTI_LANG
//	public boolean		bLanguageSet;
//	public int			iLang;
//#endif
	
	// PlayerData
	int		aiCountry[] = new int[4/*@MAX_TOTAL_PLAYERS*/];					// selected country for the player
//#ifdef _LIMITED_EVENTS
	int		aiResults[][] = new int[4/*@MAX_TOTAL_PLAYERS*/][3/*@EVENT_COUNT*/];
//#else
//	int		aiResults[][][] = new int[4/*@MAX_TOTAL_PLAYERS*/][3/*@EVENT_COUNT*/][3/*@MAX_ATTEMPTS*/];
//#endif
	int		aiTotalScore[] = new int[4/*@MAX_TOTAL_PLAYERS*/];				// total competition score
	int		aiAttempt[] = new int[4/*@MAX_TOTAL_PLAYERS*/];					// which attempt are we on?
	String	asName[] = new String[4/*@MAX_TOTAL_PLAYERS*/];					// player name
	
	// RecordData
	int			aiRecordScores[][] = new int[3/*@EVENT_COUNT*/+1][10/*@NUM_LOCAL_RECORDS*/];
	String		asRecordNames[][] = new String[3/*@EVENT_COUNT*/+1][10/*@NUM_LOCAL_RECORDS*/];
	boolean		abRecordNew[][] = new boolean[3/*@EVENT_COUNT*/+1][10/*@NUM_LOCAL_RECORDS*/];	// indicates if this is a new local record

	// SettingsData
//#ifndef _NO_ONLINE
//#ifndef _IS_SPRINT
//	String		sOnlineName = new String();			// online nickname
//	boolean		bOnlineNameSet;						// online name has been set
//#endif
//	int			iLastTransmit;						// last score transmitted
//#endif
	boolean		bDisableSound;						// disable sound effects
	boolean		bDisableTips;						// disable event tips
	int			iDifficulty;						// difficulty level
	
	// event data
	int					iEvent;					// current event
	int					iElapsedTime;			// time elapsed in current event
	int					iState;					// event state
	int					iLastUpdateTime;		// last update time (event time)
	int					iStateStartTime;		// state start time (event time)

	//shared variables
	SimData				aSimData[] = new SimData[2/*@NUM_ATHLETES*/];
	int					aiAthleteState[] = new int[2/*@NUM_ATHLETES*/];
	boolean				bFault;
	boolean				bWasPaused;
	int					iGoTime[]  = new int[2/*@NUM_ATHLETES*/];
	int					iTimeWindow[] = new int[2/*@NUM_ATHLETES*/];
	int					iPreviousTime[] = new int[2/*@NUM_ATHLETES*/];	
	//int					aiAnimationFrame[] = new int[NUM_ATHLETES];
	int					iPenaltyTime;
		
	//skating
	int					iNextButton;
	int					iCPUDeltaV;
	int					iCPUDeltaTime;
	int					iCursorTime;
	int					iAINation;

	//skijump
	boolean				bHasJumped;
	boolean				bIsCrashed;
	boolean				bPlayerDone[] = new boolean[2/*@NUM_ATHLETES*/];
	int					fpGroundY;
	int					fpStartingXPos;
	int					fpAirDecel[] = new int[2/*@NUM_ATHLETES*/];
	int					fpDistanceScore;
	int					fpStyleScore;
	int					fpTotalScore;
	int					iPressTime;
	int					iTotalAirTime;
	int					iCorrectTime;
	int					fpJumpPower;
	int					iManualUpdate;
	int					aiFrame[] = new int[2/*@NUM_ATHLETES*/];
	int					iLastFrame;
	int					iRampSections;
	int					iLastSection;
	int					iBalance;
	int					iPressed;

	//biathlon
	int					iStartTime;
	int					iTargetTime[] = new int[5/*@NUM_TARGETS*/];
	int					iScrollX;
	int					iRifleState;
	int					iGhostTime;
	int					iGhostPrevTime;
	int					iYScroll;
	int					iYInitial;
	int					iCrosshairPos;
	int					iCurrentSprite[] = new int[2/*@NUM_ATHLETES*/];
	int					iCrosshairDir;
	int					iTargetOffset;
	int					iCurrentScreen[] = new int[2/*@NUM_ATHLETES*/];
	int					iCurrentBackground[] = new int[2/*@NUM_ATHLETES*/];
	int					iCurrentTarget;
	int					aiRands[] = new int[20];
	int					iHeartRate;
	boolean				bYScrolling;
	boolean				bRightFoot;
	boolean				bInShootingArea[] = new boolean[2/*@NUM_ATHLETES*/];
	boolean				bDoneShooting[] = new boolean[2/*@NUM_ATHLETES*/];
	boolean				bTargetHit[] = new boolean[5/*@NUM_TARGETS*/];
	boolean				bAnimating;
	boolean				bEndEvent;

	//slalom
	int					iDirection;
	int					iGhostDirection;
	int					iLean;
	int					iGhostLean;
	int					iLastTurnTime;
	int					iGhostTurnTime;
	int					aiCurrentSprite[] = new int[2/*@NUM_ATHLETES*/];
	int					iNextGate;
	int					iFirstVisibleGate;
	int					aiBrushTime[] = new int[8/*@GATE_CACHE_SIZE*/];  // time we hit the gate
	int					aiBrushFlag[] = new int[8/*@GATE_CACHE_SIZE*/];  // which flag of the gate did we hit?
	int					aiBrushRtoL[] = new int[8/*@GATE_CACHE_SIZE*/];  // which side of the flag did we hit?
	boolean				bRecoverFlash;

	boolean				bInitialized;			// event data is initialized
	boolean				bEventLoading;

//#ifndef _NO_GHOST
//	String				sGhostName = new String();
//	int					iGhostScore;
//	
//	//Hack variables for challenge mode
//	boolean					bGhostOnlineNameSearch;
//	boolean					bGhostScoreSearch;
//#endif
	int						iMaxPlayers;
	
	public GameData()
	{
		for( int i = 0; i < 4/*@MAX_TOTAL_PLAYERS*/; i++ )
			asName[i] = new String();
			
		for( int i = 0; i < 3/*@EVENT_COUNT*/ + 1; i++ )
		{
			for (int j = 0; j < 10/*@NUM_LOCAL_RECORDS*/; j++ )
			{
				asRecordNames[i][j] = new String();
			}
		}
		
		for( int i = 0; i < 2/*@NUM_ATHLETES*/; i++ )
			aSimData[i] = new SimData();
	}
	
	public void read( DataInputStream ds )
		throws IOException
	{
		// structure version
		ubyVersion = ds.readInt();
	
		// game mode data
		iGameMode = ds.readInt();
		
		// CompetitionData
		iNumPlayers = ds.readInt();
		iCurrentPlayer = ds.readInt();
//#ifndef _NO_ONLINE
//		bOnline = ds.readBoolean();
//#endif
		bCompetitionInitialized = ds.readBoolean();
			
		//PlayerData
		for ( int i = 0; i < 4/*@MAX_TOTAL_PLAYERS*/; i++ )
		{
			for ( int j = 0; j < 3/*@EVENT_COUNT*/; j++ )
			{
//#ifdef _LIMITED_EVENTS
				aiResults[i][j] = ds.readInt();
//#else
//				for ( int k = 0; k < 3/*@MAX_ATTEMPTS*/; k++ )
//				{
//					aiResults[i][j][k] = ds.readInt();
//				}
//#endif
			}
			
			aiCountry[i] = ds.readInt();
			aiTotalScore[i] = ds.readInt();
			aiAttempt[i] = ds.readInt();
			asName[i] = ds.readUTF();
		}

		// RecordData	
		for ( int i = 0; i < 3/*@EVENT_COUNT*/+1; i++ )
		{
			for ( int j = 0; j < 10/*@NUM_LOCAL_RECORDS*/; j++ )
			{
				aiRecordScores[i][j] = ds.readInt();
				asRecordNames[i][j] = ds.readUTF();
				abRecordNew[i][j] = ds.readBoolean();
			}	
		}

		// SettingsData
//#ifndef _NO_ONLINE
//#ifndef _IS_SPRINT
//		sOnlineName = ds.readUTF();
//		bOnlineNameSet = ds.readBoolean();
//#endif
//		iLastTransmit = ds.readInt();
//#endif
		bDisableSound = ds.readBoolean();
		bDisableTips = ds.readBoolean();
		iDifficulty = ds.readInt();
		
		// event data
		iEvent = ds.readInt();
		iElapsedTime = ds.readInt();
		iState = ds.readInt();
		iLastUpdateTime = ds.readInt();
		iStateStartTime = ds.readInt();

		//shared variables
		for ( int i = 0; i < 2/*@NUM_ATHLETES*/; i++ )
		{
			aSimData[i].read(ds);
			aiAthleteState[i] = ds.readInt();
			iGoTime[i] = ds.readInt();
			iTimeWindow[i] = ds.readInt();
			iPreviousTime[i] = ds.readInt();
			//aiAnimationFrame[i] = ds.readInt();
			aiFrame[i] = ds.readInt();
		}
		
		bFault = ds.readBoolean();
		bWasPaused = ds.readBoolean();
		iPenaltyTime = ds.readInt();
		
		//skating
		iNextButton = ds.readInt();
		iCPUDeltaV = ds.readInt();
		iCPUDeltaTime = ds.readInt();
		iCursorTime = ds.readInt();
		iAINation = ds.readInt();

		//skijump
		bHasJumped = ds.readBoolean();
		bIsCrashed = ds.readBoolean();

		fpGroundY = ds.readInt();
		fpStartingXPos = ds.readInt();

		fpDistanceScore = ds.readInt();
		fpStyleScore = ds.readInt();
		fpTotalScore = ds.readInt();
		iPressTime = ds.readInt();
		iTotalAirTime = ds.readInt();
		iCorrectTime = ds.readInt();
		fpJumpPower = ds.readInt();
		iManualUpdate = ds.readInt();
		iRampSections = ds.readInt();
		iLastSection = ds.readInt();
		iBalance = ds.readInt();
		iPressed = ds.readInt();

		for ( int i = 0; i < 2/*@NUM_ATHLETES*/; i++ )
		{
			bPlayerDone[i] = ds.readBoolean();
			fpAirDecel[i] = ds.readInt();
		}

		//biathlon
		iStartTime = ds.readInt();
		iScrollX = ds.readInt();
		iRifleState = ds.readInt();
		iGhostTime = ds.readInt();
		iGhostPrevTime = ds.readInt();
		iYScroll = ds.readInt();
		iYInitial = ds.readInt();
		iCrosshairPos = ds.readInt();
		iCrosshairDir = ds.readInt();
		iTargetOffset = ds.readInt();
		iCurrentTarget = ds.readInt();
		iHeartRate = ds.readInt();
		bYScrolling = ds.readBoolean();
		bRightFoot = ds.readBoolean();
		bAnimating = ds.readBoolean();
		bEndEvent = ds.readBoolean();
		
		for ( int i = 0; i < 20; i++ )
			aiRands[i] = ds.readInt();
		
		for ( int i = 0; i < 2/*@NUM_ATHLETES*/; i++ )
		{
			iCurrentSprite[i] = ds.readInt();
			iCurrentScreen[i] = ds.readInt();
			iCurrentBackground[i] = ds.readInt();
			bInShootingArea[i] = ds.readBoolean();
			bDoneShooting[i] = ds.readBoolean();
		}
		
		for ( int i = 0; i < 5/*@NUM_TARGETS*/; i++ )
		{
			iTargetTime[i] = ds.readInt();
			bTargetHit[i] = ds.readBoolean();
		}
		
		//slalom
		iDirection = ds.readInt();
		iGhostDirection = ds.readInt();
		iLean = ds.readInt();
		iGhostLean = ds.readInt();
		iLastTurnTime = ds.readInt();
		iGhostTurnTime = ds.readInt();
		iNextGate = ds.readInt();
		iFirstVisibleGate = ds.readInt();
		bRecoverFlash = ds.readBoolean();
		
		for ( int i = 0; i < 2/*@NUM_ATHLETES*/; i++ )
			aiCurrentSprite[i] = ds.readInt();
		
		for ( int i = 0; i < 8/*@GATE_CACHE_SIZE*/; i++ )
		{
			aiBrushTime[i] = ds.readInt();
			aiBrushFlag[i] = ds.readInt();
			aiBrushRtoL[i] = ds.readInt();
		}
		

		bInitialized = ds.readBoolean();
		bEventLoading = ds.readBoolean();
//#ifndef _NO_GHOST
//		sGhostName = ds.readUTF();
//		iGhostScore = ds.readInt();
//		
//		bGhostOnlineNameSearch = ds.readBoolean();
//		bGhostScoreSearch = ds.readBoolean();
//#endif
		iMaxPlayers = ds.readInt();
	}
	
	public void write( DataOutputStream ds )
		throws IOException
	{
		// structure version
		ds.writeInt( ubyVersion );
	
		// game mode data
		ds.writeInt( iGameMode );
		
		// CompetitionData
		ds.writeInt( iNumPlayers );
		ds.writeInt( iCurrentPlayer );
//#ifndef _NO_ONLINE
//		ds.writeBoolean( bOnline );
//#endif
		ds.writeBoolean( bCompetitionInitialized );
			
		//PlayerData
		for ( int i = 0; i < 4/*@MAX_TOTAL_PLAYERS*/; i++ )
		{
			for ( int j = 0; j < 3/*@EVENT_COUNT*/; j++ )
			{
//#ifdef _LIMITED_EVENTS
				ds.writeInt( aiResults[i][j] );
//#else
//				for ( int k = 0; k < 3/*@MAX_ATTEMPTS*/; k++ )
//				{
//					ds.writeInt( aiResults[i][j][k] );
//				}
//#endif
			}
			
			ds.writeInt( aiCountry[i] );
			ds.writeInt( aiTotalScore[i] );
			ds.writeInt( aiAttempt[i] );
			ds.writeUTF( asName[i] );
		}

		// RecordData	
		for ( int i = 0; i < 3/*@EVENT_COUNT*/+1; i++ )
		{
			for ( int j = 0; j < 10/*@NUM_LOCAL_RECORDS*/; j++ )
			{
				ds.writeInt( aiRecordScores[i][j] );
				ds.writeUTF( asRecordNames[i][j] );
				ds.writeBoolean( abRecordNew[i][j] );
			}	
		}

		// SettingsData
//#ifndef _NO_ONLINE
//#ifndef _IS_SPRINT
//		ds.writeUTF( sOnlineName );
//		ds.writeBoolean( bOnlineNameSet );
//#endif
//		ds.writeInt( iLastTransmit );
//#endif
		ds.writeBoolean( bDisableSound );
		ds.writeBoolean( bDisableTips );
		ds.writeInt( iDifficulty );
		
		// event data
		ds.writeInt( iEvent );
		ds.writeInt( iElapsedTime );
		ds.writeInt( iState );
		ds.writeInt( iLastUpdateTime );
		ds.writeInt( iStateStartTime );

		//shared variables
		for ( int i = 0; i < 2/*@NUM_ATHLETES*/; i++ )
		{
			aSimData[i].write(ds);
			ds.writeInt( aiAthleteState[i] );
			ds.writeInt( iGoTime[i] );
			ds.writeInt( iTimeWindow[i] );
			ds.writeInt( iPreviousTime[i] );
			//ds.writeInt( aiAnimationFrame[i] );
			ds.writeInt( aiFrame[i] );
		}
		
		ds.writeBoolean( bFault );
		ds.writeBoolean( bWasPaused );
		ds.writeInt( iPenaltyTime );
		
		//skating
		ds.writeInt( iNextButton );
		ds.writeInt( iCPUDeltaV );
		ds.writeInt( iCPUDeltaTime );
		ds.writeInt( iCursorTime );
		ds.writeInt( iAINation );

		//skijump
		ds.writeBoolean( bHasJumped );
		ds.writeBoolean( bIsCrashed );

		ds.writeInt( fpGroundY );
		ds.writeInt( fpStartingXPos );

		ds.writeInt( fpDistanceScore );
		ds.writeInt( fpStyleScore );
		ds.writeInt( fpTotalScore );
		ds.writeInt( iPressTime );
		ds.writeInt( iTotalAirTime );
		ds.writeInt( iCorrectTime );
		ds.writeInt( fpJumpPower );
		ds.writeInt( iManualUpdate );
		ds.writeInt( iRampSections );
		ds.writeInt( iLastSection );
		ds.writeInt( iBalance );
		ds.writeInt( iPressed );

		for ( int i = 0; i < 2/*@NUM_ATHLETES*/; i++ )
		{
			ds.writeBoolean( bPlayerDone[i] );
			ds.writeInt( fpAirDecel[i] );
		}

		//biathlon
		ds.writeInt( iStartTime );
		ds.writeInt( iScrollX );
		ds.writeInt( iRifleState );
		ds.writeInt( iGhostTime );
		ds.writeInt( iGhostPrevTime );
		ds.writeInt( iYScroll );
		ds.writeInt( iYInitial );
		ds.writeInt( iCrosshairPos );
		ds.writeInt( iCrosshairDir );
		ds.writeInt( iTargetOffset );
		ds.writeInt( iCurrentTarget );
		ds.writeInt( iHeartRate );
		
		ds.writeBoolean( bYScrolling );
		ds.writeBoolean( bRightFoot );
		ds.writeBoolean( bAnimating );
		ds.writeBoolean( bEndEvent );
		
		for ( int i = 0; i < 20; i++ )
			ds.writeInt( aiRands[i] );
		
		for ( int i = 0; i < 2/*@NUM_ATHLETES*/; i++ )
		{
			ds.writeInt( iCurrentSprite[i] );
			ds.writeInt( iCurrentScreen[i] );
			ds.writeInt( iCurrentBackground[i] );
			ds.writeBoolean( bInShootingArea[i] );
			ds.writeBoolean( bDoneShooting[i] );
		}
		
		for ( int i = 0; i < 5/*@NUM_TARGETS*/; i++ )
		{
			ds.writeInt( iTargetTime[i] );
			ds.writeBoolean( bTargetHit[i] );
		}
		
		//slalom
		ds.writeInt( iDirection );
		ds.writeInt( iGhostDirection );
		ds.writeInt( iLean );
		ds.writeInt( iGhostLean );
		ds.writeInt( iLastTurnTime );
		ds.writeInt( iGhostTurnTime );
		ds.writeInt( iNextGate );
		ds.writeInt( iFirstVisibleGate );
		ds.writeBoolean( bRecoverFlash );
		
		for ( int i = 0; i < 2/*@NUM_ATHLETES*/; i++ )
			ds.writeInt( aiCurrentSprite[i] );
		
		for ( int i = 0; i < 8/*@GATE_CACHE_SIZE*/; i++ )
		{
			ds.writeInt( aiBrushTime[i] );
			ds.writeInt( aiBrushFlag[i] );
			ds.writeInt( aiBrushRtoL[i] );
		}
		

		ds.writeBoolean( bInitialized );
		ds.writeBoolean( bEventLoading );
//#ifndef _NO_GHOST
//		ds.writeUTF( sGhostName );
//		ds.writeInt( iGhostScore );
//		
//		ds.writeBoolean( bGhostOnlineNameSearch );
//		ds.writeBoolean( bGhostScoreSearch );
//#endif
		ds.writeInt( iMaxPlayers );
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -