Пример #1
0
 private void Soc_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         Mag.Focus();
     }
 }
Пример #2
0
        static void Main(string[] args)
        {
            Hero hero = StworzBohatera();
            Mag  mag  = StworzMaga();

            StworzBron(hero);

            //troszkę tekstu
            {
                Console.WriteLine(hero.Statystyki());
                Console.WriteLine($"Walczysz z magiem:\n{mag.Statystyki()}");
                Console.WriteLine("WALKA SIĘ ROZPOCZYNA");
                Console.WriteLine("naciśnij enter aby kontynuować");
                Console.ReadLine();
            }

            if (Walka(hero, mag))
            {
                DodajPieniadze(hero);
                OtworzSklep(hero);
            }
            else
            {
                KoniecGry(hero);
            }
            KoniecGry(hero);
        }
Пример #3
0
    public static void Main()
    {
        Mag witek = new Mag();

        Console.WriteLine(witek.ToString());

        Console.Read();
    }
Пример #4
0
    public override void SetPart(WeaponPart part)
    {
        base.SetPart(part);
        data = part as Mag;

        magSize    = data.GetStatsI(WeaponPartStats.MagSize, 1);
        reloadTime = data.GetStats(WeaponPartStats.ReloadTime, 1f);
    }
Пример #5
0
        static void Main(string[] args)
        {
            var w = new Wojownik();
            var m = new Mag();

            m.Stan();
            w.MakeAttack(m);
            m.Stan();
            Console.ReadKey();
        }
Пример #6
0
        private static bool Walka(Hero hero, Mag mag)
        {
            int odpowiedz = 0;

            while (true)
            {
                int iloscOdpowiedzi = 1;
                odpowiedz = 0;
                while (true)
                {
                    Console.WriteLine("Czy chcesz atakować? [1]");
                    if (hero.PotkiNaLeczenie > 0)
                    {
                        iloscOdpowiedzi = 2;
                        Console.WriteLine("Czy leczyć się? [2]");
                    }
                    odpowiedz = int.Parse(Console.ReadLine());

                    if (odpowiedz == 1 || (odpowiedz == 2 && iloscOdpowiedzi == 2))
                    {
                        break;
                    }
                    Console.WriteLine("Zła liczba");
                }

                if (odpowiedz == 1)
                {
                    mag.OdejmijHp(hero.PobierzSileAtaku());
                    Console.WriteLine("hp maga {0} wynosi {1}", mag.Nazwa, mag.Hp);
                }
                else
                {
                    hero.WypijPotke();
                }

                if (mag.Hp <= 0)
                {
                    Console.WriteLine("mag przegrał");
                    return(true);
                }



                Console.WriteLine($"Mag atakuje za {mag.PobierzSileAtaku()} ataku");
                hero.OdejmijHp(mag.PobierzSileAtaku());
                Console.WriteLine("hp {0} wynosi {1}", hero.Nazwa, hero.Hp);

                if (hero.Hp <= 0)
                {
                    Console.WriteLine("mag wygrał");
                    return(false);
                }
            }
        }
    public bool load(Mag mag)
    {
        if (mag == null)
        {
            return(false);
        }
        if (mag.GetType() != typeof(AK_Mag))
        {
            return(false);
        }

        return(true);
    }
 //private Thread fireThread;
 #endregion
 private void Awake()
 {
     mag = GetComponent <Mag>();
     //mag.Ammo = mag.Capacity;
     muzzle        = Camera.main.gameObject;
     update       += isWeaponAutomatic
         ? update += () => { if (InputManager.GetBind("Primary"))
                             {
                                 fire();
                             }
     }
     : () => { if (InputManager.GetBindDown("Primary"))
               {
                   fire();
               }
     };
     //if (allowADS) update += () => { // };
 }
Пример #9
0
        private static Mag StworzMaga()
        {
            string[] nazwyMagow = new string[] { "Gandalf",
                                                 "Saruman",
                                                 "Sauron",
                                                 "Yenefer",
                                                 "Vilgefords" };

            Random random = new Random();

            Mag mag = new Mag(random.Next(10, 30),
                              nazwyMagow[random.Next(0, nazwyMagow.Length)],
                              random.Next(11, 14),
                              random.Next(45, 60),
                              0);

            return(mag);
        }
