private void Game_gameUpdateEvent(GameTime gameTime) { _updateViewport(); SnakeNPC npc; if (_npcs.Count < 100) { var snake = _scene.newSnake(); npc = new SnakeNPC(this, snake); _getNpcById[snake.id] = npc; int colorCount = Game.random.Next(1, 8); for(int i=0; i< colorCount; ++i) { if (_allSnakeColors.Count < 1) { _allSnakeColors.AddRange((from x in _iterAllSnakeColors() orderby Game.random.Next() select x)); } if (_allSnakeColors.Count > 0) { snake.colors.Add(_allSnakeColors[0]); _allSnakeColors.RemoveAt(0); } } snake.setup(); int centerX = (_scene.gameRect.X + _scene.gameRect.Width / 2); int centerY = (_scene.gameRect.Y + _scene.gameRect.Height / 2); snake.x = centerX + Game.random.Next(-_scene.gameRect.Width/3, _scene.gameRect.Width/3); snake.y = centerY + Game.random.Next(-_scene.gameRect.Height/3, _scene.gameRect.Height / 3); _npcs.Add(npc); } for(int i=0; i<_npcs.Count; ++i) { npc = _npcs[i]; npc.update(gameTime); } _updateVisibleInViewport(gameTime); }
public UpdateWork(SnakeNPC npc) { _npc = npc; }