コード例 #1
0
ファイル: GameController.cs プロジェクト: pushyka/chess-all
 public GameController()
 {
     gameInput = null;
     infoMessage = null;
     displayableGameModel = null;
     evaluator = null;
     gLoopThread = null;
     gameState = EGameControlState.PreInitial;
 }
コード例 #2
0
ファイル: GameController.cs プロジェクト: pushyka/chess-all
 /* This takes a value indicating a gameModel and returns the values of the displayable
 and game models and utilities to null. */
 public void UnInitialiseModel(EGameModels model)
 {
     switch(model)
     {
         case EGameModels.Chess:
             chessModel = null;
             evaluator = null;
             break;
         case EGameModels.TicTacToe:
             tictactoeModel = null;
             break;
     }
     displayableGameModel = null;
     gameState = EGameControlState.PreInitial;
 }
コード例 #3
0
ファイル: GameController.cs プロジェクト: pushyka/chess-all
 /* This takes a value indicating a gameModel and terminates any running gameLoop,
 sets some values to null and sets the models player value to null. */
 public void Terminate(EGameModels model)
 {
     //terminate t, if its running
     StopGameLoop();
     gameInput = null;
     infoMessage = null;
     switch(model)
     {
         case EGameModels.Chess:
             chessModel.Player = null;
             break;
         case EGameModels.TicTacToe:
             tictactoeModel.Player = null;
             break;
     }
     gameState = EGameControlState.Initial;
     this.Message = "Game is terminated";
 }
コード例 #4
0
ファイル: GameController.cs プロジェクト: pushyka/chess-all
 /* This takes a value indicating a gameModel and starts a new thread
 running the appropriate gameLoop for the gameModel. */
 public void StartGameLoop(EGameModels model)
 {
     switch(model)
     {
         case EGameModels.Chess:
             gLoopThread = new Thread(ChessGameLoop);
             break;
         case EGameModels.TicTacToe:
             gLoopThread = new Thread(TicTacToeGameLoop);
             break;
     }
     if (gameState == EGameControlState.Ready)
         gLoopThread.Start();
         gameState = EGameControlState.GameInProgress;
 }
コード例 #5
0
ファイル: GameController.cs プロジェクト: pushyka/chess-all
 /* This takes a value indicating a gameModel and performs the initial setup of the
 model. Mainly populating with initial starting pieces / setting the starting player. */
 public void PrepareModel(EGameModels model)
 {
     switch(model)
     {
         case EGameModels.Chess:
             chessModel.Setup();
             chessModel.Player = new Player(EGamePlayers.White);
             break;
         case EGameModels.TicTacToe:
             tictactoeModel.Setup();
             tictactoeModel.Player = new Player(EGamePlayers.X);
             break;
     }
     gameState = EGameControlState.Ready;
 }
コード例 #6
0
ファイル: GameController.cs プロジェクト: pushyka/chess-all
 /* Receives a value indicating a game model and sets up the model as
 'displayableModel' (to which the view is bound) and also
 '*Model' (which is used in the game loop etc). This method also
 sets up any dependent utilities. */
 public void InitialiseModel(EGameModels model, System.Windows.Forms.Form viewRef)
 {
     switch(model)
     {
         case EGameModels.Chess:
             displayableGameModel = new ChessPositionModel();
             chessModel = (ChessPositionModel)displayableGameModel;
             evaluator = new Evaluator();
             evaluator.ViewRef = viewRef;
             evaluator.GenerateRays();
             evaluator.GeneratePawnRays();
             break;
         case EGameModels.TicTacToe:
             displayableGameModel = new TicTacToePositionModel();
             tictactoeModel = (TicTacToePositionModel)displayableGameModel;
             break;
     }
     gameState = EGameControlState.Initial;
 }