public void startJourney(Point realStart, Point realEnd, double distThroughJourney) { this.startPos = (PointF)realStart; this.endPos = (PointF)realEnd; if (distThroughJourney >= 1.0) { this.currentPos = this.endPos; this.state = VillagePeopleStates.STATIONARY; } else { TimeSpan span = VillageBuildingsData.calcTravelTime(GameEngine.Instance.LocalWorldData, realStart, realEnd); this.startTime = DateTime.Now; this.endTime = DateTime.Now.Add(span); if (distThroughJourney != 0.0 && !double.IsNaN(distThroughJourney)) { double num = span.TotalSeconds * distThroughJourney; this.startTime = this.startTime.AddSeconds(0.0 - num); // TODO Ex here this.endTime = this.endTime.AddSeconds(0.0 - num); } this.state = VillagePeopleStates.MOVING; this.facing = SpriteWrapper.getFacing(this.startPos, this.endPos, 8); this.updateJourney(); } }
public void updateJourney() { if (this.state == VillagePeopleStates.MOVING) { DateTime now = DateTime.Now; if (now >= this.endTime) { this.currentPos = this.endPos; this.state = VillagePeopleStates.STATIONARY; } else { TimeSpan span = (TimeSpan)(this.endTime - this.startTime); TimeSpan span2 = (TimeSpan)(now - this.startTime); double num = span2.TotalSeconds / span.TotalSeconds; double num2 = ((this.endPos.X - this.startPos.X) * num) + this.startPos.X; double num3 = ((this.endPos.Y - this.startPos.Y) * num) + this.startPos.Y; this.currentPos = new PointF((float)num2, (float)num3); } } }
public void updateJourney() { if (this.state == VillagePeopleStates.MOVING) { DateTime now = DateTime.Now; if (now >= this.endTime) { this.currentPos = this.endPos; this.state = VillagePeopleStates.STATIONARY; } else { TimeSpan span = (TimeSpan) (this.endTime - this.startTime); TimeSpan span2 = (TimeSpan) (now - this.startTime); double num = span2.TotalSeconds / span.TotalSeconds; double num2 = ((this.endPos.X - this.startPos.X) * num) + this.startPos.X; double num3 = ((this.endPos.Y - this.startPos.Y) * num) + this.startPos.Y; this.currentPos = new PointF((float) num2, (float) num3); } } }
public void startJourney(Point realStart, Point realEnd, double distThroughJourney) { this.startPos = (PointF) realStart; this.endPos = (PointF) realEnd; if (distThroughJourney >= 1.0) { this.currentPos = this.endPos; this.state = VillagePeopleStates.STATIONARY; } else { TimeSpan span = VillageBuildingsData.calcTravelTime(GameEngine.Instance.LocalWorldData, realStart, realEnd); this.startTime = DateTime.Now; this.endTime = DateTime.Now.Add(span); if (distThroughJourney != 0.0 && !double.IsNaN(distThroughJourney)) { double num = span.TotalSeconds * distThroughJourney; this.startTime = this.startTime.AddSeconds(0.0 - num); // TODO Ex here this.endTime = this.endTime.AddSeconds(0.0 - num); } this.state = VillagePeopleStates.MOVING; this.facing = SpriteWrapper.getFacing(this.startPos, this.endPos, 8); this.updateJourney(); } }