Beispiel #1
0
        public override void Action(Creature target)
        {
            var random = new Random();
            var chanceToUseAbility = random.Next(0, 4);
            var randomAbility = this.GetRandomAbility();
            var damage = 0;

            if (chanceToUseAbility == 2 && this.Energy >= randomAbility.EnergyCost)
            {
                MediaPlayer.Play(Sound.Slam);
                this.Energy -= randomAbility.EnergyCost;

                if (randomAbility.AbilityEffect == AbilityEffects.DirectDamage)
                {
                   damage = randomAbility.EnergyCost;

                    if (target.Health < damage)
                    {
                        target.Health = 0;
                        return;
                    }

                    target.Health -= damage;

                    Console.WriteLine(
                        DrawHelper.Color("► " + this.Name, ConsoleColor.Cyan),
                        DrawHelper.Color("hit you with", ConsoleColor.Green),
                        DrawHelper.Color(randomAbility.Name, ConsoleColor.Yellow),
                        DrawHelper.Color("for:", ConsoleColor.Green),
                        DrawHelper.Color(damage.ToString(), ConsoleColor.Red),
                        DrawHelper.Color("damage!", ConsoleColor.Green));
                }
            }
            else
            {
                MediaPlayer.Play(Sound.Strike);

                damage = random.Next(1, this.Attack);

                if (target.Health >= damage)
                {
                    target.Health -= damage;
                }
                else
                {
                    target.Health = 0;
                }

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("► The nasty {0} inflicts {1} damage to your skinny body.", this.Name, damage);
                Console.ResetColor();
            }

            DrawHelper.ReloadStats(target);
        }
Beispiel #2
0
        public static void ReloadStats(Creature enemy)
        {
            string charClass = Player.Pesho.GetType().Name;
            int level = Player.Pesho.Level;
            const int StartPos = 7;

            var peshoStats = new[]
            {
               new { stat = Player.Pesho.Health, color = ConsoleColor.Magenta },
               new { stat = Player.Pesho.Energy, color = ConsoleColor.Cyan },
               new { stat = Player.Pesho.Initiative, color = ConsoleColor.DarkGreen },
               new { stat = Player.Pesho.Attack, color = ConsoleColor.Red },
            };

            var enemyStats = new[]
            {
                new { stat = enemy.Health, color = ConsoleColor.Magenta },
                new { stat = enemy.Energy, color = ConsoleColor.Cyan },
                new { stat = enemy.Initiative, color = ConsoleColor.DarkGreen },
                new { stat = enemy.Attack, color = ConsoleColor.Red },
            };

            for (int i = 0; i < peshoStats.Length; i++)
            {
                Console.SetCursorPosition(100, StartPos + i);
                Console.Write(Color(peshoStats[i].stat.ToString(), peshoStats[i].color));
                Console.SetCursorPosition(25, StartPos + i);
                Console.Write(Color(enemyStats[i].stat.ToString(), enemyStats[i].color));
            }

            var classColor = charClass == "Mage" ? ConsoleColor.Blue : ConsoleColor.DarkRed;

            TextAtPosition(level + " lvl", 94, 5, ConsoleColor.Yellow);
            TextAtPosition(charClass + "  ", 101, 5, classColor);

            if (enemy.Name.Length > 10)
            {
                TextAtPosition(enemy.Name, 17, 5, ConsoleColor.DarkCyan);
            }
            else if (enemy.Name.Length > 6)
            {
                TextAtPosition(enemy.Name, 19, 5, ConsoleColor.DarkCyan);
            }
            else
            {
                TextAtPosition(enemy.Name, 21, 5, ConsoleColor.DarkCyan);
            }
        }
Beispiel #3
0
 public virtual void Action(Creature target)
 {
 }
