public void UpdateCurrentPosition() { // This is the player's current position on the game map. This is updated after a level exit to be // the next room whether you actually enter that room or navigate to another room. Therefore, this // position will change (triggering hasPositionChangedSinceExit) even if you finish a room, then // navigate back to the same room to do it again. So even though the same room is done twice in a // row, we will still know they are seperate exits. MapPosition?pos = goatMemory.GetCurrentPosition(); if (!pos.HasValue) { return; } int x = pos.Value._x; int y = pos.Value._y; // Check if the current position has changed if (this.currentPosition._x != x || this.currentPosition._y != y) { // Sanity check position is sensical. if (x >= 0 && x <= this.positionChangedSanity && y >= 0 && y <= this.positionChangedSanity) { LogWriter.WriteLine("Player Position Changed in Room {1} ({2},{3} to {4},{5}) (Last Exit {0}) (P:{6})", this.lastRoomID, (int)goatMemory.GetRoomID(), this.currentPosition._x, this.currentPosition._y, x, y, this.pulseCount); this.currentPosition = pos.Value; this.hasPositionChangedSinceExit = true; } } }
public void Reset() { this.isStarted = false; this.hasPositionChangedSinceExit = false; this.lastRoomID = 0; this.collectedShards = 0; this.collectedSheepOrbs = 0; this.levelState = LevelState.Outside; this.playerState = PlayerState.Dead; this.doorEnteredState = DoorState.Clear; this.lastSeen = TimeSpan.Zero; this.currentPosition = new MapPosition(0, 0); this.exceptionsCaught = 0; this.totalExceptionsCaught = 0; this.pulseCount = 0; }