void MaintainFields() { if (_fieldsNeedingMaintenance.Count > 0) { _fieldMaintaining = _fieldsNeedingMaintenance[0]; _fieldsNeedingMaintenance.RemoveAt(0); _farmerState = FarmerStates.MOVING; _agent.SetDestination(_fieldMaintaining.transform.position); } }
void FarmingState() { timeFarming += Time.deltaTime; //Debug.Log("Time Farming: " + timeFarming); Debug.Log("Farminng: " + _fieldMaintaining + "- " + _fieldMaintaining.GrowthState); if (timeFarming > 2.0) { if (_fieldMaintaining.NextGrowthState == 0) { Bushels++; } _fieldMaintaining.AdvanceState(); _fieldMaintaining = null; _farmerState = FarmerStates.IDLE; timeFarming = 0.0f; } }
void MovingState() { //---------------------- // Are we still moving? // if (!_agent.pathPending) { // Are we in stopping distance? if (_agent.remainingDistance <= _agent.stoppingDistance) { // Is there a path to the destination? Is the speed 0? if (!_agent.hasPath || _agent.velocity.sqrMagnitude == 0f) { if (_fieldMaintaining != null) { Debug.Log("Arrived at Field"); _farmerState = FarmerStates.FARMING; } else { float distanceHome = (transform.position - Home).magnitude; if (distanceHome <= _agent.stoppingDistance) { Debug.Log("Arrived Home."); _farmerState = FarmerStates.HOME; } else { _agent.destination = Home; //Debug.Log("Stopped with no known desitination. Going Home"); } } } } } }
void MoveTo(Vector3 dest) { _agent.destination = Home; _farmerState = FarmerStates.MOVING; }