Beispiel #1
0
    }         //CreatePD

    public Vector3 FindBuildPoint(Vector3 _pos, Transform _transform)
    {
        Patches       temp_patch_sc = GetComponent <Patches>();
        ClassPointMan temp_point;
        ClassPointMan temp_near_point = new ClassPointMan();
        float         temp_distance;
        float         temp_distance_big = 20;
        bool          temp_find_point   = false;
        Vector3       temp_position     = _pos;

        for (var i = 0; i < temp_patch_sc.point_man_build.Count; i++)
        {
            temp_point    = temp_patch_sc.point_man_build[i];
            temp_distance = Vector3.Distance(_pos, temp_point._position);
            if (temp_distance < temp_distance_big)
            {
                temp_distance_big = temp_distance;
                temp_near_point   = temp_patch_sc.point_man_build[i];
                temp_find_point   = true;
            }
        }//for
        if (temp_find_point && temp_near_point.controll_point.Count != 0)
        {
            _transform.GetComponent <PlaceDeath>().have_point = true;
            for (var j = 0; j < temp_near_point.controll_point.Count; j++)
            {
                _transform.GetComponent <PlaceDeath>().near_point.Add(temp_patch_sc.point_man_build[temp_near_point.controll_point[j]]);
            }//for
            ClassPointMan temp_point1 = temp_patch_sc.point_man_build[temp_near_point.controll_point[Random.Range(0, temp_near_point.controll_point.Count)]];
            temp_position = temp_point1._position;
        }
        return(temp_position);
    }//FindBuildPoint
Beispiel #2
0
    }//GetThisPoint

    public void Doing(ClassPointMan _point)
    {
        if (_point.doing == 0)
        {
            return;
        }
        else if (_point.doing == 1)
        {
            doing = "idle"; timer_step_max = Random.Range(10.0f, 20.0f);
        }
        else
        {
            doing      = "idle";
            timer_step = 0;
            if (_point.doing == 2)
            {
                timer_step_max = Random.Range(10.0f, 20.0f);
                man_script.Doing(Random.Range(1, 4), timer_step_max, Vector3.zero, Vector3.zero);
            }
            else if (_point.doing == 3)
            {
                timer_step_max = Random.Range(10.0f, 20.0f);
                man_script.Doing(4, timer_step_max, _point.rotation, _point._position);
            }
            else if (_point.doing == 4)
            {
                timer_step_max = Random.Range(10.0f, 20.0f);
                man_script.Doing(5, timer_step_max, Vector3.zero, Vector3.zero);
            }
        } //else
    }     //Doing
Beispiel #3
0
    }//NextPoint

    public void GetPoint(ClassPointMan _point)
    {
        old_point     = point;
        point         = _point;
        target_pos    = point._position;
        target_pos.x += Random.Range(-point.distance, point.distance); target_pos.z += Random.Range(-point.distance, point.distance);
        Doing(old_point);
    }//GetPoint
Beispiel #4
0
    }//GetPoint

    public void GetThisPoint(ClassPointMan _point, bool _build)
    {
        Patches temp_patch_script = GameObject.Find("Game").GetComponent <Patches>();

        if (_build)
        {
            point_man = temp_patch_script.point_man_build;
        }
        else
        {
            point_man = temp_patch_script.point_man;
        }
        GetPoint(_point);
    }//GetThisPoint
Beispiel #5
0
    }         //Update

    public void FindNearPoint(int _build)
    {
        Patches temp_patch_script = GameObject.Find("Game").GetComponent <Patches>();

        if (_build == 1)
        {
            point_man = temp_patch_script.point_man;
        }
        else if (_build == 2)
        {
            point_man = temp_patch_script.point_man_build;
        }

        if (point_man.Count > 0)
        {
            ClassPointMan temp_point;
            ClassPointMan temp_near_point   = null;
            float         temp_distance_big = 1000;
            float         temp_distance;

            for (var i = 0; i < point_man.Count; i++)
            {
                temp_point    = point_man[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 != null)
            {
                GetPoint(temp_near_point);
            } //temp_near_point
        }     //Count
    }         //FindNearPoint
    }    //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