private void MoveOnPath(GameTime gameTime) { Tile currentTile; if (path.Count() > 0) { currentTile = path.First.Value; prevPosition = position; position = Behavior.StraightLineChase(this.position, currentTile.globalPosition, gameTime, speed); rotation = BasicModel.RotateToFace(position, currentTile.globalPosition, Vector3.UnitX); if (currentTile.IsAtCenter(this.position)) { currentTile.RemoveEnemyFromTile(this); path.RemoveFirst(); if (path.Count != 0) { path.First.Value.AddEnemyToTile(this); } } } }
/// <summary> /// Load the content for the global models in the scene /// </summary> protected override void LoadContent() { xml = XElement.Load("Content/enemy_behaviour.xml"); ground = new Ground(Game.Content.Load <Model>(@"GroundModels\ground"), new Vector3(0, 0, 0)); models.Add(ground); selectionCube = new SelectionCube(Game.Content.Load <Model>(@"Models\selectionCube"), new Vector3(0, 0, MODEL_OFFSET)); models.Add(selectionCube); Tile towerOnTile = grid.GetTile(new Vector2(0, Game1.WORLD_BOUNDS_HEIGHT / 2)); tower = new Tower(Game.Content.Load <Model>(@"Models\Buildings\Tower\tower"), towerOnTile.globalPosition, game, Tower.DEFAULT_TOWER_HEALTH, Tower.DEFAULT_DAMAGE, null, game.spriteBatch, grid.GetTile(new Vector2(0, Game1.WORLD_BOUNDS_HEIGHT / 2))); BasicModel cabin; for (int i = -Game1.WORLD_BOUNDS_WIDTH / 2 + 2; i < Game1.WORLD_BOUNDS_WIDTH / 2 - 2; i++) { cabin = new BasicModel(Game.Content.Load <Model>(@"Models\Buildings\enemyCabin"), grid.GetTile(new Vector2(i, -Game1.WORLD_BOUNDS_HEIGHT / 2 + 2)).globalPosition); models.Add(cabin); } //CreateEnemy(); base.LoadContent(); }
public void RemoveModel(BasicModel model) { models.Remove(model); }
public void AddModel(BasicModel model) { models.Add(model); }