void Move(Vector2 pos) { input = false; Enemy enemy = this; LevelGrid grid = GameWorld.GetObject("levelgrid") as LevelGrid; Player player = GameWorld.GetObject("player") as Player; Vector2 movpos = grid.AnchorPosition((int)pos.X, (int)pos.Y); //de ai beweegt naar de gewezen positie float dx = movpos.X - this.Position.X; float dy = movpos.Y - this.Position.Y; float distance = Vector2.Distance(movpos, this.Position); float scale = speed / distance; float aiplayerdistance = Vector2.Distance(this.GridPos, player.GridPos); if (aiplayerdistance < 2.2f) { this.velocity = Vector2.Zero; } else { this.velocity.X = dx * scale; this.velocity.Y = dy * scale; } }
private void LoadOverlay() { RootList.Add(new EditorMouse()); OverlayStatus overlay = new OverlayStatus(this); RootList.Add(overlay); overlay.AddStatus("Floor", new TileOverlay(this, "Content/Editor/Tiles/Floor.txt")); overlay.AddStatus("Wall", new TileOverlay(this, "Content/Editor/Tiles/Wall.txt")); //overlay.AddStatus("Cave", new TileOverlay(this, "Content/Editor/Tiles/Cave.txt")); overlay.AddStatus("Tree", new TileOverlay(this, "Content/Editor/Tiles/Tree.txt")); overlay.AddStatus("Items", new EntityOverlay(this, "Content/Editor/Entities/Item.txt")); overlay.AddStatus("Objects-1", new EntityOverlay(this, "Content/Editor/Entities/Object.txt")); overlay.AddStatus("Objects-2", new EntityOverlay(this, "Content/Editor/Entities/Objects2.txt")); //overlay.AddStatus("Cave_Objects", new EntityOverlay(this, "Content/Editor/Entities/Cave_Object.txt")); overlay.AddStatus("Enemies", new EntityOverlay(this, "Content/Editor/Entities/Enemy.txt")); overlay.AddStatus("Spawn", new EntityOverlay(this, "Content/Editor/Entities/Spawn.txt")); LevelGrid levelGrid = GetObject("levelgrid") as LevelGrid; Camera camera = new Camera(); camera.SetupCamera = levelGrid.AnchorPosition(5, 5) - GameEnvironment.Screen.ToVector2() / 2; RootList.Add(camera); }
private void MakePath(Node node) { LevelGrid levelGrid = GameWorld.GetObject("levelgrid") as LevelGrid; if (levelGrid == null) { return; } path = new List <Vector2>(); Node current = node; while (current.parent != null) { path.Add(levelGrid.AnchorPosition((int)current.position.X, (int)current.position.Y)); //(levelGrid.Get((int)current.position.X, (int)current.position.Y) as Tile).Sprite.Color = Color.Blue; current = current.parent; if (current.position == gridpos) { return; } } }
public virtual void MovePositionOnGrid(int x, int y) { LevelGrid levelGrid = GameWorld.GetObject("levelgrid") as LevelGrid; position = levelGrid.AnchorPosition(x, y); }