Exemplo n.º 1
0
        public void Init(List <Actor> playerParty, List <Actor> enemyPartyDef)
        {
            SelectedActor   = null;
            SelectedAbility = null;

            IsEnemyTurn = false;

            VictoryScreen.gameObject.SetActive(false);
            GameOverScreen.gameObject.SetActive(false);

            PlayerParty.Clear();

            int i = 0;

            foreach (var p in playerParty)
            {
                if (p.IsAlive)
                {
                    p.transform.localPosition = new Vector3(i / 3 * -3.25f, -(i - 1) * 2.75f, 0);
                    if (i == 3)
                    {
                        var v = p.transform.localPosition;
                        v.y = 0;
                        p.transform.localPosition = v;
                    }
                    p.transform.SetParent(PlayerRoot.transform, worldPositionStays: false);
                    p.gameObject.SetActive(true);
                    p.Init();
                    PlayerParty.Add(p);
                }

                ++i;
            }

            foreach (var e in EnemyParty)
            {
                Destroy(e.gameObject);
            }
            EnemyParty.Clear();


            i = 0;
            foreach (var def in enemyPartyDef)
            {
                int onColumns = enemyPartyDef.Count - (i / 3) * 3;
                if (onColumns > 3)
                {
                    onColumns = 3;
                }
                float y = 0;

                float off = 2.75f;

                if (onColumns == 1)
                {
                    y = 2.75f;
                }
                else if (onColumns == 2)
                {
                    y   = 3.5f / 2.0f;
                    off = 3.5f;
                }

                var p = Instantiate(def, EnemeyRoot.transform);

                p.MaxHealth = (def.MaxHealth * (100 + GameController.Instance.GameDifficulty.EnemiesHealthModifier)) / 100;

                p.transform.localPosition = new Vector3(i / 3 * 3f - 0.5f, (i % 3 - 1) * off + y, 0);
                p.SetToMaxHP();
                p.gameObject.SetActive(true);
                p.Init();
                EnemyParty.Add(p);


                ++i;
            }

            SetSelection(PlayerParty.FirstOrDefault());

            foreach (var p in PlayerParty)
            {
                p.NewTurn();
            }

            ToIdleState();
        }