コード例 #1
0
    public void OnTriggerEnter(Collider col)
    {
        //Speed Pads Collision
        if (col.tag == "SpeedPad")
        {
            Actions.Action01.JumpBall.SetActive(false);
            if (Actions.Action08 != null)
            {
                if (Actions.Action08.DropEffect.isPlaying == true)
                {
                    Actions.Action08.DropEffect.Stop();
                }
            }
            if (col.GetComponent <SpeedPadData>() != null)
            {
                transform.rotation = Quaternion.identity;
                //ResetPlayerRotation

                if (col.GetComponent <SpeedPadData>().LockToDirection)
                {
                    Player.rigidbody.velocity = Vector3.zero;
                    Player.AddVelocity(col.transform.forward * col.GetComponent <SpeedPadData>().Speed);
                }
                else
                {
                    Player.AddVelocity(col.transform.forward * col.GetComponent <SpeedPadData>().Speed);
                }
                if (col.GetComponent <SpeedPadData>().Snap)
                {
                    transform.position = col.transform.position;
                }
                if (col.GetComponent <SpeedPadData>().isDashRing)
                {
                    Actions.ChangeAction(0);
                    Actions.Action00.CharacterAnimator.SetBool("Grounded", false);
                    Actions.Action00.CharacterAnimator.SetInteger("Action", 0);
                }

                if (col.GetComponent <SpeedPadData>().LockControl)
                {
                    Inp.LockInputForAWhile(col.GetComponent <SpeedPadData>().LockControlTime, true);
                }
                if (col.GetComponent <SpeedPadData>().AffectCamera)
                {
                    Vector3 dir = col.transform.forward;
                    Cam.SetCamera(dir, 2.5f, 20, 5f, 1);
                    col.GetComponent <AudioSource>().Play();
                }
            }
        }

        //Rings Collision
        if (col.tag == "Ring")
        {
            Instantiate(RingCollectParticle, col.transform.position, Quaternion.identity);
            Destroy(col.gameObject);
            StartCoroutine(IncreaseRing());
        }
        if (col.tag == "MovingRing")
        {
            if (col.GetComponent <MovingRing>() != null)
            {
                if (col.GetComponent <MovingRing>().colectable)
                {
                    StartCoroutine(IncreaseRing());
                    Instantiate(RingCollectParticle, col.transform.position, Quaternion.identity);
                    Destroy(col.gameObject);
                }
            }
        }

        //Switch
        if (col.tag == "Switch")
        {
            if (col.GetComponent <Switch_Properties> () != null)
            {
                col.GetComponent <Switch_Properties> ().Activate();
            }
        }

        //Hazard
        if (col.tag == "Hazard")
        {
            Actions.Action01.JumpBall.SetActive(false);
            if (Actions.Action08 != null)
            {
                if (Actions.Action08.DropEffect.isPlaying == true)
                {
                    Actions.Action08.DropEffect.Stop();
                }
            }
            DamagePlayer();
            HedgeCamera.Shakeforce = EnemyDamageShakeAmmount;
        }

        //Enemies
        if (col.tag == "Enemy")
        {
            HedgeCamera.Shakeforce = EnemyHitShakeAmmount;
            //If 1, destroy, if not, take damage.
            if (Actions.Action == 3)
            {
                col.transform.parent.GetComponent <EnemyHealth>().DealDamage(1);
                updateTargets = true;
            }
            if (Actions.Action00.CharacterAnimator.GetInteger("Action") == 1)
            {
                //Actions.Action01.JumpBall.enabled = false;
                if (col.transform.parent.GetComponent <EnemyHealth>() != null)
                {
                    if (!Player.isRolling)
                    {
                        Vector3 newSpeed = new Vector3(1, 0, 1);

                        if ((Actions.Action == 1 || Actions.Action == 0) && CanHitAgain)
                        {
                            StartCoroutine(ResetTriggerBool());

                            ////Debug.Log ("AfterJumping");
                            newSpeed   = new Vector3(Player.rigidbody.velocity.x, 0, Player.rigidbody.velocity.z);
                            newSpeed.y = BouncingPower + Mathf.Abs(Player.rigidbody.velocity.y);
                            ////Debug.Log (newSpeed);
                            Player.rigidbody.velocity = newSpeed;
                        }

                        else if ((Actions.Action == 2 || Actions.PreviousAction == 2) && !StopOnHit && CanHitAgain)
                        {
                            StartCoroutine(ResetTriggerBool());

                            //Debug.Log ("AfterHoming");
                            //Vector3 Direction = col.transform.position - Player.transform.position;
                            newSpeed = new Vector3(Player.rigidbody.velocity.x * (1 / EnemyHomingStoppingPowerWhenAdditive), HomingBouncingPower, Player.rigidbody.velocity.z * (1 / EnemyHomingStoppingPowerWhenAdditive));
                            ////Debug.Log (newSpeed);
                            Player.rigidbody.velocity = newSpeed;
                        }
                        else if (StopOnHit)
                        {
                            //Debug.Log ("AfterHomingStop");
                            newSpeed   = new Vector3(0, 0, 0);
                            newSpeed   = Vector3.Scale(Player.rigidbody.velocity, newSpeed);
                            newSpeed.y = HomingBouncingPower;
                            Player.rigidbody.velocity = newSpeed;
                        }

                        if (Actions.Action == 6 && CanHitAgain)
                        {
                            StartCoroutine(ResetTriggerBool());
                            //	//Debug.Log ("AfterBouncing");
                            newSpeed = new Vector3(1, 0, 1);
                            ////Debug.Log ("AfterHoming");
                            newSpeed   = Vector3.Scale(Player.rigidbody.velocity, newSpeed);
                            newSpeed.y = HomingBouncingPower * 2;
                            Player.rigidbody.velocity = newSpeed;

                            Actions.Action01.JumpBall.SetActive(false);
                            if (Actions.Action08 != null)
                            {
                                if (Actions.Action08.DropEffect.isPlaying == true)
                                {
                                    Actions.Action08.DropEffect.Stop();
                                }
                            }
                        }
                    }
                    col.transform.parent.GetComponent <EnemyHealth>().DealDamage(1);
                    updateTargets = true;
                    Actions.Action01.JumpBall.SetActive(false);
                    if (Actions.Action08 != null)
                    {
                        if (Actions.Action08.DropEffect.isPlaying == true)
                        {
                            Actions.Action08.DropEffect.Stop();
                        }
                    }
                    Actions.ChangeAction(0);
                }
            }


            else if (Actions.Action != 3)
            {
                DamagePlayer();
            }
        }

        //Monitors
        if (col.tag == "Monitor")
        {
            if (Actions.Action00.CharacterAnimator.GetInteger("Action") == 1)
            {
                if (!Player.isRolling)
                {
                    Vector3 newSpeed = new Vector3(1, 0, 1);

                    if ((Actions.Action == 1 || Actions.Action == 0) && CanHitAgain)
                    {
                        StartCoroutine(ResetTriggerBool());

                        ////Debug.Log ("AfterJumping");
                        newSpeed   = new Vector3(Player.rigidbody.velocity.x, 0, Player.rigidbody.velocity.z);
                        newSpeed.y = BouncingPower + Mathf.Abs(Player.rigidbody.velocity.y);
                        ////Debug.Log (newSpeed);
                        Player.rigidbody.velocity = newSpeed;
                    }

                    else if ((Actions.Action == 2 || Actions.PreviousAction == 2) && !StopOnHit && CanHitAgain)
                    {
                        StartCoroutine(ResetTriggerBool());

                        //Debug.Log ("AfterHoming");
                        //Vector3 Direction = col.transform.position - Player.transform.position;
                        newSpeed = new Vector3(Player.rigidbody.velocity.x * (1 / EnemyHomingStoppingPowerWhenAdditive), HomingBouncingPower, Player.rigidbody.velocity.z * (1 / EnemyHomingStoppingPowerWhenAdditive));
                        ////Debug.Log (newSpeed);
                        Player.rigidbody.velocity = newSpeed;
                    }
                    else if (StopOnHit)
                    {
                        //Debug.Log ("AfterHomingStop");
                        newSpeed   = new Vector3(0, 0, 0);
                        newSpeed   = Vector3.Scale(Player.rigidbody.velocity, newSpeed);
                        newSpeed.y = HomingBouncingPower;
                        Player.rigidbody.velocity = newSpeed;
                    }

                    if (Actions.Action == 6 && CanHitAgain)
                    {
                        StartCoroutine(ResetTriggerBool());
                        //	//Debug.Log ("AfterBouncing");
                        newSpeed = new Vector3(1, 0, 1);
                        ////Debug.Log ("AfterHoming");
                        newSpeed   = Vector3.Scale(Player.rigidbody.velocity, newSpeed);
                        newSpeed.y = HomingBouncingPower * 2;
                        Player.rigidbody.velocity = newSpeed;

                        Actions.Action01.JumpBall.SetActive(false);
                        if (Actions.Action08 != null)
                        {
                            if (Actions.Action08.DropEffect.isPlaying == true)
                            {
                                Actions.Action08.DropEffect.Stop();
                            }
                        }
                    }
                }
                updateTargets = true;
                Actions.Action01.JumpBall.SetActive(false);
                if (Actions.Action08 != null)
                {
                    if (Actions.Action08.DropEffect.isPlaying == true)
                    {
                        Actions.Action08.DropEffect.Stop();
                    }
                }
                Actions.ChangeAction(0);
            }
        }


        //Spring Collision

        if (col.tag == "Spring")
        {
            Actions.Action01.JumpBall.SetActive(false);
            if (Actions.Action08 != null)
            {
                if (Actions.Action08.DropEffect.isPlaying == true)
                {
                    Actions.Action08.DropEffect.Stop();
                }
            }


            if (col.GetComponent <Spring_Proprieties>() != null)
            {
                spring = col.GetComponent <Spring_Proprieties>();
                if (spring.IsAdditive)
                {
                    transform.position = col.transform.GetChild(0).position;
                    if (col.GetComponent <AudioSource>())
                    {
                        col.GetComponent <AudioSource>().Play();
                    }
                    Actions.Action00.CharacterAnimator.SetInteger("Action", 0);
                    if (Actions.Action02 != null)
                    {
                        Actions.Action02.HomingAvailable = true;
                    }
                    Player.rigidbody.velocity += (spring.transform.up * spring.SpringForce);
                    Actions.ChangeAction(0);
                    spring.anim.SetTrigger("Hit");
                }
                else
                {
                    transform.position = col.transform.GetChild(0).position;
                    if (col.GetComponent <AudioSource>())
                    {
                        col.GetComponent <AudioSource>().Play();
                    }
                    Actions.Action00.CharacterAnimator.SetInteger("Action", 0);
                    if (Actions.Action02 != null)
                    {
                        Actions.Action02.HomingAvailable = true;
                    }
                    Player.rigidbody.velocity = spring.transform.up * spring.SpringForce;
                    Actions.ChangeAction(0);
                    spring.anim.SetTrigger("Hit");
                }

                if (col.GetComponent <Spring_Proprieties>().LockControl)
                {
                    Inp.LockInputForAWhile(col.GetComponent <Spring_Proprieties>().LockTime, false);
                }
            }
        }

        if (col.tag == "Bumper")
        {
            Actions.Action01.JumpBall.SetActive(false);
            if (Actions.Action08 != null)
            {
                if (Actions.Action08.DropEffect.isPlaying == true)
                {
                    Actions.Action08.DropEffect.Stop();
                }
            }


            if (col.GetComponent <Spring_Proprieties>() != null)
            {
                spring = col.GetComponent <Spring_Proprieties>();
                if (spring.IsAdditive)
                {
                    //	transform.position = col.transform.GetChild(0).position;
                    if (col.GetComponent <AudioSource>())
                    {
                        col.GetComponent <AudioSource>().Play();
                    }
                    Actions.Action00.CharacterAnimator.SetInteger("Action", 0);
                    if (Actions.Action02 != null)
                    {
                        Actions.Action02.HomingAvailable = true;
                    }
                    Player.rigidbody.velocity += (Player.transform.position - spring.transform.position) * spring.SpringForce;
                }
                else
                {
                    //transform.position = col.transform.GetChild(0).position;
                    if (col.GetComponent <AudioSource>())
                    {
                        col.GetComponent <AudioSource>().Play();
                    }
                    Actions.Action00.CharacterAnimator.SetInteger("Action", 0);
                    if (Actions.Action02 != null)
                    {
                        Actions.Action02.HomingAvailable = true;
                    }
                    Player.rigidbody.velocity = (Player.transform.position - spring.transform.position) * spring.SpringForce;
                }

                if (col.GetComponent <Spring_Proprieties>().LockControl)
                {
                    Inp.LockInputForAWhile(col.GetComponent <Spring_Proprieties>().LockTime, false);
                }
            }
        }

        //Monitors
        if (col.tag == "CancelHoming")
        {
            if (Actions.Action == 2)
            {
                Vector3 newSpeed = new Vector3(1, 0, 1);

                Actions.ChangeAction(0);
                newSpeed = new Vector3(0, HomingBouncingPower, 0);
                ////Debug.Log (newSpeed);
                Player.rigidbody.velocity = newSpeed;
                //Player.transform.position = col.ClosestPoint (Player.transform.position);
                if (Actions.Action02 != null)
                {
                    Actions.Action02.HomingAvailable = true;
                }
            }
        }
    }
