Example #1
0
        public void AttackMainPlayWithEnemy(Humanoid Enemy)
        {
            var power  = Enemy.GetWearablePower();
            var damage = 0;

            if (power.Strength > power.Inteligence)
            {
                damage = Enemy.GetAttackDamage();
            }
            else
            {
                damage = Enemy.GetMagicDamage();
            }
            Enemy.AttackOther(MainCharacter, damage);
        }
Example #2
0
        public void AttackOther(Humanoid other, int damage)
        {
            if (damage < 0)
            {
                damage = 0;
            }

            damage = other.CompressDamage(damage);

            var xp = damage * 4;

            CombatLevel.AddXP(xp);

            if (this == Program.ActiveWorld.MainCharacter)
            {
                WriteLineColor($"You did {damage} damage to {(string.IsNullOrWhiteSpace(other.Name) ? "the enemy" : other.Name)}", ConsoleColor.Red, ConsoleColor.Black);
                if (xp > 0)
                {
                    WriteLineColor($"You received {xp} xp", ConsoleColor.DarkCyan, ConsoleColor.Black);
                }
            }
            else if (other == Program.ActiveWorld.MainCharacter)
            {
                WriteLineColor($"You received {damage} damage from {(string.IsNullOrWhiteSpace(this.Name) ? "the enemy" : this.Name)}", ConsoleColor.Red, ConsoleColor.Black);
            }
            else
            {
                WriteLineColor($"{(string.IsNullOrWhiteSpace(this.Name) ? "the enemy 1" : this.Name)} did {damage} damage to {(string.IsNullOrWhiteSpace(other.Name) ? "the enemy 2" : other.Name)}", ConsoleColor.Red, ConsoleColor.Black);
            }

            other.AddHealth(-damage);

            if (other == Program.ActiveWorld.MainCharacter)
            {
                WriteLineColor($"{(string.IsNullOrWhiteSpace(this.Name) ? "the enemy" : this.Name)}'s health is now {this.Health}", ConsoleColor.Red, ConsoleColor.Black);
            }

            Program.UpdateStats(Program.ActiveWorld.MainCharacter);
        }
Example #3
0
 public static void UpdateStats(Humanoid livingEntity)
 {
     stats.UpdateStats(livingEntity);
 }
Example #4
0
 public void Death(Humanoid humanoid)
 {
     Humanoids.Remove(humanoid);
 }
Example #5
0
 public Humanoid Born(Humanoid humanoid)
 {
     Humanoids.Add(humanoid);
     return(humanoid);
 }
Example #6
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);
            }
        }
