Beispiel #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            Debug.Log(m_Rigidbody.velocity.magnitude);
            if (m_Rigidbody.velocity.magnitude > 0 && m_ThrownBy != null && m_ThrownBy != other.gameObject && m_IsThrown)
            {
                Scr_PlayerStateController state = m_ThrownBy.GetComponent <Scr_PlayerStateController>();
                if (!state.IsMomInRoom)
                {
                    Scr_ScoreManager.UpdateScore(m_ThrownBy, 500);
                }
                else
                {
                    Scr_ScoreManager.UpdateScore(m_ThrownBy, -50);
                }

                Vector3 dir = transform.forward + transform.up;
                other.gameObject.GetComponent <Scr_CharacterController>().AddImpact(dir, 250.0f);
                other.gameObject.GetComponent <Scr_Combat>().SetHitBy(gameObject);
                m_IsThrown = false;

                //gameObject.SetActive(false);
                Scr_AudioManager.SetRandomPitch("ObjectBreak");
                Scr_AudioManager.Play("ObjectBreak");
            }
        }
    }
Beispiel #2
0
    private void Punch()
    {
        //Punching
        if (Input.GetButtonDown(m_Input.GetFire()))
        {
            GameObject closestPlayer = GetClosestObjectWithTag("Player");
            m_AnimationController.Animate("Punch");

            if (closestPlayer != null)
            {
                Scr_PlayerStateController state = closestPlayer.GetComponent <Scr_PlayerStateController>();
                if (state.PlayerState != Scr_PlayerStateController.State.BabyBox)
                {
                    Vector3 dir = transform.forward + transform.up;
                    closestPlayer.GetComponent <Scr_CharacterController>().AddImpact(dir, m_PunchingPower);
                    closestPlayer.GetComponent <Scr_Combat>().SetHitBy(gameObject);
                    Scr_AudioManager.SetRandomPitch("PlayerPunch");
                    Scr_AudioManager.Play("PlayerPunch");
                    Scr_ScoreManager.UpdateScore(gameObject, 25);
                }
            }
        }
    }