Esempio n. 1
0
        public object Clone()
        {
            Penguin tmp = (Penguin)this.MemberwiseClone();

            tmp.Kills = (int[])this.Kills.Clone();
            return(tmp);
        }
Esempio n. 2
0
        public bool CheckInside(Penguin obj)
        {
            if (obj.InAviary(ax, ay, adx, ady) && empty == true)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        public void Zoo_Keydown(KeyEventArgs e)
        {
            const int dx = 10;
            const int dy = 10;

            switch (e.KeyCode)
            {
            case Keys.Up:
                foreach (Penguin i in arr)
                {
                    if (i != null && i.Inside == false)
                    {
                        i.Move(0, -dy);
                    }
                }
                break;

            case Keys.Left:
                foreach (Penguin i in arr)
                {
                    if (i != null && i.Inside == false)
                    {
                        i.Move(-dx, 0);
                    }
                }
                break;

            case Keys.Right:
                foreach (Penguin i in arr)
                {
                    if (i != null && i.Inside == false)
                    {
                        i.Move(dx, 0);
                    }
                }
                break;

            case Keys.Down:
                foreach (Penguin i in arr)
                {
                    if (i != null && i.Inside == false)
                    {
                        i.Move(0, dy);
                    }
                }
                break;

            case Keys.C:
                foreach (var VAR in arr.ToArray())
                {
                    if (VAR.isActive() == true && VAR is Killer == true && VAR.Inside == false)
                    {
                        Killer k = new Killer();
                        k    = (Killer)(VAR as Killer).Clone();
                        k.x += 20;
                        k.y += 20;
                        k.Inactive();
                        arr.Add(k);
                    }
                }
                break;

            case Keys.Delete:
                for (int i = 0; i < arr.Count; i++)
                {
                    if (arr[i].isActive())
                    {
                        arr.Remove(arr[i]);
                        i--;
                    }
                }
                break;

            case Keys.Escape:
                for (int i = 0; i < arr.Count; i++)
                {
                    if (arr[i].isActive())
                    {
                        arr[i].Inactive();
                    }
                }
                break;

            case Keys.Insert:
            {
                Form2 NewPenguin = new Form2();
                if (NewPenguin.ShowDialog() == DialogResult.OK)
                {
                    if (NewPenguin.TypeOfMicroObject == 1)
                    {
                        Penguin p = new Penguin(NewPenguin.MyName, NewPenguin.Weight, NewPenguin.Energy,
                                                NewPenguin.Active, NewPenguin.X, NewPenguin.Y);
                        arr.Add(p);
                    }

                    if (NewPenguin.TypeOfMicroObject == 2)
                    {
                        Speedy p = new Speedy(NewPenguin.MyName, NewPenguin.Weight, NewPenguin.Energy,
                                              NewPenguin.Active, NewPenguin.X, NewPenguin.Y);
                        arr.Add(p);
                    }

                    if (NewPenguin.TypeOfMicroObject == 3)
                    {
                        Killer p = new Killer(NewPenguin.MyName, NewPenguin.Weight, NewPenguin.Energy,
                                              NewPenguin.Active, NewPenguin.X, NewPenguin.Y);
                        arr.Add(p);
                    }
                }
            }
            break;
            }
        }
Esempio n. 4
0
 public void AddPenguin(Penguin obj)
 {
     pen.Add(obj);
     obj++;
 }