Exemplo n.º 1
0
    IEnumerator BattleCycle()
    {
        yield return(liveEnemyParty.BattleStart());

        while (!liveEnemyParty.IsDead())
        {
            //act
            yield return(livePlayerParty.ChooseActions());

            yield return(liveEnemyParty.ChooseActions());

            //check if player party is dead
            if (livePlayerParty.IsDead())
            {
                if (liveEnemyParty.unfailable)
                {
                    break;
                }
                else
                {
                    yield return(MessageManager.ShowMessage("", "Everyone died..."));

                    SceneManager.LoadScene("gameover");
                }
            }
        }

        yield return(liveEnemyParty.BattleFinish());

        FinishBattle();
    }
Exemplo n.º 2
0
        public bool Update(float elapsedTime)
        {
            switch (battleState)
            {
            case BattleStateEnum.Running:

                foreach (var enemy in EnemyParty.Enemies)
                {
                    if (enemy.TimeLapse(timeIncrement))
                    {
                        var target = enemy.Action(Party);
                        Effects.Add(new DialogEffect(_graphics, _dialog, $"{enemy.Name} attacked."));
                        Effects.Add(new HpEffect(_graphics, "1", target.X, target.Y));
                    }
                }

                foreach (var actor in Party.Actors)
                {
                    if (actor.TimeLapse(timeIncrement))
                    {
                        battleState        = BattleStateEnum.Idle;
                        Party.ActivePlayer = actor;
                        break;
                    }
                }
                break;

            case BattleStateEnum.Idle:

                if (_inputManager.JustPressedInput((int)Input.FaceButtonDown, (int)Input.Up))
                {
                    var enemy  = EnemyParty.Enemies.First();
                    int damage = Party.ActivePlayer.Attack(enemy);
                    Effects.Add(new HpEffect(_graphics, damage.ToString(), 60, 200));

                    Party.ActivePlayer = null;

                    battleState = BattleStateEnum.Running;

                    if (EnemyParty.IsDead())
                    {
                        return(false);
                    }
                }
                break;
            }

            return(true);
        }