Esempio n. 1
0
        public Travicka(PoleTravy pole)
        {
            var rnd = new Random();

            this.posX      = rnd.Next(1, pole.height - 1);
            this.posY      = rnd.Next(1, pole.width - 1);
            this.zdravi    = 1;
            this.skore     = 0;
            this.pole      = pole;
            this.idBytosti = index;
            index++;
            this.nick = "T" + this.idBytosti;
            pole.data.Rows[this.posY - 1][this.posX - 1] = nick;
            this.sila = 10;
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // Rozmery pole
            int height = 10;
            int width  = 10;

            // Kontejnery na objekty
            PoleTravy pole = new PoleTravy(width, height);

            // Policko = objekt, na kterym muze byt jinej objekt

            // Model = data, co mame

            // Kontroler = neco jako GUI, ovladani hry

            // MVC = model view controller = pattern, jak se delaji hry, nebo neco takovy

            // Extra tridy / metody = nahazet zvlast do jine tridy

            // Generovani travicek
            for (int i = 0; i < height * width / 2; i++)
            {
                bytosti.Add(new Travicka(pole));
            }

            // Generovani berusek
            for (int i = 0; i < height * width / 10; i++)
            {
                bytosti.Add(new Beruska(pole));
            }

            // Generovani holcicek
            for (int i = 0; i < height * width / 50; i++)
            {
                bytosti.Add(new Holcicka(pole));
            }

            // Cyklus pro chod programu
            string input = "";

            while (input != "K")
            {
                // Rust travy
                bytosti.Add(new Travicka(pole));

                // Pohyb bytosti (Travicka, holcicky, berusky)
                foreach (var bytost in bytosti)
                {
                    bytost.Move();
                    foreach (var cil in bytosti)
                    {
                        if (bytost.posX == cil.posX && bytost.posY == cil.posY && bytost.sila > cil.sila && cil.isAlive == true)
                        {
                            SimpleFight(
                                Convert.ToInt32(bytost.nick.Substring(1, bytost.nick.Length - 1)),
                                Convert.ToInt32(cil.nick.Substring(1, cil.nick.Length - 1))
                                );

                            /*
                             * Fight(
                             *  Convert.ToInt32(bytost.nick.Substring(1, bytost.nick.Length-1)),
                             *  Convert.ToInt32(cil.nick.Substring(1, cil.nick.Length-1))
                             *  );*/
                        }
                    }
                }
                // Zobrazeni bytosti
                foreach (var bytost in bytosti)
                {
                    if (bytost.isAlive == true)
                    {
                        bytost.ShowMe();
                    }
                }

                // Zobrazeni hranic pole
                pole.ShowMe();

                // Zobrazeni skore
                ShowScore();

                // Cteni vstupu
                Console.SetCursorPosition(0, 0);
                input = Console.ReadLine();
                Console.Clear();
            }
        }