void Awake() { // Creating Game Board this.gameBoard = new GameBoardController(this.boardView, new GameBoardModel(ROWS, COLS)); // Creating Players var userPlayer = new UserPlayer(gameBoard, TileMark.Cross); // Use different AI player settings based on selected difficulty AbstractPlayer aiPlayer; if (PlayerProfile.PreferredDifficulty == 0) { aiPlayer = new RandomAIPlayer(gameBoard, TileMark.Circle); } else { aiPlayer = new MinMaxAIPlayer(gameBoard, TileMark.Circle, PlayerProfile.PreferredDifficulty == 1 ? 0.3f : 0.0f); } this.turnManager = new TurnManager(gameBoard, userPlayer, aiPlayer); this.hudManager.Init(); // Initializing State Machine this.fsm = new SKStateMachine <GameManager>(this, new GameplayState()); this.fsm.addState(new GameoverState()); this.fsm.addState(new GameLoadingState()); #if DEBUG this.fsm.onStateChanged += () => { Debug.LogFormat("<color=green>GameManager FSM state changed to {0}</color>", this.fsm.currentState); }; #endif }
public Entity ReplaceGameBoard(GameBoardController newController) { var componentPool = GetComponentPool(CellsComponentIds.GameBoard); var component = (GameBoardComponent)(componentPool.Count > 0 ? componentPool.Pop() : new GameBoardComponent()); component.Controller = newController; ReplaceComponent(CellsComponentIds.GameBoard, component); return this; }
void Awake() { corpo = gameObject.GetComponent<Rigidbody> (); controller = GameObject.Find ("GameBoardController").GetComponent<GameBoardController>(); GameObject botao_de_rolar = GameObject.Find ("Button"); botao_op= botao_de_rolar.GetComponent<Button> (); }
public GameBoardRenderer(GameInstance gameInstance, GameBoardController gameBoardController, GameEventHub eventHub) { _gameInstance = gameInstance; _gameBoardController = gameBoardController; _eventHub = eventHub; _camera = Camera2D.Instance; }
// given a string postName of "0-0" representing row-column, ask the GameBoardController how many pieces // exist on that specific gameBoardPost private int caclulatePiecesOnPost() { string[] rowAndColumn = this.name.Split('-'); int row = int.Parse(rowAndColumn[0]); int column = int.Parse(rowAndColumn[1]); int piecesOnPost = GameBoardController.findPiecesOnPostForRowAndColumn(row, column); return piecesOnPost; }
public Entity SetGameBoard(GameBoardController newController) { if (hasGameBoard) { throw new EntitasException("Could not set gameBoard!\n" + this + " already has an entity with GameBoardComponent!", "You should check if the pool already has a gameBoardEntity before setting it or use pool.ReplaceGameBoard()."); } var entity = CreateEntity(); entity.AddGameBoard(newController); return entity; }
public override void Initialize() { HistoryLog.Initialize(_assetManager.Font, 400, _assetManager); HistoryLog.Instance.SortOrder = Camera2D.SortUI + 100; HistoryLog.Instance.Hidden = false; AddAndInitializeRootEntity(HistoryLog.Instance, _assetManager); var cursorSprite = _assetManager[AssetManager.CrosshairCursor]; var crosshairCursor = CreateRootEntity(Camera2D.SortUI + 10000); crosshairCursor.Renderer = new SpriteRenderer(cursorSprite); crosshairCursor.AddComponent(() => { crosshairCursor.Position = InputManager.Instance.MousePosition.ToVector2() - cursorSprite.Bounds.Size.ToVector2() / 2; }); Camera2D.Instance.Translate = new Vector3(600, 400, 0); var gameBoardEntity = CreateRootEntity(Camera2D.SortBackground); gameBoardEntity.AddComponent(() => { if (InputManager.Instance.IsKeyJustPressed(Keys.P)) { Terminate(); } }); _gameBoardController = new GameBoardController(_game, crosshairCursor, this, _replay); _gameBoardController.GameFinishedCallback = () => GameFinishedCallback?.Invoke(); gameBoardEntity.AddComponent(_gameBoardController); gameBoardEntity.CustomBatch = true; BuildUi(); foreach (var mobId in _game.MobManager.Mobs) { var mobAnimationController = new MobAnimationController(_game); var mobEntity = new MobEntity(mobId, _game) { SortOrder = Camera2D.SortMobs, Renderer = new MobRenderer(_game, mobId, mobAnimationController), Transform = () => Camera2D.Instance.Transform }; mobEntity.AddComponent(mobAnimationController); AddAndInitializeRootEntity(mobEntity, _assetManager); MobEntities[mobId] = mobEntity; } }
public SpellRenderer(GameInstance game, GameBoardController gameBoardController, Func <CachedMob> mobFunc, int abilityIndex) { _game = game; _gameBoardController = gameBoardController; _mobFunc = mobFunc; _abilityIndex = abilityIndex; }
public Entity ReplaceGameBoard(GameBoardController newController) { var entity = gameBoardEntity; if (entity == null) { entity = SetGameBoard(newController); } else { entity.ReplaceGameBoard(newController); } return entity; }
// undo the lastMove // entry into this method comes as a result of two things; 1) a player has clicked on the // undo button and, 2) the .Update() method of this class has picked up the truthy value of // undoLastMoveButtonControllerScript.shouldUndoLastMove. private void revertLastMove() { undoLastMoveButtonControllerScript.disable(); inturruptUndoLastMoveCoroutine(); PlayerMoveModel lastMove = GameBoardHistory.findLastPlayerMove(); if (GameBoardHistory.removeLastMoveFromHistory() && GameBoardController.removePlayerAtPoint(lastMove)) { removePlayerPieceFromPost(lastMove); finalizePlayerChange(); } }
// perform system cleanups and updates after a move has been made successfully // check for a win and stop the game if one is found. private void didExecutePlayerMove(string postName, PlayerMoveModel playerMove) { FormationModel winningFormation = GameBoardController.findWinningFormation(playerMove); if (winningFormation != null) { inturruptUndoLastMoveCoroutine(); isComplete = true; // show winning formation PlayerScoreController.declareWinner(playerMove.player); buildWinnerText(); return; } undoLastMoveCoroutine = enableUndoLastMove(); StartCoroutine(undoLastMoveCoroutine); }
void OnDestroy() { piece.PieceTouch -= OnPieceTouch; if(gameBoardController != null) { gameBoardController = null; } }
void Awake() { Application.targetFrameRate = 25; gameBoardController = this; GoogleMobileAdsController.Instance.ShowInterstitial(); GoogleMobileAdsController.Instance.HideBanner(); timer = MAX_TIME; SetInitialGameSettings(); //MultiplayerController.Instance.SignInAndStartMPGame(); MultiplayerController.Instance.TrySilentSignIn(); }
public EndCurrentTurn() { control = FindObjectsOfType <GameBoardController>()[0]; endTheTurn(); }
public GameApiTest() { _gameBoardController = new GameBoardController(new GameService()); }
void Awake() { corpo = gameObject.GetComponent<Rigidbody> (); controller = GameObject.Find ("GameBoardController").GetComponent<GameBoardController>(); }
public RandomAIPlayer(GameBoardController board, TileMark playerType) : base(board, playerType) { }
////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// // place player piece in the view on the selected post private void executePlayerMove(PlayerMoveModel playerMove, Vector3 postPosition, string postName) { GameBoardController.addPlayerAtPoint(playerMove); GameBoardHistory.addMoveToHistory(playerMove); placePlayerPieceOnPost(postPosition, postName, playerMove.player); }
public void resetGame() { GameBoardController.resetGameBoard(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); }
public MinMaxAIPlayer(GameBoardController board, TileMark playerType, float errorProbability) : base(board, playerType) { this.errorProbability = errorProbability; MinMaxTree.Instance.PrepareTree(); }
public UserPlayer(GameBoardController board, TileMark playerType) : base(board, playerType) { }
public TurnManager(GameBoardController board, params AbstractPlayer[] players) { this.gameBoard = board; this.players = players; this.dOnMoveCompleted = this.OnMoveCompleted; }
public AbstractPlayer(GameBoardController board, TileMark defaultType) { this.board = board; this.PrepareForGame(defaultType); }