Ejemplo n.º 1
0
    // Drives the current behavior based on what phase of the game is taking place.
    void ManageTurn()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        switch (gP)
        {
        case (GamePhase.Deploy):
            DeployMaster.SetTiles();     // let users set units
            break;

        case (GamePhase.Cannon):
            CannonMaster.HandleCannons();     // let users turn and fire cannons
            break;

        case (GamePhase.Move):
            MoveMaster.DecideMove();     // let users move available units
            break;

        case (GamePhase.Attack):     // Attack phase currently resolves itself with no need for user input
            break;

        default:
            break;
        }
    }
Ejemplo n.º 2
0
 public static void SetDeployButtons()
 {
     for (int i = 0; i < instance.deployButtons.Length - 1; i++)
     {
         int j = i;
         instance.deployButtons[i].onClick.AddListener(() => DeployMaster.SetToSpawnUnit(j));
     }
     instance.deployButtons[instance.deployButtons.Length - 1].onClick.AddListener(() => DeployMaster.SetToSpawnUnit(-1));
     UpdateDeployAmount();
 }
Ejemplo n.º 3
0
 public DeployMaster()
 {
     //iLim = 20;
     //cLim = 12;
     //cnLim = 4;
     p1List = new int[4];
     p2List = new int[4];
     UnitDistributionMaster.P1Dist.CopyTo(p1List, 0);
     UnitDistributionMaster.P2Dist.CopyTo(p2List, 0);
     toSpawnUnit = -1;
     uoList      = new List <UnitOrder>();
     unitsUsed   = new int[] { p1List[0], p1List[1], p1List[2] };
     instance    = this;
 }
Ejemplo n.º 4
0
    //initialize
    void Start()
    {
        instance = this;
        // canSkip = false;
        uiM = new UIMaster();
        sM  = new ScoreMaster();
        mM  = new MapMaster();
        pM  = new PlayerMaster();
        dM  = new DeployMaster();
        mvM = new MoveMaster();
        aM  = new AttackMaster();

        acceptInput = true;
        turnNum     = 0;

        CannonMaster.ResetCurrent();

        gP = GamePhase.Deploy;
        ScoreMaster.ResetScore();

        mL = new MapLoader();
        mL.LoadMapFromTextAsset(((TextAsset)Resources.Load("Maps/" + mapName)));
        PlayerMaster.SetBackLines(MapMaster.Map);
        TopDownCamera.ActivateMainCamera(MapMaster.Height, MapMaster.Width, MapMaster.MapRadius);

        UIMaster.SetGeneralUI();
        UIMaster.SetDeployUI();
        UIMaster.SetCannonUI();
        UIMaster.DisplayScore();

        UIMaster.SetPanelAlpha(false, (int)UIPannels.Cannon);
        UIMaster.SetPanelAlpha(false, (int)UIPannels.Phase);
        UIMaster.SetPanelAlpha(false, (int)UIPannels.View);
        UIMaster.SetPanelAlpha(false, (int)UIPannels.Fight);

        UIMaster.SetActionPanel(true);

        if (!tutorial)
        {
            UIMaster.DisplayState(gP, PlayerMaster.CurrentTurn);
        }

        // norton = VS_AI ? new AIBrain() : null; // must be called after UIMaster.SetGeneralUI to percive turns properly
    }
