示例#1
0
 public bool Perevirka(MediumFish a)
 {
     if (a.IsSatisfied == 1)
     {
         return(true);
     }
     return(false);
 }
示例#2
0
        /// <summary>
        /// test function
        /// </summary>
        public void TestFunc()
        {
            Console.WriteLine("\nLEVEL 1\n");
            int length = 10;
            int width  = 5;

            SmallFish[,] Fishes = new SmallFish[length, width];
            Fishes[0, 0]        = new SmallFish();
            Fishes[0, 1]        = new MediumFish();
            Fishes[0, 2]        = new BigFish();
            ShowFishes(Fishes);
            Console.ReadKey();
            Fishes[0, 1]  = new SmallFish();
            Console.Title = "Test Func";
            RefreshConsole(Fishes);
            Console.ReadKey();
        }
示例#3
0
        public void GunSetorGetFish(int ListID)
        {
            if (work.GetStack(ListID).Count != 0 && gun.Content() == null && work.GetStack(ListID)[work.GetStack(ListID).Count - 1].GetType() != new BigFish().GetType())
            {
                if (work.GetStack(ListID)[work.GetStack(ListID).Count - 1].GetType() == new DestroyerFish().GetType())
                {
                    DestroyerFish(ListID);
                }
                else
                {
                    gun.Set(work.GetStack(ListID));
                }
            }
            else if (gun.Content() != null)
            {
                List <Fish> f = work.GetStack(ListID);


                if (f.Count == 0)
                {
                    f.Add(gun.Get());
                }

                else if (gun.Content() != null && f[f.Count - 1].GetType() == new BigFish().GetType() && gun.Content().GetType() == new MediumFish().GetType())// потрібен метод який повертає чи є рибка у gun і яка вона
                {
                    BigFish b = (BigFish)f[f.Count - 1];

                    if (Perevirka((MediumFish)gun.Content()))
                    {
                        f.RemoveAt(f.Count - 1);// видаляю рибу
                        gun.Get();
                        gun.Score += 3;
                    }
                    else if (b.IsSatisfied == 1)
                    {
                        f.RemoveAt(f.Count - 1);// видаляю рибу
                        gun.Get();
                        gun.Score += 3;
                    }
                    else
                    {
                        b.Eat((MediumFish)gun.Get());
                    }
                }
                else if (f[f.Count - 1].GetType() == new MediumFish().GetType() && gun.Content().GetType() == new SmallFish().GetType())
                {
                    MediumFish b = (MediumFish)f[f.Count - 1];

                    if (b.IsSatisfied == 1)
                    {
                        f.RemoveAt(f.Count - 1); // видаляю рибу
                        gun.Get();
                        gun.Score += 3;
                    }
                    else
                    {
                        b.Eat((SmallFish)gun.Get());
                    }
                }
            }
        }