void Update() { if (StateControl.GetState() != StateType.Playing || BirdManager.Instance.IsBirdDie) { return; } this.GetComponent <RectTransform>().localPosition += new Vector3(1, 0, 0) * _speed; if (this.GetComponent <RectTransform>().localPosition.x < -1900f) { ResetPosition(); } }
void Update() { if (StateControl.GetState() != StateType.Playing) { if (BirdManager.Instance.IsBirdGround) { if (transform.localPosition.y + _stepY < -502f) { transform.localPosition = new Vector3(transform.localPosition.x, -502f, transform.localPosition.z); } } return; } if (Input.GetMouseButtonDown(0)) { if (!BirdManager.Instance.IsBirdDie) { AudioManager.Instance.PlayWing(); _stepY = _distance + Time.deltaTime * _fixedSpeed; } } _stepY -= Time.deltaTime * _fixedSpeed; transform.localPosition += new Vector3(0, _stepY, 0); Quaternion initial = this.GetComponent <RectTransform>().localRotation; Quaternion target; if (_stepY >= 0) { target = Quaternion.Euler(_upRotation); } else { target = Quaternion.Euler(_downRotation); } float rotateSpeed = _stepY >= 0 ? _rotateSpeed : _rotateSpeed * 0.5f; this.GetComponent <RectTransform>().localRotation = Quaternion.Lerp(initial, target, rotateSpeed * Time.deltaTime); }
private void OnEnable() { BirdManager.Instance.OnBirdDie += OnBirdDie; StateControl.OnStateChange += OnStateChange; OnStateChange(StateControl.GetState()); }