}//FindTargetPoint public void FindTargetNearPoint(Vector3 _pos) { if (patch_script.point_car.Count > 0) { ClassPointCar temp_point; ClassPointCar temp_near_point = new ClassPointCar(); float temp_distance; float temp_angle_big = 360; float temp_diff_angle; float temp_angle_point; float temp_angle; for (var i = 0; i < patch_script.point_car.Count; i++) { temp_point = patch_script.point_car[i]; temp_distance = Vector3.Distance(temp_point._position, _pos); if (temp_distance < 20) { temp_angle = Quaternion.LookRotation(global_target_pos - temp_point._position).eulerAngles.y; temp_angle_point = Quaternion.LookRotation(patch_script.point_car[temp_point.near_point[0]]._position - temp_point._position).eulerAngles.y; temp_diff_angle = Functions.AngleSingle180Abs(temp_angle - temp_angle_point); if (temp_diff_angle < temp_angle_big) { temp_angle_big = temp_diff_angle; temp_near_point = patch_script.point_car[i]; } } //temp_distance } //for if (temp_near_point.index != -1) { GetPoint(temp_near_point); //Instantiate(target,temp_near_point._position,transform.rotation); } //temp_near_point } //Count } //FindTargetNearPoint
}//FindCentrPoint public ClassPointCar FindTargetPoint(Vector3 _pos) { if (patch_script.point_car.Count > 0) { ClassPointCar temp_point; ClassPointCar temp_near_point = new ClassPointCar(); float temp_distance_big = 1000; float temp_distance; float temp_diff_angle; for (var i = 0; i < patch_script.point_car.Count; i++) { temp_point = patch_script.point_car[i]; temp_distance = Vector3.Distance(temp_point._position, _pos); if (temp_distance < temp_distance_big) { temp_distance_big = temp_distance; temp_near_point = temp_point; } }//for if (temp_near_point.index != -1) { return(temp_near_point); }//temp_near_point else { return(null); } }//Count else { return(null); } }//FindTargetPoint
}//GetPosition public void GetPointPolice(ClassPointCar _point) { point = _point; target_pos = point._position; if (point.near_point.Count > 1) { float temp_angle_big = 360; float temp_angle_point; ClassPointCar temp_point = new ClassPointCar(); float temp_diff_angle; float temp_angle = Quaternion.LookRotation(global_target_pos - transform.position).eulerAngles.y; for (var i = 0; i < point.near_point.Count; i++) { temp_angle_point = Quaternion.LookRotation(patch_script.point_police[point.near_point[i]]._position - transform.position).eulerAngles.y; temp_diff_angle = Functions.AngleSingle180Abs(temp_angle - temp_angle_point); if (temp_diff_angle < temp_angle_big) { temp_angle_big = temp_diff_angle; temp_point = patch_script.point_police[point.near_point[i]]; } } //for next_point = temp_point; } //global_target else { next_point = patch_script.point_police[point.near_point[Random.Range(0, point.near_point.Count)]]; } }//GetPosition
public void FindNearPoint() { if (go_to_target) { return; } if (patch_script.point_car.Count > 0) { ClassPointCar temp_point; ClassPointCar temp_near_point = new ClassPointCar(); float temp_distance_big = 1000; float temp_distance; for (var i = 0; i < patch_script.point_car.Count; i++) { temp_point = patch_script.point_car[i]; temp_distance = Vector3.Distance(temp_point._position, transform.position); if (temp_distance < temp_distance_big) { temp_distance_big = temp_distance; temp_near_point = temp_point; } }//for if (temp_near_point.index != -1) { GetPoint(temp_near_point); } //temp_near_point } //Count } //FindNearPoint
}//GetPosition public void GetPointStart(ClassPointCar _point) { Patches temp_patch_sc = GameObject.Find("Game").GetComponent <Patches>(); point = _point; target_pos = point._position; next_point = temp_patch_sc.point_car[point.near_point[Random.Range(0, point.near_point.Count)]]; }//GetPosition
}//Start public void FindPoint() { ClassVehicleArea new_vehicle_area = new ClassVehicleArea(); new_vehicle_area._position = transform.position; new_vehicle_area.width = width; new_vehicle_area.height = height; new_vehicle_area.procent = procent; new_vehicle_area.limit_speed = limit_speed; new_vehicle_area.man = man; AddManProcent(new_vehicle_area.man_procent); for (var i = 0; i < patch_sc.point_car.Count; i++) { if (!patch_sc.point_car[i].use && Functions.HitArea(patch_sc.point_car[i]._position, transform.position, width, height)) { patch_sc.point_car[i].use = true; new_vehicle_area.point.Add(patch_sc.point_car[i]); } }//for //ManPoint for (var j = 0; j < patch_sc.point_man.Count; j++) { if (!patch_sc.point_man[j].use && Functions.HitArea(patch_sc.point_man[j]._position, transform.position, width, height) && patch_sc.point_man[j].create) { patch_sc.point_man[j].use = true; new_vehicle_area.point_man.Add(patch_sc.point_man[j]); } }//for if (car_stay_ob && car_stay_ob.childCount > 0) { for (var i1 = 0; i1 < car_stay_ob.childCount; i1++) { if (car_stay_ob.GetChild(i1).gameObject.active&& Functions.HitArea(car_stay_ob.GetChild(i1).position, transform.position, width, height)) { ClassPointCar temp_point = new ClassPointCar(); temp_point.index = -99999; temp_point._position = car_stay_ob.GetChild(i1).position; temp_point._rotation = car_stay_ob.GetChild(i1).eulerAngles; temp_point.stop = true; car_stay_ob.GetChild(i1).gameObject.SetActive(false); new_vehicle_area.point.Add(temp_point); } //car_stay_ob } //for } //childCount if (new_vehicle_area.point.Count > 0 || new_vehicle_area.point_man.Count > 0) { vehicle_creator_sc.vehicle_area.Add(new_vehicle_area); } }//FindPoint
} //FindTargetNearPoint public void FindPolicePoint(Vector3 _pos) { if (patch_script.point_police.Count > 0) { ClassPointCar temp_point; ClassPointCar temp_near_point = new ClassPointCar(); float temp_distance_big = 1000; float temp_distance; for (var i = 0; i < patch_script.point_police.Count; i++) { temp_point = patch_script.point_police[i]; temp_distance = Vector3.Distance(temp_point._position, _pos); if (temp_distance < temp_distance_big) { temp_distance_big = temp_distance; temp_near_point = temp_point; } }//for if (temp_near_point.index != -1) { GetPoint(temp_near_point); } //temp_near_point } //Count } //FindTargetPoint
} //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