public override void Initialize() { MiniInit(); for (int i = 0; i < vertices.Length; i++) { VertexPositionNormalTexture vertex = vertices[i]; vertex.Position.X = ((i > 1) ? (mapX + 1) * Tile.SIZE : mapX * Tile.SIZE); vertex.Position.Y = ((i % 2 != 0) ? (mapY + 1) * Tile.SIZE : mapY * Tile.SIZE); vertex.Position.Z = ((i % 2 != 0) ? (mapZ * Tile.HEIGHT) + HEIGHT : (mapZ) * Tile.HEIGHT); vertices[i] = vertex; } //config animations animations = new Dictionary <string, AdvancedAnimation>(); for (int i = 0; i < 4; i++) { AdvancedAnimation a = new AdvancedAnimation(texture, new Rectangle(0, i * (texture.Height / 4), texture.Width, texture.Height / 4), 4); a.frameTime = (i <= (int)Tile.Direction.SOUTH) ? 75 : 90; a.Start(); animations[Enum.GetName(typeof(Tile.Direction), i)] = a; } animation = animations[dir.ToString()]; animation.running = false; UpdateUVCoords(); }
public void SetDir(Tile.Direction dir) { this.dir = dir; if (animations != null) { animation = animations[dir.ToString()]; animation.PauseSet(0); } travel = new Vector2(0f); }
/// <summary> /// Called when a directional button is being held. /// </summary> /// <param name="dir">The direction requested for motion</param> public void Move(Tile.Direction dir) { //DIRECT CLONE IN OWPLAYER... if (travel.X == 0 && travel.Y == 0) { this.dir = dir; animation = animations[dir.ToString()]; if (GetTileCollision() && GetBuildingCollision() && GetEventCollision()) { if (!animation.running) { animation.Start(); } else { animation.running = true; } if (dir == Tile.Direction.NORTH) { travel.Y = +0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] + 1 }); } if (dir == Tile.Direction.SOUTH) { travel.Y = -0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] - 1 }); } if (dir == Tile.Direction.EAST) { travel.X = +0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] + 1, GetMapPos()[1] }); } if (dir == Tile.Direction.WEST) { travel.X = -0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] - 1, GetMapPos()[1] }); } } } }
/// <summary> /// Called when a directional button is being held. /// </summary> /// <param name="dir">The direction requested for motion</param> public void Move(Tile.Direction dir) { //DIRECT CLONE IN OWPLAYER... if (travel.X == 0 && travel.Y == 0){ this.dir = dir; animation = animations[dir.ToString()]; if (GetTileCollision() && GetBuildingCollision() && GetEventCollision()){ if (!animation.running) animation.Start(); else animation.running = true; if (dir == Tile.Direction.NORTH){ travel.Y = +0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] + 1 }); } if (dir == Tile.Direction.SOUTH){ travel.Y = -0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0], GetMapPos()[1] - 1 }); } if (dir == Tile.Direction.EAST){ travel.X = +0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] + 1, GetMapPos()[1] }); } if (dir == Tile.Direction.WEST){ travel.X = -0.01f; Global.action.tileMap.UpdateEventGrid(this, GetMapPos(), new int[2] { GetMapPos()[0] - 1, GetMapPos()[1] }); } } } }
public void SetDir(Tile.Direction dir) { this.dir = dir; if (animations != null){ animation = animations[dir.ToString()]; animation.PauseSet(0); } travel = new Vector2(0f); }