public void SetToOtherAgentData(HackGameAgent otherAgent) { this.setCurrentBoardLocation(otherAgent.getCurrentBoardLocation(), gameboard); this.setDestinationBoardLocation(otherAgent.getDestinationBoardLocation(), gameboard); this.setTtoDestination(otherAgent.getTtoDestination()); this.SetCurrentState(otherAgent.GetCurrentState()); if (otherAgent is HackGameAgent_Trail) { this.specialZoom = ((HackGameAgent_Trail)(otherAgent)).specialZoom; } }
public virtual bool IsCollidingWith(HackGameAgent otherAgent) { if (otherAgent == this) { return false; } if (!this.IsActive() || !otherAgent.IsActive()) { return false; } else { //start with the simplest case if (this.getMovementDirection() == MovementDirection.MovementDirection_None && otherAgent.getMovementDirection() == MovementDirection.MovementDirection_None && this.currentBoardElementLocation == otherAgent.currentBoardElementLocation) { return true; } else if (otherAgent.getMovementDirection() == MovementDirection.MovementDirection_None) { //he's stationary, we just need to see if we're imminent to him and our distance to him is in tolerance if (this.getMovementDirection() != MovementDirection.MovementDirection_None && this.currentBoardElementDestination == otherAgent.currentBoardElementLocation && this.getTtoDestination() > 1.0 - HackGameAgent.CollideTWindow) { return true; } return false; } else if (this.getMovementDirection() == MovementDirection.MovementDirection_None) { //we're stationary, we just need to see if he's imminent to use and his distance to us is in tolerance if (otherAgent.getMovementDirection() != MovementDirection.MovementDirection_None && otherAgent.currentBoardElementDestination == this.currentBoardElementLocation && otherAgent.getTtoDestination() > 1.0 - HackGameAgent.CollideTWindow) { return true; } return false; } else { //well, we're both moving. //so - if source and destination are both the same.. if (this.getCurrentBoardLocation() == otherAgent.getCurrentBoardLocation() && this.getDestinationBoardLocation() == otherAgent.getDestinationBoardLocation()) { if (Math.Abs(this.getTtoDestination() - otherAgent.getTtoDestination()) < HackGameAgent.CollideTWindow) { return true; } return false; } //if we're coming from different places but destination is the same... else if (this.getDestinationBoardLocation() == otherAgent.getDestinationBoardLocation()) { //then two things must be true - we must each be w/in threshhold of destination and of each other. if (this.getTtoDestination() < HackGameAgent.CollideTWindowCrossing && otherAgent.getTtoDestination() < HackGameAgent.CollideTWindowCrossing && Math.Abs(this.getTtoDestination() - otherAgent.getTtoDestination()) < HackGameAgent.CollideTWindowCrossing) { return true; } return false; } //if we're "swapping places" - a head-on collision else if (this.getDestinationBoardLocation() == otherAgent.getCurrentBoardLocation() && otherAgent.getDestinationBoardLocation() == this.getCurrentBoardLocation()) { //now you have to measure your T vs his 1.0 - T. float fixedT = 1.0f - otherAgent.getTtoDestination(); if (Math.Abs(this.getTtoDestination() - fixedT) < HackGameAgent.CollideTWindow) { return true; } return false; } else { return false; } } } }