Пример #10
0
    //========================================================================
    //  private funcs
    //Initialize Components Value
    void initializeComponents()
    {
        animator = gameObject.GetComponent <Animator>();
        if (!animator)
        {
            print("there isn't Animator"); return;
        }

        rigid = gameObject.GetComponent <Rigidbody2D>();
        if (!rigid)
        {
            print("There isn't rigid_2d"); return;
        }

        stat = gameObject.GetComponent <GamePlayerStat>();
        if (!stat)
        {
            print("There isn't Game Player Stat"); return;
        }

        state = gameObject.GetComponent <GamePlayerState>();
        if (!state)
        {
            print("Thee isn't Game Player State"); return;
        }

        collision = gameObject.GetComponent <BoxCollider2D>();
        if (!collision)
        {
            print("There isn't BoxCollider2D"); return;
        }
        mag = gameObject.GetComponent <Mag>();
        if (!mag)
        {
            print("There isn't mag"); return;
        }
    }
Пример #11
0
        static void Main(string[] args)
        {
            //PisakTest();
            //Dziedziczenie();
            //ToStringTest();
            //StatyczneTest();

            /*
             * Zadanie: Napisać program konsolowy, który będzie prosił użytkownika o podawanie
             *  kolejno liczb całkowitych, zapisywał je w tablicy i wyświetlał za każdym razem
             *  zawartość tablicy i średnią podanych liczb. Dodać metodę ZamienNaTekst, która
             *  przyjmie tablicę i zwróci ją w postaci tekstu: [el1, el2, el3].
             */

            Wojownik gracz = new Wojownik("Jan", 100, 15, 5);
            Mag      mag   = new Mag("Gandalf", 50, 20, 3);

            Console.WriteLine(gracz.WyswietlStatystyki());
            Console.WriteLine(mag.WyswietlStatystyki());

            //gracz atakuje maga:
            mag.OdejmijHP(gracz.PobierzSileAtaku());
            // \/
            mag.OdejmijHP(15);
            // \/
            mag.Hp -= 15;

            //mag atakuje grazcz:
            gracz.OdejmijHP(mag.PobierzSileAtaku());
            // Damage + Moc
            // Atak - Obrona



            //Tablice();
            //Listy();
        }
Пример #12
0
        private static void GraAdvanced()
        {
            Random random = new Random();

            Console.WriteLine("Witaj w grze Wojownik vs Magowie");
            Console.WriteLine("Podaj imie Twojego bohatera:");
            string imie = Console.ReadLine();

            // tworzymy gracza i przeciwników
            Wojownik gracz = new Wojownik(imie, random.Next(150, 300), random.Next(20, 60), 5);

            Mag[] przeciwnicy = new Mag[random.Next(1, 5)];

            for (int i = 0; i < przeciwnicy.Length; i++)
            {
                przeciwnicy[i] = new Mag("Super czarodziej " + i, random.Next(50, 150), random.Next(5, 15), 10);
            }

            Console.WriteLine("Na swojej drodze spotkałeś przeciwników.");
            foreach (Mag mag in przeciwnicy)
            {
                mag.WyswietlStatystyki();
            }

            // walka toczy się dopóki zycie któregoś z graczy nie spadnie poniżej zera
            while (true)
            {
                Console.WriteLine("Chcesz atakować [atak] czy blokować? [blok]?\n[esc] - wyjście z gry");
                string odpowiedź = Console.ReadLine();
                if (odpowiedź == "esc")
                {
                    Console.WriteLine("Wyjście z gry");
                    break;
                }
                else if (odpowiedź == "blok")
                {
                    gracz.BronSie();
                }
                else if (odpowiedź == "atak")
                {
                    Console.WriteLine("Którego przeciwnika chcesz atakować? [0-9]");
                    int index = Convert.ToInt32(Console.ReadLine());
                    if (index > przeciwnicy.Length || index < 0)
                    {
                        index = 0;
                    }
                    przeciwnicy[index].OdejmijHp(gracz.PobierzSileAtaku());
                    Console.WriteLine($"Gracz {gracz.Nazwa} atakuje.");
                    Console.WriteLine($"Przeciwnikowi zostało { przeciwnicy[index].Hp} życia.");
                }
                else
                {
                    Console.WriteLine("Podałeś złą odpowiedź, spróbuj jeszcze raz");
                    //jeżeli odpowiedź jest niepoprawna to pytamy znowu
                    continue;
                }
                // przeciwnik atakuje
                foreach (Mag mag in przeciwnicy)
                {
                    if (mag.Hp > 0)
                    {
                        int poprzednieHP = gracz.Hp;
                        gracz.OdejmijHp(mag.PobierzSileAtaku());
                        Console.WriteLine($"Mag {mag.Nazwa} zaatakował, odjął {poprzednieHP - gracz.Hp} hp");
                        Console.WriteLine($"Pozostało Ci {gracz.Hp} życia.\n");
                    }
                }
                Console.WriteLine($"Koniec ataków!\nPozostało Ci {gracz.Hp} życia.\n");
                if (gracz.Hp <= 0)
                {
                    break;
                }

                bool magowieZyja = false;
                foreach (Mag mag in przeciwnicy)
                {
                    if (mag.Hp > 0)
                    {
                        magowieZyja = true;
                        break;
                    }
                    else
                    {
                        gracz.Atak++;
                    }
                }

                if (!magowieZyja)
                {
                    break;
                }
            }

            if (gracz.Hp <= 0)
            {
                Console.WriteLine($"Niestety zostałeś pokonany. Przeciwnicy wygrali.");
            }
            else
            {
                Console.WriteLine($"Gratulację. Pokonałeś przeciwników");
            }

            Console.ReadKey();
        }
