Пример #1
0
    private void createArc()
    {
        if (arc == null)
        {
            arc = new Vector3[3];
        }

        if (GameGlobals.Instance.controller.currentLevelSpeed <= 0)
        {
            GameGlobals.Instance.controller.currentLevelSpeed = GameGlobals.Instance.controller.Accelerate(Time.time - Time.time);
        }

        lastAddedIndex = 0;
        coinCount      = 0;

        float jumpHeight = GameGlobals.Instance.controller.jumpHeight;
        float jumpLenght = GameGlobals.Instance.controller.JumpLength();

        Vector3 endPos = transform.forward * jumpLenght;

        float endZ = endPos.z + 2.0f;

        float startZ = 0;

        if (offsetObject != null)
        {
            startZ = offsetObject.transform.localPosition.z - (endZ / 2.0f);
            this.transform.localPosition = new Vector3(this.transform.localPosition.x, this.transform.localPosition.y, startZ);
        }



        arc[0] = new Vector3(0, 0, 0);
        arc[1] = new Vector3(0, jumpHeight, endZ / 2.0f);
        arc[2] = new Vector3(0, 0, endZ);


        coinCount = (int)Mathf.Round(Mathf.Abs(arc[2].z) / coinSpacing);
        float perIncrement = 1.0f / coinCount;

        float currentPercent = perIncrement;

        // Start Coin
        insetCoin(new Vector3(0, 0, 0));


        // Curved Coins
        for (int i = 0; i < coinCount; i++)
        {
            Vector3 coinPos = ThunderTween.PointOnPath(arc, currentPercent);
            insetCoin(coinPos);
            currentPercent += perIncrement;
        }
    }
Пример #2
0
    private void updateArc()
    {
        if (coins == null)
        {
            return;
        }
        if (coins.Count <= 0)
        {
            return;
        }

        if (refreshTime >= 2000)
        {
            float jumpHeight = GameGlobals.Instance.controller.jumpHeight;
            float jumpLenght = GameGlobals.Instance.controller.JumpLength();

            Vector3 endPos = transform.forward * jumpLenght;
            float   endZ   = endPos.z + 2.0f;

            float startZ = 0;

            if (offsetObject != null)
            {
                startZ = offsetObject.transform.localPosition.z - (endZ / 2.0f);
                this.transform.localPosition = new Vector3(this.transform.localPosition.x, this.transform.localPosition.y, startZ);
            }


            arc[0] = new Vector3(0, 0, 0);
            arc[1] = new Vector3(0, jumpHeight, endZ / 2.0f);
            arc[2] = new Vector3(0, 0, endZ);

            int   coinCount      = (int)Mathf.Round(Mathf.Abs(arc[2].z) / coinSpacing);
            float perIncrement   = 1.0f / coinCount;
            float currentPercent = perIncrement;

            for (int i = 1; i < coins.Count; i++)
            {
                coins[i].transform.localPosition = ThunderTween.PointOnPath(arc, currentPercent);
                currentPercent += perIncrement;
            }

            refreshTime = 0;
        }
        else
        {
            refreshTime++;
        }
    }
Пример #3
0
 void FixedUpdate()
 {
     if (orbitedObjects != null)
     {
         for (int i = 0; i < orbitedObjects.Length; i++)
         {
             if (orbitedObjects[i] != null)
             {
                 if (pathPercents[i] >= 1.0f)
                 {
                     pathPercents[i] = 0;
                 }
                 ThunderTween.PutOnPath(orbitedObjects[i].transform, circlePath.ToArray(), pathPercents[i]);
                 orbitedObjects[i].transform.transform.LookAt(ThunderTween.PointOnPath(circlePath.ToArray(), pathPercents[i] + 0.05f));
                 pathPercents[i] += 0.0005f;
             }
         }
     }
 }
