Example #1
0
    // Removes the specified sprite from the animation list,
    // thereby not receiving animation updates.
    // s: A reference to the sprite to be removed.
    public static void Remove(ISpriteAnimatable s)
    {
        if (head == s)
        {
            head = (ISpriteAnimatable)s.next;

            // See if we need to stop the pump:
            if (head == null)
            {
                StopAnimationPump();
            }
        }
        else
        {
            if (s.next != null)
            {                   // Connect either side:
                s.prev.next = s.next;
                s.next.prev = s.prev;
            }
            else if (s.prev != null)
            {
                // Removing the last item:
                s.prev.next = null;
            }
        }
        s.next = null;
        s.prev = null;
    }
Example #2
0
 public void OnDestroy()
 {
     head     = null;
     cur      = null;
     next     = null;
     instance = null;
 }
Example #3
0
    void Update()
    {
        if (!pumpIsRunning)
        {
            return;             // Abort
        }
        // Check for pause:
        if ((!isPaused && Time.timeScale == 0) ||
            (isPaused && Time.timeScale != 0))
        {
            instance.OnApplicationPause(Time.timeScale == 0);
        }

#if !USE_DELTA_TIME
        time      = Time.realtimeSinceStartup;
        elapsed   = (time - startTime) * _timeScale;
        startTime = time;
#endif

        cur = head;

        while (cur != null)
        {
            next = (ISpriteAnimatable)cur.next;
#if !USE_DELTA_TIME
            cur.StepAnim(elapsed);
#else
            cur.StepAnim(Time.deltaTime);
#endif
            cur = next;
        }
    }
Example #4
0
/*
 *      void Update()
 *      {
 *              if(!pumpIsRunning)
 *                      return;	// Abort
 *
 *              cur = head;
 *
 *              while(cur != null)
 *              {
 *                      cur.StepAnim(Time.deltaTime);
 *                      cur = cur.next;
 *              }
 *      }
 */

    // The coroutine that drives animation:
    protected static IEnumerator AnimationPump()
    {
#if !USE_DELTA_TIME
        startTime = Time.realtimeSinceStartup;
#else
        startTime = Time.time;
#endif
        float             elapsed;
        ISpriteAnimatable next;

        pumpIsDone = false;

        while (pumpIsRunning)
        {
            // Check for pause:
            if ((!isPaused && Time.timeScale == 0) ||
                (isPaused && Time.timeScale != 0))
            {
                instance.OnApplicationPause(Time.timeScale == 0);
            }

#if !PUMP_EVERY_FRAME
            yield return(new WaitForSeconds(animationPumpInterval));
#else
            yield return(null);
#endif


#if USE_DELTA_TIME
            time      = Time.time;
            elapsed   = time - startTime;
            startTime = time;
#else
            time      = Time.realtimeSinceStartup;
            elapsed   = time - startTime;
            startTime = time;
#endif

            // Start at the beginning:
            cur = head;

            while (cur != null)
            {
                next = (ISpriteAnimatable)cur.next;
                cur.StepAnim(elapsed);
                cur = next;
            }
        }

        pumpIsDone = true;
    }
