Ejemplo n.º 1
0
    // Changes the phase and updates the UI as needed
    public static IEnumerator ChangeTurn()
    {
        UIMaster.SetActionPanel(false);

        yield return(AlterState()); // pauses before executing the rest of the code based on phase.

        if (PlayerMaster.PriorTurn == 0)
        {
            yield return(EndofRound());
        }

        if (gP != GamePhase.Attack)
        {
            PlayerMaster.SwitchPlayer();
            TopDownCamera.ChangePlayerCamera();
        }

        UIMaster.ChangeDisplayedPlayer();
        UIMaster.ChangePlayerDeploy(gP);
        UIMaster.DisplayState(gP, PlayerMaster.CurrentTurn);

        turnNum++;

        yield return(null);
    }
Ejemplo n.º 2
0
    void Start()
    {
        GameBrain.ChangeAcceptInput(false);
        TopDownCamera.AllowMovement(false);
        instance    = this;
        tm          = new TutorialUIMaster();
        t_ai        = new TutorialAI();
        acceptInput = false;
        ai_turn     = false;
        image_on    = false;
        turn_button = GameObject.Find("PlayerPanel").GetComponent <Button>();
        d_markers   = GameObject.Find("DeployMarkers");
        d_markers.SetActive(false);

        UIMaster.SetActionPanel(false);

        phase       = T_Phases.Introduction;
        whichText   = 0;
        phaselength = TutorialUIMaster.TutorialText[(int)phase].Length;
        TutorialUIMaster.ChangeText((int)phase, whichText);

        GameObject.Find("Back Button").GetComponent <Button>().onClick.AddListener(BackText);
        GameObject.Find("Forward Button").GetComponent <Button>().onClick.AddListener(ForwardText);
        GameObject.Find("Continue Button").GetComponent <Button>().onClick.AddListener(PlayersTurn);
        GameObject.Find("Raise Button").GetComponent <Button>().onClick.AddListener(RaiseBox);
    }
