Exemple #1
0
    private void OnCollisionStay(Collision col)
    {
        //If a player doesn't hit you ignore it
        if (!col.gameObject.name.Contains("Player"))
        {
            return;
        }

        Player otherPlayer = col.gameObject.GetComponent <Player>();

        //If the player that hit you is punching teleport you down
        if (otherPlayer.punching)
        {
            PlayerML ml = GetComponent <PlayerML>();
            if (blocking)
            {
                if (ml)
                {
                    // ml.reward += 0.8f;
                }

                otherPlayer.recoverTime   = recoverReset * 3;
                otherPlayer.animationTime = 0;
                otherPlayer.punching      = false;

                GetComponent <Rigidbody>().velocity = Vector3.zero;
                PAM.PlayBlock();
                blockParticle.PlayParticle();
            }
            else
            {
                if (dead)
                {
                    return;
                }

                deathParticle.PlayParticles();
                if (ml)
                {
                    //ml.reward -= 0.8f;
                }


                //Increase the amount of kills the player has
                col.gameObject.GetComponent <Player>().kills++;

                transform.position += Vector3.down * 10;
                ResetCamera(col.gameObject, -1);
                dead = true;
                otherPlayer.PAM.PlayHit();
                PAM.PlayDeath();
            }
        }
    }