Example #1
0
        public void ProcessAttackScreen(Humanoid Enemy)
        {
            stats.UpdateWorld(this);
            while (Enemy.IsAlive() && MainCharacter.IsAlive())
            {
                Humanoid FirstAttacker  = MainCharacter.GetWearablePower().Defence <= Enemy.GetWearablePower().Defence ? MainCharacter : Enemy;
                Humanoid SecondAttacker = FirstAttacker == MainCharacter ? Enemy : MainCharacter;

                int damage = 0;

                if (FirstAttacker == MainCharacter)
                {
                    if (GetMainCharacterAttackAnswer(out damage))
                    {
                        return;
                    }
                    else
                    {
                        MainCharacter.AttackOther(Enemy, damage);
                    }
                    if (Enemy.IsAlive())
                    {
                        AttackMainPlayWithEnemy(Enemy);
                    }
                }
                else
                {
                    AttackMainPlayWithEnemy(Enemy);

                    if (MainCharacter.IsAlive())
                    {
                        if (GetMainCharacterAttackAnswer(out damage))
                        {
                            return;
                        }
                        else
                        {
                            MainCharacter.AttackOther(Enemy, damage);
                        }
                    }
                }
            }

            double distance = (new System.Windows.Point(CurrentX, CurrentY) - new System.Windows.Point(HomeTown.X, HomeTown.Y)).LengthSquared;

            if (distance < 0)
            {
                distance = -distance;
            }

            int Income = (int)(distance * 0.25d);

            if (Enemy.IsAlive())
            {
                if (Income > 0)
                {
                    MainCharacter.Orens -= Income;

                    WriteLineColor($"You have been defeated in battle.", ConsoleColor.DarkMagenta, ConsoleColor.Black);
                    WriteLineColor($"You woke in your bed.", ConsoleColor.DarkMagenta, ConsoleColor.Black);
                    WriteLineColor($"{GetOrenLabel(Income)} have been deducted from your bag...", ConsoleColor.DarkMagenta, ConsoleColor.Black);
                    WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black);
                }
                CurrentLocation = Location.LocationSpot;
                CurrentX        = HomeTown.X;
                CurrentY        = HomeTown.Y;
                ActiveLocation  = HomeTown;

                ActiveWorld.IncrementTime(12, false);
            }
            else
            {
                WriteLineColor($"You have defeated your enemy in battle!", ConsoleColor.DarkMagenta, ConsoleColor.Black);

                switch (Enemy.Race)
                {
                case Race.Orc:
                    TotalOrcsDefeated += 1;
                    break;

                case Race.Human:
                    TotalHumansDefeated += 1;
                    break;

                case Race.Elf:
                    TotalElfsDefeated += 1;
                    break;

                default:
                    break;
                }

                if (Income > 0)
                {
                    MainCharacter.Orens += Income;

                    WriteLineColor($"You found {GetOrenLabel(Income)} while searching the enemies body!!!", ConsoleColor.Yellow, ConsoleColor.Black);

                    if (Enemy.Hands != null && Percent(50))
                    {
                        WriteLineColor($"You have found {Enemy.Hands.Name}.", ConsoleColor.Yellow, ConsoleColor.Black);
                        MainCharacter.Inventory.Items.Add(WeaponItem.Clone(Enemy.Hands));
                    }

                    WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black);
                }

                ActiveWorld.IncrementTime(1, false);
            }
        }