Пример #1
0
    private void Awake()
    {
        gameOverPanel.SetActive(false);
        PlayerMeta player = BaseSaver.GetPlayer();

        background1.SetActive(false);
        background2.SetActive(false);
        background3.SetActive(false);
        background4.SetActive(false);
        switch (player.world)
        {
        case GameMeta.World.nile: background1.SetActive(true); break;

        case GameMeta.World.mountain: background2.SetActive(true); break;

        case GameMeta.World.pyramid: background3.SetActive(true); break;

        case GameMeta.World.candy: background4.SetActive(true); break;
        }

        boardMeta = BaseSaver.GetBoard();
        width     = boardMeta.width;
        height    = boardMeta.height;

        tileMap  = GetComponentInChildren <Tilemap>();
        instance = this;
        //tiles = new TileProxy[width, height];
        grid = GetComponent <Grid>();
    }
Пример #2
0
    public void PutSelect(string selected)
    {
        PlayerMeta player        = BaseSaver.GetPlayer();
        BoardMeta  selectedBoard = BaseSaver.GetBoards()[(int)(StoryStatic.Dests)Enum.Parse(typeof(StoryStatic.Dests), selected)];

        if (this.selected == selected && !CompDests().Contains(selected))
        {
            player.lastDest = selected;
            BaseSaver.PutPlayer(player);
            BaseSaver.PutBoard(selectedBoard);
            MusicTransitionToBattle();
            SceneManager.LoadScene("BattleScene");
            //MusicTransitionToBattle();
        }
        else
        {
            BoardMeta bMeta = BaseSaver.GetBoard();
            if (this.selected.Length > 0)
            {
                ByName(this.selected).transform.GetChild(0).gameObject.SetActive(false);
            }
            this.selected = selected;
            ByName(this.selected).transform.GetChild(0).gameObject.SetActive(true);

            string mapName = StoryStatic.GetMapName(player.world, player.faction, this.selected);

            setDesc("<color=#9BC2C2>" + mapName + "</color>\n\n<color=#CFE4E4>" + selectedBoard.ReturnMapDesc() +
                    "</color>\n<color=#669999>" + CalcArmyString(selectedBoard.enemies) + "</color>");
        }
    }
    void EndGame(bool won)
    {
        BoardProxy.instance.gameOverPanel.SetActive(true);
        this.won = won;
        string txt = "Defeat";

        if (won)
        {
            List <UnitProxy> units  = BoardProxy.instance.GetUnits().Where(unit => unit.GetData().GetTeam() == BoardProxy.PLAYER_TEAM).ToList();
            PlayerMeta       player = BaseSaver.GetPlayer();
            List <Unit>      pChars = units.Select(unit => new Unit(unit.GetData())).ToList();
            List <string>    dests  = new List <string>(player.stats.dests);
            foreach (string unlock in BaseSaver.GetBoard().unlocks)
            {
                if (!dests.Contains(unlock))
                {
                    dests.Add(unlock);
                    unlkChar = true;
                }
            }
            player.stats.dests = dests.ToArray();
            player.characters  = pChars.ToArray();
            player.stats.dests = dests.ToArray();
            BaseSaver.PutPlayer(player);
            txt = "Victory";
        }
        BoardProxy.instance.gameOverPanel.transform.Find("GameOverHeader").GetComponent <TextMeshProUGUI>().text = txt;
    }
Пример #4
0
 void Awake()
 {
     instance = this;
     board    = BaseSaver.GetBoard();
     if (board == null)
     {
         board = new BoardMeta();
     }
     won      = false;
     unlkChar = false;
 }
Пример #5
0
    private void Awake()
    {
        gameOverPanel.SetActive(false);
        boardMeta = BaseSaver.GetBoard();
        width     = boardMeta.width;
        height    = boardMeta.height;

        tileMap  = GetComponentInChildren <Tilemap>();
        instance = this;
        tiles    = new TileProxy[width, height];
        grid     = GetComponent <Grid>();
    }
