(C#)2d game - Image sequence moving forward and backwards

(This is my original question, read update below to understand what i need)
So I’ve found different solutions for this, but none specifically for what I’m doing.

Here is the scenario: There is a “Jump” bar similar to a health bar, i have an animated sequence that I want to use as the “jump bar” if you collect an item it increases and if you jump it decreases.

What my question is, what is the code to increasing and decreasing an image sequence or animation by frame? I want to say if collect item move +10 frames, if jump -2 frames in the animation.

Make since? Ive been looking everywhere for what the code would be, but my lingo with C# is limited.

Thanks for your help

======== UPDATE =========

[32600-screen+shot+2014-09-18+at+10.28.04+pm.png|32600]

Ok So sorry for not adding this earlier. Im using a SPRITE sheet, above is the basic image i want the Animator to start on (image 0 in the Animator) and the basic Animator preview. At the end of the Animator Im adding an event that just translates to Death to the player.

I want to figure out specifically how to get ‘batteryLife’ Animation to freeze on a specific frame. I was looking at AnimationState to achieve this, but its not working correctly.

so basically I want to see something that I found in the Scripting API like

public class ExampleClass : MonoBehaviour {
    void Example() {
        animation["Walk"].time = 0.0F;
    }
}

To then say if Jump, move animation 1 frame and stop.

How I can do this with the IEnumerator? or is there something easier?

Read the comment ^^^

Ok, I got this working… If you dont understand anything, just look up a few tutorials about it or look through the answers! :smiley:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

//This bit makes sure you can change the List variable in the Unity Editor...
[System.Serializable]

public class Example : MonoBehaviour {

	//This is a list of 2D images... You could also use materials if you want, but I made this script for images...
	public List<Texture2D> theList = new List<Texture2D>();

	//This is the amount of time you have to wait between each "slide"...
	public float amountOfTime = 1f;

	//This counts what image you are on. (This must between 0 and the amount of images you have in the list minus 1)
	int imageNumber = 0;

	void Start()
	{
		StartCoroutine("ImageSequence");
	}

	//This is the workings behind my idea. If you dont understand what it is... Google it.
	IEnumerator ImageSequence ()
	{
		//                                                                         \/ THIS IS IMPORTANT \/
		/*This is the output ->*/ renderer.material.mainTexture = theList[imageNumber];

		yield return new WaitForSeconds(amountOfTime);


		if(imageNumber == theList.Count - 1)
		{
			imageNumber = 0;
		}
		else
		{
			imageNumber++;
		}

//If you want to reverse the sequence
//if(imageNumber == 0)
//{
//	imageNumber = theList.Count - 1;
//}
//else
//{
//	imageNumber--;
//}


		StartCoroutine("ImageSequence");
		yield return null;

	}
}

ok, so I used a version of this but for Sprites. it looks like this.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

//This bit makes sure you can change the List variable in the Unity Editor...
[System.Serializable]

public class batteryGUI : MonoBehaviour {

	public Sprite[] array;
	
	int imageNumber = 0;

	public int batteryAmount;

//	public int imageNumber;

	void Start()
	{
		batteryAmount = array.Length;

		GetComponent<SpriteRenderer> ().sprite = array[imageNumber];

	}
	

	public void BatteryPlus()
	{
		if(imageNumber == 0)
		{
			imageNumber = array.Length - 1;
		}
		else
		{    
			imageNumber--;
		}
		
		GetComponent<SpriteRenderer> ().sprite = array[imageNumber];


	}

	public void BatteryMinus()
	{		
			
		if(imageNumber == array.Length - 1)
		{
			imageNumber -= 0;
			PlayerManager.Instance.Death();
			Debug.Log("Death");
		}
		else
		{
			imageNumber ++;
		}
		
		GetComponent<SpriteRenderer> ().sprite = array[imageNumber];

	}

	public void RestartBattery()
	{
		imageNumber = 0;
	}

}