コード例 #1
0
ファイル: Combat.cs プロジェクト: vvoland/TextRPG
        public void Tick()
        {
            if (IsFinished)
            {
                return;
            }

            var sortedByInitiative = Actors
                                     .OrderByDescending(actor => InitiativeStatsVisitor.Calculate(actor.Stats));

            foreach (var actor in sortedByInitiative)
            {
                if (actor.AttemptRetreat)
                {
                    actor.AttemptRetreat = false;
                    if (AttemptRetreat(actor))
                    {
                        break;
                    }
                }
                else if (actor.IsAlive)
                {
                    Attack(actor);
                }
            }

            EnemiesDead = Enemies.All(a => !a.IsAlive);
            PlayerDead  = !Player.IsAlive && !EnemiesDead;
            IsFinished  = PlayerDead || EnemiesDead || FinishedByRetreat;
        }
コード例 #2
0
 private bool CheckEnemiesDead()
 {
     return(Enemies.All(enemy => enemy.IsDead || enemy.IsEmpty));
 }