Пример #1
0
	void setRageSpline(Vector2[] splinePoints) {
		rageSpline = GetComponent<RageSpline>();
		rageSpline.ClearPoints();
		for (int i=0;i<splinePoints.Length;i++) {
			rageSpline.AddPoint(0, new Vector3(splinePoints[i].x,splinePoints[i].y,0),new Vector3(0,0,0));
		}
		rageSpline.RefreshMesh();
	}
Пример #2
0
 private void ShuffleSpline(IRageSpline rageSpline, float shuffleAmount)
 {
     for (int i = 0; i < rageSpline.GetPointCount(); i++)
     {
         Vector3 point = rageSpline.GetPosition(i);
         point += new Vector3(Random.Range(shuffleAmount * -0.5f, shuffleAmount * 0.5f), Random.Range(shuffleAmount * -0.5f, shuffleAmount * 0.5f), 0f);
         rageSpline.SetPoint(i, point);
     }
 }
Пример #3
0
    void setRageSpline(Vector2[] splinePoints)
    {
        IRageSpline rageSpline = GetComponent <RageSpline>();

        rageSpline.ClearPoints();
        for (int i = 0; i < splinePoints.Length; i++)
        {
            rageSpline.AddPoint(0, new Vector3(splinePoints[i].x, splinePoints[i].y, 0), new Vector3(0, 0, 0));
        }
        rageSpline.RefreshMesh();
    }
Пример #4
0
 void Awake()
 {
     spline        = this.GetComponent <RageSpline>() as IRageSpline;
     thisTransform = this.transform;
     //rb2D = this.rigidbody2D;
             #if UNITY_EDITOR
     AntiAliasPlaftformFactor = 1f;
             #endif
             #if UNITY_STANDALONE
     AntiAliasPlaftformFactor = 1f;
             #endif
             #if UNITY_IPHONE
     AntiAliasPlaftformFactor = 0.5f;
             #endif
 }
Пример #5
0
    void Awake()
    {
        // Store the instance of RageSpline to avoid calling it every frame for speed/convenience.
        // Cast to IRageSpline for cleaner API access
        rageSpline = GetComponent(typeof(RageSpline)) as IRageSpline;

        // Array for movement target positions per control point
        targetPositions = new Vector3[rageSpline.GetPointCount()];

        // Store the original control point positions
        originalPositions = new Vector3[rageSpline.GetPointCount()];

        for (int index = 0; index < rageSpline.GetPointCount(); index++)
        {
            originalPositions[index] = rageSpline.GetPosition(index);
        }
    }
Пример #6
0
    void Awake()
    {
        // Store the instance of RageSpline to avoid calling it every frame for speed/convenience.
        // Cast to IRageSpline for cleaner API access
        rageSpline = GetComponent(typeof(RageSpline)) as IRageSpline;

        // Array for movement Target positions per control point
        targetPositions = new Vector3[rageSpline.GetPointCount()];

        // Store the original control point positions
        originalPositions = new Vector3[rageSpline.GetPointCount()];

        for (int index = 0; index < rageSpline.GetPointCount(); index++)
        {
            originalPositions[index] = rageSpline.GetPosition(index);
        }
    }
Пример #7
0
 public static bool RemoveOverlap(this IRageSpline path, int index0, int index1, float snapRadius, bool debug)
 {
     if (index1 == 0)
     {
         index0 = path.GetPointCount() - 1;
     }
     if (Vector3.Distance(path.GetPositionWorldSpace(index0), path.GetPositionWorldSpace(index1)) <= snapRadius)
     {
         if (debug)
         {
             Debug.Log("overlap path pos = " + path.GetPositionWorldSpace(index0));
         }
         path.SetNatural(index1, false);
         path.SetInControlPositionWorldSpace(index1, path.GetInControlPositionWorldSpace(index0));
         path.RemovePoint(index0);      // Then deletes the duplicate previous point
         return(true);
     }
     return(false);
 }
Пример #8
0
    void OnCollisionEnter(Collision collision)
    {
        foreach (ContactPoint contact in collision.contacts)
        {
            if (contact.otherCollider.name == "Landscape")
            {
                onGround = true;
            }
            if (contact.otherCollider.name == "_Rock" && !isGameOver)
            {
                isGameOver = true;
                IRageSpline rageSpline = GetComponent(typeof(RageSpline)) as IRageSpline;
                rageSpline.SetFillColor1(new Color(1f, 0.2f, 0.2f));
                rageSpline.RefreshMesh();
                scoreCounter.SendMessage("GameOver");
                Invoke("GameOverFinal", 2f);
            }
        }

        onGround = true;
    }
Пример #9
0
    /// <summary> Special case for start-end points, where the out tangent must be copied instead of the in tangent </summary>
    public static bool MergeStartEndPoints(this IRageSpline rageSpline, bool debug)
    {
        if (rageSpline.GetPointCount() <= 2)
        {
            return(false);
        }
        var lastPointIdx  = rageSpline.GetPointCount() - 1;
        var lastPointPos  = rageSpline.GetPositionWorldSpace(lastPointIdx);
        var firstPointPos = rageSpline.GetPositionWorldSpace(0);

        if (Vector3.Distance(firstPointPos, lastPointPos) < 0.0001f)
        {
            if (debug)
            {
                Debug.Log("\t Removing endpoint overlap ");
            }
            rageSpline.SetInControlPositionWorldSpace(0, rageSpline.GetInControlPositionWorldSpace(lastPointIdx));
            rageSpline.RemovePoint(lastPointIdx);      // Then deletes the last point
            return(true);
        }
        return(false);
    }
Пример #10
0
 void Awake()
 {
     // Store the instance of RageSpline to avoid calling it every frame for speed/convenience.
     // Cast to IRageSpline for cleaner API access
     rageSpline = GetComponent(typeof(RageSpline)) as IRageSpline;
 }
Пример #11
0
 void Start()
 {
     landscapeSpline = landscape.GetComponent(typeof(RageSpline)) as IRageSpline;
     InvokeRepeating("CheckForOutOfBounds", 0.1f, 1f);
 }
Пример #12
0
 // Use this for initialization
 void Start()
 {
     rageSpline = GetComponent(typeof(RageSpline)) as IRageSpline;
     CreateNewLandscape();
 }
Пример #13
0
 void Start()
 {
     landscapeSpline = landscape.GetComponent(typeof(RageSpline)) as IRageSpline;
     InvokeRepeating("CheckForOutOfBounds", 0.1f, 1f);
 }
Пример #14
0
 private void ShuffleSpline(IRageSpline rageSpline, float shuffleAmount)
 {
     for (int i = 0; i < rageSpline.GetPointCount(); i++)
     {
         Vector3 point = rageSpline.GetPosition(i);
         point += new Vector3(Random.Range(shuffleAmount*-0.5f, shuffleAmount*0.5f), Random.Range(shuffleAmount*-0.5f, shuffleAmount*0.5f), 0f);
         rageSpline.SetPoint(i, point);
     }
 }
Пример #15
0
 void Awake()
 {
     // Store the instance of RageSpline to avoid calling it every frame for speed/convenience.
     // Cast to IRageSpline for cleaner API access
     rageSpline = GetComponent(typeof(RageSpline)) as IRageSpline;
 }
Пример #16
0
 // Use this for initialization
 void Start()
 {
     rageSpline = GetComponent(typeof(RageSpline)) as IRageSpline;
     CreateNewLandscape();
 }