示例#1
0
    }                 //Update

    public void FindEnemy()
    {
        Invoke("FindEnemy", 2);
        if (!this.enabled)
        {
            return;
        }
        Man       temp_enemy_sc;
        Transform temp_enemy;
        Transform temp_near_enemy   = null;
        float     temp_distance_big = see_range;
        float     temp_distance;

        if (enemy && man_script_enemy && man_script_enemy.health > 0)
        {
            temp_distance = Vector3.Distance(enemy.position, transform.position);
            if (temp_distance < temp_distance_big)
            {//&&Physics.Linecast (transform.position+Vector3(0,1.5,0),man_script_enemy.bip_target.position, hit)
             //if(hit.transform==enemy || hit.transform.root==enemy || hit.transform.root==man_script_enemy.vehicle){
                enemy_distance = temp_distance;
                bot_script.Racer(true, vehicle_sc.max_speed);
                if (vehicle_sc.sirena)
                {
                    vehicle_sc.sirena.gameObject.SetActive(true);
                }
                return;
                //}//enemy
                //else {game_sc.GetPositionKiller(enemy);}
            } //temp_distance
        }     //enemy


        enemy = null;
        for (var i = 0; i < game_sc.man.Count; i++)
        {
            temp_enemy    = game_sc.man[i];
            temp_enemy_sc = temp_enemy.GetComponent <Man>();
            if (temp_enemy && temp_enemy_sc && temp_enemy_sc.health > 0 && temp_enemy_sc.danger)
            {
                RaycastHit hit = new RaycastHit();
                temp_distance = Vector3.Distance(temp_enemy.position, transform.position);
                if (temp_distance < temp_distance_big && Physics.Linecast(transform.position + new Vector3(0, 1.5f, 0), temp_enemy_sc.bip_target.position, out hit))
                {
                    if (hit.transform == temp_enemy || hit.transform.root == temp_enemy || hit.transform.root == temp_enemy_sc.vehicle)
                    {
                        temp_near_enemy   = temp_enemy;
                        temp_distance_big = temp_distance;
                    } //temp_enemy
                }     //temp_distance
            }         //danger
        }             //for

        if (temp_near_enemy != null)
        {
            enemy            = temp_near_enemy;
            man_script_enemy = enemy.GetComponent <Man>();
            place_death      = null;
            man_script_enemy.Danger();
            SeeEnemyTrue(enemy.position, vehicle_sc.max_speed);
        }//temp_near_enemy
        else if (see_enemy)
        {
            have_enemy = false;
            Invoke("SeeEnemyFalse", 20);
        } //else
    }     //FindEnemy
示例#2
0
    }//Start

    void Update()
    {
        if (see_enemy && vehicle_sc.engine_work)
        {
            if (enemy)
            {
                bot_script.global_target_pos = enemy.position;
                enemy_distance = Vector3.Distance(transform.position, enemy.position);
                if (enemy_distance < 100)
                {
                    man_script_enemy.Danger();
                }
                float temp_radius    = 40;
                float temp_magnitude = 0.5f;

                if (vehicle_sc.boat)
                {
                    temp_radius    = 200;
                    temp_magnitude = 10;
                }
                if (enemy_distance < temp_radius)
                {
                    have_point            = false;
                    bot_script.have_point = false;
                    //if(enemy_distance<5)bot_script.target_pos=enemy.position;
                    if (enemy_distance < 20)
                    {
                        bot_script.racer_collision = false;
                        bot_script.target_pos      = enemy.TransformPoint(enemy_pos);
                    }
                    else
                    {
                        bot_script.racer_collision = true;
                        bot_script.target_pos      = enemy.position;
                    }
                }//30
                else if (!have_point && !vehicle_sc.boat)
                {
                    bot_script.FindPolicePoint(enemy.position); have_point = true;
                }

                if (enemy_distance < 20)
                {
                    if ((man_script_enemy.vehicle && man_script_enemy.vehicle.GetComponent <Rigidbody>().velocity.magnitude < 10) || man_script_enemy.doing != "sit_vehicle")
                    {
                        vehicle_sc.throttle = 0;
                        vehicle_sc.StopVehicle(200);
                        if (GetComponent <Rigidbody>().velocity.magnitude < temp_magnitude)
                        {
                            AllOutVehicle();
                        }
                    } //magnitude
                     //else if(enemy_distance<5){vehicle_sc.steer=1;}
                }     //enemy_distance
            }         //enemy
            else if (place_death)
            {
                bot_script.global_target_pos = pd_pos;
                float pd_distance = Vector3.Distance(transform.position, pd_pos);
                if (pd_distance < 60)
                {
                    bot_script.target_pos = pd_pos;
                    stop_timer           += Time.deltaTime;
                    if (stop_timer > 20)
                    {
                        stop = true;
                    }
                }//pd_distance
                if (pd_distance < 20 || stop)
                {
                    vehicle_sc.throttle = 0;
                    vehicle_sc.StopVehicle(200);
                    if (GetComponent <Rigidbody>().velocity.magnitude < 0.5)
                    {
                        AllOutVehicle();
                        GetBPoint();
                    } //magnitude
                }     //pd_distance
            }         //place_death
        }             //engine_work
    }                 //Update
