// Use this for initialization void Start() { iniGameParam(); iniSeting(); rigidbody = GetComponent <Rigidbody>(); if (TrackTo != null) { gameObject.transform.LookAt(TrackTo.transform); } piiTarget = gameObject.GetComponent <PiiTarget>(); //Останавливаем фары if (left_face != null) { left_face.Stop(); } if (right_face != null) { right_face.Stop(); } if (left_botm != null) { left_botm.Stop(); } if (right_botm != null) { right_botm.Stop(); } speed_face_ray = Random.Range(0.8f, 1.5f); police = gameObject.GetComponent <police_car>(); //Агрессия автомобиля Agress = Random.Range(20f, 80f); //Создаем источник звука под клаксон Create_BeepAudioSource(); }
public void TrigerPii(float presure, FaceController faceController, PiiController piiController, GameObject score_Text_func) { //Если у мочи достаточно инерции и если у предмета еще есть здоровье if (presure >= MinPresure && heath != 0) { float score_plus_now = 0; if (heath > 0) { //Сперва проверяем напрягся ли игрок if (player_save != null && player_save.bolt.GetComponent <PiiController>().ChargeOn) { heath -= presure; if (!gameplayParametrs.GameOver) { score_plus_now = score * 1.5f; player_save.PlusScore(score_plus_now); } } else if (player_save != null && !player_save.bolt.GetComponent <PiiController>().ChargeOn) { score_plus_now = score; player_save.PlusScore(score_plus_now); } heath -= presure; if (heath < 0) { heath = 0; } heath_percent = heath / (start_heath / 100); //Если есть частицы то воспроизводим их if (particle != null) { particle.Play(); } SetColorNeed(heath_percent); //Если здоровье закончилось if (heath <= 0) { DeathTarget(); test_lvl_target(player_save.gameplayParametrs); score_plus_now = score * score_destroy; player_save.PlusScore(score_plus_now); if (faceController != null && fear_emotion_dead && Random.Range(0, 100) < 50) { faceController.set_fear(3f); } helicopter helicopterObj = gameObject.GetComponent <helicopter>(); if (helicopterObj != null) { player_save.SetFullCharge(); } } //Иначе звук попадания else { //Воспросизводим звук попадания TargetSound sounds = gameObject.GetComponent <TargetSound>(); if (sounds != null) { gameObject.GetComponent <TargetSound>().PlaySoundPii(); } //Если цель автомобиль воспроизводим сигнализацию CarStatic CarSiren = gameObject.GetComponent <CarStatic>(); if (CarSiren != null) { CarSiren.StartSignal(); } //Если цель полиция то запускаем сирену police_car police = gameObject.GetComponent <police_car>(); if (police != null && !police.police_active_now) { police.police_active_now = true; police.need_sound_yn = true; } } } if (faceController != null && !piiController.ChargeOn) { if (Random.Range(0, 100) < 1.1f) { faceController.set_bliss_voice(1.2f); } if (Random.Range(0, 100) < 0.1f) { faceController.set_surprise_voice(1.2f); } if (Random.Range(0, 100) < 0.1f && fear_emotion) { faceController.set_choked_voice(); } } if (score_Text_func != null) { if (score_text != null) { GameObject.Destroy(score_text); } score_text = Instantiate(score_Text_func); Score_text_3d score_Text_3D = score_text.GetComponent <Score_text_3d>(); ScoreSum += score_plus_now; //Проверка того что нужно написать в зависимости от здоровья if (heath > 0) { Color color_new = new Color(1f, 0.92f, 0, 0.62f); score_Text_3D.inicialize(player_save.gameObject, ((int)heath_percent).ToString() + "%", gameObject.transform.position, color_new); } else { Color color_new = new Color(1f, 0.47f, 0, 0.62f); score_Text_3D.inicialize(player_save.gameObject, ((int)ScoreSum).ToString(), gameObject.transform.position, color_new); } } } }
//Убийство цели 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(); } } } }