Esempio n. 1
0
 public void Otocit(NatoceniLode uhel)
 {
     if (Console.ReadKey(true).KeyChar == 'e')
     {
         uhel++;
     }
 }
Esempio n. 2
0
        public override void RozmistitLode()
        {
            Random nahoda = new Random((int)DateTime.Now.Ticks);

            List <Souradnice> polickaVsechLodi;

            int jeti = 1;


            polickaVsechLodi = new List <Souradnice>();

            foreach (Lod l in Lode)
            {
                List <Souradnice> testovanaPolicka = new List <Souradnice>();

                do
                {
                    testovanaPolicka.Clear();
                    testovanaPolicka.AddRange(polickaVsechLodi);

                    int x = nahoda.Next(10);
                    int y = nahoda.Next(10);

                    NatoceniLode natoceni = (NatoceniLode)nahoda.Next(4);

                    l.Premistit(new Souradnice(x, y), natoceni);

                    foreach (Souradnice p in l.Policka)
                    {
                        testovanaPolicka.Add(p);
                    }


                    //Console.WriteLine(testovanaPolicka.Count + " policek...");
                } while (ObsahujeDuplicity(testovanaPolicka));

                foreach (Souradnice p in l.Policka)
                {
                    polickaVsechLodi.Add(p);
                }

                Console.WriteLine("Loď umístěna!");
                //Console.ReadLine();
            }

            Console.WriteLine("Úspěch!");

            //foreach (Souradnice p in polickaVsechLodi)
            //    Console.WriteLine(p.X + " " + p.Y);

            // umistit lode do herniho pole
            // TODO


            Console.WriteLine("Hotovo");
            Console.ReadLine();
        }
Esempio n. 3
0
        static bool muzeSeOtocit(Souradnice souradnice, NatoceniLode uhel, TypLode lod)
        {
            if (lod == TypLode.Clun)
            {
                if (uhel == NatoceniLode.Stupnu0)
                {
                    if (souradnice.X >= 0 || souradnice.Y + 1 <= herniPoleY.Length || souradnice.X <= herniPoleX.Length || souradnice.Y > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (uhel == NatoceniLode.Stupnu90)
                {
                    if (souradnice.X >= 0 || souradnice.Y <= herniPoleY.Length || souradnice.X + 1 <= herniPoleX.Length || souradnice.Y > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                if (uhel == NatoceniLode.Stupnu180)
                {
                    if (souradnice.X >= 0 || souradnice.Y + 1 <= herniPoleY.Length || souradnice.X <= herniPoleX.Length || souradnice.Y > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (uhel == NatoceniLode.Stupnu270)
                {
                    if (souradnice.X >= 0 || souradnice.Y <= herniPoleY.Length || souradnice.X + 1 <= herniPoleX.Length || souradnice.Y > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
Esempio n. 4
0
 public bool BlokujePolicko(Souradnice souradnice, NatoceniLode uhel)
 {
     foreach (var policko in Policka)
     {
         if (policko.X >= herniPoleX.Length || policko.X <= 0 || policko.Y >= herniPoleY.Length || policko.Y <= 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
Esempio n. 5
0
 public void Premistit(Souradnice souradnice, NatoceniLode natoceni)
 {
 }
Esempio n. 6
0
        public void Posunout(int dx, int dy, Souradnice souradnice, NatoceniLode uhelNatoceni)
        {
            if (Typ == TypLode.Clun)
            {
                if (uhelNatoceni == NatoceniLode.Stupnu0)
                {
                    switch (Console.ReadKey(true).KeyChar)
                    {
                    case 'd':
                        if (souradnice.X <= herniPoleX.Length - 3)
                        {
                            Souradnice.X++;
                            Console.Clear();
                        }
                        break;

                    case 's':
                        if (souradnice.Y <= herniPoleY.Length - 2)
                        {
                            souradnice.Y++;
                            Console.Clear();
                        }
                        break;

                    case 'w':

                        if (souradnice.Y > 0 || souradnice.Y == herniPoleY.Length - 1)
                        {
                            souradnice.Y--;
                            Console.Clear();
                        }
                        break;

                    case 'a':
                        if (souradnice.X > 0 || souradnice.X == herniPoleX.Length - 1)
                        {
                            Souradnice.X--;
                            Console.Clear();
                        }
                        break;
                    }
                }

                if (uhelNatoceni == NatoceniLode.Stupnu90)
                {
                    switch (Console.ReadKey(true).KeyChar)
                    {
                    case 'd':
                        if (souradnice.X <= herniPoleX.Length - 2)
                        {
                            souradnice.X++;
                            Console.Clear();
                        }
                        break;

                    case 's':
                        if (souradnice.Y <= herniPoleY.Length - 3)
                        {
                            souradnice.Y++;
                            Console.Clear();
                        }
                        break;

                    case 'w':

                        if (souradnice.Y > 0 || souradnice.Y == herniPoleY.Length - 1)
                        {
                            souradnice.Y--;
                            Console.Clear();
                        }
                        break;

                    case 'a':
                        if (souradnice.X > 0 || souradnice.X == herniPoleX.Length)
                        {
                            souradnice.X--;
                            Console.Clear();
                        }
                        break;
                    }
                }
                if (uhelNatoceni == NatoceniLode.Stupnu180)
                {
                    switch (Console.ReadKey(true).KeyChar)
                    {
                    case 'd':
                        if (souradnice.X <= herniPoleX.Length - 3)
                        {
                            souradnice.X++;
                            Console.Clear();
                        }
                        break;

                    case 's':
                        if (souradnice.Y <= herniPoleY.Length - 2)
                        {
                            souradnice.Y++;
                            Console.Clear();
                        }
                        break;

                    case 'w':

                        if (souradnice.Y > 0 || souradnice.Y == herniPoleY.Length - 1)
                        {
                            souradnice.Y--;
                            Console.Clear();
                        }
                        break;

                    case 'a':
                        if (souradnice.X > 0 || souradnice.X == herniPoleX.Length - 1)
                        {
                            souradnice.X--;
                            Console.Clear();
                        }
                        break;
                    }
                }
                if (uhelNatoceni == NatoceniLode.Stupnu270)
                {
                    switch (Console.ReadKey(true).KeyChar)
                    {
                    case 'd':
                        if (souradnice.X <= herniPoleX.Length - 2)
                        {
                            souradnice.X++;
                            Console.Clear();
                        }
                        break;

                    case 's':
                        if (souradnice.Y <= herniPoleY.Length - 3)
                        {
                            souradnice.Y++;
                            Console.Clear();
                        }
                        break;

                    case 'w':

                        if (souradnice.Y > 0 || souradnice.Y == herniPoleY.Length - 2)
                        {
                            souradnice.Y--;
                            Console.Clear();
                        }
                        break;

                    case 'a':
                        if (souradnice.X > 0 || souradnice.X == herniPoleX.Length)
                        {
                            souradnice.X--;
                            Console.Clear();
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 7
0
 public void Premistit(Souradnice souradnice, NatoceniLode natoceni)
 {
     throw new NotImplementedException();
 }
Esempio n. 8
0
 public void Otocit(NatoceniLode uhel)
 {
     throw new NotImplementedException();
 }