/// <summary> /// If the entity to go to is a tree then we set it as our target tree. /// If the rntity to go to is a lumber mill then we set it as our target /// mill. /// /// Otherwise it delegates to the parent's implementation. /// </summary> /// <param name="toEntity"></param> /// <param name="distance"></param> public override void MoveDistanceInFrontOfEntity(GameEntity toEntity, int distance) { // If the target is a tree then save it // as a target. if (toEntity is TreeEntity) { m_TargetTree = (TreeEntity)toEntity; if (!m_MyStateMachine.IsInState(GLumberjack_TreeTravel.GetInstance())) { m_MyStateMachine.ChangeState(GLumberjack_TreeTravel.GetInstance()); } } // If it is a lumbermill then save it // as a target. else if (toEntity is LumberMill) { m_TargetLumberMill = (LumberMill)toEntity; if (!m_MyStateMachine.IsInState(GLumberjack_MillTravel.GetInstance())) { m_MyStateMachine.ChangeState(GLumberjack_MillTravel.GetInstance()); } } // Perform the normal logic. base.MoveDistanceInFrontOfEntity(toEntity, distance); Vector2 tempOut; if (FindPathToDestination(m_WorldPosition, m_DestinationPosition, out tempOut)) { m_DestinationPosition = tempOut; } //Vector2 startIndex = Map.MapHandler.GetInstance().GetTileIndex(m_WorldPosition); //Vector2 endIndex = Map.MapHandler.GetInstance().GetTileIndex(m_DestinationPosition); //// Call path finder to find path from the startIndex to the endIndex. //m_pnCurrPath = m_pfMyPathFinder.FindPath(startIndex, endIndex); //// If a pass was found then set the first node in the path //// as the first destination. //if (m_pnCurrPath != null) //{ // m_DestinationPosition = Map.MapHandler.GetInstance().GetTilePosition(m_pnCurrPath.GetNodePosition()); //} }
/// <summary> /// Sets both target mill and tree to null. /// Then it refers to the parent. /// </summary> /// <param name="targetPos"></param> public override void MoveTo(Vector2 targetPos) { m_TargetLumberMill = null; m_TargetEntity = null; if (FindPathToDestination(m_WorldPosition, targetPos, out targetPos)) { base.MoveTo(targetPos); } //Vector2 startIndex = Map.MapHandler.GetInstance().GetTileIndex(m_WorldPosition); //Vector2 endIndex = Map.MapHandler.GetInstance().GetTileIndex(targetPos); //// Call Pathfinder find a path from the startIndex to the end index. //m_pnCurrPath = m_pfMyPathFinder.FindPath(startIndex, endIndex); //// If a path was found, then make the first node in the //// path the first destination of this entity. //if (m_pnCurrPath != null) //{ // targetPos = Map.MapHandler.GetInstance().GetTilePosition(m_pnCurrPath.GetNodePosition()); // base.MoveTo(targetPos); //} }
public void SetTargetLumberMill(LumberMill mill) { m_TargetLumberMill = mill; }
public void SetTargetLumberMill(LumberMill mill) { m_TargetLumberMill = mill; }
/// <summary> /// Sets both target mill and tree to null. /// Then it refers to the parent. /// </summary> /// <param name="targetPos"></param> public override void MoveTo(Vector2 targetPos) { m_TargetLumberMill = null; m_TargetEntity = null; if (FindPathToDestination(m_WorldPosition, targetPos, out targetPos)) { base.MoveTo(targetPos); } //Vector2 startIndex = Map.MapHandler.GetInstance().GetTileIndex(m_WorldPosition); //Vector2 endIndex = Map.MapHandler.GetInstance().GetTileIndex(targetPos); //// Call Pathfinder find a path from the startIndex to the end index. //m_pnCurrPath = m_pfMyPathFinder.FindPath(startIndex, endIndex); //// If a path was found, then make the first node in the //// path the first destination of this entity. //if (m_pnCurrPath != null) //{ // targetPos = Map.MapHandler.GetInstance().GetTilePosition(m_pnCurrPath.GetNodePosition()); // base.MoveTo(targetPos); //} }
/// <summary> /// If the entity to go to is a tree then we set it as our target tree. /// If the rntity to go to is a lumber mill then we set it as our target /// mill. /// /// Otherwise it delegates to the parent's implementation. /// </summary> /// <param name="toEntity"></param> /// <param name="distance"></param> public override void MoveDistanceInFrontOfEntity(GameEntity toEntity, int distance) { // If the target is a tree then save it // as a target. if (toEntity is TreeEntity) { m_TargetTree = (TreeEntity)toEntity; if(!m_MyStateMachine.IsInState(GLumberjack_TreeTravel.GetInstance())) m_MyStateMachine.ChangeState(GLumberjack_TreeTravel.GetInstance()); } // If it is a lumbermill then save it // as a target. else if (toEntity is LumberMill) { m_TargetLumberMill = (LumberMill)toEntity; if(!m_MyStateMachine.IsInState(GLumberjack_MillTravel.GetInstance())) m_MyStateMachine.ChangeState(GLumberjack_MillTravel.GetInstance()); } // Perform the normal logic. base.MoveDistanceInFrontOfEntity(toEntity, distance); Vector2 tempOut; if (FindPathToDestination(m_WorldPosition, m_DestinationPosition, out tempOut)) { m_DestinationPosition = tempOut; } //Vector2 startIndex = Map.MapHandler.GetInstance().GetTileIndex(m_WorldPosition); //Vector2 endIndex = Map.MapHandler.GetInstance().GetTileIndex(m_DestinationPosition); //// Call path finder to find path from the startIndex to the endIndex. //m_pnCurrPath = m_pfMyPathFinder.FindPath(startIndex, endIndex); //// If a pass was found then set the first node in the path //// as the first destination. //if (m_pnCurrPath != null) //{ // m_DestinationPosition = Map.MapHandler.GetInstance().GetTilePosition(m_pnCurrPath.GetNodePosition()); //} }
/// <summary> /// Sets both target mill and tree to null. /// Then it refers to the parent. /// </summary> /// <param name="targetPos"></param> public override void MoveTo(Vector2 targetPos) { m_TargetLumberMill = null; m_TargetEntity = null; base.MoveTo(targetPos); }