Пример #13
0
        private static void Gra()
        {
            Random random = new Random();

            Console.WriteLine("Witaj w grze Wojownik vs Magowie");
            Console.WriteLine("Podaj imie Twojego bohatera:");
            string imie = Console.ReadLine();

            // tworzymy gracza i przeciwnika
            Wojownik gracz      = new Wojownik(imie, random.Next(150, 300), random.Next(5, 15), 5);
            Mag      przeciwnik = new Mag("Super czarodziej", random.Next(150, 300), random.Next(5, 15), 10);

            Console.WriteLine("Na swojej drodze spotkałeś przeciwnika.");
            przeciwnik.WyswietlStatystyki();

            // walka toczy się dopóki zycie któregoś z graczy nie spadnie poniżej zera
            while (gracz.Hp >= 0 && przeciwnik.Hp >= 0)
            {
                // przeciwnik atakuje
                Console.WriteLine($"Gracz {przeciwnik.Nazwa} atakuje.");
                int atakPrzeciwnika = przeciwnik.PobierzSileAtaku();
                gracz.OdejmijHp(atakPrzeciwnika);
                Console.WriteLine($"Pozostało Ci {gracz.Hp} życia.\n");

                // sprawdzamy czy po ataku czasem nie zgineliśmy
                // jeżeli tak to kończymy walkę
                if (gracz.Hp <= 0)
                {
                    break;
                }

                // zatrzymujemy na pól sekundy program dla ciekawszego efektu
                System.Threading.Thread.Sleep(500);

                // my atakujemy
                Console.WriteLine($"Gracz {gracz.Nazwa} atakuje.");
                int atakGracza = gracz.PobierzSileAtaku();


                przeciwnik.OdejmijHp(atakGracza);


                Console.WriteLine($"Przeciwnikowi zostało {gracz.Hp} życia.\n");

                // sprawdzamy czy po ataku czasem nie pokonaliśmy wroga
                // jeżeli tak to kończymy walkę
                if (przeciwnik.Hp <= 0)
                {
                    break;
                }

                // zatrzymujemy na pól sekundy program dla ciekawszego efektu
                System.Threading.Thread.Sleep(500);
            }

            if (gracz.Hp <= 0)
            {
                Console.WriteLine($"Niestety zostałeś pokonany. Przeciwnik {przeciwnik.Nazwa} wygrał.");
            }
            else
            {
                Console.WriteLine($"Gratulację. Pokonałeś przeciwnika {przeciwnik.Nazwa}");
            }


            //zmniejszy hp przeciwnika o siłę ataku gracza
            przeciwnik.OdejmijHp(gracz.PobierzSileAtaku());



            Console.ReadKey();
        }
