示例#1
0
    void PopulatePlayer(TileProxy[] sideTiles)
    {
        PlayerMeta player = BaseSaver.GetPlayer();
        //Queue<TileProxy> validTls = new Queue<TileProxy>(GetSideTiles(BoardProxy.PLAYER_TEAM));
        Queue <TileProxy> validTls = new Queue <TileProxy>(sideTiles);
        List <UnitProxy>  units    = new List <UnitProxy>();
        List <Unit>       roster   = new List <Unit>(player.characters);

        roster.Reverse();
        //Debug.Log("PopulatePlayer: " + validTls.Count.ToString());
        List <Unit> inactiveUnits = new List <Unit>();

        for (int i = 3; i < roster.Count; i++)
        {
            inactiveUnits.Add(roster[i]);
        }

        for (int i = 0; i < roster.Count && i < 3; i++)
        {
            Unit cMeta = new Unit(roster[i]);
            //UnitProxy goodGuy = Instantiate(glossary.GetComponent<Glossary>().units[PLAYER_TEAM], transform);
            UnitProxy goodGuy = Instantiate(ClassNode.ComputeClassBaseUnit(cMeta.GetFactionType(),
                                                                           cMeta.GetUnitType(), glossary.GetComponent <Glossary>()), transform);
            units.Add(goodGuy);
            cMeta = ClassNode.ApplyClassBonusesBattle(cMeta, inactiveUnits.ToArray());
            goodGuy.PutData(cMeta);
            goodGuy.Init();
            TileProxy popTile = validTls.Dequeue();
            popTile.ReceiveGridObjectProxy(goodGuy);
            goodGuy.SnapToCurrentPosition();
            //Debug.Log("goodGuy placed at: " + popTile.GetPosition().ToString());
        }
    }
示例#2
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;
    }