Beispiel #4
0
        public void Action(Creature target, ConsoleKeyInfo action)
        {
            var random = new Random();
            var result = random.Next(0, 10);
            var attackSucceeded = result > 1;
            int key = (int)action.Key - 49;

            var damageModifier = this.GetType().Name == "Mage" ? this.Intellect : this.Strength;

            if (action.Key.Equals(ConsoleKey.Escape))
            {
                LoadScreen.LoadIngameMenu();
            }
            else if (key > this.Abilities.Count || key < 0)
            {
                throw new GameException("You need to choose action between 1 and " + Abilities.Count);
            }
            else if (this.Energy < this.Abilities[key].EnergyCost)
            {
                throw new GameException("You don't have enough energy for this ability!");
            }
            else
            {
                Ability ability = this.Abilities[key];
                var damage = (this.Attack + ((damageModifier / 2) + ability.EnergyCost)) / 2;
                var storedAgility = this.Agility;
                this.Energy -= ability.EnergyCost;

                if (ability.AbilityEffect.Equals(AbilityEffects.Speed))
                {
                    var chancesToEscape = this.Agility + this.Initiative;
                    bool gotLucky = random.Next(0, 10) >= 5;

                    if (chancesToEscape > target.Initiative && gotLucky)
                    {
                        Console.WriteLine(
                            DrawHelper.Color("► You successfully escaped from", ConsoleColor.Green),
                            DrawHelper.Color(target.Name, ConsoleColor.Red));
                        this.Agility = storedAgility;
                        Engine.BossFight = false;
                        DrawHelper.BlockInputAndWaitFor(3);
                        StoryEngine.StateAfterBattle();
                    }
                    else
                    {
                        Console.WriteLine(
                            DrawHelper.Color("► You fail to escape from", ConsoleColor.Red),
                            DrawHelper.Color(target.Name, ConsoleColor.DarkMagenta));
                    }
                }
                else if (ability.AbilityEffect.Equals(AbilityEffects.Dodge))
                {
                    if (this.Agility < 50)
                    {
                        Console.WriteLine(
                            DrawHelper.Color("► You perform", ConsoleColor.White),
                            DrawHelper.Color(ability.Name, ConsoleColor.Yellow),
                            DrawHelper.Color("which increases your chance to dodge by", ConsoleColor.White),
                            DrawHelper.Color("50%", ConsoleColor.Green));
                        damage = 0;
                        this.Agility += 50;
                    }
                    else
                    {
                        throw new GameException(
                            "You can not use this ability more than once in a single battle!");
                    }
                }
                else
                {
                    if (attackSucceeded)
                    {
                        switch (ability.AbilityEffect)
                        {
                            case AbilityEffects.DirectDamage:
                                MediaPlayer.Play(Sound.Hit);
                                Console.WriteLine(
                                    DrawHelper.Color("► You perform", ConsoleColor.White),
                                    DrawHelper.Color(ability.Name, ConsoleColor.Yellow),
                                    DrawHelper.Color("and hit", ConsoleColor.White),
                                    DrawHelper.Color(target.Name, ConsoleColor.Cyan),
                                    DrawHelper.Color("for", ConsoleColor.White),
                                    DrawHelper.Color(damage.ToString(), ConsoleColor.Green),
                                    DrawHelper.Color("damage!", ConsoleColor.White));
                                break;
                            case AbilityEffects.Freeze:
                                MediaPlayer.Play(Sound.Freeze);
                                Console.WriteLine(
                                    DrawHelper.Color("► You cast", ConsoleColor.White),
                                    DrawHelper.Color(ability.Name, ConsoleColor.Blue),
                                    DrawHelper.Color("on", ConsoleColor.White),
                                    DrawHelper.Color(target.Name, ConsoleColor.Cyan),
                                    DrawHelper.Color("dealing", ConsoleColor.White),
                                    DrawHelper.Color(damage.ToString(), ConsoleColor.Yellow),
                                    DrawHelper.Color("damage", ConsoleColor.White),
                                    DrawHelper.Color("freezing him for the next turn.", ConsoleColor.Blue));
                                target.Initiative = 0;
                                break;

                            case AbilityEffects.Ultimate:
                                if (this.GetType().Name == "Mage")
                                {
                                    this.Energy = 0;
                                    damage = target.Energy;
                                    target.Energy = 0;

                                    Console.WriteLine(
                                        DrawHelper.Color(
                                            "► You gaze deep into your opponent's eyes and and slowly but steadly drain all his and yours remaining energy dealing",
                                            ConsoleColor.Magenta),
                                        DrawHelper.Color(damage.ToString(), ConsoleColor.Yellow),
                                        DrawHelper.Color("damage!", ConsoleColor.Magenta));
                                }
                                else
                                {
                                    if (this.Health >= 10)
                                    {
                                        damage = (this.Attack + damageModifier) * 2;
                                        this.Health -= Health / 10;
                                        Console.WriteLine(
                                            DrawHelper.Color(
                                                "► You strike ferociously thrusting your blade through",
                                                ConsoleColor.Magenta),
                                            DrawHelper.Color(target.Name + "'s", ConsoleColor.Cyan),
                                            DrawHelper.Color("dark and corrupted flesh, inflicting",
                                                ConsoleColor.Magenta),
                                            DrawHelper.Color(damage.ToString(), ConsoleColor.Yellow),
                                            DrawHelper.Color("damage!", ConsoleColor.Magenta));
                                    }
                                    else
                                    {
                                        throw new GameException("You can not use this ability when you are below 10 hp.");
                                    }
                                }

                                break;
                        }

                        if (target.Health < damage)
                        {
                            target.Health = 0;
                            DrawHelper.ReloadStats(target);
                            return;
                        }

                        target.Health -= damage;
                    }
                    else
                    {
                        MediaPlayer.Play(Sound.Miss);
                        Console.WriteLine(result == 0
                            ? DrawHelper.Color("You missed.", ConsoleColor.Gray)
                            : DrawHelper.Color(target.Name + " evaded your " + ability.Name, ConsoleColor.DarkGray));
                    }
                }
            }

            DrawHelper.ReloadStats(target);
        }