コード例 #2
0
    public void OnTriggerEnter(Collider col)
    {
        //Speed Pads Collision
        if (col.tag == "SpeedPad")
        {
            if (col.GetComponent <SpeedPadData>() != null)
            {
                transform.rotation = Quaternion.identity;
                //ResetPlayerRotation

                if (col.GetComponent <SpeedPadData>().LockToDirection)
                {
                    Player.rigidbody.velocity = Vector3.zero;
                    Player.AddVelocity(col.transform.forward * col.GetComponent <SpeedPadData>().Speed);
                }
                else
                {
                    Player.AddVelocity(col.transform.forward * col.GetComponent <SpeedPadData>().Speed);
                }
                if (col.GetComponent <SpeedPadData>().Snap)
                {
                    transform.position = col.transform.position;
                }
                if (col.GetComponent <SpeedPadData>().isDashRing)
                {
                    Actions.ChangeAction(0);
                    Actions.Action00.CharacterAnimator.SetBool("Grounded", false);
                    Actions.Action00.CharacterAnimator.SetInteger("Action", 0);
                }

                if (col.GetComponent <SpeedPadData>().LockControl)
                {
                    Inp.LockInputForAWhile(col.GetComponent <SpeedPadData>().LockControlTime, true);
                }
                if (col.GetComponent <SpeedPadData>().AffectCamera)
                {
                    Vector3 dir = col.transform.forward;
                    Cam.SetCamera(dir, 2.5f, 20, 5f, 1);
                    col.GetComponent <AudioSource>().Play();
                }
            }
        }

        //Rings Collision
        if (col.tag == "Ring")
        {
            RingAmmount += 1;
            Instantiate(RingCollectParticle, col.transform.position, Quaternion.identity);
            Destroy(col.gameObject);
        }
        if (col.tag == "MovingRing")
        {
            if (col.GetComponent <MovingRing>() != null)
            {
                if (col.GetComponent <MovingRing>().colectable)
                {
                    RingAmmount += 1;
                    Instantiate(RingCollectParticle, col.transform.position, Quaternion.identity);
                    Destroy(col.gameObject);
                }
            }
        }

        //Hazard
        if (col.tag == "Hazard")
        {
            DamagePlayer();
            HedgeCamera.Shakeforce = EnemyDamageShakeAmmount;
        }

        //Enemies
        if (col.tag == "Enemy")
        {
            HedgeCamera.Shakeforce = EnemyHitShakeAmmount;
            //If 1, destroy, if not, take damage.
            if (Actions.Action == 3)
            {
                col.transform.parent.GetComponent <EnemyHealth>().DealDamage(1);
                updateTargets = true;
            }
            if (Actions.Action00.CharacterAnimator.GetInteger("Action") == 1)
            {
                if (col.transform.parent.GetComponent <EnemyHealth>() != null)
                {
                    if (!Player.isRolling)
                    {
                        Vector3 newSpeed = new Vector3(1, 0, 1);

                        if (StopOnHommingAttackHit && Actions.Action == 2)
                        {
                            newSpeed   = new Vector3(0, 0, 0);
                            newSpeed   = Vector3.Scale(Player.rigidbody.velocity, newSpeed);
                            newSpeed.y = BouncingPower;
                        }
                        else if (StopOnHit)
                        {
                            newSpeed   = new Vector3(0, 0, 0);
                            newSpeed   = Vector3.Scale(Player.rigidbody.velocity, newSpeed);
                            newSpeed.y = BouncingPower;
                        }
                        else
                        {
                            newSpeed   = Vector3.Scale(Player.rigidbody.velocity, newSpeed);
                            newSpeed.y = BouncingPower;
                        }


                        Player.rigidbody.velocity = newSpeed;
                    }
                    col.transform.parent.GetComponent <EnemyHealth>().DealDamage(1);
                    updateTargets = true;
                    Actions.ChangeAction(0);
                }
            }
            else if (Actions.Action != 3)
            {
                DamagePlayer();
            }
        }

        //Spring Collision

        if (col.tag == "Spring")
        {
            if (col.GetComponent <Spring_Proprieties>() != null)
            {
                spring = col.GetComponent <Spring_Proprieties>();
                if (spring.IsAdditive)
                {
                    transform.position = col.transform.GetChild(0).position;
                    if (col.GetComponent <AudioSource>())
                    {
                        col.GetComponent <AudioSource>().Play();
                    }
                    Actions.Action00.CharacterAnimator.SetInteger("Action", 0);
                    Actions.Action02.HomingAvailable = true;
                    Player.rigidbody.velocity       += (spring.transform.up * spring.SpringForce);
                    Actions.ChangeAction(0);
                    spring.anim.SetTrigger("Hit");
                }
                else
                {
                    transform.position = col.transform.GetChild(0).position;
                    if (col.GetComponent <AudioSource>())
                    {
                        col.GetComponent <AudioSource>().Play();
                    }
                    Actions.Action00.CharacterAnimator.SetInteger("Action", 0);
                    Actions.Action02.HomingAvailable = true;
                    Player.rigidbody.velocity        = spring.transform.up * spring.SpringForce;
                    Actions.ChangeAction(0);
                    spring.anim.SetTrigger("Hit");
                }

                if (col.GetComponent <Spring_Proprieties>().LockControl)
                {
                    Inp.LockInputForAWhile(col.GetComponent <Spring_Proprieties>().LockTime, false);
                }
            }
        }
    }