public void requestPath(Point start, Point end, PathRequest.FoundPathCallBack callBack) { lock (this.pathRequests) { this.pathRequests.Add(new PathRequest(start, end, callBack)); } }
public Guard(ContentManager content, Placement startingLocation, string state, string movementDirection) : base(content, "Guard", startingLocation, MOVEMENT_SPEED_WALK) { this.callBackDelegate = delegate(Stack <Point> path) { if (this != null) { this.path = path; } }; // figure out our direction if (movementDirection == MovementDirection.Clockwise.ToString()) { this.movementDirection = MovementDirection.Clockwise; } else { this.movementDirection = MovementDirection.CounterClockwise; } // figure out our starting state State initalState; if (state == State.Chase.ToString()) { initalState = State.Chase; } else if (state == State.Patrol.ToString()) { initalState = State.Patrol; } else if (state == State.Standing.ToString()) { initalState = State.Standing; } else { initalState = State.NotSpawned; } updateState(initalState); if (this.currentState == State.Patrol && !AIManager.getInstance().PlayerDetected) { this.destinationWayPoint = AIManager.getInstance().getNextWayPoint(base.Placement.index, this.movementDirection); AIManager.getInstance().requestPath(base.Placement.index, this.destinationWayPoint, delegate(Stack <Point> path) { this.callBackDelegate.Invoke(path); if (this.path != null && this.path.Count >= 1) { this.closestsPoint = this.path.Pop(); } }); } else if (this.currentState == State.Chase || AIManager.getInstance().PlayerDetected) { AIManager.getInstance().requestPath(base.Placement.index, delegate(Stack <Point> path) { this.callBackDelegate.Invoke(path); if (this.path != null && this.path.Count >= 1) { this.closestsPoint = this.path.Pop(); } }); } else if (this.currentState == State.Standing || this.currentState == State.NotSpawned) { // set the closest point to our guards location this.closestsPoint = base.Placement.index; } this.ring = new RadiusRing(content, base.activeSprite.Position); this.openDoorSfx = LoadingUtils.load <SoundEffect>(content, "OpenDoor"); this.prisonCellSfx = LoadingUtils.load <SoundEffect>(content, "CellDoor"); }
public void requestPath(Point start, PathRequest.FoundPathCallBack callBack) { requestPath(start, findEndNode(), callBack); }