예제 #1
0
    public void DoBattle()
    {
        if (BattleHasEnded == false)
        {
            foreach (Monster opponent in CurrentOpponents)
            {
                if (opponent.IsDefeated)
                {
                    opponent.TicksToNextAttack = opponent.AttackSpeed;
                }
                else
                {
                    opponent.TicksToNextAttack--;
                    opponent.TickStatusEffects();
                }
            }
            Player.Instance.TicksToNextAttack--;
            if (Player.Instance.TicksToNextAttack < 0)
            {
                Attack();
                if (CurrentBoss != null)
                {
                    CurrentBoss.OnBeAttacked(Target);
                }
                Player.Instance.TicksToNextAttack = Player.Instance.GetWeaponAttackSpeed();
            }
            foreach (Monster opponent in CurrentOpponents)
            {
                if (opponent.CurrentHP <= 0 && opponent.IsDefeated == false)
                {
                    opponent.CurrentHP = 0;
                    RollForDrops(opponent);
                    opponent.IsDefeated = true;
                    if (CurrentBoss != null)
                    {
                        CurrentBoss.OnDie(opponent);
                    }
                }
                else if (opponent.TicksToNextAttack < 0 && opponent.IsDefeated == false)
                {
                    if (CurrentBoss != null && CurrentBoss.CustomAttacks)
                    {
                        CurrentBoss.OnAttack();
                    }
                    else if (CurrentBoss != null)
                    {
                        CurrentBoss.OnAttack();
                        BeAttacked(opponent);
                    }
                    else
                    {
                        BeAttacked(opponent);
                    }
                    opponent.TicksToNextAttack = opponent.AttackSpeed;
                }
            }
            if (AllOpponentsDefeated())
            {
                if (CurrentDojo != null)
                {
                    CurrentDojo.CurrentOpponent++;
                    if (CurrentDojo.CurrentOpponent >= CurrentDojo.Opponents.Count)
                    {
                        CurrentDojo.LastWinTime = DateTime.Now;
                    }
                }
                WonLastBattle = true;
                EndBattle();
            }
            if (CurrentBoss != null)
            {
                CurrentBoss.TicksToNextSpecialAttack--;
                if (CurrentBoss.TicksToNextSpecialAttack <= 0)
                {
                    CurrentBoss.OnSpecialAttack();
                }
            }

            if (Player.Instance.CurrentHP <= 0)
            {
                Player.Instance.Die();
                WonLastBattle = false;
            }
        }
    }
예제 #2
0
    public void DoBattle()
    {
        if (BattleHasEnded == false)
        {
            foreach (Monster opponent in CurrentOpponents)
            {
                if (opponent.IsDefeated)
                {
                    opponent.TicksToNextAttack = opponent.AttackSpeed;
                }
                else
                {
                    opponent.TicksToNextAttack--;
                }
            }
            Player.Instance.TicksToNextAttack--;
            if (Player.Instance.TicksToNextAttack < 0)
            {
                Attack();
                if (CurrentBoss != null)
                {
                    CurrentBoss.OnBeAttacked(Target);
                }
                Player.Instance.TicksToNextAttack = Player.Instance.GetWeaponAttackSpeed();
            }
            foreach (Monster opponent in CurrentOpponents)
            {
                if (opponent.CurrentHP <= 0 && opponent.IsDefeated == false)
                {
                    opponent.CurrentHP = 0;
                    Drop drop = opponent.DropTable.GetDrop();

                    if (LootTracker.Instance.TrackLoot)
                    {
                        foreach (Drop d in opponent.DropTable.AlwaysDrops)
                        {
                            LootTracker.Instance.Inventory.AddDrop(d);
                        }
                        LootTracker.Instance.Inventory.AddDrop(drop);
                    }
                    else
                    {
                        MessageManager.AddMessage("You defeated the " + opponent.Name + ".");
                        foreach (Drop d in opponent.DropTable.AlwaysDrops)
                        {
                            Player.Instance.Inventory.AddDrop(d);
                        }
                        Player.Instance.Inventory.AddDrop(drop);
                    }

                    opponent.IsDefeated = true;
                    if (CurrentBoss != null)
                    {
                        CurrentBoss.OnDie(opponent);
                    }
                }
                else if (opponent.TicksToNextAttack < 0 && opponent.IsDefeated == false)
                {
                    if (CurrentBoss != null && CurrentBoss.CustomAttacks)
                    {
                        CurrentBoss.OnAttack();
                    }
                    else if (CurrentBoss != null)
                    {
                        CurrentBoss.OnAttack();
                        BeAttacked(opponent);
                    }
                    else
                    {
                        BeAttacked(opponent);
                    }
                    opponent.TicksToNextAttack = opponent.AttackSpeed;
                }
            }
            if (AllOpponentsDefeated())
            {
                if (CurrentDojo != null)
                {
                    CurrentDojo.CurrentOpponent++;
                    if (CurrentDojo.CurrentOpponent >= CurrentDojo.Opponents.Count)
                    {
                        CurrentDojo.LastWinTime = DateTime.Now;
                    }
                }
                WonLastBattle = true;
                EndBattle();
            }
            if (CurrentBoss != null)
            {
                CurrentBoss.TicksToNextSpecialAttack--;
                if (CurrentBoss.TicksToNextSpecialAttack <= 0)
                {
                    CurrentBoss.OnSpecialAttack();
                }
            }

            if (Player.Instance.CurrentHP <= 0)
            {
                Player.Instance.Die();
                WonLastBattle = false;
            }
        }
    }