当前位置: 首页>>代码示例>>C#>>正文


C# IBoard.SwitchStones方法代码示例

本文整理汇总了C#中IBoard.SwitchStones方法的典型用法代码示例。如果您正苦于以下问题:C# IBoard.SwitchStones方法的具体用法?C# IBoard.SwitchStones怎么用?C# IBoard.SwitchStones使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBoard的用法示例。


在下文中一共展示了IBoard.SwitchStones方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FSM_SinglePlayer

		/// <summary>
		/// Single player mode
		/// </summary>
		/// <param name="gameLogic"></param>
		/// <param name="models"></param>
		/// <param name="gameSettings"></param>
		#region private static void FSM_SinglePlayer(...)
		private static void FSM_SinglePlayer(Connect4Game gameLogic, GameSettings gameSettings, IBoard board)
		{
			switch (gameLogic.GameState)
			{
			case GameSettings.GAMESTATE.S_BeforeGame:
			{
				if (gameLogic.STARTING_PLAYER == gameSettings.RED_PLAYER)
				{
					gameLogic.GameState = GameSettings.GAMESTATE.S_Player1Move;
					gameLogic.HUMAN_PLAYER = gameSettings.RED_PLAYER;
				}
				else
				{
					gameLogic.GameState = GameSettings.GAMESTATE.S_WaitForCPU;
					gameLogic.HUMAN_PLAYER = gameSettings.YELLOW_PLAYER;
				}

				break;
			}
			case GameSettings.GAMESTATE.S_Player1Move:
			{
				//HandleMouseInput(gameSettings, gameLogic);
				
				//HandleKeyInput(gameSettings, gameLogic);
				
				break;
			}
			case GameSettings.GAMESTATE.S_DropPlayerStone:
			{
				if (board.DropStone(gameLogic))
				{
					if (board.Bounce())
						gameLogic.GameState = GameSettings.GAMESTATE.S_SwitchPlayer;
				}
				
				break;
			}
			case GameSettings.GAMESTATE.S_SwitchPlayer:
			{
				// Change player
				gameLogic.SwitchPlayer();
				
				gameLogic.CheckIfFinished();
				
				
				if (gameLogic.NextGameState == GameSettings.GAMESTATE.S_GameFinished)
				{
					gameLogic.GameState = GameSettings.GAMESTATE.S_GameFinished;
				}
				else
				{
					board.SwitchStones(gameLogic);
					
					if (gameLogic.activePlayer == gameSettings.RED_PLAYER)
					{
						// Reset stone position for the next new stone
						gameLogic.SetNextPlayerStone();
						
						gameLogic.GameState = GameSettings.GAMESTATE.S_Player1Move;
					}
					else
					{
						gameLogic.GameState = GameSettings.GAMESTATE.S_WaitForCPU;
					}
				}
				
				break;
			}
			case GameSettings.GAMESTATE.S_WaitForCPU:
			{
				// Start the AI
				if (!gameLogic.AIStarted)
				{
					gameLogic.CPUMove();
				}
				
				if (gameLogic.NextGameState == GameSettings.GAMESTATE.S_DropCPUStone)
				{
					gameLogic.AbortAI();

					board.Update(gameLogic.column * board.ColumnDistance);
					
					gameLogic.GameState = GameSettings.GAMESTATE.S_DropCPUStone;
				}
				break;
			}
			case GameSettings.GAMESTATE.S_DropCPUStone:
			{
				if (board.DropStone(gameLogic))
				{
					if (board.Bounce())
						gameLogic.GameState = GameSettings.GAMESTATE.S_SwitchPlayer;
				}
//.........这里部分代码省略.........
开发者ID:mantenpanther,项目名称:MonoConnect,代码行数:101,代码来源:FSM.cs


注:本文中的IBoard.SwitchStones方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。