示例#1
0
文件: fork.cs 项目: Fatty-AR/Fatty-AR
    void hitRandomly()
    {
        //Vector3
        interval = (2.5f >= interval - (eat.GetPlayerSize() - 1) * 0.2f) ? 2.5f : interval - (eat.GetPlayerSize() - 1) * 0.2f;
        length   = (0 >= length - (eat.GetPlayerSize() - 1) * 0.2f) ? 0 : length - (eat.GetPlayerSize() - 1) * 0.2f;
        //Debug.Log("interval = " + interval);

        // hit
        Vector3 pos = hitPosition();
        Vector3 up  = new Vector3(pos.x, 10.5f, pos.z);

        transform.position = up;
        transform.Translate(Vector3.Normalize(pos - up) * (Vector3.Distance(up, pos) / (interval / 4 * Time.deltaTime)));
        transform.Translate(Vector3.Normalize(up - pos) * (Vector3.Distance(pos, up) / (interval / 4 * Time.deltaTime)));

        if (TimeCount >= hitTime)
        {
            TimeCount -= hitTime - interval;
            Invoke("definitelyHit", interval);
        }
        else
        {
            TimeCount += interval;
            Invoke("hitRandomly", interval);
        }
    }
示例#2
0
    void hitRandomly()
    {
        //Vector3
        interval = (2.5f >= interval - (eat.GetPlayerSize() - 1) * 0.2f) ? 2.5f : interval - (eat.GetPlayerSize() - 1) * 0.2f;
        length   = (0 >= length - (eat.GetPlayerSize() - 1) * 0.2f) ? 0 : length - (eat.GetPlayerSize() - 1) * 0.2f;
        //Debug.Log("interval = " + interval);

        // hit

        /*Vector3 pos = hitPosition();
         * Vector3 up = new Vector3(pos.x, 10.5f, pos.z);
         * transform.position = up;
         * transform.Translate(Vector3.Normalize(pos - up) * (Vector3.Distance(up, pos) / (interval / 4 * Time.deltaTime)));
         * transform.Translate(Vector3.Normalize(up - pos) * (Vector3.Distance(pos, up) / (interval / 4 * Time.deltaTime)));*/

        targetPos          = hitPosition();
        nowPos             = new Vector3(targetPos.x, 10.5f, targetPos.z);
        transform.position = nowPos;

        Timer timer;

        timer           = new Timer(interval / 4);
        timer.OnUpdate += move;
        timer.OnEnd    += moveUpStart;
        timer.Start();

        Debug.Log("done!!!");

        if (TimeCount >= hitTime)
        {
            TimeCount -= hitTime - interval;
            Invoke("definitelyHit", interval);
        }
        else
        {
            TimeCount += interval;
            Invoke("hitRandomly", interval);
        }
    }
示例#3
0
    void hitRandomly()
    {
        if (moving)
        {
            return;
        }
        moving = true;
        //Vector3
        interval = (2.5f >= interval - (eat.GetPlayerSize() - 1) * 0.2f) ? 2.5f : interval - (eat.GetPlayerSize() - 1) * 0.2f;
        length   = (0 >= length - (eat.GetPlayerSize() - 1) * 0.2f) ? 0 : length - (eat.GetPlayerSize() - 1) * 0.2f;
        //Debug.Log("interval = " + interval);

        // hit

        /*Vector3 pos = hitPosition();
         * Vector3 up = new Vector3(pos.x, 10.5f, pos.z);
         * transform.position = up;
         * transform.Translate(Vector3.Normalize(pos - up) * (Vector3.Distance(up, pos) / (interval / 4 * Time.deltaTime)));
         * transform.Translate(Vector3.Normalize(up - pos) * (Vector3.Distance(pos, up) / (interval / 4 * Time.deltaTime)));*/

        targetPos          = hitPosition();
        nowPos             = new Vector3(targetPos.x, 10.5f, targetPos.z);
        transform.position = nowPos;

        Timer timer;

        timer           = new Timer(1.0f);
        timer.OnUpdate += move;
        timer.OnEnd    += moveUpStart;
        timer.OnEnd    += disableMark;
        timer.Start();

        //Debug.Log("done!!!");
        moving = false;

        if (TimeCount >= hitTime)
        {
            TimeCount -= hitTime - interval;
            if (am.GetNoticeBuff())
            {
                //Debug.Log("true!!!");
                parameter = "definitelyHit";
                Invoke("markFlash", interval - 1.5f);
            }
            else
            {
                Invoke("definitelyHit", interval);
            }
        }
        else
        {
            TimeCount += interval;
            if (am.GetNoticeBuff())
            {
                //Debug.Log("true!!!");
                parameter = "hitRandomly";
                Invoke("markFlash", interval - 1.5f);
            }
            else
            {
                Invoke("hitRandomly", interval);
            }
        }
    }