Example #5
0
    // Adds the specified sprite to the animation list.
    // s: A reference to the sprite to be animated.
    public static void Add(ISpriteAnimatable s)
    {
        if (head != null)
        {
            s.next    = head;
            head.prev = s;
            head      = s;
        }
        else
        {
            head = s;

            // We've got our first item, so
            // we need to start the pump:
            Instance.StartAnimationPump();
        }
    }
	public void SetupSelection()
	{
		bool somethingChanged = false;

		// See if something changed:
		if (sprite != null)
		{
			if (sprite.gameObject != Selection.activeGameObject)
				somethingChanged = true;
			else if (sprite.States.Length != animList.Length)
				somethingChanged = true;
			else if (sprite.States.Length < 1)
				somethingChanged = true;
			else if (selectedAnim >= sprite.States.Length || selectedAnim < 0)
				somethingChanged = true;
			else if (sprite.States[selectedAnim].frameGUIDs.Length != frames.Count)
				somethingChanged = true;
		}
		else
			somethingChanged = true;

		if (somethingChanged)
		{
			if (Selection.activeGameObject != null)
			{
				sprite = (ISpriteAnimatable)Selection.activeGameObject.GetComponent(typeof(ISpriteAnimatable));
				selGO = Selection.activeGameObject;
				zoomCoef = 1f;
			}
			else
			{
				// If another GameObject wasn't selected,
				// don't change anything so we can drag
				// textures in, etc.
				// So only change if there is no activeObject
				// (as opposed to activeGameObject):
				if(Selection.activeObject == null)
				{
					selGO = null;
					sprite = null;
				}
			}

			// Select a safe value for our selected frame:
			if (sprite != null)
			{
				if (sprite.States.Length > 0)
				{
					selectedAnim = Mathf.Clamp(selectedAnim, 0, sprite.States.Length - 1);
					animSettingsTracker.Synch(sprite.States[selectedAnim]);
				}

				// Commented out because two different sprites with
				// the same number of frames in their selected anim
				// would cause the list not to be updated:
				//if (sprite.States.Length != animList.Length)
				BuildAnimList();

				if (sprite.States.Length > 0)
				{
					selectedAnim = Mathf.Clamp(selectedAnim, 0, sprite.States.Length - 1);
					if (sprite.States[selectedAnim].frameGUIDs.Length != frames.Count)
						RebuildFrameList();

					// Only change the selected frame if it is not valid:
					if (selectedFrame != null)
						if (selectedFrame.index >= sprite.States[selectedAnim].frameGUIDs.Length)
						{
							selectedFrame = null;
						}
				}
				else
					selectedFrame = null;
			}
			else
			{
				selectedFrame = null;
			}

			if (m_editor != null)
				m_editor.Repaint();
		}
	}
	// Removes the specified sprite from the animation list,
	// thereby not receiving animation updates.
	// s: A reference to the sprite to be removed.
	public static void Remove(ISpriteAnimatable s)
	{
		if(head == s)
		{
			head = (ISpriteAnimatable)s.next;
			
			// See if we need to stop the pump:
			if(head == null)
			{
				StopAnimationPump();
			}
		}
		else
		{
			if(s.next != null)
			{	// Connect either side:
				s.prev.next = s.next;
				s.next.prev = s.prev;
			}
			else if(s.prev != null)
			{
				// Removing the last item:
				s.prev.next = null;
			}
		}
		s.next = null;
		s.prev = null;
	}
	// Adds the specified sprite to the animation list.
	// s: A reference to the sprite to be animated.
	public static void Add(ISpriteAnimatable s)
	{
		if(head != null)
		{
			s.next = head;
			head.prev = s;
			head = s;
		}
		else
		{
			head = s;

			// We've got our first item, so
			// we need to start the pump:
			Instance.StartAnimationPump();
		}
	}
	// The coroutine that drives animation:
	protected static IEnumerator AnimationPump()
	{
#if !USE_DELTA_TIME
		startTime = Time.realtimeSinceStartup;
#else
		startTime = Time.time;
#endif

		pumpIsDone = false;

		while (pumpIsRunning)
		{
			// Check for pause:
			if ((!isPaused && Time.timeScale == 0) ||
				(isPaused && Time.timeScale != 0))
				instance.OnApplicationPause(Time.timeScale == 0);

#if !PUMP_EVERY_FRAME
			yield return new WaitForSeconds(animationPumpInterval);
#else
			yield return null;
#endif


#if USE_DELTA_TIME
			time = Time.time;
            elapsed = time - startTime;
            startTime = time;
#else
			time = Time.realtimeSinceStartup;
			elapsed = (time - startTime) * _timeScale;
			startTime = time;
#endif

			// Start at the beginning:
			cur = head;

			while( cur != null )
			{
				next = (ISpriteAnimatable)cur.next;
				cur.StepAnim(elapsed);
				cur = next;
			}
		}

		pumpIsDone = true;
	}
	void Update()
	{
		if(!pumpIsRunning)
			return;	// Abort

		// Check for pause:
		if ((!isPaused && Time.timeScale == 0) ||
			(isPaused && Time.timeScale != 0))
			instance.OnApplicationPause(Time.timeScale == 0);

#if !USE_DELTA_TIME
		time = Time.realtimeSinceStartup;
		elapsed = (time - startTime) * _timeScale;
		startTime = time;
#endif

		cur = head;

		while (cur != null)
		{
			next = (ISpriteAnimatable)cur.next;
#if !USE_DELTA_TIME
			cur.StepAnim(elapsed);
#else
			cur.StepAnim(Time.deltaTime);
#endif
			cur = next;
		}
	}
	public void OnDestroy()
	{
		head = null;
		cur = null;
		next = null;
		instance = null;
	}
/*
	void Update()
	{
		if(!pumpIsRunning)
			return;	// Abort

		cur = head;
		
		while(cur != null)
		{
			cur.StepAnim(Time.deltaTime);
			cur = cur.next;
		}
	}
*/

	// The coroutine that drives animation:
	protected static IEnumerator AnimationPump()
	{
		float elapsed;
		ISpriteAnimatable next;

		pumpIsDone = false;

		while (pumpIsRunning)
		{
#if !PUMP_EVERY_FRAME
			yield return new WaitForSeconds(animationPumpInterval);
#else
			yield return null;
#endif


#if USE_DELTA_TIME
			elapsed = Time.deltaTime;
#else
			time = Time.realtimeSinceStartup;
			elapsed = time - startTime;
			startTime = time;
#endif

			// Start at the beginning:
			cur = head;

			while( cur != null )
			{
				next = (ISpriteAnimatable)cur.next;
				cur.StepAnim(elapsed);
				cur = next;
			}
		}

		pumpIsDone = true;
	}