Exemplo n.º 1
0
    // The player hits the enemy on collision.
    private void OnCollisionEnter(Collision collision)
    {
        GameObject   target = collision.transform.gameObject;
        PhotonPlayer player = target.GetComponent <PhotonPlayer>();

        if (player != null)
        {
            // enemy is killed when the HP becomes below 0.
            player.GotDamaged(damage: DAMAGE);

            TraumaInducer explosion = Instantiate(explosionPrefab, transform.position, Quaternion.identity).GetComponent <TraumaInducer>();
            explosion.PlayExplosion();

            if (player.hp <= 0)
            {
                player.HasKilled();
            }
        }

        Destroy(gameObject);
    }