Esempio n. 1
0
    public void EndTurn()
    {
        ActiveTurn = false;

        if (this.GameState == GameState.AttackerTurn)
        {
            this.GameState = GameState.DefenderTurn;
            this.AttackerUI.SetActive(false);
            this.DefenderUI.SetActive(true);
            TurnText.text  = "Defender's\nTurn";
            TurnText.color = new Color(0, .5F, 1F);

            this.WaterLeavingSystemOnLastTurnChange = this.WaterFlowController.TickModules();
            foreach (WaterObject w in this.WaterLeavingSystemOnLastTurnChange)
            {
                ScoreController.AddDefenderScore(w.GetWaterScore());
            }
            TurnText.transform.Rotate(0, 0, 180);
            ScoreController.RotateScoreText(180);
            AttackerUICover.gameObject.SetActive(true);
            DefenderUICover.gameObject.SetActive(false);
        }
        else
        {
            this.GameState           = GameState.AttackerTurn;
            this.NumAvailableAttacks = this.NumberOfAttacksPerTurn;

            AttackerUICover.gameObject.SetActive(false);
            DefenderUICover.gameObject.SetActive(true);
            ScoreController.RotateScoreText(180);
            this.AttackerUI.SetActive(true);
            this.DefenderUI.SetActive(false);

            // Reset modules attachments
            foreach (AttackableModule m in this.GameBoardObjects)
            {
                m.HasInspectorAttached = false;
                m.HasFixerAttached     = false;
                m.ResetColor();
            }

            // Oracles Get their values and fixes done
            foreach (Oracle o in this.oracles)
            {
                o.InputActive = false;
                o.InspectModule();
                o.FixModule();
            }

            // Score points for non-fixed modules
            foreach (AttackableModule m in this.GameBoardObjects)
            {
                if (m.IsAttacked)
                {
                    m.SetAttackDuration(m.GetAttackDuration() + 1);
                    ScoreController.AddAttackerScore(m.GetAttackDuration() * Ints.Score.Defender.Fix);
                }
            }

            if (++Turn > TurnLimit)
            {
                Options.Round           = ++Options.Round;
                Results.AttackerVictory = ScoreController.GetWinner();
                this.SceneLoader.LoadVictoryScene();
            }
            AttackerUIObject.SetTurnText(" Turn: " + Turn + "/" + TurnLimit);
            DefenderUIObject.SetTurnText(" Turn: " + Turn + "/" + TurnLimit);
            TurnText.text  = "Attacker's\n Turn";
            TurnText.color = new Color(1F, 0, 0);
            TurnText.transform.Rotate(0, 0, 180);
        }

        ScreenCover.gameObject.GetComponentsInChildren <Text>()[0].text  = TurnText.text;
        ScreenCover.gameObject.GetComponentsInChildren <Text>()[0].color = TurnText.color;

        StartCoroutine(WaitForClick());

        GameEvents.DispatchTurnChangeEvent(this.GameState);
    }