/// <summary> /// Handles the go state. /// </summary> void HandleGo() { // Error handling if (_currentBoxTarget.boxManager == null) { Debug.LogWarning("Current box target is not found? Probably an error finding it?"); _currentState = RobotState.SEARCH; return; } if (_currentBoxTarget.boxManager.GetState() == BoxState.PICKED) { _currentBoxTarget = new BoxRobot(); _currentState = RobotState.SEARCH; return; } // Move to desired box. _rm.Move(_currentBoxTarget.box.transform.position); if (_rm.IsHeNearInstance(_currentBoxTarget.box.transform.position)) { _currentState = RobotState.TAKEBOX; _currentBoxPicked = _currentBoxTarget; // Clean target of box. _currentBoxTarget = new BoxRobot(); return; } }
void Control() { Debug.Log(_currentState); switch (_currentState) { case RobotState.SEARCH: _currentBoxPicked = new BoxRobot(); _currentBoxTarget = new BoxRobot(); Wandering(); break; case RobotState.GO: HandleGo(); break; case RobotState.TAKEBOX: HandleTakeBox(); SoundManager.instance.PlayRobotSoundMovement(gameObject.GetComponent <AudioSource>()); break; case RobotState.WITHBOX: HandleWithBox(); break; case RobotState.QUEUE: HandleQueue(); break; case RobotState.GOTOWAITZONE: HandleGoToWaitZone(); break; case RobotState.INWAITZONE: HandleInWaitZone(); break; case RobotState.GONNADROP: HandleGonnaDrop(); break; case RobotState.LEAVEBOX: HandleLeaveBox(); break; case RobotState.EXIT: HandleExitDropper(droppedInRight); break; case RobotState.WAIT: break; } }
/// <summary> /// Handles the take box state. /// </summary> void HandleTakeBox() { if (_currentBoxPicked.boxManager.GetState() == BoxState.PICKED) { _currentBoxPicked = new BoxRobot(); _currentState = RobotState.SEARCH; return; } _op.SetTarget(_currentBoxPicked.box); _currentBoxPicked.boxManager.SetPicked(); _op.PickUpObject(); _currentState = RobotState.WITHBOX; return; }