Ejemplo n.º 1
0
    void OnTriggerEnter(Collider collision)
    {
        Instantiate(TokenParticlePrefab, GameObj.transform.position, GameObj.transform.rotation);

        TokenSpawner.RemoveWithId(_id);

        Destroy(gameObject);

        GridDisplay.HitTokenUpdate(collision.gameObject.GetComponent <HoverMotor>().id, Metronome.CurTokenCycle, _tokenColour);
    }
 // Use this for initialization
 void Start()
 {
     sr           = GetComponent <SpriteRenderer> ();
     rb           = GetComponent <Rigidbody2D> ();
     rps          = GetComponent <RPSSystem> ();
     grounded     = true;
     tokenSpawner = GameObject.Find("TokenSpawner");
     ts           = tokenSpawner.GetComponent <TokenSpawner> ();
     sui          = GetComponent <StackUI> ();
 }
Ejemplo n.º 3
0
    //TODO:: this function doesn't do well on slopes or loops. Make it look at the normal.
    // Called for the entire track to generate all the tokens for the track. (randomly) Self explanitory...
    public static void SetTokenPositions(int numTokens)
    {
        int closedAdjustment = Instance.ClosedLoop ? 0 : 1;

        float currentDistance = 0.0f;
        float step            = Instance.TotalLength / numTokens;

        int ind = 0;

        // First for loop goes through each individual control point and connects it to the next, so 0-1, 1-2, 2-3 and so on
        for (int i = 0; i < TrackManager.Track.Points.Count - closedAdjustment; i++)
        {
            Instance.calculatePandM(i);

            Vector3 position;

            float t;

            while (currentDistance < Instance._distances[i + 1])
            {
                t = Mathf.InverseLerp(Instance._distances[i], Instance._distances[i + 1], currentDistance);

                Vector3 tangent;

                float percentThrough = t;

                position = CatmullRom.Interpolate(Instance.p0, Instance.p1, Instance.m0, Instance.m1, t, out tangent);

                Vector3 normal;
                float   centre;
                float   width;
                Instance.CalculateNormalCenterWidth(i, percentThrough, out normal, out centre, out width);

                float centerOffset = Random.Range(-1.0f, 1.0f);

                TokenSpawner.SpawnTokensAtPoint(2 * normal + position + Vector3.Cross(tangent, normal).normalized *width *(centre + centerOffset));

                ++ind;
                currentDistance += step;
            }
        }
    }