Beispiel #1
0
    private static IEnumerator Randomizer(Gun gun, BulletScript script)
    {
        float num = UnityEngine.Random.Range(.5f, 2.5f);

        while (!script.homer)
        {
            yield return(new WaitForEndOfFrame());
        }
        HomingScript h = script.homer.GetComponent <HomingScript>();

        if (!script.Target && !h.main_col)
        {
            NetworkMethods.Instance.RpcSetEnabled(script.gameObject, "Renderer", false);
            NetworkMethods.Instance.RpcSetLayer(script.gameObject, 16);
            Rigidbody rb    = script.GetComponent <Rigidbody>();
            Vector3   speed = rb.velocity;
            rb.velocity = Vector3.zero;
            float start_time = Time.time;
            while (start_time + num > Time.time && !h.main_col && !script.Target)
            {
                yield return(new WaitForEndOfFrame());
            }
            NetworkMethods.Instance.RpcSetEnabled(script.gameObject, "Renderer", true);
            NetworkMethods.Instance.RpcSetLayer(script.gameObject, gun.layer);
            rb.velocity = speed.magnitude * script.transform.forward;
        }
    }
Beispiel #2
0
    private static IEnumerator Hunter(Gun gun, BulletScript script)
    {
        script.coroutines_running++;
        while (!script.homer)//wait for homingscript reference
        {
            yield return(new WaitForEndOfFrame());
        }
        HomingScript home = script.homer.GetComponent <HomingScript>();

        while (!home.homing && !script.has_collided)//Wait untuil it homes or collides
        {
            yield return(new WaitForEndOfFrame());
        }
        Collider[] bullet_colliders = Physics.OverlapSphere(script.gameObject.transform.position,
                                                            10,
                                                            LayerMask.GetMask("Default"),
                                                            QueryTriggerInteraction.Collide);
        foreach (Collider col in bullet_colliders)
        {
            /*Check if its a flurry bullet that isn't isn't homing*/
            BulletScript b = col.GetComponent <BulletScript>();
            if (b &&
                b.gameObject.layer == script.gameObject.layer &&
                b.gun_reference is Flurry &&
                !b.homer.GetComponent <HomingScript>().homing &&
                home.main_col)
            {
                /*Make bullet face target and fire towards them*/
                b.transform.LookAt(new Vector3(home.main_col.gameObject.transform.position.x, script.transform.position.y, home.main_col.gameObject.transform.position.z));
                b.GetComponent <Rigidbody>().velocity = b.transform.forward * b.GetComponent <Rigidbody>().velocity.magnitude;
            }
        }
        script.coroutines_running--;
    }
Beispiel #3
0
    private static IEnumerator Shadow(Gun gun, BulletScript script)
    {
        while (!script.homer)
        {
            yield return(new WaitForEndOfFrame());
        }
        HomingScript h = script.homer.GetComponent <HomingScript>();

        while (!h.homing)
        {
            yield return(new WaitForEndOfFrame());
        }
        if (rand.NextDouble() < .25)
        {
            Vector3 path = h.main_col.transform.position - script.transform.position;
            script.transform.position += (path * 1.5f);
        }
    }
Beispiel #4
0
    IEnumerator WaitForGunReference()
    {
        while (!gun_reference)
        {
            yield return(new WaitForEndOfFrame());
        }
        homer = transform.GetChild(0).gameObject;
        homer.GetComponent <SphereCollider>().radius = home_radius;
        homer.layer = gun_reference.home_layer;
        GetComponent <Collider>().isTrigger = can_pierce;
        HomingScript script = homer.GetComponent <HomingScript>();

        script.home_speed = home_speed;
        if (!homes)
        {
            homer.GetComponent <HomingScript>().enabled = true;
        }
        StartCoroutine(WaitForNetworkDestruction(gameObject));
    }
Beispiel #5
0
    IEnumerator WaitForGunReference()
    {
        while (!gun_reference)
        {
            yield return(new WaitForEndOfFrame());
        }
        homer = transform.GetChild(0).gameObject;
        homer.GetComponent <SphereCollider>().radius = home_radius;
        homer.layer = gun_reference.home_layer;
        GetComponent <Collider>().isTrigger = can_pierce;
        HomingScript script = homer.GetComponent <HomingScript>();

        script.home_speed = home_speed;
        StartCoroutine(WaitForNetworkDestruction());
        if (gameObject.layer != LayerMask.NameToLayer("AllyAttackUndetectable"))
        {
            StartCoroutine(TrackBulletCoordinates());
        }
    }
Beispiel #6
0
    private static IEnumerator Thirst(Gun gun, BulletScript script)
    {
        Vector3   start_pos = script.transform.position;
        Rigidbody rb        = script.GetComponent <Rigidbody>();

        while (!script.homer)
        {
            yield return(new WaitForEndOfFrame());
        }
        HomingScript   hm              = script.homer.GetComponent <HomingScript>();
        SphereCollider col             = hm.GetComponent <SphereCollider>();
        float          original_radius = col.radius;

        while (script)
        {
            if (!hm.homing)
            {
                col.radius          += original_radius * .1f;
                hm.home_speed       += .1f;
                script.lasting_time += .001f;
            }
            yield return(new WaitForFixedUpdate());
        }
    }
Beispiel #7
0
    private static IEnumerator Accelerate(Gun gun, BulletScript script)
    {
        Vector3   start_pos = script.transform.position;
        Rigidbody rb        = script.GetComponent <Rigidbody>();

        while (!script.homer)
        {
            yield return(new WaitForEndOfFrame());
        }
        HomingScript hm = script.homer.GetComponent <HomingScript>();

        while (script)
        {
            if (!hm.homing)
            {
                rb.velocity = rb.velocity.normalized
                              * (rb.velocity.magnitude
                                 + Math.Abs(
                                     Vector3.Distance(start_pos, script.transform.position))
                                 / 10);
            }
            yield return(new WaitForFixedUpdate());
        }
    }