Exemple #1
0
 public PocDecorator()
 {
     fish         = new Fish("    I'm a fish");
     goldenFish   = new GoldenFish(fish);
     troutFish    = new TroutFish(goldenFish);
     carpeFish    = new CarpeFish(troutFish);
     magiKarpFish = new MagiKarpFish(carpeFish);
     gyarados     = new Gyarados(magiKarpFish);
 }
        private Rectangle GetFishAnimation(GoldenFish fish)
        {
            var res = fish.CurrentFrame <= 16
                ? new Rectangle(new Point(10 * 16, 7 * 16),
                                new Size(16, 16))
                : new Rectangle(new Point(12 * 16, 7 * 16),
                                new Size(16, 16));

            if (fish.CurrentFrame < fish.IdleFrames - 1)
            {
                fish.CurrentFrame++;
            }
            else
            {
                fish.CurrentFrame = 0;
            }
            return(res);
        }
        private void button1AddFish_Click(object sender, EventArgs e)
        {
            string fishType;
            string fishGender;

            if (radioButton1Male.Checked)
            {
            }

            if (radioButton3Shark.Checked)
            {
                fishType = radioButton3Shark.Text;
            }
            if (radioButton4GoldFish.Checked)
            {
                fishType = radioButton4GoldFish.Text;
            }

            if (radioButton1Male.Checked)
            {
                fishGender = radioButton1Male.Text;
            }
            if (radioButton2Female.Checked)
            {
                fishGender = radioButton2Female.Text;
            }

            string fishName = textBox2Name.Text;

            int sizeInCm       = int.Parse(textBox3Size.Text);
            int minTemp        = int.Parse(textBox4MinTemperature.Text);
            int maxTemp        = int.Parse(textBox5MaxTemperature.Text);
            int needdedLitters = int.Parse(textBox6NeedLitters.Text);

            if (radioButton3Shark.Checked)
            {
                shark = new Shark();
                aquarium.AllAnimalsCollection.Add(shark);
                aquarium.FishCollection.Add(shark);
                shark.Img        = FishGUI.Properties.Resources.shark_icon;
                shark.XPossition = locationGenerator.Next(Аquarium.xMinValue, Аquarium.xMaxValue);
                shark.YPossition = locationGenerator.Next(Аquarium.yMinValue, Аquarium.yMaxValue);
            }

            if (radioButton4GoldFish.Checked)
            {
                goldFish = new GoldenFish();
                aquarium.AllAnimalsCollection.Add(goldFish);
                aquarium.FishCollection.Add(goldFish);
                goldFish.Img        = FishGUI.Properties.Resources.goldenfish_icon;
                goldFish.XPossition = locationGenerator.Next(Аquarium.xMinValue, Аquarium.xMaxValue);
                goldFish.YPossition = locationGenerator.Next(Аquarium.yMinValue, Аquarium.yMaxValue);


                //PictureBox pb = new PictureBox();
                //pb.Location = new Point(goldFish.XPossition, goldFish.YPossition);
                //pb.Image = goldFish.Img;
                //this.Controls.Add(goldFish.picBox);
            }

            this.DialogResult = DialogResult.OK;
        }