Example #7
0
        public void ProcessRandomEvent()
        {
            if (Percent(50))     // 100 / 2 = 50%
            {
                if (Percent(25)) // 100 / 4 = 25%
                {
                    CurrentForestEvent = ForestEvent.Battle;
                    var Enemies = new Humanoid();

                    Enemies.Gender = (Gender)random.Next(2);
                    Enemies.Race   = (Race)random.Next(3);

                    Enemies.SetLevel(MainCharacter.CombatLevel.Value);
                    if (Percent(50))
                    {
                        Enemies.Hands = WeaponItem.Clone(Database.Weapons[random.Next(Database.Weapons.Count)]);
                    }

                    WriteLineColor($"You are under attack by a {Enemies.Gender} {Enemies.Race} level {Enemies.CombatLevel.Value}!!!!", ConsoleColor.Red, ConsoleColor.Black);
                    var power = Enemies.GetWearablePower();
                    WriteLineColor($"this enemy has {power.Strength} strength {power.Defence} defence and {power.Inteligence} inteligence", ConsoleColor.DarkCyan, ConsoleColor.Black);
                    ProcessAttackScreen(Enemies);
                    if (CurrentLocation == Location.Forest)
                    {
                        WriteLine($"Your current location is now {CurrentX}, {CurrentY}.");
                    }
                    CurrentForestEvent = ForestEvent.None;
                    stats.UpdateWorld(this);
                }
                else if (Percent(10))
                {
                    var orens = random.Next(30, 101);

                    MainCharacter.Orens += orens;
                    WriteLineColor($"You found {GetOrenLabel(orens)} on the ground!!!", ConsoleColor.Yellow, ConsoleColor.Black);
                    WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black);
                }
                else if (Percent(10))
                {
                    CurrentForestEvent = ForestEvent.Stranger;
                    var person = new Humanoid();
                    person.Gender = (Gender)random.Next(2);
                    person.Race   = (Race)random.Next(3);
                    person.SetRandomNewName();
                    person.SetLevel(random.Next(MainCharacter.CombatLevel.Value + 5));
                    stats.UpdateWorld(this);
                    WriteLineColor($"Stranger approachers...\r\n i'm looking for somewhere to live", ConsoleColor.Red, ConsoleColor.Black);
                    string input = Question("Do you want to help this stranger?", "no", "yes");
                    if (input == "yes")
                    {
                        TotalStrangersCollected += 1;

                        WriteLine($"Sure you can come to my town {HomeTown.Name}.");
                        WriteLine($"The Coordinates are {HomeTown.X}, {HomeTown.Y}.");
                        int xp = 100;

                        if (Percent(15))
                        {
                            person.Smithing.AddXP(person.Smithing.GetXPToLevelUp(RandomNumber(30)));

                            if (person.Smithing.Value > 15)
                            {
                                HomeTown.Buildings.Add(new Buildings()
                                {
                                    Owner = person, Type = BuildingType.Blacksmith
                                });

                                WriteLineColor($"{person.Name}, Just opened a new Blacksmith at your home town.", ConsoleColor.Yellow, ConsoleColor.Black);
                                xp += 100;
                            }
                        }
                        else if (Percent(15))
                        {
                            person.Barter.AddXP(person.Barter.GetXPToLevelUp(RandomNumber(30)));

                            if (person.Barter.Value > 10)
                            {
                                HomeTown.Buildings.Add(new Buildings()
                                {
                                    Owner = person, Type = BuildingType.Store
                                });

                                WriteLineColor($"{person.Name}, Just opened a new store at your home town.", ConsoleColor.Yellow, ConsoleColor.Black);
                                xp += 100;
                            }
                        }

                        WriteLineColor($"{person.Name}: Well i better get going then, Thank you so much, Catch you soon.", ConsoleColor.Yellow, ConsoleColor.Black);

                        int orens = RandomNumber(50);
                        if (orens > 0)
                        {
                            MainCharacter.Orens += orens;

                            WriteLineColor($"Hope this helps you, {person.Name} gave you {GetOrenLabel(orens)}", ConsoleColor.Yellow, ConsoleColor.Black);
                            WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black);

                            UpdateStats(MainCharacter);

                            xp += 10;
                        }

                        MainCharacter.Barter.AddXP(xp);

                        WriteLineColor($"You received {xp} xp for Barter Skill.", ConsoleColor.DarkCyan, ConsoleColor.Black);

                        HomeTown.PeopleWhoLiveHere.Add(person);
                    }
                    else
                    {
                        int orens = 100;

                        MainCharacter.Orens += orens;

                        WriteLine("I'm a bandit, give me all your orens and you wont get hurt!");
                        WriteLineColor($"You stole {GetOrenLabel(orens)}!!!", ConsoleColor.Yellow, ConsoleColor.Black);
                        WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black);

                        UpdateStats(MainCharacter);
                    }
                    CurrentForestEvent = ForestEvent.None;
                    stats.UpdateWorld(this);
                    WriteLine($"Your current location is now {CurrentX}, {CurrentY}.");
                }
            }
            UpdateStats(MainCharacter);
        }
