コード例 #1
0
        static void Fight()
        {
            Pantera[] panteras = new Pantera[5];
            T34[]     t34s     = new T34[5];

            int destroyedPanteras = 0;
            int destroyedT34s     = 0;


            for (int i = 0; i < 5; i++)
            {
                panteras[i] = new();
                t34s[i]     = new();
            }

            for (int i = 0; i < 5; i++)
            {
                System.Console.WriteLine();

                Console.Write("Pantera\t\t\tT34\n");

                Console.Write(panteras[i].GetAmmunition() + "\t\t\t"
                              + t34s[i].GetAmmunition() + '\n');

                Console.Write(panteras[i].GetArmor() + "\t\t\t"
                              + t34s[i].GetArmor() + '\n');

                Console.Write(panteras[i].GetManeuverability() + "\t\t\t"
                              + t34s[i].GetManeuverability() + '\n');

                Base winner = panteras[i] * t34s[i];

                if (winner is Pantera)
                {
                    System.Console.Write("\n\t\tPantera WON!");
                    destroyedT34s++;
                }
                else if (winner is T34)
                {
                    System.Console.Write("\n\t\tT34 WON!");
                    destroyedPanteras++;
                }

                System.Console.WriteLine();
            }

            if (destroyedPanteras > destroyedT34s)
            {
                System.Console.WriteLine("\n\n\n\t\tWINNER : T34 WON");
            }
            else if (destroyedPanteras < destroyedT34s)
            {
                System.Console.WriteLine("\n\n\n\t\tWINNER : PANTERAS");
            }
            else
            {
                System.Console.WriteLine("\n\n\n\t\tDRAW");
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var rnd = new Random();

            Tank[] p = new Tank[3];
            T34[]  t = new T34[3];
            for (int i = 0; i < 3; i++)
            {
                p[i] = new Tank();
            }
            for (int i = 0; i < p.Length; i++)
            {
                t[i] = new T34(rnd.Next(5, 10), rnd.Next(80, 110), rnd.Next(1, 100), rnd.Next(1, 10), rnd.Next(1, 10), "T34");
            }
            Pantera[] pantera = new Pantera[3];
            for (int i = 0; i < p.Length; i++)
            {
                pantera[i] = new Pantera(rnd.Next(5, 10), rnd.Next(80, 110), rnd.Next(1, 100), rnd.Next(1, 10), rnd.Next(1, 10), "pantera");
            }

            for (int i = 0; i < 3; i++)
            {
                //Console.WriteLine("До боя:");
                //t[i].Print();
                //pantera[i].Print();
                //Console.WriteLine("ПослЕ боя:");
                //t[i].Print();
                //pantera[i].Print();
                Tank.Winner(t[i], pantera[i]);
                p[i] = t[i] * pantera[i];
                Console.WriteLine("Победил:");
                p[i].Print();
                if (p[i] == p[2])
                {
                    if (p[0].Name == p[1].Name || p[0].Name == p[2].Name)
                    {
                        Console.WriteLine("Победила армия " + p[0].Name);
                    }
                    else
                    {
                        Console.WriteLine("Победила армия " + p[1].Name);
                    }
                }
                Console.WriteLine();
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Random        rnd       = new Random();
            List <string> Wins      = new List <string>();
            int           warresult = 0;
            bool          result;

            for (int i = 1; i < 6; i++)
            {
                T34 t1     = new T34 {
                };
                Pantera t2 = new Pantera {
                };
                result = t1 ^ t2;

                if (result)
                {
                    Wins.Add(t1.model);
                    warresult++;
                }
                else
                {
                    Wins.Add(t2.model);
                }
            }

            Wins.Sort();
            foreach (string i in Wins)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine();
            if (warresult >= 3)
            {
                Console.WriteLine($"First tank win in war");
            }
            else
            {
                Console.WriteLine($"Second tank win in war");
            }
        }
コード例 #4
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Pantera scr = rbd.gameObject.GetComponent <Pantera>();

        if (col.tag.Equals("ataque"))
        {
            PegaAtaque  dano = col.gameObject.GetComponent <PegaAtaque>();
            Rigidbody2D ribd = rbd.GetComponent <Rigidbody2D>();
            if (ribd.transform.position.x < col.transform.position.x)
            {
                scr.encostouDir = true;
            }
            else
            {
                scr.encostouDir = false;
            }
            scr.tomouDano(dano.dano, dano.knockback);
        }
        if (col.tag.Equals("itemArremeco"))
        {
            itemArremeco danoI = col.gameObject.GetComponent <itemArremeco>();



            Rigidbody2D ribd = rbd.GetComponent <Rigidbody2D>();
            if (ribd.transform.position.x < col.transform.position.x)
            {
                scr.encostouDir = true;
            }
            else
            {
                scr.encostouDir = false;
            }
            scr.tomouDano(danoI.dano, danoI.knockback);
        }
    }