Esempio n. 1
0
    IEnumerator Spw()
    {
        int k, s;

        boolCoroutine = false;
        Vector2 acI = target.velocity;

        yield return(new WaitForSeconds(0.1f));

        Vector2 acF = target.velocity;

        V = new Vector3(Random.Range((int)limL.position.x + 3, (int)limR.position.x - 3), target.position.y + ((acF.y * t) + ((acF.y - acI.y) * ((t) * (t))) / 2), 0);

        selected = null;

        if (Singleton.subiendo)
        {
            k = Random.Range(0, mPools.halfWay + ((int)((mPools.maxProb - mPools.halfWay) * Difficulty)));
            if (k >= mPools.halfWay)
            {
                k = Random.Range(mPools.halfWay, mPools.maxProb);
            }
        }
        else
        {
            k = Random.Range(mPools.halfWay, mPools.maxProb);
        }

        //print(k);
        s = SelectorB(k);

        if (s < 0)
        {
            boolCoroutine = true; yield break;
        }
        selected = mPools.pool[s];

        if (selected == null || selected.active)
        {
            boolCoroutine = true;
            yield break;
        }

        //yield return new WaitForSeconds(t / 200f);
        if (V.y <= 20 || Vector3.Distance(target.transform.position, V) < (Camara.height / 2) + 5 || Physics2D.OverlapCircle(V, maxRadious) != null)
        {
            boolCoroutine = true; yield break;
        }

        selected.transform.position = V;
        selected.selfR.simulated    = true;
        selected.active             = true;
        boolCoroutine = true;
        yield return(null);
    }
Esempio n. 2
0
    IEnumerator Spw()
    {
        int k, s, d = 0;

        Bool = false;
        Vector2 acI = target.velocity;

        yield return(new WaitForSeconds(0.1f));

        Vector2 acF = target.velocity;

        V = target.transform.position + new Vector3((acF.x * t) + ((acF.x - acI.x) * (t) * (t)) / 2, (acF.y * t) + ((acF.y - acI.y) * (t) * (t)) / 2, 0);

        selected = null;
        for (int i = 0; i < aspirant.Length; i++)
        {
            k = Random.Range(0, mPools.maxProb);
            //print(k);
            s = SelectorB(k);

            if (s < 0)
            {
                d = s; break;
            }
            aspirant[i] = mPools.pool[s];

            yield return(new WaitForSeconds(0.01f));
        }
        if (d < 0)
        {
            Bool = true; yield break;
        }
        for (int i = 0; i < aspirant.Length; i++)
        {
            if (!aspirant[i].active)
            {
                if (selected == null)
                {
                    selected = aspirant[i];
                }

                if ((-(((V.y - selected.height) * (V.y - selected.height)) * selected.inverseRange) + 3) < (-(((V.y - aspirant[i].height) * (V.y - aspirant[i].height)) * aspirant[i].inverseRange) + 3))
                {
                    if (!aspirant[i].active)
                    {
                        selected = aspirant[i];
                    }
                }


                yield return(new WaitForSeconds(0.01f));
            }
        }

        if (selected == null || ((-(((V.y - selected.height) * (V.y - selected.height)) * selected.inverseRange) + 3) <= 0))
        {
            Bool = true;
            yield break;
        }
        yield return(new WaitForSeconds(0.01f));

        if (V.y + selected.offSet.y <= 20 || Vector3.Distance(target.transform.position, V + selected.offSet + new Vector3(-target.velocity.x * .87f / 1f, 0, 0)) < (Camera.main.transform.position.z / -2f) + 10)
        {
            Bool = true; yield break;
        }

        //posible correccion de offsets
        selected.transform.position = V + selected.offSet + new Vector3(-target.velocity.x * .87f / 1f, 0, 0);
        selected.selfR.simulated    = true;
        selected.selfR.velocity     = new Vector2(target.velocity.x * 0.99f, 0);
        selected.active             = true;
        Bool = true;
        yield return(null);
    }