void MoveBackChopstick() { ChopstickData ch = chopstick.GetComponent <ChopstickData>(); if (ch.CheckFinish(endCenterPoint.transform.position, pointDistanceChopstick)) { ch.chopstickState = State.CENTER; CanReturnCupstick = false; return; } ch.MoveTo(endCenterPoint.transform.position); }
//Move Chopstick private void MoveToPointState() { if (!startMoving) { return; } State newState = State.CENTER; State currentState = chopstick.GetComponent <ChopstickData>().chopstickState; ChopstickData chopstikBehaviour = chopstick.GetComponent <ChopstickData>(); Vector3 goTo = Vector3.zero; if (direction == "left") { switch (currentState) { case State.CENTER: goTo = endLeftPoint.transform.position; newState = State.LEFT; break; case State.RIGHT: goTo = endCenterPoint.transform.position; newState = State.CENTER; break; case State.LEFT: newState = State.RIGHT; Debug.Log("Can't move"); break; default: break; } } else { switch (currentState) { case State.CENTER: goTo = endRightPoint.transform.position; newState = State.RIGHT; break; case State.RIGHT: Debug.Log("Can't move"); break; case State.LEFT: goTo = endCenterPoint.transform.position; newState = State.CENTER; break; default: break; } } if (goTo == Vector3.zero) { startMoving = false; return; } chopstikBehaviour.MoveTo(goTo); if (chopstikBehaviour.CheckFinish(goTo, pointDistanceChopstick)) { startMoving = false; chopstikBehaviour.chopstickState = newState; } }