示例#3
0
    }     //Update

    public void FindEnemy()
    {
        Invoke("FindEnemy", 1);
        Man         temp_enemy_sc;
        ClassWeapon temp_weapon = weapon_script.weapon[weapon_script.weapon_index];
        Transform   temp_enemy;
        Transform   temp_near_enemy   = null;
        float       temp_distance_big = 100;
        float       temp_distance;
        RaycastHit  hit;


        if (temp_weapon.range > temp_distance_big)
        {
            temp_distance_big = temp_weapon.range;
        }
        if (enemy && man_script_enemy && man_script_enemy.health > 0)
        {
            temp_distance = Vector3.Distance(enemy.position, transform.position);
            if (temp_distance < temp_distance_big && Physics.Linecast(transform.position + game_sc.Vector(0, 1.7f, 0), man_script_enemy.bip_target.position, out hit))
            {
                if (hit.transform == enemy || hit.transform.root == man_script_enemy.vehicle || (hit.collider.name != "Terrain" && hit.collider.material.name == "Glass (Instance)"))
                {
                    enemy_distance = temp_distance;
                    return;
                }//enemy
                else
                {
                    game_sc.GetPositionKiller(enemy);
                }
            } //temp_distance
        }     //enemy


        enemy = null;
        for (var i = 0; i < game_sc.man.Count; i++)
        {
            temp_enemy    = game_sc.man[i];
            temp_enemy_sc = temp_enemy.GetComponent <Man>();
            if (temp_enemy && temp_enemy_sc && temp_enemy_sc.health > 0 && temp_enemy_sc.danger)
            {
                temp_distance = Vector3.Distance(temp_enemy.position, transform.position);
                if (temp_distance < temp_distance_big && Physics.Linecast(transform.position + game_sc.Vector(0, 1.7f, 0), temp_enemy_sc.bip_target.position, out hit))
                {
                    if (hit.transform == temp_enemy || hit.transform.root == temp_enemy || hit.transform.root == temp_enemy_sc.vehicle || (hit.collider.name != "Terrain" && hit.collider.material.name == "Glass (Instance)"))
                    {
                        temp_near_enemy   = temp_enemy;
                        temp_distance_big = temp_distance;
                        old_pos           = temp_enemy.position;
                    } //temp_enemy
                }     //temp_distance
            }         //danger
        }             //for

        if (temp_near_enemy != null)
        {
            if (weapon_script.weapon_index == 0)
            {
                weapon_script.WeaponSelect(1); return;
            }
            fire             = true;
            enemy            = temp_near_enemy;
            man_script_enemy = enemy.GetComponent <Man>();
            man_script_enemy.Danger();
            enemy_distance = temp_distance_big;
            old_pos        = enemy.position;
        }//temp_near_enemy
        else if (fire)
        {
            fire          = false;
            go_to_old_pos = true;
            weapon_script.EndFire();
        }
    }//FindEnemy