Example #8
0
        public void UpdateStats(Humanoid livingEntity)
        {
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.InvokeRequired)
            {
                VoidWithAbility d = new VoidWithAbility(UpdateStats);
                this.Invoke(d, new object[] { livingEntity });
            }
            else
            {
                ActiveHuman = livingEntity;

                var x = livingEntity.GetWearablePower();

                this.labelStrength.Text    = "Strength: " + livingEntity.Power.Strength + " / " + x.Strength;
                this.labelInteligence.Text = "Inteligence: " + livingEntity.Power.Inteligence + " / " + x.Inteligence;
                this.labelDefence.Text     = "Defence: " + livingEntity.Power.Defence + " / " + x.Defence;
                this.labelHealth.Text      = "Health: " + livingEntity.Health;
                this.labelXP.Text          = $"XP: {livingEntity.CombatLevel.XP} / {livingEntity.CombatLevel.XPToLevelUp}";
                this.labelName.Text        = "Name: " + livingEntity.Name;
                this.labelRace.Text        = "Race: " + livingEntity.Race.ToString("G");
                this.labelGender.Text      = "Gender: " + livingEntity.Gender.ToString("G");
                this.labelTime.Text        = "Time: " + ActiveWorld.TimeInDay;
                this.labelDay.Text         = "Day: " + ActiveWorld.Day;

                if (livingEntity.Orens == 1)
                {
                    this.labelOrens.Text = "Oren: " + livingEntity.Orens;
                }
                else
                {
                    this.labelOrens.Text = "Orens: " + livingEntity.Orens;
                }

                this.labelPoints.Text = livingEntity.AvailablePowerPoints.ToString();
                this.labelLevel.Text  = "Level: " + livingEntity.CombatLevel.Value;
                UpdatePointButtons();

                dataEquipt.Columns.Clear();
                dataEquipt.DataSource = null;

                var dt = new DataTable();

                dt.Columns.Add("Name", typeof(string));
                dt.Columns.Add("Description", typeof(string));
                dt.Columns.Add("Strength", typeof(int));
                dt.Columns.Add("Inteligence", typeof(int));
                dt.Columns.Add("Defence", typeof(int));
                dt.Columns.Add("Location", typeof(string));
                dt.Columns.Add("Item", typeof(Item));

                AddRowToEquipt(dt, livingEntity.Head);
                AddRowToEquipt(dt, livingEntity.Chest);
                AddRowToEquipt(dt, livingEntity.Legs);
                AddRowToEquipt(dt, livingEntity.Feet);
                AddRowToEquipt(dt, livingEntity.Hands);
                AddRowToEquipt(dt, livingEntity.Belt);

                dt.AcceptChanges();

                var dt2 = new DataTable();

                dt2.Columns.Add("Name", typeof(string));
                dt2.Columns.Add("Description", typeof(string));
                dt2.Columns.Add("Item", typeof(Item));

                foreach (Item item in livingEntity.Inventory.Items)
                {
                    DataRow dr   = dt2.NewRow();
                    string  name = item.Name;

                    if (item is ResourceItem)
                    {
                        name = (item as ResourceItem).Quantity + " " + name;
                    }

                    dr["Name"]        = name;
                    dr["Description"] = item.Description;
                    dr["Item"]        = item;

                    dt2.Rows.Add(dr);
                }

                dt2.AcceptChanges();


                dataEquipt.DataSource    = dt;
                dataInventory.DataSource = dt2;

                HideAndReadOnlyDT(dataEquipt);
                HideAndReadOnlyDT(dataInventory);

                gridQuests.Columns.Clear();
                gridQuests.DataSource = null;

                DataTable dt3 = new DataTable();

                dt3.Columns.Add("Description", typeof(string));
                dt3.Columns.Add("Days Old", typeof(int));
                dt3.Columns.Add("quest", typeof(Quest));

                foreach (Quest quest in livingEntity.ActivatedQuests)
                {
                    DataRow dr = dt3.NewRow();

                    switch (quest.Type)
                    {
                    case QuestType.GatherTrees:
                    case QuestType.GatherFish:
                        dr["Description"] = $"Gather {quest.QuantityTillFinished} {(quest.Type == QuestType.GatherTrees ? "wood" : "fish")}";
                        break;

                    case QuestType.GatherStrangers:
                        dr["Description"] = $"Meet {quest.QuantityTillFinished} strangers and allow them to join your home town.";

                        break;

                    case QuestType.FightOrc:
                    case QuestType.FightElfs:
                    case QuestType.FightHumans:
                        dr["Description"] = $"Defeat {quest.QuantityTillFinished} {((quest.Type == QuestType.FightOrc ? "orc" : quest.Type == QuestType.FightElfs ? "elf" : "human") + (quest.QuantityTillFinished > 1 ? "'s" : ""))} in battle.";
                        break;
                    }
                    dr["quest"] = quest;

                    dt3.Rows.Add(dr);
                }

                dt3.AcceptChanges();

                gridQuests.DataSource = dt3;

                gridQuests.Columns["quest"].Visible = false;
            }
        }