public override void ChangeCycle(DayNightCycle newCycle) { cycle = newCycle; switch (newCycle) { case DayNightCycle.Day: WalkTo(farm.GetClosestWaypoint(transform.position)); ateToday = false; currentState = iguanaState.gathering; break; case DayNightCycle.Afternoon: break; case DayNightCycle.Night: WalkTo(wpWell); currentState = iguanaState.sleeping; if (!ateToday) { Die(); } break; default: break; } }
private void STM(iguanaState state, ref float _time) { switch (state) { case iguanaState.gathering: //WalkTo(farm.GetClosestWaypoint(transform.position)); Move(walker.MoveToDirection(shouldSmooth)); if (ProximityRange()) { WalkTo(wpWell); currentState = iguanaState.returning; } break; case iguanaState.returning: Move(walker.MoveToDirection(shouldSmooth)); if (isInWell()) { currentState = iguanaState.waiting; } break; case iguanaState.sleeping: if (!isInWell()) { Move(walker.MoveToDirection(shouldSmooth)); } else { WalkStop(); } break; case iguanaState.waiting: WalkStop(); _time += deltaTime; if (_time > waitingTime) { isFull = false; if (ShouldBeActive()) { WalkTo(farm.GetClosestWaypoint(transform.position)); currentState = iguanaState.gathering; } else { currentState = iguanaState.sleeping; } _time = 0; } break; default: break; } }
void OnControllerColliderHit(ControllerColliderHit hit) { if (!isFull) { var candy = hit.collider.GetComponent <Candy>(); if (candy != null) { if (candy.Exists()) { candy.Eat(); isFull = ateToday = true; WalkTo(wpWell); currentState = iguanaState.returning; } } } }