/// <summary> /// Set the camera center, all map is updated after that. /// Invoke not required. /// </summary> public void SetView(SRCoord ViewPoint) { if (!m_ViewPoint.Equals(ViewPoint)) { // Update layer if (m_ViewPoint.Region != ViewPoint.Region && ViewPoint.inDungeon()) { SelectMapLayer(ViewPoint.Region); RemoveTiles(); m_ViewPoint = ViewPoint; } else { m_ViewPoint = ViewPoint; ClearTiles(); } UpdateTiles(); } UpdateMarkerLocations(); }
public override SRCoord GetRealtimePosition() { if (MovementPosition != null) { SRCoord P = Position; SRCoord Q = MovementPosition; // Check if it's updated.. if (!P.Equals(Q)) { // Scale 1920units:192px = 10:1 => To Ms double MilisecondsPerUnit = GetMovementSpeed(); // Checking update times! long milisecondsTranscurred = PositionUpdateTimer.ElapsedMilliseconds; long milisecondsMaximum = P.TimeTo(Q, MilisecondsPerUnit); if (milisecondsTranscurred >= milisecondsMaximum) { // The entity has reached the position long ago Position = Q; } else { // Create vector unit double PQMod = P.DistanceTo(Q); SRCoord PQUnit = new SRCoord((Q.PosX - P.PosX) / PQMod, (Q.PosY - P.PosY) / PQMod); double DistanceTillNow = milisecondsTranscurred * MilisecondsPerUnit; if (P.inDungeon()) { Position = new SRCoord(PQUnit.PosX * DistanceTillNow + P.PosX, PQUnit.PosY * DistanceTillNow + P.PosY, P.Region, P.Z); } else { Position = new SRCoord(PQUnit.PosX * DistanceTillNow + P.PosX, PQUnit.PosY * DistanceTillNow + P.PosY); } } PositionUpdateTimer.Restart(); } } return(Position); }