예제 #1
0
        static void Main()
        {
            List <fighter> LadderEasy = new List <fighter>();

            LadderEasy.Add(new fighter("raiden", 100, 8));
            LadderEasy.Add(new fighter("scorpion", 110, 9));
            LadderEasy.Add(new fighter("motaro", 150, 10));
            LadderEasy.Add(new fighter("Shao-Khan", 180, 12));

start:
            fighter player = new fighter("player", 100, 10);

            Console.WriteLine("press any key to start");
            Console.ReadKey();

            for (int i = 0; i < LadderEasy.Count; i++)
            {
                if (player.fight(LadderEasy[i]))
                {
                    Buff(player);
                }
                else
                {
                    goto start;
                }
            }


            Console.WriteLine("you beat everyone!");
        }
예제 #2
0
        static void Buff(fighter player)
        {
            Console.WriteLine("1 - max health + 20%");
            Console.WriteLine("2 - damage +25%");
            Console.WriteLine();
            int choice;

inp:

            try
            {
                choice = int.Parse(Console.ReadLine());
            }
            catch
            {
                Console.WriteLine("input the right one");
                goto inp;
            }


            if (choice == 1)
            {
                player.MaxHealth *= 1.2;
            }
            else if (choice == 2)
            {
                player.Damage *= 1.25;
            }
            else
            {
                Console.WriteLine("input the right one");
                goto inp;
            }
        }
예제 #3
0
        public bool fight(fighter enemy)
        {
            this.health  = this.maxHealth;
            enemy.health = enemy.maxHealth;
            this.Mana    = 0;
            enemy.Mana   = 0;

            List <hit> hits = new List <hit>();

            hits.Add(new hit(50, 2, "High Kick"));          //0
            hits.Add(new hit(75, 1.35, "Low Kick"));        //1
            hits.Add(new hit(60, 1.75, "High Punch"));      //2
            hits.Add(new hit(100, 1, "Low Punch"));         //3
            hits.Add(new hit(100, 0.1, "Block"));           //4
            hits.Add(new Spell(100, 0, "Ice Bolt", 2, 30)); //5
            hits.Add(new Spell(80, 0.5, "Zap", 1, 10));     //6

            Console.WriteLine("input action:");
            Console.WriteLine("e-high kick");
            Console.WriteLine("d-low kick");
            Console.WriteLine("q-high punch");
            Console.WriteLine("a-low punch");
            Console.WriteLine("s-block");
            Console.WriteLine("w-ice bolt(30MP)");
            Console.WriteLine("f-zap(10MP)");

            Console.WriteLine(this.name + " " + this.health + "   " + enemy.health + " " + enemy.name);

            while (true)
            {
                ConsoleKeyInfo act = Console.ReadKey();
                Console.WriteLine();


                this.currDamage  = this.damage;
                enemy.currDamage = enemy.damage;
                switch (act.KeyChar)    //playerHitting
                {
                case 'e':
                {
                    this.currDamage = hits[0].attack(this.damage);
                    this.Mana      += 10;
                    break;
                }

                case 'd':
                {
                    this.currDamage = hits[1].attack(this.damage);
                    this.Mana      += 10;
                    break;
                }

                case 'q':
                {
                    this.currDamage = hits[2].attack(this.damage);
                    this.Mana      += 10;
                    break;
                }

                case 'a':
                {
                    this.currDamage = hits[3].attack(this.damage);
                    this.Mana      += 10;
                    break;
                }

                case 's':
                {
                    this.currDamage  = 0;
                    enemy.currDamage = hits[4].attack(enemy.damage);
                    this.Mana       += 5;
                    break;
                }

                case 'w':
                {
                    if (this.Mana >= 30)
                    {
                        this.Mana           -= 30;
                        enemy.StunnedRounds += 3;
                        this.currDamage      = hits[5].attack(this.Damage);
                    }
                    else
                    {
                        Console.WriteLine("not enough mana!");
                    }
                    break;
                }

                case 'f':
                {
                    if (this.Mana >= 10)
                    {
                        this.Mana      -= 10;
                        this.currDamage = hits[6].attack(this.Damage);
                        if (this.CurrDamage > 0)
                        {
                            enemy.StunnedRounds += 1;
                        }
                    }
                    else
                    {
                        Console.WriteLine("not enough mana!");
                    }
                    break;
                }

                default:
                {
                    this.currDamage = 0;
                    Console.WriteLine("stop doing nothing and hit the enemy!");
                    break;
                }
                }


                if (this.checkStunned())
                {
                    this.CurrDamage = 0;
                }
                if (enemy.checkStunned())
                {
                    enemy.CurrDamage = 0;
                }


                enemy.health -= this.currDamage;
                this.health  -= enemy.currDamage;



                //results
                Console.WriteLine();
                Console.WriteLine(this.name + " " + this.Mana + "MP  " + this.health + "HP    " + enemy.health + " " + enemy.name);
                if (this.health <= 0 && enemy.health <= 0)
                {
                    Console.WriteLine("draw!");
                    return(false);
                }
                if (this.health <= 0)
                {
                    Console.WriteLine("enemy won with " + enemy.health + " HP");
                    Console.WriteLine();
                    return(false);
                }

                if (enemy.health <= 0)
                {
                    Console.WriteLine("you won with " + this.health + " HP");
                    Console.WriteLine();
                    return(true);
                }
            }
        }