예제 #1
0
	/// <summary>
	/// position path tween
	/// </summary>
	public GoTweenConfig positionPath( GoSpline path, bool isRelative = false, GoLookAtType lookAtType = GoLookAtType.None, Transform lookTarget = null )
	{
		var prop = new PositionPathTweenProperty( path, isRelative, false, lookAtType, lookTarget );
		_tweenProperties.Add( prop );
		
		return this;
	}
예제 #2
0
    public override IEnumerator execute()
    {
        if ( path != null && path.Count != 0 )
        {
            GameManager.DisableUnitSelection();
            //Debug.Log( "Executing!" );
            var vecPath = new Vector3[ path.Count ];

            for ( int i = 0 ; i < vecPath.Length ; i++ )
                vecPath[ i ] = path[ i ].position;

            GoSpline g = new GoSpline( vecPath , true );

            Board.instance.clearVirtualPosition( caster.transform.position );
            Board.instance.occupyVirtualPosition( vecPath[ vecPath.Length - 1 ] , caster.transform );

            //TODO: play move animation while tween is playing
            Go.to( caster.transform , moveSpeed , new TweenConfig().positionPath( g , false , LookAtType.None ).setEaseType( EaseType.QuartInOut ) );
            //TODO: play stop animation after tween finishes

            cleanup();
            caster.deselect();
            yield return new WaitForSeconds( moveSpeed );
            GameManager.EnableUnitSelection();
        }
        else
        {
            cleanup();
            caster.deselect();
            yield return null;
        }
    }
    public void Event()
    {
        if(firstRun) {
            firstRun = false;
            spline = new GoSpline(eventPath);
            var pathProperty = new PositionPathTweenProperty(spline);

            var config = new GoTweenConfig();
            config.addTweenProperty(pathProperty);

            var tween = new GoTween(PoPCamera.instance.transform, pathLength, config);
            Go.addTween(tween);
            if(multipleTargets) {
                focusTimer = focusPoints[0].time;
            }
        }

        if(multipleTargets) {
            if(focusTimer >= focusPoints[focusIndex].time && focusIndex != focusPoints.Count - 1) {
                focusIndex++;
            }
            Quaternion rotation = Quaternion.LookRotation(focusPoints[focusIndex].focus - PoPCamera.instance.transform.position);
            PoPCamera.instance.transform.rotation = Quaternion.Slerp(PoPCamera.instance.transform.rotation, rotation, 0.4f);
        } else {
            Quaternion rotation = Quaternion.LookRotation(singleTargetPos - PoPCamera.instance.transform.position);
            PoPCamera.instance.transform.rotation = Quaternion.Slerp(PoPCamera.instance.transform.rotation, rotation, 0.4f);
        }

        if(pathLength < 0) {
            PoPCamera.State = Camera_2.CameraState.Normal;
            Destroy(this.gameObject);
        } else
            pathLength -= Time.deltaTime;
    }
예제 #4
0
	void Start()
	{
		
		// example showing how to create a GoVector3Path from a saved file that was made with the visual editor. Note: the web player cannot load files from
		// disk so we will make a path directly for it
#if !UNITY_WEBPLAYER
		var path = new GoSpline( "demoRoute" );
#else
		// alternatively, paths can be created from an array of Vector3s
		var vectors = new Vector3[] { new Vector3( 0, 1, 1 ), new Vector3( 4, 5, 6 ) };
		var path = new GoSpline( vectors );
#endif
		
		
		// create the Tween and set the path to be relative (this will make the cube move BY the values stored in the
		// path instead of TO them). autoRemoveOnComplete is also set to false so that the Tween stays in the GoKit
		// engine and we can start/stop/reset it at will using the playback controls
		//_tween = Go.to( cube, 4f, new TweenConfig().positionPath( path, true ).setIterations( -1, LoopType.PingPong ) );
		
		// optionally, the target can be set to look at the next path node
		//_tween = Go.to( cube, 4f, new TweenConfig().positionPath( path, true, LookAtType.NextPathNode ).setIterations( -1, LoopType.PingPong ) );
		
		// or the target can be set to look at another transform
		_tween = Go.to( cube, 4f, new GoTweenConfig()
			.positionPath( path, true, GoLookAtType.TargetTransform, optionalLookTarget )
			.setIterations( -1, GoLoopType.PingPong ) );
	}
