예제 #1
0
    private void Explode()
    {
        cameraEffects.Shake(0.25f);
        MyParticles.Stop();
        MyParticles.gameObject.AddComponent <ParticleKiller>();
        MyParticles.transform.parent = null;

        if (SpawnExplosion)
        {
            BulletExplosion explosion = Instantiate(ExplosionPrefab).GetComponent <BulletExplosion>();
            explosion.transform.position   = transform.position;
            explosion.transform.localScale = new Vector3(ExplosionRadius, ExplosionRadius, ExplosionRadius);
            explosion.Damage = Damage;
            AudioSource audio = explosion.GetComponent <AudioSource>();
            audio.clip = ExplosionSound;
            audio.Play();
        }

        Destroy(gameObject);
        if (!IgnoreLanding)
        {
            manager.BulletLanded();
        }
        // todo - cause different effects here depending on the bullet
    }
예제 #2
0
    private void OnTriggerEnter(Collider other)
    {
        Tank otherTank = other.GetComponent <Tank>();

        if (otherTank != null)
        {
            if (!SpawnExplosion)
            {
                if (!manager.OnlineGame || PhotonNetwork.IsMasterClient)
                {
                    otherTank.Health -= Damage;
                    if (PhotonNetwork.IsMasterClient)
                    {
                        Hashtable hash = otherTank.MyPlayer.CustomProperties;
                        hash["Health"] = otherTank.Health;
                        otherTank.MyPlayer.SetCustomProperties(hash);
                    }
                }

                BulletExplosion explosion = Instantiate(ExplosionPrefab).GetComponent <BulletExplosion>();
                explosion.transform.position   = transform.position;
                explosion.transform.localScale = new Vector3(ExplosionRadius, ExplosionRadius, ExplosionRadius);
                explosion.Damage = 0;
                AudioSource audio = explosion.GetComponent <AudioSource>();
                audio.clip = ExplosionSound;
                audio.Play();
            }
            Explode();
        }
    }