Пример #14
0
        private void PlacePawns()
        {
            ///Never spend 6 minutes doing something by hand when you can spend 6 hours failing to automate it

            //red
            Pawn defR0 = new Defender(false, new Cord(0, 3));
            Pawn defR1 = new Defender(false, new Cord(0, 7));
            Pawn defR2 = new Defender(false, new Cord(1, 4));
            Pawn defR3 = new Defender(false, new Cord(1, 5));
            Pawn defR4 = new Defender(false, new Cord(1, 6));
            Pawn defR5 = new Defender(false, new Cord(2, 5));

            Pawn magR0 = new Mag(false, new Cord(0, 4));
            Pawn magR1 = new Mag(false, new Cord(0, 6));

            Pawn kingR = new King(false, new Cord(0, 5));

            Pawn assassinR0 = new Assassin(false, new Cord(0, 0));
            Pawn assassinR1 = new Assassin(false, new Cord(0, 10));

            Pawn archerR0 = new Archer(false, new Cord(0, 1));
            Pawn archerR1 = new Archer(false, new Cord(0, 9));

            Pawn axemanR0 = new Axeman(false, new Cord(0, 2));
            Pawn axemanR1 = new Axeman(false, new Cord(0, 8));
            Pawn axemanR2 = new Axeman(false, new Cord(1, 2));
            Pawn axemanR3 = new Axeman(false, new Cord(1, 8));


            B[0, 3].PawnOnField = defR0;
            B[0, 7].PawnOnField = defR1;
            B[1, 4].PawnOnField = defR2;
            B[1, 5].PawnOnField = defR3;
            B[1, 6].PawnOnField = defR4;
            B[2, 5].PawnOnField = defR5;

            B[0, 4].PawnOnField = magR0;
            B[0, 6].PawnOnField = magR1;

            B[0, 5].PawnOnField = kingR;

            B[0, 0].PawnOnField  = assassinR0;
            B[0, 10].PawnOnField = assassinR1;

            B[0, 1].PawnOnField = archerR0;
            B[0, 9].PawnOnField = archerR1;

            B[0, 2].PawnOnField = axemanR0;
            B[0, 8].PawnOnField = axemanR1;
            B[1, 2].PawnOnField = axemanR2;
            B[1, 8].PawnOnField = axemanR3;

            //blue
            Pawn defB0 = new Defender(true, new Cord(10, 3));
            Pawn defB1 = new Defender(true, new Cord(10, 7));
            Pawn defB2 = new Defender(true, new Cord(9, 4));
            Pawn defB3 = new Defender(true, new Cord(9, 5));
            Pawn defB4 = new Defender(true, new Cord(9, 6));
            Pawn defB5 = new Defender(true, new Cord(8, 5));

            Pawn magB0 = new Mag(true, new Cord(10, 4));
            Pawn magB1 = new Mag(true, new Cord(10, 6));

            Pawn kingB = new King(true, new Cord(10, 5));

            Pawn assassinB0 = new Assassin(true, new Cord(10, 0));
            Pawn assassinB1 = new Assassin(true, new Cord(10, 10));

            Pawn archerB0 = new Archer(true, new Cord(10, 1));
            Pawn archerB1 = new Archer(true, new Cord(10, 9));

            Pawn axemanB0 = new Axeman(true, new Cord(10, 2));
            Pawn axemanB1 = new Axeman(true, new Cord(10, 8));
            Pawn axemanB2 = new Axeman(true, new Cord(9, 2));
            Pawn axemanB3 = new Axeman(true, new Cord(9, 8));



            B[10, 3].PawnOnField = defB0;
            B[10, 7].PawnOnField = defB1;
            B[9, 4].PawnOnField  = defB2;
            B[9, 5].PawnOnField  = defB3;
            B[9, 6].PawnOnField  = defB4;
            B[8, 5].PawnOnField  = defB5;

            B[10, 4].PawnOnField = magB0;
            B[10, 6].PawnOnField = magB1;

            B[10, 5].PawnOnField = kingB;

            B[10, 0].PawnOnField  = assassinB0;
            B[10, 10].PawnOnField = assassinB1;

            B[10, 1].PawnOnField = archerB0;
            B[10, 9].PawnOnField = archerB1;

            B[10, 2].PawnOnField = axemanB0;
            B[10, 8].PawnOnField = axemanB1;
            B[9, 2].PawnOnField  = axemanB2;
            B[9, 8].PawnOnField  = axemanB3;
        }
Пример #15
0
        /// <summary>
        /// Requests a reading from the sensor and updates its data properties with the gathered values.
        /// </summary>
        /// <returns>An awaitable Task</returns>
        /// <remarks>
        /// Note that when #AutoUpdateWhenPropertyRead is `true` (which it is, by default), this method is implicitly
        /// called when any sensor data property is read from --- there's no need to call this method unless you set
        /// AutoUpdateWhenPropertyRead to `false`.
        ///
        /// Unless otherwise noted, this method updates all sensor data simultaneously, which can often lead to more efficient
        /// bus usage (as well as reducing USB chattiness).
        /// </remarks>
        public async Task UpdateAsync()
        {
            await Accel.UpdateAsync().ConfigureAwait(false);

            await Mag.UpdateAsync().ConfigureAwait(false);
        }