예제 #5
0
    /// <summary>
    /// scale through a series of Vector3s
    /// </summary>
    public GoTweenConfig scalePath ( GoSpline path , bool isRelative = false )
    {
        var prop = new ScalePathTweenProperty( path, isRelative );
        _tweenProperties.Add( prop );

        return this;
    }
 public PositionPathTweenProperty ( GoSpline path , bool isRelative = false , bool useLocalPosition = false , GoLookAtType lookAtType = GoLookAtType.None , Transform lookTarget = null ) : base( isRelative )
 {
     _path = path;
     _useLocalPosition = useLocalPosition;
     _lookAtType = lookAtType;
     _lookTarget = lookTarget;
 }
예제 #7
0
 // Use this for initialization
 void Start()
 {
     thePath = new GoSpline (dummy.nodes);
     thePath.buildPath ();
     startSpeed = Random.Range (0.01f, .3f);
     targetSpeed = startSpeed;
     currentSpeed = 0f;
 }
예제 #8
0
    // Use this for initialization
    void Start()
    {
        // make the item bounce
        // uses GoKit! Google it for documentation
        Vector3[] points = new Vector3[] { new Vector3(0, 0, 0), new Vector3(0, .25f, 0), new Vector3(0, 0, 0) };  // this path uses relative values rather than world values
        GoSpline path = new GoSpline(points);

        Go.to(transform, 2f, new GoTweenConfig().positionPath(path, true).setIterations(-1));
    }
예제 #9
0
	protected void BuildSplines(int num) {
		for (int s=0; s<num; s++) {
			GoSpline spline = new GoSpline(splineNodes);
			spline.buildPath();

			if (splineLookupCount > 0) {
				LookupSpline(spline);
			}
		}
	}
예제 #10
0
 public void OnDrawGizmos ()
 {
     // the editor will draw paths when force straight line is on
     if ( !forceStraightLinePath )
     {
         var spline = new GoSpline( nodes );
         Gizmos.color = pathColor;
         spline.drawGizmos( pathResolution );
     }
 }