Пример #6
0
    IEnumerator TimeEndGame(bool won)
    {
        if (!AnimationInteractionController.AllAnimationsFinished())
        {
            yield return(new WaitForSeconds(AnimationInteractionController.AFTER_KILL));
        }

        BoardProxy.instance.gameObject.GetComponent <Grid>().enabled = false;

        BoardProxy.instance.gameOverPanel.SetActive(true);
        BoardProxy.instance.gameOverPanel.transform.GetChild(2).gameObject.SetActive(false);
        BoardProxy.instance.gameOverPanel.transform.GetChild(3).gameObject.SetActive(false);

        /*
         * Replace shit here
         */

        PlayerMeta player = BaseSaver.GetPlayer();
        BoardMeta  brd    = BaseSaver.GetBoard();
        Glossary   glossy = BoardProxy.instance.glossary.GetComponent <Glossary>();

        Unit.FactionType fact = won ? player.faction : brd.enemies[0].GetFactionType();
        switch (fact)
        {
        case Unit.FactionType.Cthulhu:
            BoardProxy.instance.gameOverPanel.transform.GetChild(0).GetComponent <Image>().sprite = glossy.endBattleOverlayCthulhuLeft;
            BoardProxy.instance.gameOverPanel.transform.GetChild(1).GetComponent <Image>().sprite = glossy.endBattleOverlayCthulhuRight;
            break;

        case Unit.FactionType.Egypt:
            BoardProxy.instance.gameOverPanel.transform.GetChild(0).GetComponent <Image>().sprite = glossy.endBattleOverlayEgyptLeft;
            BoardProxy.instance.gameOverPanel.transform.GetChild(1).GetComponent <Image>().sprite = glossy.endBattleOverlayEgyptRight;
            break;

        case Unit.FactionType.Human:
            BoardProxy.instance.gameOverPanel.transform.GetChild(0).GetComponent <Image>().sprite = glossy.endBattleOverlayHumanLeft;
            BoardProxy.instance.gameOverPanel.transform.GetChild(1).GetComponent <Image>().sprite = glossy.endBattleOverlayHumanRight;
            break;

        default:
            BoardProxy.instance.gameOverPanel.transform.GetChild(0).GetComponent <Image>().sprite = glossy.endBattleOverlaySusieLeft;
            BoardProxy.instance.gameOverPanel.transform.GetChild(1).GetComponent <Image>().sprite = glossy.endBattleOverlaySusieRight;
            break;
        }

        GameObject screenChild = BoardProxy.instance.gameOverPanel.transform.GetChild(0).gameObject;

        Vector3 moveToPos    = screenChild.transform.position;
        float   screenHeight = screenChild.GetComponent <RectTransform>().rect.height;

        Vector3 startPosHigh = new Vector3(0, moveToPos.y + screenHeight, moveToPos.z);
        Vector3 startPosLow  = new Vector3(0, moveToPos.y - screenHeight, moveToPos.z);

        BoardProxy.instance.gameOverPanel.transform.GetChild(0).localPosition = startPosHigh;
        BoardProxy.instance.gameOverPanel.transform.GetChild(1).localPosition = startPosLow;

        if (!won)
        {
            BoardProxy.instance.gameOverPanel.transform.GetChild(2).gameObject.SetActive(true);
            BoardProxy.instance.gameOverPanel.transform.GetChild(2).localPosition = startPosHigh;
            iTween.MoveTo(BoardProxy.instance.gameOverPanel.transform.GetChild(2).gameObject, moveToPos, 3f);
        }
        else
        {
            BoardProxy.instance.gameOverPanel.transform.GetChild(3).gameObject.SetActive(true);
            switch (fact)
            {
            case Unit.FactionType.Cthulhu:
                BoardProxy.instance.gameOverPanel.transform.GetChild(3).GetChild(0).GetComponent <Image>().sprite = glossy.endBattleWinOverlayCthulhu1;
                BoardProxy.instance.gameOverPanel.transform.GetChild(3).GetChild(1).GetComponent <Image>().sprite = glossy.endBattleWinOverlayCthulhu2;
                break;

            case Unit.FactionType.Egypt:
                BoardProxy.instance.gameOverPanel.transform.GetChild(3).GetChild(0).GetComponent <Image>().sprite = glossy.endBattleWinOverlayEgypt1;
                BoardProxy.instance.gameOverPanel.transform.GetChild(3).GetChild(1).GetComponent <Image>().sprite = glossy.endBattleWinOverlayEgypt2;
                break;

            case Unit.FactionType.Human:
                BoardProxy.instance.gameOverPanel.transform.GetChild(3).GetChild(0).GetComponent <Image>().sprite = glossy.endBattleWinOverlayHuman1;
                BoardProxy.instance.gameOverPanel.transform.GetChild(3).GetChild(1).GetComponent <Image>().sprite = glossy.endBattleWinOverlayHuman2;
                break;

            default:
                BoardProxy.instance.gameOverPanel.transform.GetChild(3).GetChild(0).GetComponent <Image>().sprite = glossy.endBattleWinOverlayCthulhu1;
                BoardProxy.instance.gameOverPanel.transform.GetChild(3).GetChild(1).GetComponent <Image>().sprite = glossy.endBattleWinOverlayCthulhu2;
                break;
            }
            BoardProxy.instance.gameOverPanel.transform.GetChild(3).localPosition = startPosHigh;
            iTween.MoveTo(BoardProxy.instance.gameOverPanel.transform.GetChild(3).gameObject, moveToPos, 3f);
        }

        iTween.MoveTo(BoardProxy.instance.gameOverPanel.transform.GetChild(0).gameObject, moveToPos, 1f);
        iTween.MoveTo(BoardProxy.instance.gameOverPanel.transform.GetChild(1).gameObject, moveToPos, 1f);


        MusicTransitionToMap();
        this.won = won;
        string txt = "Defeat";

        if (won)
        {
            //Apply inactive unit class bonuses
            if (player.characters.Length > 3)
            {
                List <Unit> inactiveUnits = new List <Unit>(new Unit[] { player.characters[0] });
                if (player.characters.Length > 4)
                {
                    inactiveUnits.Add(player.characters[1]);
                }
                for (int i = 0; i < inactiveUnits.Count; i++)
                {
                    Debug.Log("Applying bonus to: " + inactiveUnits[i].characterMoniker + " - " + inactiveUnits[i].characterName);
                    inactiveUnits[i] = ClassNode.ApplyClassBonusesBattle(inactiveUnits[i], inactiveUnits.ToArray());
                    if (inactiveUnits[i].GetInactiveExpBuff() > 0)
                    {
                        inactiveUnits[i].ApplyInactiveExpBuff();
                    }
                }
            }

            List <UnitProxy> units = BoardProxy.instance.GetUnits().Where(unit => unit.GetData().GetTeam() == BoardProxy.PLAYER_TEAM &&
                                                                          unit.GetData().GetCurrHealth() > 0 && !unit.GetData().GetSummoned()).ToList();
            //PlayerMeta player = BaseSaver.GetPlayer();
            List <Unit> pChars = new List <Unit>(player.characters);
            pChars.Reverse();
            //Remove the top three chars from the roster
            pChars.RemoveAt(0);
            if (pChars.Count > 0)
            {
                pChars.RemoveAt(0);
            }
            if (pChars.Count > 0)
            {
                pChars.RemoveAt(0);
            }
            Debug.Log("pChars Before");
            foreach (Unit unt in pChars)
            {
                Debug.Log(unt.ToString());
            }
            //Fill them back in if they are still on the board
            List <Unit> pCharsBoard = new List <Unit>(new HashSet <Unit>(units.Select(unit => new Unit(unit.GetData()))));
            foreach (Unit unt in pCharsBoard)
            {
                Debug.Log(unt.ToString());
                if (!pChars.Where(pCh => pCh.characterMoniker.Equals(unt.characterMoniker)).Any())
                {
                    pChars.Add(unt);
                }
            }
            Debug.Log("pChars After");
            for (int i = 0; i < pChars.Count(); i++)
            {
                Debug.Log(pChars[i].ToString());
                //pChars[i] = ClassNode.ApplyClassBonusesBattle(pChars[i], inactiveUnits.ToArray());
            }
            List <string> dests = new List <string>(player.stats.dests);
            foreach (string unlock in BaseSaver.GetBoard().unlocks)
            {
                if (!dests.Contains(unlock))
                {
                    dests.Add(unlock);
                    unlkChar = true;
                }
            }
            player.stats.dests = dests.ToArray();
            player.characters  = pChars.ToArray();
            BaseSaver.PutPlayer(player);
            txt = "Victory";
        }
        BoardProxy.instance.gameOverPanel.transform.GetChild(5).GetComponent <TextMeshProUGUI>().text = txt;
    }