Ejemplo n.º 5
0
    //Alters aspects of the game state (such as highlights or unit numbers) based on phase and other information
    private static IEnumerator AlterState()
    {
        switch (gP)
        {
        case (GamePhase.Deploy):

            if (DeployMaster.instance.uoList.Count != 0)
            {
                yield return(DeployMaster.DeployUnitsCoroutine());

                yield return(new WaitForSeconds(1.5f));
            }
            UIMaster.UpdateDeployAmount();
            break;

        case (GamePhase.Cannon):
            // CheckSkip();

            /*      if (PlayerMaster.CurrentTurn == 0)
             *    {
             *        CheckSkip();
             *    } */

            CannonMaster.ExitCannon();
            HighlightMaster.UnhighlightCannons(PlayerMaster.CurrentPlayer);
            DeactivateCannonByCannon(PlayerMaster.OtherPlayer);

            if (PlayerMaster.CurrentTurn == 0)
            {
                //DeactivateCannonByMove(PlayerMaster.OtherPlayer);
                HighlightMaster.HighlightActiveCannons(PlayerMaster.OtherPlayer);
            }
            break;

        case (GamePhase.Move):

            if (MoveMaster.UnitsToMove != 0)
            {
                HighlightMaster.UnhighlightMovable(PlayerMaster.CurrentPlayer);
                MoveMaster.ClearMoveVariables();
            }
            AttackMaster.BuildCombatAreas();

            ActivateCannonByMove(PlayerMaster.CurrentPlayer);
            DeactivateCannonByMove(PlayerMaster.CurrentPlayer);

            if (AttackMaster.CombatCount == 0)
            {
                CannonMaster.CheckCannonCapture();
                yield return(WinByMove());

                if (PlayerMaster.CurrentTurn == 0)
                {
                    MoveMaster.PrimeMoveVariables(PlayerMaster.OtherPlayer);
                    HighlightMaster.HighlightMovable(PlayerMaster.OtherPlayer);
                }
            }

            else if (AttackMaster.CombatCount != 0)
            {
                //  AttackMaster.BuildCombatAreas();
                //gP = GamePhase.Attack;

                UIMaster.SetActionPanel(false);     //Deactivates off action panel
                UIMaster.FadePhanel((int)UIPannels.Action);
                acceptInput = false;

                instance.StartCoroutine(Fight());
                //yield return Fight();
            }
            break;

        case (GamePhase.Attack):
            break;

        default:
            yield return(null);

            break;
        }
    }
Ejemplo n.º 6
0
    void Update()
    {
        Debug.Log(PlayerMaster.PriorTurn);

        if (acceptInput)
        {
            switch (phase)
            {
            case T_Phases.Deploy:
                DeployMaster.SetTutorialTiles();
                if (d_markers.transform.childCount == 0)
                {
                    turn_button.interactable = true;
                }
                if (PlayerMaster.CurrentTurn == 1)
                {
                    acceptInput = false;
                    ai_turn     = true;
                    instance.StartCoroutine(TutorialAI.Deploy());
                }
                break;

            case T_Phases.Move:
                MoveMaster.DecideMove();
                if (PlayerMaster.CurrentTurn == 1)
                {
                    acceptInput = false;
                    ai_turn     = true;
                    instance.StartCoroutine(TutorialAI.Move());
                }
                break;

            case T_Phases.Cannon:
                CannonMaster.HandleCannons();
                if (PlayerMaster.CurrentTurn == 1)
                {
                    acceptInput = false;
                    ai_turn     = true;
                    instance.StartCoroutine(TutorialAI.IDontHaveCannons());
                }
                break;

            case T_Phases.Fight:
                MoveMaster.DecideMove();
                if (PlayerMaster.CurrentTurn == 1)
                {
                    acceptInput = false;
                    ai_turn     = true;
                    instance.StartCoroutine(TutorialAI.Move());
                }
                break;

            default:
                Debug.Log("Default");
                break;
            }
        }

        if (ai_turn)
        {
            if (PlayerMaster.CurrentTurn == 0)
            {
                ai_turn = false;
                TutorialUIMaster.c_bool = false;
                TutorialUIMaster.SetContinue(false);
                NextPhase();
                instance.StartCoroutine(TutorialUIMaster.MoveTextbox());
            }
        }
    }
Ejemplo n.º 7
0
 public static void UpdateDeployAmount()
 {
     for (int i = 0; i < instance.deployButtons.Length - 1; i++)
     {
         instance.deployButtons[i].gameObject.GetComponentInChildren <Text>().text = DeployMaster.UnitsUsed(i).ToString();
     }
 }