예제 #11
0
 static public int get_splineType(IntPtr l)
 {
     try {
         GoSpline self = (GoSpline)checkSelf(l);
         pushEnum(l, (int)self.splineType);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #12
0
 static public int unreverseNodes(IntPtr l)
 {
     try {
         GoSpline self = (GoSpline)checkSelf(l);
         self.unreverseNodes();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        private void BakeRoutine(BakedPathInfo info)
        {
            GoSpline spline = info.path.Spline();

            while (info.progress < 1.0f)
            {
                Vector3 pos = spline.getPointOnPath(info.progress);
                info.bakedNodes.Add(pos);
                info.progress += info.step;
            }
        }
예제 #14
0
 static public int get_currentSegment(IntPtr l)
 {
     try {
         GoSpline self = (GoSpline)checkSelf(l);
         pushValue(l, self.currentSegment);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #15
0
    private void OnTriggerExit(Collider other)
    {
        var doorMove  = new Vector3[] { new Vector3( 0, 0, 0 ), new Vector3( 0, 0, -0.25f), new Vector3( 0, 0, -0.5f)};
        var path = new GoSpline( doorMove );
        path.closePath();

        GoTweenConfig doorConfig = new GoTweenConfig().positionPath(path,true).onComplete(DoorCleanup);

        doorConfig.setEaseType(GoEaseType.QuadInOut);
        Go.to( transform, openTime, doorConfig);
    }
예제 #16
0
    public override void DoClickToAct()
    {
        var doorMove  = new Vector3[] { new Vector3( 0, 0, 0 ), new Vector3( 0, 0, 0.25f), new Vector3( 0, 0, 0.5f)};
        var path = new GoSpline( doorMove );
        path.closePath();

        GoTweenConfig doorConfig = new GoTweenConfig().positionPath(path,true).onComplete(DoorCleanup);

        doorConfig.setEaseType(GoEaseType.QuadInOut);
        Go.to( transform, openTime, doorConfig);
    }
예제 #17
0
 static public int get_isClosed(IntPtr l)
 {
     try {
         GoSpline self = (GoSpline)checkSelf(l);
         pushValue(l, self.isClosed);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    private void closeRoute()
    {
        // we will use the GoSpline class to handle the dirtywork of closing the path
        var path = new GoSpline(_target.nodes, _target.forceStraightLinePath);

        path.closePath();

        _target.nodes = path.nodes;

        GUI.changed = true;
    }
예제 #19
0
    public static GoTween from(object target, GoSpline path, float speed, GoTweenConfig config)
    {
        config.setIsFrom();
        path.buildPath();
        float duration = path.pathLength / speed;
        var   tween    = new GoTween(target, duration, config);

        addTween(tween);

        return(tween);
    }
예제 #20
0
 static public int get_pathLength(IntPtr l)
 {
     try {
         GoSpline self = (GoSpline)checkSelf(l);
         pushValue(l, self.pathLength);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #21
0
    public override void DoClickToAct()
    {
        var doorMove = new Vector3[] { new Vector3(0, 0, 0), new Vector3(0, 0, -0.25f), new Vector3(0, 0, -0.5f) };
        var path     = new GoSpline(doorMove);

        path.closePath();

        GoTweenConfig doorConfig = new GoTweenConfig().positionPath(path, true).onComplete(DoorCleanup);

        doorConfig.setEaseType(GoEaseType.QuadInOut);
        Go.to(transform, openTime, doorConfig);
    }
예제 #22
0
    private void OnTriggerExit(Collider other)
    {
        var doorMove = new Vector3[] { new Vector3(0, 0, 0), new Vector3(0, 0, 0.25f), new Vector3(0, 0, 0.5f) };
        var path     = new GoSpline(doorMove);

        path.closePath();

        GoTweenConfig doorConfig = new GoTweenConfig().positionPath(path, true).onComplete(DoorCleanup);

        doorConfig.setEaseType(GoEaseType.QuadInOut);
        Go.to(transform, openTime, doorConfig);
    }
예제 #23
0
 static public int getLastNode(IntPtr l)
 {
     try {
         GoSpline self = (GoSpline)checkSelf(l);
         var      ret  = self.getLastNode();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #24
0
    public void Push()
    {
        var pushPoints = new Vector3[] { new Vector3(0, 0, 0), buttonPushVector };
        var path       = new GoSpline(pushPoints);

        path.closePath();

        GoTweenConfig pushConfig = new GoTweenConfig().positionPath(path, true);

        pushConfig.setEaseType(GoEaseType.QuadInOut);
        Go.to(transform, timeForButtonPush, pushConfig);
    }
예제 #25
0
    protected void LookupSpline(GoSpline spline)
    {
        float tStep = 1f / splineLookupCount;

        float t = tStep;

        for (int i = 0; i < splineLookupCount; i++)
        {
            spline.getPointOnPath(t);
            t += tStep;
        }
    }
예제 #26
0
    protected void BuildSplines(int num)
    {
        for (int s = 0; s < num; s++)
        {
            GoSpline spline = new GoSpline(splineNodes);
            spline.buildPath();

            if (splineLookupCount > 0)
            {
                LookupSpline(spline);
            }
        }
    }
예제 #27
0
    public override void DoClickToAct()
    {
        //ScaleTweenProperty DoorScale = new blabla
        buttonPush.Push ();
        var elevatorPath = new Vector3[] { new Vector3( 0, 0, 0 ), new Vector3( 0, 2.4f, 0 )};
        var path = new GoSpline( elevatorPath );
        //path.closePath();

        GoTweenConfig stepConfig = new GoTweenConfig().positionPath(path,true).onComplete(OpenDoors);

        stepConfig.setEaseType(GoEaseType.QuadInOut);
        Go.to( transform.parent.gameObject.transform, callTime, stepConfig);
    }
예제 #28
0
    public override void DoClickToAct()
    {
        var jumpPath  = new Vector3[] { new Vector3( 0, 0, 0 ), new Vector3( -jumpLength/2, jumpHeight, 0), new Vector3( -jumpLength, 0, 0 )};
        var path = new GoSpline( jumpPath );
        path.closePath();

        //GoTweenConfig stepConfig = new GoTweenConfig().positionPath(path,true).onComplete(OnJumpComplete);
        GoTweenConfig jumpConfig = new GoTweenConfig().positionPath(path,true).onComplete(JumpGapCleanup);

        jumpConfig.setEaseType(GoEaseType.QuadInOut);
        Go.to( player.transform, jumpGapTime, jumpConfig);
        Invoke ("PlayLandAudio", timeTillPlayLand);
    }
예제 #29
0
 static public int drawGizmos(IntPtr l)
 {
     try {
         GoSpline      self = (GoSpline)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         self.drawGizmos(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #30
0
    public override void DoClickToAct()
    {
        //ScaleTweenProperty DoorScale = new blabla
        buttonPush.Push();
        var elevatorPath = new Vector3[] { new Vector3(0, 0, 0), new Vector3(0, 2.4f, 0) };
        var path         = new GoSpline(elevatorPath);
        //path.closePath();

        GoTweenConfig stepConfig = new GoTweenConfig().positionPath(path, true).onComplete(OpenDoors);

        stepConfig.setEaseType(GoEaseType.QuadInOut);
        Go.to(transform.parent.gameObject.transform, callTime, stepConfig);
    }
예제 #31
0
 static public int bytesToVector3List_s(IntPtr l)
 {
     try {
         System.Byte[] a1;
         checkType(l, 1, out a1);
         var ret = GoSpline.bytesToVector3List(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #32
0
 static public int drawGizmos_s(IntPtr l)
 {
     try {
         UnityEngine.Vector3[] a1;
         checkType(l, 1, out a1);
         System.Single a2;
         checkType(l, 2, out a2);
         GoSpline.drawGizmos(a1, a2);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #33
0
    public override void DoClickToAct()
    {
        var jumpPath = new Vector3[] { new Vector3(0, 0, 0), new Vector3(-jumpLength / 2, jumpHeight, 0), new Vector3(-jumpLength, 0, 0) };
        var path     = new GoSpline(jumpPath);

        path.closePath();

        //GoTweenConfig stepConfig = new GoTweenConfig().positionPath(path,true).onComplete(OnJumpComplete);
        GoTweenConfig jumpConfig = new GoTweenConfig().positionPath(path, true).onComplete(JumpGapCleanup);

        jumpConfig.setEaseType(GoEaseType.QuadInOut);
        Go.to(player.transform, jumpGapTime, jumpConfig);
        Invoke("PlayLandAudio", timeTillPlayLand);
    }
예제 #34
0
 static public int getPointOnPath(IntPtr l)
 {
     try {
         GoSpline      self = (GoSpline)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         var ret = self.getPointOnPath(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #35
0
파일: PointPath.cs 프로젝트: apautrot/gdp9
    private GoSpline CreateSpline()
    {
        List<Vector3> points = new List<Vector3> ( Points );

        if ( !UseControlPoints || ClosePath )
        {
            points.Insert ( 0, points[0] );
            points.Add ( points[points.Count - 1] );
        }

        GoSpline spline = new GoSpline ( points, UseStraightLines );
        if ( ClosePath )
            spline.closePath ();

        return spline;
    }
예제 #36
0
        public override void ApplyPattern(Transform transform, ref AbstractGoTween tween)
        {
            var path = new GoSpline("little_curve_r");
            var move = Go.to(transform, 1f, new GoTweenConfig().positionPath(path, true));

            var path2 = new GoSpline("forward_top_bot");
            var move3 = Go.to(transform, 5f, new GoTweenConfig().positionPath(path2, true));

            var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1));

            chain.append(move);
            chain.append(move3);

            tween = chain;
            tween.play();
        }
예제 #37
0
    public override void DoClickToAct()
    {
        if (isJumping == false)
        {
            //Bob
            isJumping = true;
            //clickToInstruction.renderer.enabled = false;
            var headPopPoints = new Vector3[] { new Vector3(0, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 0) };
            var path          = new GoSpline(headPopPoints);
            path.closePath();

            GoTweenConfig stepConfig = new GoTweenConfig().positionPath(path, true).onComplete(OnJumpComplete);

            stepConfig.setEaseType(GoEaseType.QuadOut);
            Go.to(player.transform, jumpTime, stepConfig);
        }
    }
예제 #38
0
    public override void DoClickToAct()
    {
        if(isJumping == false)
        {
                //Bob
                isJumping = true;
                //clickToInstruction.renderer.enabled = false;
                var headPopPoints = new Vector3[] { new Vector3( 0, 0, 0 ), new Vector3( 0, 1, 0), new Vector3( 0, 0, 0 )};
                var path = new GoSpline( headPopPoints );
                path.closePath();

                GoTweenConfig stepConfig = new GoTweenConfig().positionPath(path,true).onComplete(OnJumpComplete);

                stepConfig.setEaseType(GoEaseType.QuadOut);
                Go.to( player.transform, jumpTime, stepConfig);
        }
    }
예제 #39
0
    public void SnapTo(ObjectSnapZone zone)
    {
        SnapTargetPos = zone.CurrentSnapSlot().pos + zone.transform.position;
        var position = transform.position;
        var points   = new[]
        {
            position,
            ((position + SnapTargetPos) / 2) + (Vector3.up * (Vector3.Distance(position, SnapTargetPos) / 2)),
            SnapTargetPos
        };
        var path   = new GoSpline(points);
        var config = new GoTweenConfig();

        config.positionPath(path, false);
        config.easeType = myEaseType;
        Go.to(transform, throwTime, config);
    }
예제 #40
0
    public void Event()
    {
        if (firstRun)
        {
            firstRun = false;
            spline   = new GoSpline(eventPath);
            var pathProperty = new PositionPathTweenProperty(spline);

            var config = new GoTweenConfig();
            config.addTweenProperty(pathProperty);

            var tween = new GoTween(PoPCamera.instance.transform, pathLength, config);
            Go.addTween(tween);
            if (multipleTargets)
            {
                focusTimer = focusPoints[0].time;
            }
        }

        if (multipleTargets)
        {
            if (focusTimer >= focusPoints[focusIndex].time && focusIndex != focusPoints.Count - 1)
            {
                focusIndex++;
            }
            Quaternion rotation = Quaternion.LookRotation(focusPoints[focusIndex].focus - PoPCamera.instance.transform.position);
            PoPCamera.instance.transform.rotation = Quaternion.Slerp(PoPCamera.instance.transform.rotation, rotation, 0.4f);
        }
        else
        {
            Quaternion rotation = Quaternion.LookRotation(singleTargetPos - PoPCamera.instance.transform.position);
            PoPCamera.instance.transform.rotation = Quaternion.Slerp(PoPCamera.instance.transform.rotation, rotation, 0.4f);
        }

        if (pathLength < 0)
        {
            PoPCamera.State = Camera_2.CameraState.Normal;
            Destroy(this.gameObject);
        }
        else
        {
            pathLength -= Time.deltaTime;
        }
    }
예제 #41
0
        //Worker thread to do the baking
        IEnumerator Worker(TrafficPath path)
        {
            Debug.Log("Start Worker");
            //open folder to create new file
            //System.IO.FileStream fstream = Ultilities.OpenFile(path.gameObject.name, System.IO.FileMode.OpenOrCreate);

            string workerName = "Worker: " + path.gameObject.name;

            GameObject trafficBaker = new GameObject(workerName);

            trafficBaker.transform.SetParent(transform);

            float    progress = 0;
            GoSpline spline   = path.Spline();
            float    speed    = path.bakedResolution;
            float    duration = path.Spline().pathLength;

            List <Vector3> pathNodes = new List <Vector3>();
            string         pathName  = path.gameObject.name;

            //baking
            while (progress <= 1.0f)
            {
                yield return(new WaitForFixedUpdate());

                progress += Time.fixedDeltaTime / (duration / (speed * 0.44704f));
                Vector3 pos = spline.getPointOnPath(progress);
                trafficBaker.transform.position = pos;
                pathNodes.Add(pos);
                trafficBaker.name = workerName + ": " + progress * 100 + "%";
            }
            //done baking

            Debug.Log(workerName + ": Done");
            Debug.Log("Nodes Count: " + pathNodes.Count);

            /*
             * BakedTrafficPath bakedPath = ScriptableObject.CreateInstance<BakedTrafficPath>();
             * bakedPath.Init(pathNodes, pathName, path.pathType, path.pathSpeedMPH, path.bakedResolution, path.splitChance, path.smartTraffic, path.phaseTypes, path.notes);
             * bakedPath.CreateAndSave(savedLocation);
             */
            yield return(null);
        }
예제 #42
0
 public void OnDrawGizmos()
 {
     if (displayInEditor && nodes != null && nodes.Count > 1)
     {
         Gizmos.color = lineColor;
         if (forceStraightLinePath)
         {
             for (int i = 0; i < nodes.Count - 1; i++)
             {
                 Gizmos.DrawLine(nodes[i], nodes[i + 1]);
             }
         }
         else
         {
             var spline = new GoSpline(nodes);
             spline.drawGizmos(50);
         }
     }
 }
예제 #43
0
    // Use this for initialization
    void Start()
    {
        var path = new GoSpline("little_curve");
        var move = Go.to(transform, 1f, new GoTweenConfig()
                         .positionPath(path, true));

        var move2 = Go.to(transform, 1f, new GoTweenConfig().positionPath(path, true));

        var path2 = new GoSpline("forward_top_bot");
        var move3 = Go.to(transform, 5f, new GoTweenConfig().positionPath(path2, true));

        var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1));

        chain.append(move);
        chain.append(move2);
        chain.append(move3);

        _tween = chain;
        _tween.play();
    }
예제 #44
0
 static public int constructor(IntPtr l)
 {
     try {
         int      argc = LuaDLL.lua_gettop(l);
         GoSpline o;
         if (matchType(l, argc, 2, typeof(List <UnityEngine.Vector3>), typeof(bool)))
         {
             System.Collections.Generic.List <UnityEngine.Vector3> a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             o = new GoSpline(a1, a2);
             pushValue(l, o);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.Vector3[]), typeof(bool)))
         {
             UnityEngine.Vector3[] a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             o = new GoSpline(a1, a2);
             pushValue(l, o);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(bool)))
         {
             System.String a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             o = new GoSpline(a1, a2);
             pushValue(l, o);
             return(1);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #45
0
    public override void DoClickToAct()
    {
        clickToStep.enabled = false;
        Vector3 nextPosition = new Vector3(nextPlatform.transform.position.x, nextPlatform.transform.position.y + jumpHitVerticalOffset, nextPlatform.transform.position.z);

        Vector3 jumpCenter;
        jumpCenter = player.transform.position + nextPlatform.transform.position;
        jumpCenter /= 2;
        jumpCenter.y += jumpHeight * Vector3.Distance(player.transform.position, nextPosition);
        //jumpCenter;
        Vector3[] jumpVecs = new Vector3[]{player.transform.position, jumpCenter ,new Vector3(nextPlatform.transform.position.x, nextPlatform.transform.position.y + jumpHitVerticalOffset, nextPlatform.transform.position.z)};
        GoSpline path = new GoSpline (jumpVecs);
        //path.closePath ();

        GoTweenConfig jumpConfig = new GoTweenConfig().positionPath(path,false).onComplete(JumpCleanup);
        jumpConfig.setEaseType (GoEaseType.SineInOut);

        Go.to(player.transform, jumpTime, jumpConfig);

        //Invoke ("PlayLandAudio", jumpTime - 0.2f);
    }
예제 #46
0
    void Start()
    {
        // example showing how to create a GoVector3Path from a saved file that was made with the visual editor. Note: the web player cannot load files from
        // disk so we will make a path directly for it
        var path = new GoSpline("textTween");

        // alternatively, paths can be created from an array of Vector3s


        // create the Tween and set the path to be relative (this will make the cube move BY the values stored in the
        // path instead of TO them). autoRemoveOnComplete is also set to false so that the Tween stays in the GoKit
        // engine and we can start/stop/reset it at will using the playback controls
        //_tween = Go.to( cube, 4f, new TweenConfig().positionPath( path, true ).setIterations( -1, LoopType.PingPong ) );

        // optionally, the target can be set to look at the next path node
        //_tween = Go.to( cube, 4f, new TweenConfig().positionPath( path, true, LookAtType.NextPathNode ).setIterations( -1, LoopType.PingPong ) );

        // or the target can be set to look at another transform
        _tween = Go.to(transform, 100f, new GoTweenConfig()
                       .positionPath(path, false)
                       .setIterations(-1, GoLoopType.PingPong));
    }
    public override void ApplyPattern(Transform transform, ref AbstractGoTween tween)
    {
        var path = new GoSpline("top_to_bot_one_third");
        var move = Go.to(transform, 2f, new GoTweenConfig().positionPath(path, true));

        var path2 = new GoSpline("diag_right_to_left_one_square");
        var move2 = Go.to(transform, 2f, new GoTweenConfig().positionPath(path2, true));

        var path3 = new GoSpline("top_to_bot_one_third");
        var move3 = Go.to(transform, 2f, new GoTweenConfig().positionPath(path3, true));
        var move4 = Go.to(transform, 2f, new GoTweenConfig().positionPath(path3, true));

        var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1));

        chain.append(move);
        chain.append(move2);
        chain.append(move3);
        chain.append(move4);

        tween = chain;
        tween.play();
    }
예제 #48
0
    private void DoClickToStep()
    {
        if(isStepping == false)
        {
            if(Input.GetMouseButtonDown(0))
            {
                float xdistance = -(stepLength*Mathf.Cos(horizontalAngle));
                float zdistance = (stepLength*Mathf.Sin(horizontalAngle));

                //Bob
                isStepping = true;
                clickToInstruction.GetComponent<Renderer>().enabled = false;
                var headPopPoints = new Vector3[] { new Vector3( 0, 0, 0 ), new Vector3( xdistance/2, stepBobHeight, zdistance/2 ), new Vector3( xdistance, heightChange, zdistance )};
                var path = new GoSpline( headPopPoints );
                path.closePath();

                GoTweenConfig stepConfig = new GoTweenConfig().positionPath(path,true).onComplete(OnStepComplete);

                stepConfig.setEaseType(GoEaseType.QuadInOut);
                Go.to( transform, stepTime, stepConfig);

            }
        }
    }
예제 #49
0
파일: Go.cs 프로젝트: SavaMinic/8plus1
    public static GoTween to( object target, GoSpline path, float speed, GoTweenConfig config )
    {
        config.setIsTo();
        path.buildPath();
        float duration = path.pathLength / speed;
        var tween = new GoTween( target, duration, config );
        addTween( tween );

        return tween;
    }
예제 #50
0
    private void closeRoute()
    {
        // we will use the GoSpline class to handle the dirtywork of closing the path
        var path = new GoSpline( _target.nodes, _target.forceStraightLinePath );
        path.closePath();

        _target.nodes = path.nodes;

        GUI.changed = true;
    }
예제 #51
0
 public static GoTween positionPathTo( this Transform self, float duration, GoSpline endValue, bool isRelative = false )
 {
     return Go.to ( self, duration, new GoTweenConfig ().positionPath ( endValue, isRelative ) );
 }
예제 #52
0
 void OnDrawGizmos()
 {
     if(eventPath.Count > 0) {
         var spline = new GoSpline(eventPath);
         Gizmos.color = Color.magenta;
         spline.drawGizmos(50f);
     }
 }
예제 #53
0
    /// <summary>
    /// shake generic vector3 path tween
    /// </summary>
    public GoTweenConfig shakeVector3PathProp( string propertyName, GoSpline path, bool isRelative = true, int frameMod = 1 )
    {
        var genericProp = new Vector3PathTweenProperty( propertyName, path, isRelative );
        var prop = new AttenuatedShakeTweenProperty( genericProp, frameMod );
        _tweenProperties.Add( prop );

        return this;
    }
 public Vector3PathTweenProperty ( string propertyName , GoSpline path , bool isRelative = false ) : base( isRelative )
 {
     this.propertyName = propertyName;
     _path = path;
 }
예제 #55
0
    /// <summary>
    /// generic vector3 path tween
    /// </summary>
    public TweenConfig vector3PathProp( string propertyName, GoSpline path, bool isRelative = false )
    {
        var prop = new Vector3PathTweenProperty( propertyName, path, isRelative );
        _tweenProperties.Add( prop );

        return this;
    }
예제 #56
0
    public override void OnInspectorGUI()
    {
        // what kind of handles shall we use?
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel( "Use Standard Handles" );
        _target.useStandardHandles = EditorGUILayout.Toggle( _target.useStandardHandles );
        EditorGUILayout.EndHorizontal();

        // path name:
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel( "Route Name" );
        _target.pathName = EditorGUILayout.TextField( _target.pathName );
        EditorGUILayout.EndHorizontal();

        if( _target.pathName == string.Empty )
            _target.pathName = "route" + Random.Range( 1, 100000 );

        // path color:
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel( "Route Color" );
        _target.pathColor = EditorGUILayout.ColorField( _target.pathColor );
        EditorGUILayout.EndHorizontal();

        // force straight lines:
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel( "Force Straight Line Path" );
        _target.forceStraightLinePath = EditorGUILayout.Toggle( _target.forceStraightLinePath );
        EditorGUILayout.EndHorizontal();

        // resolution
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel( "Editor Drawing Resolution" );
        _target.pathResolution = EditorGUILayout.IntSlider( _target.pathResolution, 2, 100 );
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        // insert node - we need 3 or more nodes for insert to make sense
        if( _target.nodes.Count > 2 )
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel( "Insert Node" );
            _insertIndex = EditorGUILayout.IntField( _insertIndex );
            if( GUILayout.Button( "Insert" ) )
            {
                // validate the index
                if( _insertIndex >= 0 && _insertIndex < _target.nodes.Count )
                {
                    // insert the node offsetting it a bit from the previous node
                    var copyNodeIndex = _insertIndex == 0 ? 0 : _insertIndex;
                    var copyNode = _target.nodes[copyNodeIndex];
                    copyNode.x += 10;
                    copyNode.z += 10;

                    insertNodeAtIndex( copyNode, _insertIndex );
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        // close route?
        if( GUILayout.Button( "Close Path" ) )
        {
            Undo.RegisterUndo( _target, "Path Vector Changed" );
            closeRoute();
            GUI.changed = true;
        }

        // shift the start point to the origin
        if( GUILayout.Button( "Shift Path to Start at Origin" ) )
        {
            Undo.RegisterUndo( _target, "Path Vector Changed" );

            var offset = Vector3.zero;

            // see what kind of path we are. the simplest case is just a straight line
            var path = new GoSpline( _target.nodes, _target.forceStraightLinePath );
            if( path.splineType == SplineType.StraightLine )
                offset = Vector3.zero - _target.nodes[0];
            else
                offset = Vector3.zero - _target.nodes[1];

            for( var i = 0; i < _target.nodes.Count; i++ )
                _target.nodes[i] += offset;

            GUI.changed = true;
        }

        // reverse
        if( GUILayout.Button( "Reverse Path" ) )
        {
            Undo.RegisterUndo( _target, "Path Vector Changed" );
            _target.nodes.Reverse();
            GUI.changed = true;
        }

        // persist to disk
        EditorGUILayout.Space();
        EditorGUILayout.LabelField( "Save to/Read from Disk" );

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel( "Serialize and Save Path" );
        if( GUILayout.Button( "Save" ) )
        {
            var path = EditorUtility.SaveFilePanel( "Save path", Application.dataPath + "/StreamingAssets", _target.pathName + ".asset", "asset" );
            if( path != string.Empty )
            {
                persistRouteToDisk( path );

                // fetch the filename and set it as the routeName
                _target.pathName = Path.GetFileName( path ).Replace( ".asset", string.Empty );
                GUI.changed = true;
            }
        }
        EditorGUILayout.EndHorizontal();

        // load from disk
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel( "Load saved path" );
        if( GUILayout.Button( "Load" ) )
        {
            var path = EditorUtility.OpenFilePanel( "Choose path to load", Path.Combine( Application.dataPath, "StreamingAssets" ), "asset" );
            if( path != string.Empty )
            {
                if( !File.Exists( path ) )
                {
                    EditorUtility.DisplayDialog( "File does not exist", "Path couldn't find the file you specified", "Close" );
                }
                else
                {
                    _target.nodes = GoSpline.bytesToVector3List( File.ReadAllBytes( path ) );
                    _target.pathName = Path.GetFileName( path ).Replace( ".asset", string.Empty );
                    GUI.changed = true;
                }
            }
        }
        EditorGUILayout.EndHorizontal();

        // node display
        EditorGUILayout.Space();
        _showNodeDetails = EditorGUILayout.Foldout( _showNodeDetails, "Show Node Values" );
        if( _showNodeDetails )
        {
            EditorGUI.indentLevel = 3;
            for( int i = 0; i < _target.nodes.Count; i++ )
                _target.nodes[i] = EditorGUILayout.Vector3Field( "Node " + ( i + 1 ), _target.nodes[i] );
        }

        // instructions
        EditorGUILayout.Space();
        EditorGUILayout.HelpBox( "While dragging a node, hold down Ctrl and slowly move the cursor to snap to a nearby point\n\n" +
                       "Click the 'Close Path' button to add a new node that will close out the current path.\n\n" +
                       "Hold Command while dragging a node to snap in 5 point increments\n\n" +
                       "Double click to add a new node at the end of the path\n\n" +
                       "Hold down alt while adding a node to prepend the new node at the front of the route\n\n" +
                       "Press delete or backspace to delete the selected node\n\n" +
                       "NOTE: make sure you have the pan tool selected while editing paths", MessageType.None );

        // update and redraw:
        if( GUI.changed )
        {
            EditorUtility.SetDirty( _target );
            Repaint();
        }
    }
예제 #57
0
	protected void LookupSpline(GoSpline spline) {
		float tStep = 1f / splineLookupCount;

		float t = tStep;
		for (int i=0; i<splineLookupCount; i++) {
			spline.getPointOnPath(t);
			t += tStep;
		}
	}
예제 #58
0
 public ScalePathTweenProperty( GoSpline path, bool isRelative = false )
     : base(isRelative)
 {
     _path = path;
 }
예제 #59
0
	/// <summary>
	/// helper for drawing gizmos in the editor
	/// </summary>
	public static void drawGizmos( Vector3[] path, float resolution = 50 )
	{
		// horribly inefficient but it only runs in the editor
		var spline = new GoSpline( path );
		spline.drawGizmos( resolution );
	}