Esempio n. 1
0
        /// <summary>
        /// Reset state and create new field, updating current field instance
        /// </summary>
        public void DoInitField()
        {
            State = DirectorState.Ready;

            TheGame.Me.CreateField((new System.Random()).Next(150));
            FieldView.SyncField();
            ActiveAction = new GameAction("none");
        }
Esempio n. 2
0
 // Start is called before the first frame update
 void Start()
 {
     if (FieldView == null)
     {
         throw new System.NullReferenceException("No fieldView in game.");
     }
     State        = DirectorState.Init;
     ActiveAction = new GameAction("InitGame");
 }
Esempio n. 3
0
        /// <summary>
        /// Set Cleaning state to repeatedly ClearSolutions
        /// </summary>
        public void ClearAllSolutions()
        {
            if (State != DirectorState.Ready)
            {
                return;
            }

            State        = DirectorState.Cleaning;
            ActiveAction = new GameAction("CleanUpSolutions");
        }
Esempio n. 4
0
    private void Update()
    {
        if (State == DirectorState.game)
        {
            if (Manager.Processing.Count == 0)
            {
                var team0         = 0;
                var team1         = 0;
                var hasAnyControl = false;

                foreach (var character in Manager.Characters)
                {
                    if (character.Team == 0)
                    {
                        team0++;
                    }
                    else if (character.Team == 1)
                    {
                        team1++;
                    }

                    if (!hasAnyControl && character.Control > 0)
                    {
                        hasAnyControl = true;
                    }
                }

                if (team0 > 0 && team1 == 0)
                {
                    Manager.Team = 0;
                    State        = DirectorState.redWins;
                }
                else if (team1 > 0 && team0 == 0)
                {
                    Manager.Team = 1;
                    State        = DirectorState.blueWins;
                }
                else if (!hasAnyControl)
                {
                    State = DirectorState.draw;
                }
                else if (team0 == 0 && team1 == 0)
                {
                    State = DirectorState.draw;
                }
            }
        }
        else
        {
            Manager.Stop();
            Manager.enabled = false;
            Manager.Grid.ClearStatus();
        }
    }
Esempio n. 5
0
        private void CleanupSolutions()
        {
            if (FieldView.State == FieldStates.Ready)
            {
                switch (ActiveAction.Step)
                {
                case 0: // remove solved tokens

                    TheGame.Me.Field.GetLines();
                    ActiveAction.Step = 1;
                    break;

                case 1: // Slide existing tokens to fill gaps
                    Game.Field.Slide();
                    if (Game.Field.GetLines(FindAndKill: false))
                    {
                        ActiveAction.Step = 0;
                    }
                    else
                    {
                        ActiveAction.Step = 2;
                    }
                    break;

                case 2: // Everything is clear and nothing to slide => add new tokens to fill up
                        //FieldView.RemoveSolution();
                    Game.Field.FillOneLine();
                    if (!Game.Field.Complete)
                    {
                        return;
                    }

                    if (Game.Field.GetLines(FindAndKill: false))
                    {
                        ActiveAction.Step = 0;
                    }
                    else
                    {
                        State        = DirectorState.Ready;
                        ActiveAction = new GameAction("none");
                    }
                    break;
                }
            }
        }
Esempio n. 6
0
    void TransitionToState(DirectorState newState)
    {
        directorState = newState;

        switch (directorState)
        {
        case DirectorState.LoadingLevel:
            StartLoadingLevel();
            break;

        case DirectorState.AwaitingLevelStart:
            StartAwaitingLevelStart();
            break;

        case DirectorState.InMainWave:
            StartInMainWave();
            break;

        case DirectorState.LoadingBossWave:
            StartLoadingBossWave();
            break;

        case DirectorState.AwaitingBossWaveStart:
            StartAwaitingBossWaveStart();
            break;

        case DirectorState.InBossWave:
            StartInBossWave();
            break;

        case DirectorState.GameOverLoss:
            StartGameOverLoss();
            break;

        case DirectorState.GameOverWin:
            StartGameOverWin();
            break;
        }
    }
Esempio n. 7
0
 public void Restart()
 {
     State           = DirectorState.game;
     Manager.enabled = true;
     Manager.Restart();
 }