public GameStateController()
    {
        gameFsm       = new FSM("GameFSM");
        preStartState = gameFsm.AddState((byte)GameState.PreStart);
        idleState     = gameFsm.AddState((byte)GameState.Idle);
        playState     = gameFsm.AddState((byte)GameState.Play);
        pauseState    = gameFsm.AddState((byte)GameState.Pause);
        gameOverState = gameFsm.AddState((byte)GameState.GameOver);

        preStartAction = new PreStartAction(preStartState);
        playingAction  = new PlayAction(playState);
        pauseAction    = new PauseAction(pauseState);
        gameOverAction = new GameOverAction(gameOverState);
        idleAction     = new IdleAction(idleState);

        preStartState.AddTransition((byte)FSMTransition.ToIdle, idleState);
        idleState.AddTransition((byte)FSMTransition.ToPlay, playState);
        playState.AddTransition((byte)FSMTransition.ToPause, pauseState);
        playState.AddTransition((byte)FSMTransition.ToGameOver, gameOverState);
        gameOverState.AddTransition((byte)FSMTransition.ToIdle, idleState);

        preStartAction.Init();
        idleAction.Init();
        playingAction.Init();
        pauseAction.Init();
        gameOverAction.Init();
    }
        private IEnumerator CancelWithMessageResponse(GameOverAction go)
        {
            IEnumerator coroutine;

            if (!HasBeenSetToTrueThisGame("HeroesCannotWinMessage"))
            {
                coroutine = base.GameController.SendMessageAction($"The heroes cannot win the game while {Card.Title} is active!", Priority.Critical, GetCardSource(), showCardSource: true);
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                SetCardPropertyToTrueIfRealAction("HeroesCannotWinMessage");
            }
            coroutine = CancelAction(go);
            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }
            yield break;
        }
Esempio n. 3
0
        public void Hit(Point point)
        {
            var ship = ships.FirstOrDefault(n => n.Points.Any(p => p == point));

            if (ship == null)
            {
                MissPoints.Add(point);
                var btn = Buttons.First(n => n.Coordinates() == point);
                btn.IsEnabled       = false;
                btn.BackgroundColor = Color.DarkBlue;
                btn.BorderColor     = Color.DarkBlue;
            }
            else
            {
                ship.HitPoints.Add(point);
                if (ship.Sank)
                {
                    var btns = new List <Button>();
                    ship.Points.ForEach(n => btns.Add(Buttons.First(b => b.Coordinates() == n)));
                    btns.ForEach(b =>
                    {
                        b.IsEnabled       = false;
                        b.BackgroundColor = Color.DarkRed;

                        b.FontAttributes = FontAttributes.Bold;
                    });
                }
                else
                {
                    var btn = Buttons.First(b => b.Coordinates() == point);
                    btn.IsEnabled       = false;
                    btn.BackgroundColor = Color.Red;
                }
            }
            if (ships.All(n => n.Sank))
            {
                GameOverAction.Invoke();
            }
        }
Esempio n. 4
0
    //check if current puzzle data matches loaded puzzle data
    void CheckGameOver(CellData cellData)
    {
        for (int r = 0; r < targetPuzzleData.RowCount; r++)
        {
            for (int c = 0; c < targetPuzzleData.ColCount; c++)
            {
                //only necessary to check all filled cells
                if (cellData.Cells[r, c] == CellType.Filled || targetPuzzleData.cellData.Cells[r, c] == CellType.Filled)
                {
                    //compare CellTypes; stop checking once a match isn't found
                    if (cellData.Cells[r, c] != targetPuzzleData.cellData.Cells[r, c])
                    {
                        return;
                    }
                }
            }
        }

        //if all filled cells in game match text file data, call gameover functions
        currentPuzzleData.completionStatus = CompletionStatus.Complete;
        targetPuzzleData.SaveAsCompletedImage();
        GameOverAction?.Invoke();
    }
 public static void doDone(GameOverAction actionObject)
 {
     SceneViews.instance.getCurFBScene().setActorsAnimatorController(true);
 }
Esempio n. 6
0
 public void GameOverInvoke()
 {
     GameOverAction?.Invoke();
 }