コード例 #1
0
 public Animal(Map map, Point position, Size size, AnimalTexture texture)
 {
     _map                  = map;
     _position             = position;
     _size                 = size;
     _texture              = texture;
     _direction            = new SizeF(0, 0);
     _favoriteEnvironnment = BoxGround.Grass;
     _viewDistance         = 1000;
 }
コード例 #2
0
        public void CreateAnimal(AnimalTexture animalType)
        {
            Animal a;

            switch (animalType.ToString())
            {
            case "Dog":
                a = new Dog(_map, _animalSelectorCursor);
                break;

            case "Cat":
                a = new Cat(_map, _animalSelectorCursor);
                break;

            case "Lion":
                a = new Lion(_map, _animalSelectorCursor);
                break;

            case "Rabbit":
                a = new Rabbit(_map, _animalSelectorCursor);
                break;

            case "Elephant":
                a = new Elephant(_map, _animalSelectorCursor);
                break;

            case "Cow":
                a = new Cow(_map, _animalSelectorCursor);
                break;

            case "Eagle":
                a = new Eagle(_map, _animalSelectorCursor);
                break;

            case "Gazelle":
                a = new Gazelle(_map, _animalSelectorCursor);
                break;

            default:
                throw new NotSupportedException("Unknown animal type");
            }
            _map.Animals.Add(a);
        }
コード例 #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            _selectedAnimal     = AnimalTexture.Rabbit;
            _fpsCount           = 0;
            this.DoubleBuffered = true;
            button1.Text        = "Hide Debug";
            _selectedTexture    = BoxGround.Grass;
            _background         = new Bitmap(this.Width, this.Height);

            _map = new Map(50, 2);

            _boxWidth = _map.BoxSize;

            _viewPort      = new MainViewPort(_map);
            _map.ShowDebug = true;
            _mouseRect     = new Rectangle(0, 0, 100, 100);

            g = this.CreateGraphics();
            _screenGraphic = Graphics.FromImage(_background);
            _screenGraphic.CompositingQuality = CompositingQuality.HighSpeed;
            _screenGraphic.InterpolationMode  = InterpolationMode.Low;


            _selectionCursorWidth = new Size(_boxWidth, _boxWidth);
            this.MouseWheel      += new MouseEventHandler(T_mouseWheel);

            t    = new System.Windows.Forms.Timer();
            fpst = new System.Windows.Forms.Timer();


            fpst.Interval = 200;
            fpst.Tick    += new EventHandler(fpst_Tick);

            t.Interval = 10;
            t.Tick    += new EventHandler(t_Tick);

            fpst.Start();
            t.Start();
            _soundEnvironment = new SoundEnvironment();
            _soundEnvironment.LoadMap(_map);
        }
コード例 #4
0
 private void gazelleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _selectedAnimal = AnimalTexture.Gazelle;
 }
コード例 #5
0
 private void cowToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _selectedAnimal = AnimalTexture.Cow;
 }
コード例 #6
0
 private void elephantToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _selectedAnimal = AnimalTexture.Elephant;
 }
コード例 #7
0
 private void lionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _selectedAnimal = AnimalTexture.Lion;
 }
コード例 #8
0
 private void rabbitToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _selectedAnimal = AnimalTexture.Rabbit;
 }