Exemplo n.º 1
0
    void Update()
    {
        var pos1 = node1.transform.position;
        if( node2 == null ) {
            node2 = JumpNodeTrigger.FindClosestNode(pos1);
            if( node2 != null ) {
                node2.oppositeTrigger = node1;
                node2.node = this;
            } else {
                return;
            }
        }
        var pos2 = node2.transform.position;
        if(node2.connectToClosest) {
            var t1 = pos1;
            var t2 = pos2;
            t1.y = 0f;
            t2.y = 0f;
            var d = Vector3.Distance( t1, t2 );
            if( d > Constants.instance.jumpNodeConnectDistance ) {
                node2.node = null;
                node2.oppositeTrigger = null;
                node2 = null;
                lineRenderer.SetVertexCount( 0 );
                return;
            }
        }

        float distance;
        CalculateCurve(pos1, pos2, heightByDistance, out distance);
        UpdateRenderer();
    }
Exemplo n.º 2
0
 void OnTriggerExit( Collider other )
 {
     var jumpNode = other.GetComponent<JumpNodeTrigger>();
     if( jumpNode != null && ignoreJumpNode == jumpNode ) {
         ignoreJumpNode = null;
     }
 }
Exemplo n.º 3
0
 void OnTriggerEnter( Collider other )
 {
     var jumpNode = other.GetComponent<JumpNodeTrigger>();
     if( jumpNode != null && ignoreJumpNode != jumpNode ) {
         jumpFunction = jumpNode.CreateJump();
         ignoreJumpNode = jumpNode.oppositeTrigger;
     }
 }
Exemplo n.º 4
0
 void OnTriggerExit(Collider other)
 {
     var jumpNode = other.GetComponent<JumpNodeTrigger>();
     if(jumpNode == ignoreJumpNode) {
         ignoreJumpNode = null;
     } else {
         GameObject.Find("RetroJump").GetComponent<AudioSource>().Play();
     }
 }
Exemplo n.º 5
0
 void onDeath()
 {
     jumpFunction = null;
     ignoreJumpNode = null;
 }
Exemplo n.º 6
0
 void onDeath()
 {
     jumpFunction = null;
     ignoreJumpNode = null;
     localVelocity = Vector3.zero;
 }
Exemplo n.º 7
0
        public JumpFunction( JumpNodeTrigger start, JumpNodeTrigger destination)
        {
            this.start = start;
            this.destination = destination;
            startPos = start.transform.position;
            destinationPos = destination.transform.position;
            elapsedTime = 0f;

            JumpNode.CalculateCurve( startPos, destinationPos, heightByDistance, out distance );
            time = distance / Constants.instance.jumpSpeed;
        }