예제 #1
0
    public static void SwapPoints(UnitTypes uT, int from)
    {
        int amt = pointValues[(int)uT];

        PlayerMaster.UnitsPlayer(from).Score -= amt;
        PlayerMaster.UnitsPlayer(from == 0 ? 1 : 0).Score += amt;
        instance.score1 = PlayerMaster.UnitsPlayer(0).Score;
        instance.score2 = PlayerMaster.UnitsPlayer(1).Score;
        UIMaster.DisplayScore();
    }
예제 #2
0
    public static IEnumerator DeployUnitsCoroutine()
    {
        GameBrain.ChangeAcceptInput(false);
        string  prefabpath = "Prefabs/";
        string  prefabName;
        HexCell h;

        foreach (UnitOrder uO in instance.uoList)
        {
            yield return(new WaitForSeconds(0.1f));

            h           = MapMaster.Map[uO.R, uO.Q];
            prefabName  = ((UnitTypes)uO.unitType).ToString();
            prefabName += prefabName == "Cannon" ? "" : PlayerMaster.CurrentTurn.ToString();

            Unit u = ((GameObject)GameObject.Instantiate(Resources.Load(prefabpath + prefabName), h.SpawnVector, Quaternion.identity)).GetComponent <Unit>();

            u.UDirection = (int)(PlayerMaster.CurrentTurn == 0 ? UnitRotations.half : UnitRotations.none);
            u.Player     = PlayerMaster.CurrentTurn;
            u.gameObject.transform.rotation = u.URotation();

            MapMaster.Map[uO.R, uO.Q].Unit            = u;
            MapMaster.Map[uO.R, uO.Q].Unit.CurrentHex = MapMaster.Map[uO.R, uO.Q];


            switch (uO.unitType)
            {
            case (0):
                PlayerMaster.CurrentPlayer.Inf.Add(u);
                break;

            case (1):
                PlayerMaster.CurrentPlayer.Cav.Add(u);
                break;

            case (2):
                Cannon c = (Cannon)u;
                c.shots = 0;
                PlayerMaster.CurrentPlayer.Can.Add(c);
                break;
            }

            GameObject.Destroy(uO.icon);

            ScoreMaster.GivePoints(ScoreMaster.PointValues[uO.unitType], u.Player);

            UIMaster.DisplayScore();
        }

        instance.uoList.Clear();
        RefreshUnitsUsed();
        GameBrain.ChangeAcceptInput(true);
    }
예제 #3
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
    }
예제 #4
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;
    }