void Awake() { Miscellaneous.CheckNullAndLogError(_rb); Miscellaneous.CheckNullAndLogError(_rightDirectionReference); Miscellaneous.CheckNullAndLogError(_upwardDirectionReference); Miscellaneous.CheckNullAndLogError(_forwardDirectionReference); Miscellaneous.CheckNullAndLogError(_centerReference); Miscellaneous.CheckNullAndLogError(_unityChanController); _avatarPositionState = AvatarPositionState.Center; _coolDownStart = -_coolDownTime; }
public void MoveHorizontal(int direction) { float extentToRight = 4; Vector3 localRight = new Vector3(1, 0, 0); //Debug.LogFormat("move horizontal with {0}", direction); if (CheckCoolDownFinished()) { switch (_avatarPositionState) { case AvatarPositionState.Center: if (direction > 0) { _avatarPositionState = AvatarPositionState.Right; _targetPositionWrtCenter = extentToRight * localRight; StartCoolDown(); } else if (direction < 0) { _avatarPositionState = AvatarPositionState.Left; _targetPositionWrtCenter = -extentToRight * localRight; StartCoolDown(); } break; case AvatarPositionState.Left: if (direction > 0) { _avatarPositionState = AvatarPositionState.Center; _targetPositionWrtCenter = Vector3.zero; StartCoolDown(); } break; case AvatarPositionState.Right: if (direction < 0) { _avatarPositionState = AvatarPositionState.Center; _targetPositionWrtCenter = Vector3.zero; StartCoolDown(); } break; } } //transform.position += amountToRight * _rightDirectionReference.right ; }