コード例 #1
0
    private void FixedUpdate()
    {
        if (_isWorking == false)
        {
            return;
        }
        var myPercent          = _spline.Project(_playerT.position);
        var followPercent      = _spline.Project(_followTransform.position);
        var indicationPosition = _cam.WorldToScreenPoint(_followTransform.position);

        if (_renderer.isVisible || Mathf.Abs((float)(myPercent - followPercent)) > 0.015f)
        {
            _myImage.color = transparent;
            return;
        }
        if (indicationPosition.z >= 0 & indicationPosition.x <= _canvas.rect.width * _canvas.localScale.x &&
            indicationPosition.y <= _canvas.rect.height * _canvas.localScale.x && indicationPosition.x >= 0f &&
            indicationPosition.y >= 0)
        {
            indicationPosition.z = 0;
        }
        else if (indicationPosition.z >= 0)
        {
            indicationPosition = OutOfRangeIndicatorPositionB(indicationPosition);
            TargetOutOfSight(true, indicationPosition);
        }
        else
        {
            indicationPosition *= -1f;
            indicationPosition  = OutOfRangeIndicatorPositionB(indicationPosition);
            TargetOutOfSight(true, indicationPosition);
        }

        _myT.position = indicationPosition;
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        var fingers = Lean.Touch.LeanTouch.Fingers;


        if (isPlayerActive)
        {
            coinTimer += Time.deltaTime;
        }
        if (isFollowing && isPlayerActive)
        {
            SlidingMethod();
            CheckIfOutOfOffset();
            if (sp.Project(transform.position).percent > 0.99)
            {
                WinGame();
            }
        }


        else
        {
            if (isPlayerActive)
            {
                FlyingMethod();
            }
        }
    }
コード例 #3
0
        public static bool CheckLineSwap(SplineComputer dest, SplineResult pos, float lineWidth)
        {
            var p1 = dest.Evaluate(dest.Project(pos.position));             // closest point on side line
            var d  = pos.position - p1.position;
            var v  = Vector3.Project(d, pos.right * lineWidth);             // project vector RIGHT from current on vector between points on lines
            var v2 = Vector3.Dot(d.normalized, pos.normal);

            return((v.magnitude <= lineWidth * 1.1f) && (Mathf.Abs(v2) <= 0.01f));
        }
コード例 #4
0
    public void StartFollow()
    {
        parentGameObject.position = transform.position;
        transform.localPosition   = new Vector3(0f, 0f, 0f);

        sp.Restart(spComp.Project(transform.position).percent);
        sp.follow = true;

        changeisInSplineBool(true);
    }
コード例 #5
0
        public static bool Slider(SplineComputer spline, ref double percent, Color color, string text = "", SplineSliderGizmo gizmo = SplineSliderGizmo.Rectangle, float buttonSize = 1f)
        {
            Camera cam = SceneView.currentDrawingSceneView.camera;

            spline.Evaluate(percent, evalResult);
            float size = HandleUtility.GetHandleSize(evalResult.position);

            Handles.color = new Color(color.r, color.g, color.b, 0.4f);
            Handles.DrawSolidDisc(evalResult.position, cam.transform.position - evalResult.position, size * 0.2f * buttonSize);
            Handles.color = Color.white;
            if ((color.r + color.g + color.b + color.a) / 4f >= 0.9f)
            {
                Handles.color = Color.black;
            }

            Vector3 center         = evalResult.position;
            Vector2 screenPosition = HandleUtility.WorldToGUIPoint(center);

            screenPosition.y += 20f;
            Vector3 localPos = cam.transform.InverseTransformPoint(center);

            if (text != "" && localPos.z > 0f)
            {
                Handles.BeginGUI();
                DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + text.Length * 4, screenPosition.y, 120, 25), text);
                Handles.EndGUI();
            }
            bool    buttonClick  = SliderButton(center, false, Color.white, 0.3f);
            Vector3 lookAtCamera = (cam.transform.position - evalResult.position).normalized;
            Vector3 right        = Vector3.Cross(lookAtCamera, evalResult.direction).normalized *size * 0.1f * buttonSize;
            Vector3 front        = Vector3.forward;

            switch (gizmo)
            {
            case SplineSliderGizmo.BackwardTriangle:
                center += evalResult.direction * size * 0.06f * buttonSize;
                front   = center - evalResult.direction * size * 0.2f * buttonSize;
                Handles.DrawLine(center + right, front);
                Handles.DrawLine(front, center - right);
                Handles.DrawLine(center - right, center + right);
                break;

            case SplineSliderGizmo.ForwardTriangle:
                center -= evalResult.direction * size * 0.06f * buttonSize;
                front   = center + evalResult.direction * size * 0.2f * buttonSize;
                Handles.DrawLine(center + right, front);
                Handles.DrawLine(front, center - right);
                Handles.DrawLine(center - right, center + right);
                break;

            case SplineSliderGizmo.DualArrow:
                center += evalResult.direction * size * 0.025f * buttonSize;
                front   = center + evalResult.direction * size * 0.17f * buttonSize;
                Handles.DrawLine(center + right, front);
                Handles.DrawLine(front, center - right);
                Handles.DrawLine(center - right, center + right);
                center -= evalResult.direction * size * 0.05f * buttonSize;
                front   = center - evalResult.direction * size * 0.17f * buttonSize;
                Handles.DrawLine(center + right, front);
                Handles.DrawLine(front, center - right);
                Handles.DrawLine(center - right, center + right);
                break;

            case SplineSliderGizmo.Rectangle:

                break;

            case SplineSliderGizmo.Circle:
                Handles.DrawWireDisc(center, lookAtCamera, 0.13f * size * buttonSize);
                break;
            }
            Vector3 lastPos = evalResult.position;

            Handles.color       = Color.clear;
            evalResult.position = Handles.FreeMoveHandle(evalResult.position, Quaternion.LookRotation(cam.transform.position - evalResult.position), size * 0.2f * buttonSize, Vector3.zero, Handles.CircleHandleCap);
            if (evalResult.position != lastPos)
            {
                percent = spline.Project(evalResult.position).percent;
            }
            Handles.color = Color.white;
            return(buttonClick);
        }
コード例 #6
0
 public void StartFollow()
 {
     follower.Restart(sp.Project(transform.position).percent); //restarts following from projected point
     follower.follow = true;
     isInSpline      = true;
 }
コード例 #7
0
    private void ProjectToSpline(Vector3 pos, SplineComputer spline)
    {
        var per = spline.Project(pos).percent;

        splineFollower.SetPercent(per);
    }