Пример #4
0
    public void doActive()
    {
        if (GameGlobals.Instance.trackGenerator == null)
        {
            return;
        }
        if (arc == null)
        {
            arc = new Vector3[4];
        }

        switch (coinLineRefraction)
        {
        case CoinLineRefraction.None:

            arc[0] = new Vector3(0, 0, 0);
            arc[1] = new Vector3(0, 0, (length / 3.0f) * 1.0f);
            arc[2] = new Vector3(0, 0, (length / 3.0f) * 2.0f);
            arc[3] = new Vector3(0, 0, (length / 3.0f) * 3.0f);

            break;

        case CoinLineRefraction.LeftStraight:

            arc[0] = new Vector3(0, 0, 0);
            arc[1] = new Vector3(-0.6f, 0, (length / 3.0f) * 1.0f);
            arc[2] = new Vector3(-6.0f, 0, (length / 3.0f) * 2.0f);
            arc[3] = new Vector3(-6.6f, 0, (length / 3.0f) * 3.0f);

            break;

        case CoinLineRefraction.RightStraight:

            arc[0] = new Vector3(0, 0, 0);
            arc[1] = new Vector3(0.6f, 0, (length / 3.0f) * 1.0f);
            arc[2] = new Vector3(6.0f, 0, (length / 3.0f) * 2.0f);
            arc[3] = new Vector3(6.6f, 0, (length / 3.0f) * 3.0f);

            break;

        case CoinLineRefraction.LeftCurved:

            arc[0] = new Vector3(0, 0, 0);
            arc[1] = new Vector3(-6.0f, 0, (length / 3.0f) * 1.0f);
            arc[2] = new Vector3(-6.0f, 0, (length / 3.0f) * 2.0f);
            arc[3] = new Vector3(0, 0, (length / 3.0f) * 3.0f);

            break;

        case CoinLineRefraction.RightCurved:

            arc[0] = new Vector3(0, 0, 0);
            arc[1] = new Vector3(6.0f, 0, (length / 3.0f) * 1.0f);
            arc[2] = new Vector3(6.0f, 0, (length / 3.0f) * 2.0f);
            arc[3] = new Vector3(0, 0, (length / 3.0f) * 3.0f);

            break;
        }

        // Reset
        lastAddedIndex = 0;
        coinCount      = 0;

        coinCount = (int)Mathf.Round(length / coinSpacing);
        float perIncrement   = 1.0f / coinCount;
        float currentPercent = perIncrement;

        // First Coint
        insetCoin(new Vector3(0, 0, 0));

        // Path Coins
        for (int i = 0; i < coinCount; i++)
        {
            Vector3 coinPos = ThunderTween.PointOnPath(arc, currentPercent);
            insetCoin(coinPos);
            currentPercent += perIncrement;
        }
    }
Пример #5
0
    public void OnDrawGizmos()
    {
        Vector3[] arcGizmo = new Vector3[4];

        float objectX = transform.position.x;
        float objectY = transform.position.y;
        float objectZ = transform.position.z;


        switch (coinLineRefraction)
        {
        case CoinLineRefraction.None:

            arcGizmo[0] = new Vector3(objectX, objectY, objectZ);
            arcGizmo[1] = new Vector3(objectX, objectY, objectZ + (length / 3.0f) * 1.0f);
            arcGizmo[2] = new Vector3(objectX, objectY, objectZ + (length / 3.0f) * 2.0f);
            arcGizmo[3] = new Vector3(objectX, objectY, objectZ + (length / 3.0f) * 3.0f);

            break;

        case CoinLineRefraction.LeftStraight:

            arcGizmo[0] = new Vector3(objectX, objectY, objectZ);
            arcGizmo[1] = new Vector3(objectX + -0.6f, objectY, objectZ + (length / 3.0f) * 1.0f);
            arcGizmo[2] = new Vector3(objectX + -6.0f, objectY, objectZ + (length / 3.0f) * 2.0f);
            arcGizmo[3] = new Vector3(objectX + -6.06f, objectY, objectZ + (length / 3.0f) * 3.0f);

            break;

        case CoinLineRefraction.RightStraight:

            arcGizmo[0] = new Vector3(objectX, objectY, objectZ);
            arcGizmo[1] = new Vector3(objectX + 0.6f, objectY, objectZ + (length / 3.0f) * 1.0f);
            arcGizmo[2] = new Vector3(objectX + 6.0f, objectY, objectZ + (length / 3.0f) * 2.0f);
            arcGizmo[3] = new Vector3(objectX + 6.06f, objectY, objectZ + (length / 3.0f) * 3.0f);

            break;

        case CoinLineRefraction.LeftCurved:

            arcGizmo[0] = new Vector3(objectX, objectY, objectZ);
            arcGizmo[1] = new Vector3(objectX + -6.0f, objectY, objectZ + (length / 3.0f) * 1.0f);
            arcGizmo[2] = new Vector3(objectX + -6.0f, objectY, objectZ + (length / 3.0f) * 2.0f);
            arcGizmo[3] = new Vector3(objectX, objectY, objectZ + (length / 3.0f) * 3.0f);

            break;

        case CoinLineRefraction.RightCurved:

            arcGizmo[0] = new Vector3(objectX, objectY, objectZ);
            arcGizmo[1] = new Vector3(objectX + 6.0f, objectY, objectZ + (length / 3.0f) * 1.0f);
            arcGizmo[2] = new Vector3(objectX + 6.0f, objectY, objectZ + (length / 3.0f) * 2.0f);
            arcGizmo[3] = new Vector3(objectX, objectY, objectZ + (length / 3.0f) * 3.0f);

            break;
        }


        ThunderTween.DrawPath(arcGizmo, Color.black);
        Gizmos.color = Color.yellow;

        int   coinCount      = (int)Mathf.Round(length / coinSpacing);
        float perIncrement   = 1.0f / coinCount;
        float currentPercent = perIncrement;

        // First Coint
        Gizmos.DrawSphere(ThunderTween.PointOnPath(arcGizmo, 0), 1f);

        // Path Coins
        for (int i = 0; i < coinCount; i++)
        {
            Vector3 coinPos = ThunderTween.PointOnPath(arcGizmo, currentPercent);
            currentPercent += perIncrement;
            Gizmos.DrawSphere(coinPos, 1f);
        }
    }