private void dispatchDeadEvent(SnakeSprite snake)
 {
     if (_scene.snakeDeadEvent != null)
     {
         _scene.snakeDeadEvent(snake);
     }
 }
示例#2
0
 public BodyUpdate(SnakeSprite snake)
 {
     _snake             = snake;
     _bodyTempList      = new List <Sprite>();
     _prevPts           = new List <Point>();
     _appendBodyCounter = 0;
 }
        private void _setupPlayer()
        {
            _scoreValue = 0;
            _updateScoreBitmap();

               // int centerX = game.gameWindow.width / 2;
               // int centerY = game.gameWindow.height / 2;

            _player = _scene.newSnake();

            _player.x = 0;
            _player.y = 0;
            //_player.x = _rand.Next(centerX - 10, centerX + 20);
            //_player.y = _rand.Next(centerY - 10, centerY + 20);

            _player.colors.Add(Color.FromArgb(255, 231, 56, 40));
            _player.colors.Add(Color.FromArgb(255, 234, 84, 20));
            _player.colors.Add(Color.FromArgb(255, 248, 182, 44));
            _player.colors.Add(Color.FromArgb(255, 0, 255, 0));
            _player.colors.Add(Color.FromArgb(255, 0, 0, 255));
            _player.colors.Add(Color.FromArgb(255, 18, 13, 105));
            _player.colors.Add(Color.FromArgb(255, 83, 62, 124));
            //_player.color = Color.FromArgb(255, 255, 255, 255);

            _player.setup();
        }
 private void _scene_scoreAddEvent(SnakeSprite snake, int score)
 {
     if(snake == _player)
     {
         _scoreValue += score;
         _updateScoreBitmap();
     }
 }
示例#5
0
        public SnakeNPC(GamePlay gamePlay, SnakeSprite snake)
        {
            this.snake = snake;
            _gamePlay  = gamePlay;
            _transform = new System.Drawing.Drawing2D.Matrix();

            _ignorePreventCollisionIds = new List <int>()
            {
                snake.id
            };
        }
        private void _scene_snakeDeadEvent(SnakeSprite snake)
        {
            //Console.WriteLine("_scene_snakeDeadEvent {0}", snake);

            int counter = 0;
            foreach(var rect in snake.iterBodyHitRects())
            {
                if(counter > 1)
                {
                    counter = 0;

                    if(Game.random.Next(0, 100) > 30)
                    {
                        int bodySize = (rect.Width + rect.Height) / 2;
                        int minSize = bodySize - 10;
                        if (minSize < 16)
                        {
                            minSize = 16;
                        }

                        int maxSize = minSize + 10;

                        var food = _scene.spawnFood(Game.random.Next(minSize, maxSize));

                        food.x = rect.X;
                        food.y = rect.Y;

                    }

                }

                counter++;
            }

            /*
            int centerX = game.gameWindow.width / 2 + _scene.boundRect.X;
            int centerY = game.gameWindow.height / 2 + _scene.boundRect.Y;

            food.x = centerX + Game.random.Next(-512, 512);
            food.y = centerY + Game.random.Next(-512, 512);*/

            if(snake == _player)
            {
                _player = null;
                _topContainer.addChild(game.newSprite<GameOverSprite>(this));
            }

            if (_getNpcById.ContainsKey(snake.id))
            {
                var npc = _getNpcById[snake.id];
                _getNpcById.Remove(snake.id);
                _npcs.Remove(npc);
            }
        }
        public void addPlayer(SnakeSprite snake)
        {
            _playerContainer.addChild(snake);

            _snakeById[snake.id] = snake;
        }