}//OldCar public void CreateOldCar() { if (creator_sc.vehicle_delete.Count <= 0) { return; } if (creator_sc.vehicle_delete[0].GetComponent <Vehicle>().death) { creator_sc.vehicle_delete[0].GetComponent <Vehicle>().destroy = false; creator_sc.vehicle_delete.RemoveAt(0); return; }//death RaycastHit hit; Transform _vehicle = creator_sc.vehicle_delete[0]; Vector3 _position = transform.position; VehicleBot temp_script = _vehicle.GetComponent <VehicleBot>(); Vehicle temp_script_vehicle = _vehicle.GetComponent <Vehicle>(); Transform temp_old_man = temp_script_vehicle.place[0].man; if (temp_script_vehicle.boat != point.boat) { return; } if (Physics.Raycast(transform.position, new Vector3(0, -1, 0), out hit, 100)) { _position.y = hit.point.y + 1; } _vehicle.position = _position; _vehicle.eulerAngles = transform.eulerAngles; _vehicle.GetComponent <Rigidbody>().velocity = Vector3.zero; //if (_vehicle.GetComponent<MotobikeJs>()) _vehicle.GetComponent<MotobikeJs>().crash = false;//temp if (!point.stop) { int random_racer = Random.Range(0, 30); if (random_racer == 0 && !temp_script_vehicle.police) { temp_script.racer = true; } else { temp_script.racer = false; } if (!temp_script_vehicle.police) { temp_script_vehicle.limit_speed = (int)Random.Range(area.limit_speed * 0.8f, (float)(area.limit_speed * 1.2f)); } if (!temp_script.enabled) { temp_script.enabled = true; } if (!temp_script_vehicle.engine_work) { temp_script_vehicle.EngineWork(); } temp_script.GetPointStart(point); if (temp_old_man && temp_old_man.GetComponent <Man>().death) { temp_script_vehicle.place[0].use = false; game_sc.man.Remove(temp_old_man); Destroy(temp_old_man.gameObject); }//temp_old_man if (!temp_old_man) { if (temp_script_vehicle.police) { _vehicle.GetComponent <CarCop>().SeeEnemyFalse(); man = info_sc.man[4]; } else { man = info_sc.man[0]; } Transform temp_man = Instantiate(info_sc.man_ob[man.man[Random.Range(0, man.man.Count)]]); temp_man.position = new Vector3(transform.position.x, -10000, transform.position.z); temp_man.GetComponent <Man>().SitVehicle(_vehicle, temp_script_vehicle.place[0], false); } //man } //stop else { if (temp_script_vehicle.sirena) { temp_script_vehicle.sirena.gameObject.SetActive(false); } temp_script_vehicle.EngineStop(); if (_vehicle.GetComponent <CarCop>()) { _vehicle.GetComponent <CarCop>().enabled = false; } if (temp_script.enabled) { temp_script.enabled = false; } if (temp_old_man) { temp_script_vehicle.place[0].use = false; game_sc.man.Remove(temp_old_man); Destroy(temp_old_man.gameObject); } //man } //else temp_script_vehicle.destroy = false; creator_sc.vehicle_delete.RemoveAt(0); creator_sc.vehicle.Remove(transform); Destroy(gameObject); }//Create
} //Update public void CreateVehicle() { Vector3 temp_camera_pos = Camera.main.transform.position; Vector3 temp_point_pos; float temp_distance; for (var i = 0; i < vehicle_area.Count; i++) { if (Functions.HitArea(temp_camera_pos, vehicle_area[i]._position, vehicle_area[i].width + distance, vehicle_area[i].height + distance)) { int temp_procent = 1; if (create_car) {//game_sc.vehicle.Count<vehicle_max&& for (int j = 0; j < vehicle_area[i].point.Count; j++) { if (Random.Range(0, 100) < vehicle_area[i].procent / temp_procent) { temp_point_pos = vehicle_area[i].point[j]._position; temp_distance = Vector3.Distance(temp_point_pos, temp_camera_pos); if (temp_distance > distance_min_temp && temp_distance < distance) { ClassPointCar temp_near_point = new ClassPointCar(); Quaternion temp_rotation; if (!vehicle_area[i].point[j].stop) { temp_near_point = GetComponent <Patches>().point_car[vehicle_area[i].point[j].near_point[0]]; temp_rotation = Quaternion.LookRotation(temp_near_point._position - temp_point_pos); } else { temp_rotation = Quaternion.Euler(vehicle_area[i].point[j]._rotation); temp_near_point = vehicle_area[i].point[j]; } Transform temp_collider = Instantiate(_collider, temp_point_pos + new Vector3(0, 2, 0), temp_rotation) as Transform; int random_man = vehicle_area[i].man_procent[Random.Range(0, vehicle_area[i].man_procent.Count)]; ClassMan temp_man_type = info_sc.man[vehicle_area[i].man[random_man]]; ColliderCreator temp_script = temp_collider.GetComponent <ColliderCreator>(); temp_script.point = temp_near_point; temp_script.area = vehicle_area[i]; temp_script.man = temp_man_type; temp_script.info_sc = info_sc; temp_script.game_sc = game_sc; temp_script.creator_sc = this; vehicle.Add(temp_collider); } //HitAreaOut } //procent } //for } //vehicle_max //MAN if (create_man) {//man_count<man_max&& for (var j1 = 0; j1 < vehicle_area[i].point_man.Count; j1++) { ClassPointMan temp_point = vehicle_area[i].point_man[j1]; temp_procent = 1; if (Random.Range(0, 100) < vehicle_area[i].procent / temp_procent) { int random_man1 = vehicle_area[i].man_procent[Random.Range(0, vehicle_area[i].man_procent.Count)]; ClassMan temp_man_type1 = info_sc.man[vehicle_area[i].man[random_man1]]; temp_point_pos = temp_point._position; temp_distance = Vector3.Distance(temp_point_pos, temp_camera_pos); if (temp_distance > distance_min_temp && temp_distance < distance) { /* * var temp_man : Transform=Instantiate(info_sc.man_ob[temp_man_type1.man[Random.Range(0,temp_man_type1.man.Count)]]); * temp_man.position=temp_point_pos+Vector3(Random.Range(-temp_point.distance,temp_point.distance),0,Random.Range(-temp_point.distance,temp_point.distance)); * temp_man.GetComponent(sc_bot).GetThisPoint(temp_point,false);*/ Transform temp_create_man = Instantiate(create_man_ob); ManCreator temp_script1 = temp_create_man.GetComponent <ManCreator>(); temp_create_man.position = temp_point_pos + game_sc.Vector(Random.Range(-temp_point.distance, temp_point.distance), 0, Random.Range(-temp_point.distance, temp_point.distance)); //temp_script1.man=info_sc.man_ob[temp_man_type1.man[Random.Range(0,temp_man_type1.man.Count)]]; temp_script1.man = temp_man_type1; temp_script1.point = temp_point; temp_script1.info_sc = info_sc; temp_script1.game_sc = game_sc; temp_script1.game_ob = transform; temp_script1.creator_sc = this; man.Add(temp_create_man); } //distance } //procent } //for } //man_max } //HitArea } //for //Functions.HitAreaOut(temp_point_pos,temp_camera_pos,distance_min,distance_min)&&Functions.HitArea(temp_point_pos,temp_camera_pos,distance,distance) //if(distance_min_temp!=distance_min){distance_min_temp=distance_min;} Invoke("CreateVehicle", cteate_timer); }//CreateVehicle