public void RCMove(Vector2 Destination) { //Initial Distance // if (_RCInitialDis == 0f) { SetInitialDis(Destination); // } //Update UIPos _RCUGUIPos.x = transform.position.x; _RCUGUIPos.y = transform.position.y; switch (_RCUIState) { case RCUIState.shouldIN: if (Vector2.Distance(_RCUGUIPos, _RCUIInitialPos) >= _RCInitialDis) { transform.position = Destination; _RCUIState = RCUIState.shouldStay; } else { transform.Translate(Time.deltaTime * _RCUIMoveSpeed * (Destination - _RCUIInitialPos).normalized); } break; case RCUIState.shouldOut: if (Vector2.Distance(_RCUGUIPos, Destination) >= _RCInitialDis) { transform.position = _RCUIInitialPos; _RCUIState = RCUIState.shouldStay; } else { transform.Translate(Time.deltaTime * _RCUIMoveSpeed * (_RCUIInitialPos - Destination).normalized); } break; case RCUIState.shouldStay: break; } }
public void SetState(RCUIState state) { _RCUIState = state; }