예제 #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
    public void CreateNewLandscape()
    {
        //transform.position = new Vector3(0f,0f,0f);

        pointGapWidth = (startX2 - startX) / (float)(pointCount - 1);

        rageSpline.ClearPoints();
        for (int i = 0; i < pointCount; i++)
        {
            float x = startX + (float)i * pointGapWidth;
            curSteepness = steepness + x * 0.00001f;
            rageSpline.AddPointWorldSpace(i, GetNewLandscapePoint(x), transform.right * pointGapWidth * 0.33f);
        }

        rageSpline.SetPoint(0, new Vector3(rageSpline.GetPosition(0).x, 0f, 0f));
        rageSpline.SetPoint(1, new Vector3(rageSpline.GetPosition(1).x, 0f, 0f));

        rageSpline.RefreshMesh();
    }
예제 #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 Update()
    {
        Vector3 mousePositionWS = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        mousePositionWS = new Vector3(mousePositionWS.x, mousePositionWS.y, 0f);
        if (Input.GetMouseButtonDown(0)) // MouseDown
        {
            selectNearestItem(mousePositionWS);
        }
        if (Input.GetMouseButton(0)) // MouseDrag
        {
            updateActiveControlPosition(mousePositionWS);
            refreshEditorGUI();
            rageSpline.RefreshMesh();
        }
    }
예제 #5
0
    void Update()
    {
        timeSinceLastShake += Time.deltaTime;

        // Is it time for a new shake?
        if (timeSinceLastShake > currentShakeGap)
        {
            // Iterate through all the control points
            for (int index = 0; index < rageSpline.GetPointCount(); index++)
            {
                // Randomise a new shake vector
                Vector3 shakeVector = new Vector3(
                    Random.Range(-0.5f * shakeSizeInNormalSpace.x, 0.5f * shakeSizeInNormalSpace.x),
                    Random.Range(-0.5f * shakeSizeInNormalSpace.y, 0.5f * shakeSizeInNormalSpace.y),
                    0f);

                // Get normal and tangent for the control point. We will shake along the normal.
                Vector3 normal  = rageSpline.GetNormal(index);
                Vector3 tangent = Vector3.Cross(normal, Camera.main.transform.forward);

                // Set a new position for the control point
                targetPositions[index] = originalPositions[index] + shakeVector.x * tangent + shakeVector.y * normal;
            }

            // When is the next new shake?
            currentShakeGap    = Random.Range(minFrameGap, maxFrameGap);
            timeSinceLastShake = 0f;
        }
        else
        {
            // Iterate through all the control points
            for (int index = 0; index < rageSpline.GetPointCount(); index++)
            {
                // Interpolate toward Target positions with Vector3.Lerp()
                Vector3 currentPosition = rageSpline.GetPosition(index);
                rageSpline.SetPoint(index, Vector3.Lerp(currentPosition, targetPositions[index], Time.deltaTime * (1f / easing)));
            }
        }

        // Finally refresh the visible mesh
        rageSpline.RefreshMesh(true, true, false);

        // Faster version (possible artifacts)
        //rageSpline.RefreshMesh(false, false, false);
    }
예제 #6
0
파일: RageDude.cs 프로젝트: r618/RageSpline
    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;
    }
예제 #7
0
파일: Shake.cs 프로젝트: migreva/CocoBounce
    void Update()
    {
        // Iterate through all the control points
        for (int index = 0; index < rageSpline.GetPointCount(); index++)
        {
            // Get the current control point position in localspace coordinates
            Vector3 oldPosition = rageSpline.GetPosition(index);

            // Randomise a new shake vector
            Vector3 shakeVector = new Vector3(
                Random.Range(-0.5f * shakeSize.x, 0.5f * shakeSize.x),
                Random.Range(-0.5f * shakeSize.y, 0.5f * shakeSize.y),
                0f);

            // Set a new position for the control point
            rageSpline.SetPoint(index, oldPosition + shakeVector);
        }

        // Finally refresh the visible mesh
        rageSpline.RefreshMesh(true, true, true);

        // Faster version (possible artifacts)
        // rageSpline.RefreshMesh(false, false, false);
    }