/// <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()); //} }
public void SetTargetTree(TreeEntity tree) { m_TargetTree = tree; }
public bool IsDoneChoppingWood() { if (m_maxLogCapacity <= m_currLogCarried || m_TargetTree == null || !m_TargetTree.IsEnabled()) { m_bChoopingWood = false; if (!m_TargetTree.IsEnabled()) m_TargetTree = null; return true; } return false; }