Пример #1
0
	public void PT_StartMove( IEnumerable<PT_Loc> locs, float timeDuration=1, float timeStart=float.NaN ) {
		if (float.IsNaN(timeStart)) timeStart = Time.time;
		ptm_start = timeStart;
		ptm_duration = timeDuration;
		ptm_locs = new List<PT_Loc>(locs);
		ptm_state = PTM_State.preMove;
	}
Пример #2
0
	// Update is called once per frame
	protected virtual void Update () {
		if (ptm_state == PTM_State.idle || ptm_state == PTM_State.postMove) return;

		// We know that we're set up to move
		float u = (Time.time - ptm_start)/ptm_duration;
		float u2 = u;
		if (u<0) {
			ptm_state = PTM_State.preMove;
			u=0;
			PT_SetLoc(ptm_locs[0]);
		} else if (u>1) {
			ptm_state = PTM_State.postMove;
			u=1;
			PT_SetLoc(ptm_locs[ptm_locs.Count-1]);
			if (callback != null) callback();
		} else {
			ptm_state = PTM_State.move;

			// Perform easing on u
			u2 = Easing.Ease(u, ptm_easing);

			PT_Loc l = PT_Loc.Bezier(u2, ptm_locs);
			PT_SetLoc(l);
		}
		// Place these variables where others can see them
		ptm_u = u;
		ptm_u2 = u2;
	}
Пример #3
0
 public void PT_StartMove(IEnumerable <PT_Loc> locs, float timeDuration = 1, float timeStart = float.NaN)
 {
     if (float.IsNaN(timeStart))
     {
         timeStart = Time.time;
     }
     ptm_start    = timeStart;
     ptm_duration = timeDuration;
     ptm_locs     = new List <PT_Loc>(locs);
     ptm_state    = PTM_State.preMove;
 }
Пример #4
0
    // Update is called once per frame
    protected virtual void Update()
    {
        if (ptm_state == PTM_State.idle || ptm_state == PTM_State.postMove)
        {
            return;
        }

        // We know that we're set up to move
        float u  = (Time.time - ptm_start) / ptm_duration;
        float u2 = u;

        if (u < 0)
        {
            ptm_state = PTM_State.preMove;
            u         = 0;
            PT_SetLoc(ptm_locs[0]);
        }
        else if (u > 1)
        {
            ptm_state = PTM_State.postMove;
            u         = 1;
            PT_SetLoc(ptm_locs[ptm_locs.Count - 1]);
            if (callback != null)
            {
                callback();
            }
        }
        else
        {
            ptm_state = PTM_State.move;

            // Perform easing on u
            u2 = Easing.Ease(u, ptm_easing);

            PT_Loc l = PT_Loc.Bezier(u2, ptm_locs);
            PT_SetLoc(l);
        }
        // Place these variables where others can see them
        ptm_u  = u;
        ptm_u2 = u2;
    }