private void FixedUpdate() { var color = SpriteRenderer.color; switch (State) { case BaitState.Holding: SpriteRenderer.color = new Color(color.r, color.g, color.b, 0.5f); break; case BaitState.Flying: m_flyingTimer += Time.fixedDeltaTime; SpriteRenderer.color = new Color(color.r, color.g, color.b, 0.0f); ShowingSprite.transform.position = m_from + m_direction * (m_flyingTimer / FlyingTime); if (m_flyingTimer >= FlyingTime) { State = BaitState.Dying; Controller.SetTarget(transform); } break; case BaitState.Dying: m_dyingTimer += Time.fixedDeltaTime; if (m_dyingTimer >= Lifetime) { Destroy(gameObject); } break; } }
public void Hold(Transform parent) { transform.SetParent(parent); transform.localPosition = Vector3.zero; m_dyingTimer = 0; State = BaitState.Holding; ShowingSprite.gameObject.SetActive(false); }
public void Throw(PlayerController.PlayerController thrower) { m_from = thrower.transform.position; State = BaitState.Flying; ShowingSprite.gameObject.SetActive(true); ShowingSprite.transform.position = m_from; m_direction = transform.position - m_from; }
void Awake() { Physics.gravity = Vector3.up * -9.8f; state = BaitState.MOVE_TO_GROUND; anim = GetComponent <Animator>(); rd = GetComponent <Rigidbody>(); fadeImage = fade.GetComponent <Image>(); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Ground")) { if (state == BaitState.MOVE_TO_GROUND) { rd.constraints = rd.constraints | RigidbodyConstraints.FreezePositionY; freezeY = transform.position.y; state = BaitState.MOVE_AROUND; } } }
private void Update() { if (Input.GetKeyDown(KeyCode.Space)) { if (state == BaitState.MOVE_AROUND) { sound_single.Instance.PlayFishingUP(); state = BaitState.CASTING; fisingCable.SetBaitBind(false); StartCoroutine(FadeOut()); StartCoroutine(Next()); } } switch (state) { case BaitState.COL_ENEMY: break; case BaitState.CASTING: break; } }
private void Awake() { State = BaitState.Idle; }
public void SetState(BaitState state) { this.state = state; }