Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        float curVelX = playerRB.velocity.x;

        if (curVelX > 0.1)
        {
            if (trueOffsetX < offsetX)
            {
                lerping   = true;
                initPos   = gameObject.transform.position;
                transTime = 0.0f;
            }
            trueOffsetX = offsetX;
        }
        else if (StaticMethods.AlmostEquals(curVelX, 0.0f, 0.1f))
        {
            if (trueOffsetX != 0)
            {
                lerping   = true;
                initPos   = gameObject.transform.position;
                transTime = 0.0f;
            }
            trueOffsetX = 0;
        }
        else
        {
            if (trueOffsetX > -offsetX)
            {
                lerping   = true;
                initPos   = gameObject.transform.position;
                transTime = 0.0f;
            }
            trueOffsetX = -offsetX;
        }
        offset = new Vector3(trueOffsetX, offsetY, gameObject.transform.position.z - player.transform.position.z);
        if (lerping)
        {
            PosTimedLerp(player.transform.position + offset);
        }
        else
        {
            gameObject.transform.position = player.transform.position + offset;
        }
    }
Ejemplo n.º 2
0
    public bool PosTimedLerp(Vector3 finalPos)
    {
        float timerVal = transTime / LERP_TIME;

        Camera.main.transform.position = Vector3.Lerp(initPos, finalPos, timerVal);

        if (StaticMethods.AlmostEquals(transTime, LERP_TIME, 0.01f))
        {
            gameObject.transform.position = finalPos;
            initPos   = finalPos;
            transTime = 0.0f;
            lerping   = false;
            return(true);
        }
        else
        {
            transTime += Time.deltaTime;
            return(false);
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        float curRot = gameObject.transform.rotation.eulerAngles.z;

        Vector2 curOffset = new Vector2(Mathf.Sin(Mathf.Deg2Rad * curRot), -Mathf.Cos(Mathf.Deg2Rad * curRot));

        Vector2 TwoDPos = (Vector2)(gameObject.transform.position);

        Vector2 curDir = TwoDPos - curOffset;

        Vector2 target = new Vector2(0.0f, 0.0f);

        if (nodeList.Count > 0)
        {
            target = (Vector2)(nodeList[0].position);
        }
        else
        {
            Destroy(this);
        }

        float isLeft   = StaticMethods.IsLeft(TwoDPos - curDir, TwoDPos - target);
        float onTarget = StaticMethods.IsLeft(TwoDPos - curDir, target - TwoDPos);

        if (StaticMethods.AlmostEquals(onTarget, 0.0f, 0.5f))
        {
            rb.AddForce(curOffset * -speed);
            rb.angularVelocity = 0.0f;
        }
        else if (isLeft > 0)
        {
            rb.angularVelocity = speed * 20.0f;
            //rb.velocity = Vector2.zero;
        }
        else if (isLeft < 0)
        {
            rb.angularVelocity = -speed * 20.0f;
            //rb.velocity = Vector2.zero;
        }
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        time += Time.deltaTime;

        if (Input.GetButtonDown("Up"))
        {
            bool hit = false;
            foreach (GameObject obj in gameObject.GetComponent <RhythmController>().getDeployed())
            {
                if (StaticMethods.AlmostEquals((Vector2)(obj.transform.position), (Vector2)(Camera.main.ScreenToWorldPoint(UpCircle.transform.position)), Difficulty))
                {
                    //hit
                    IncrementScore((int)(BASE_F * Mathf.Sqrt(time) * Random.Range(1.0f, 3.0f)));
                    hit = EmitAndDestroy(obj);
                    break;
                }
            }
            if (!hit)
            {
                IncrementScore((int)((-1.00 * (BASE_F / 2.0f) * Mathf.Sqrt(Mathf.Sqrt(time))) * Random.Range(1.0f, 2.0f)));
            }
        }

        if (Input.GetButtonDown("Right"))
        {
            bool hit = false;
            foreach (GameObject obj in gameObject.GetComponent <RhythmController>().getDeployed())
            {
                if (StaticMethods.AlmostEquals((Vector2)(obj.transform.position), (Vector2)(Camera.main.ScreenToWorldPoint(RightCircle.transform.position)), Difficulty))
                {
                    //hit
                    IncrementScore((int)(BASE_F * Mathf.Sqrt(time) * Random.Range(1.0f, 3.0f)));
                    hit = EmitAndDestroy(obj);
                    break;
                }
            }
            if (!hit)
            {
                IncrementScore((int)((-1.00 * (BASE_F / 2.0f) * Mathf.Sqrt(Mathf.Sqrt(time))) * Random.Range(1.0f, 2.0f)));
            }
        }

        if (Input.GetButtonDown("Down"))
        {
            bool hit = false;
            foreach (GameObject obj in gameObject.GetComponent <RhythmController>().getDeployed())
            {
                if (StaticMethods.AlmostEquals((Vector2)(obj.transform.position), (Vector2)(Camera.main.ScreenToWorldPoint(DownCircle.transform.position)), Difficulty))
                {
                    //hit
                    IncrementScore((int)(BASE_F * Mathf.Sqrt(time) * Random.Range(1.0f, 3.0f)));
                    hit = EmitAndDestroy(obj);
                    break;
                }
            }
            if (!hit)
            {
                IncrementScore((int)((-1.00 * (BASE_F / 2.0f) * Mathf.Sqrt(Mathf.Sqrt(time))) * Random.Range(1.0f, 2.0f)));
            }
        }

        if (Input.GetButtonDown("Left"))
        {
            bool hit = false;
            foreach (GameObject obj in gameObject.GetComponent <RhythmController>().getDeployed())
            {
                if (StaticMethods.AlmostEquals((Vector2)(obj.transform.position), (Vector2)(Camera.main.ScreenToWorldPoint(LeftCircle.transform.position)), Difficulty))
                {
                    //hit
                    IncrementScore((int)(BASE_F * Mathf.Sqrt(time) * Random.Range(1.0f, 3.0f)));
                    hit = EmitAndDestroy(obj);
                    break;
                }
            }
            if (!hit)
            {
                IncrementScore((int)((-1.00 * (BASE_F / 2.0f) * Mathf.Sqrt(Mathf.Sqrt(time))) * Random.Range(1.0f, 2.0f)));
            }
        }

        foreach (GameObject obj in gameObject.GetComponent <RhythmController>().getDeployed())
        {
            if (!(obj.GetComponent <SpriteRenderer>().isVisible) &&
                obj.GetComponent <LiveAndBreathe>().getStartTime() < this.time + 3)
            {
                //swing and a miss!
                //IncrementScore((int)(-1.00 * (int)(BASE_F * Mathf.Sqrt(time) * Random.Range(1.0f, 3.0f))));
                //DestroyPlz(obj);
                break;
            }
        }

        if (time >= 129.00f)
        {
            SceneManager SM = GameObject.Find("SceneManager").GetComponent <SceneManager>();
            SM.MoveToScene(0);
        }
    }