Ejemplo n.º 3
0
    static void NextPhase()
    {
        whichText = 0;
        ++phase;
        switch (phase)
        {
        case T_Phases.Deploy:
            UIMaster.DisplayState(GamePhase.Deploy, PlayerMaster.CurrentTurn);
            UIMaster.SetActionPanel(true);
            UIMaster.FadePhanel(0);
            break;

        case T_Phases.Cannon:
            for (int i = 0; i < PlayerMaster.CurrentPlayer.Can.Count; ++i)
            {
                PlayerMaster.CurrentPlayer.Can[i].Moved = false;
            }
            HighlightMaster.HighlightActiveCannons(PlayerMaster.CurrentPlayer);
            break;

        default:
            break;
        }

        turn_button.interactable = false;
        phaselength = TutorialUIMaster.TutorialText[(int)phase].Length;
        TutorialUIMaster.ChangeText((int)phase, whichText);
    }
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
    static IEnumerator Fight() //Handles and manages the FightScene
    {
        gP = GamePhase.Attack;

        while (AttackMaster.CombatCount != 0)
        {
            float rotation;
            if (PlayerMaster.CurrentTurn == 0)
            {
                rotation = 180;
            }
            else
            {
                rotation = 0;
            }

            instance.StartCoroutine(TopDownCamera.LerpToPosition(AttackMaster.CenterOfCombat(), Quaternion.Euler(90, rotation, 0)));
            yield return(new WaitForSeconds(2.0f));               //Wait to give the player a chance to see stuff

            instance.StartCoroutine(UIMaster.MoveCurtains(true)); //lower curtains
            yield return(null);                                   //Wait at least one frame so that UIMaster.MovingCurtians can change value

            while (UIMaster.MovingCurtains)
            {
                yield return(null);
            }

            List <Unit> currentCombat = AttackMaster.CurrentCombatArea;
            List <Unit> toKill        = AttackMaster.FightResults();
            FightSceneMaster.SetUpFight(currentCombat, toKill);    //Prepare the fightscene

            yield return(new WaitForSeconds(1.0f));                //Pause for dramatic effect

            instance.StartCoroutine(UIMaster.MoveCurtains(false)); //Raise Curtains
            yield return(null);

            while (UIMaster.MovingCurtains)
            {
                yield return(null);
            }

            SoundMaster.AttackCharge();
            instance.StartCoroutine(FightSceneMaster.ToBattle()); //Begins FightScene
            yield return(null);                                   //Wait at least one frame so that FightSceneMaster.Fighting can change value

            while (FightSceneMaster.Fighting)
            {
                yield return(null);
            }

            //SoundMaster.AttackResolution();
            instance.StartCoroutine(UIMaster.MoveCurtains(true)); //Lower curtains again
            yield return(null);                                   //Wait at least one frame so that UIMaster.MovingCurtians can change value

            while (UIMaster.MovingCurtains)
            {
                yield return(null);
            }

            FightSceneMaster.CleanUp();                            //Resets FightScene

            yield return(new WaitForSeconds(0.25f));               //Pause

            instance.StartCoroutine(UIMaster.MoveCurtains(false)); //Raise curtains
            yield return(new WaitForFixedUpdate());                //Wait at least one frame so that UIMaster.MovingCurtians can change value

            while (UIMaster.MovingCurtains)
            {
                yield return(null);
            }

            yield return(new WaitForSeconds(1.0f));

            foreach (Unit u in toKill)
            {
                PlayerMaster.KillUnit(u);           //Kills dead units
            }
            yield return(new WaitForSeconds(1.0f)); //Pause to see aftermath
        }

        //return to player's position after the fight
        instance.StartCoroutine(TopDownCamera.LerpToPosition(PlayerMaster.CurrentPlayer.CameraPosistion, PlayerMaster.CurrentPlayer.CameraRotation));

        DeactivateCannonByMove(PlayerMaster.OtherPlayer);

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

        UIMaster.DisplayScore();

        // WinByMove();

        UIMaster.SetActionPanel(true); //Turns action pannel back on
        UIMaster.FadePhanel((int)UIPannels.Action);

        CannonMaster.CheckCannonCapture();

        gP = GamePhase.Move;
        yield return(ChangeTurn());

        acceptInput = true;
    }
Ejemplo n.º 6
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.º 7
0
    private static IEnumerator FollowPath(List <HexCell> path, Unit u)
    {
        u.Moved = true;
        u.CurrentHex.Passable         = true;
        u.CurrentHex.unit             = null;
        path[path.Count - 1].passable = false;

        Animator a        = null;
        bool     infOrCav = u.UName == "Cannon" ? false : true;

        if (infOrCav)
        {
            a = u.gameObject.GetComponentInChildren <Animator>();
        }

        yield return(new WaitForFixedUpdate());

        ++movingUnits;

        UIMaster.SetActionPanel(false);
        //  path[path.Count - 1].Unit = u;

        if (infOrCav)
        {
            a.Play("MoveStart");
        }

        Rigidbody r = u.gameObject.GetComponent <Rigidbody>();

        if (r != null)
        {
            r.detectCollisions = false;
            r.useGravity       = false;
        }

        yield return(new WaitForSeconds(0.25f));

        SoundMaster.StartUnitMove();

        while (path.Count > 0)
        {
            yield return(new WaitForEndOfFrame());

            yield return(LearpToTile(u, path[0]));

            path.RemoveAt(0);
        }

        SoundMaster.StopUnitMove();

        yield return(new WaitForFixedUpdate());

        --movingUnits;

        if (!(movingUnits > 0))
        {
            UIMaster.SetActionPanel(true);
        }

        if (r != null)
        {
            r.detectCollisions = true;
            r.useGravity       = true;
        }

        if (infOrCav)
        {
            a.Play("MoveEnd");
        }

        u.CurrentHex.Unit    = u;
        u.transform.rotation = u.URotation();
        HighlightMaster.HighlightUnitToggle(false, u);
        AttackMaster.BuildCombatPoints(u.CurrentHex);
    }