Ejemplo n.º 1
0
        public void OnFire(InputAction.CallbackContext callbackContext)
        {
            m_fireTriggerPhase = callbackContext.phase;
            switch (callbackContext.phase)
            {
            case InputActionPhase.Started:
                if (State == State.Holding && m_timer >= CoolDown)
                {
                    State        = State.Throwing;
                    m_pressTimer = 0;
                }
                break;

            case InputActionPhase.Canceled:
                if (State == State.Throwing)
                {
                    State = State.Idle;
                    GameHud.Release();
                    m_holdingBait.Throw(this);
                    m_holdingBait = null;
                    m_timer       = 0;
                }
                break;

            case InputActionPhase.Waiting:
                break;

            case InputActionPhase.Disabled:
                break;
            }
        }
Ejemplo n.º 2
0
 private void FixedUpdate()
 {
     transform.rotation     = Quaternion.Euler(0, 0, m_angle - 90);
     m_rigidbody2D.velocity = m_direction * Velocity;
     m_timer += Time.fixedDeltaTime;
     switch (m_fireTriggerPhase)
     {
     case InputActionPhase.Performed:
         m_pressTimer += Time.fixedDeltaTime;
         if (State == State.Throwing)
         {
             GameHud.Press(m_pressTimer, MaxPressingTime);
             var progress = Mathf.Clamp01(m_pressTimer / MaxPressingTime);
             var rad      = (transform.rotation.eulerAngles.z - 90) * Mathf.Deg2Rad;
             var cosRad   = Mathf.Cos(rad);
             var sinRad   = Mathf.Sin(rad);
             var maxY     = MaxThrowDistance * sinRad;
             var maxX     = MaxThrowDistance * cosRad;
             var minY     = MinThrowDistance * sinRad;
             var minX     = MinThrowDistance * cosRad;
             if (m_holdingBait == null)
             {
                 m_holdingBait = Instantiate(BaitTemplate, new Vector3(minX, minY) + transform.position, Quaternion.identity, BaitRoot);
                 m_holdingBait.gameObject.SetActive(true);
             }
             else
             {
                 m_holdingBait.transform.position =
                     transform.position + (new Vector3(maxX, maxY) - new Vector3(minX, minY)) * progress;
             }
         }
         break;
     }
 }