예제 #1
0
 void iniBoomtarget()
 {
     if (boomTarget == null)
     {
         boomTarget = gameObject.GetComponent <BoomTarget>();
     }
 }
예제 #2
0
    //Убийство цели
    public void DeathTarget()
    {
        if (heath > 0)
        {
            heath = 0;
        }

        achievement.plus_1_destroy_object();
        player_save.PlusCombo();

        //Уменьшаем вес
        Rigidbody rigidbody = gameObject.GetComponent <Rigidbody>();

        if (rigidbody != null)
        {
            //Размораживаем
            rigidbody.constraints = RigidbodyConstraints.None;
        }

        HingeJoint hingeJoint = gameObject.GetComponent <HingeJoint>();

        if (hingeJoint != null)
        {
            GameObject.Destroy(hingeJoint);
        }

        //Если есть частицы смерти
        if (particleDie != null)
        {
            particleDie.Play();
        }

        //Воспросизводим звук смерти
        TargetSound sounds = gameObject.GetComponent <TargetSound>();

        if (sounds != null)
        {
            gameObject.GetComponent <TargetSound>().PlaySoundDestroy();
        }

        //Спавним обьект после смерти
        if (ObjSpawnDie != null)
        {
            GameObject DieObj = Instantiate(ObjSpawnDie, gameObject.transform.parent);
            DieObj.transform.position = gameObject.transform.position;
        }

        //Если это постройка
        BildTarget bild = gameObject.GetComponent <BildTarget>();

        if (bild != null)
        {
            bild.need_destroy = true;
        }
        //Если цель автомобиль
        CarStatic CarSiren = gameObject.GetComponent <CarStatic>();

        if (CarSiren != null)
        {
            CarSiren.OffSignal();
        }

        //Если это автомобиль
        Automobile automobile = gameObject.GetComponent <Automobile>();

        if (automobile != null && rigidbody != null)
        {
            rigidbody.mass = rigidbody.mass / 100;

            police_car police = gameObject.GetComponent <police_car>();
            if (police != null && achievement != null)
            {
                achievement.plus_1_destroy_police();
            }
        }

        //Если это танк
        Tank tank = gameObject.GetComponent <Tank>();

        if (tank != null)
        {
            tank.BrokenTank();
        }
        //Если это пуля танка
        TankBullet tankBullet = gameObject.GetComponent <TankBullet>();

        if (tankBullet != null)
        {
            tankBullet.testBoom = true;
        }

        flyer fly = gameObject.GetComponent <flyer>();

        if (fly != null && achievement != null)
        {
            achievement.destroy_fighter();
        }

        //Взрываем
        BoomTarget boom = gameObject.GetComponent <BoomTarget>();

        if (boom != null)
        {
            boom.BOOM();
        }

        //Убиваем все дочерние обьекты
        //PiiTarget[] piiTargets = gameObject.GetComponentsInChildren<PiiTarget>();
        //if (piiTargets != null) {
        //    for (int num = 0; num < piiTargets.Length; num++) {
        //        if (piiTargets[num] != gameObject.GetComponent<PiiTarget>()) {
        //            piiTargets[num].DeathTarget();
        //        }
        //   }
        //}

        //убиваем все дочерние обьекты по новому
        if (SiskoTarget != null && SiskoTarget.Length != 0)
        {
            for (int x = 0; x < SiskoTarget.Length; x++)
            {
                if (SiskoTarget[x] != null && SiskoTarget[x].heath > 0)
                {
                    SiskoTarget[x].DeathTarget();
                }
            }
        }
    }