void Update() { if (animState == MAIckyAnimationState.unknown) { animState = MAIckyAnimationState.idle; } int index = (int)(Time.time * fps); if (index > currentFrame) { currentFrame = index; playAnimations(); } }
public void playAnimations() { if (animState == MAIckyAnimationState.unknown) { renderer.material.mainTexture = ickyImage; transform.localScale = new Vector3(140, 165, 1); colCount = 1; rowCount = 1; colNumber = 0; rowNumber = 0; totalCells = 1; fps = 30; setCurrentFrame(0); } else if (animState == MAIckyAnimationState.giggle) { renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_Giggle"); transform.localScale = new Vector3(135, 148, 1); colCount = 8; rowCount = 3; colNumber = 0; rowNumber = 0; totalCells = 23; fps = 30; if (giggleFrames == null || giggleFrames.Count == 0) { createAnimations(); } setCurrentFrame((int)giggleFrames[0]); giggleFrames.RemoveAt(0); if (giggleFrames.Count == 0) { currentFrame = 0; fps = 30; animState = MAIckyAnimationState.unknown; createAnimations(); } } else if (animState == MAIckyAnimationState.celebration) { renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_Celebration"); transform.localScale = new Vector3(200, 175, 1); colCount = 8; rowCount = 7; colNumber = 0; rowNumber = 0; totalCells = 53; fps = 30; if (celebrationFrames == null || celebrationFrames.Count == 0) { createAnimations(); } setCurrentFrame((int)celebrationFrames[0]); celebrationFrames.RemoveAt(0); if (celebrationFrames.Count == 0) { fps = 30; currentFrame = 0; animState = MAIckyAnimationState.unknown; createAnimations(); } } else if (animState == MAIckyAnimationState.want) { renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_Wants"); transform.localScale = new Vector3(-145, 160, 1); colCount = 5; rowCount = 5; colNumber = 0; rowNumber = 0; totalCells = 25; fps = 30; if (wantFrames == null || wantFrames.Count == 0) { createAnimations(); } setCurrentFrame((int)wantFrames[0]); wantFrames.RemoveAt(0); if (wantFrames.Count == 0) { currentFrame = 0; fps = 30; animState = MAIckyAnimationState.idle; createAnimations(); } } else if (animState == MAIckyAnimationState.idle) { renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_Idle_1"); transform.localScale = new Vector3(140, 165, 1); colCount = 10; rowCount = 6; colNumber = 0; rowNumber = 0; totalCells = 59; fps = 30; if (idleFrames == null || idleFrames.Count == 0) { createAnimations(); } setCurrentFrame((int)idleFrames[0]); idleFrames.RemoveAt(0); if (idleFrames.Count == 0) { currentFrame = 0; fps = 30; animState = MAIckyAnimationState.want; createAnimations(); } } else if (animState == MAIckyAnimationState.wrong) { renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_NoNo"); transform.localScale = new Vector3(115, 145, 1); colCount = 8; rowCount = 2; colNumber = 0; rowNumber = 0; totalCells = 24; fps = 30; if (wrongFrames == null || wrongFrames.Count == 0) { createAnimations(); } setCurrentFrame((int)wrongFrames[0]); wrongFrames.RemoveAt(0); if (wrongFrames.Count == 0) { fps = 30; currentFrame = 0; animState = MAIckyAnimationState.unknown; createAnimations(); } } }
public void playAnimations() { if(animState == MAIckyAnimationState.unknown) { renderer.material.mainTexture = ickyImage; transform.localScale = new Vector3 (140, 165, 1); colCount = 1; rowCount = 1; colNumber = 0; rowNumber = 0; totalCells = 1; fps = 30; setCurrentFrame(0); } else if (animState == MAIckyAnimationState.giggle) { renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_Giggle"); transform.localScale = new Vector3(135,148,1); colCount = 8; rowCount = 3; colNumber = 0; rowNumber = 0; totalCells = 23; fps = 30; if(giggleFrames == null || giggleFrames.Count == 0) createAnimations(); setCurrentFrame((int)giggleFrames[0]); giggleFrames.RemoveAt(0); if(giggleFrames.Count == 0) { currentFrame=0; fps = 30; animState = MAIckyAnimationState.unknown; createAnimations(); } }else if (animState == MAIckyAnimationState.celebration) { renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_Celebration"); transform.localScale = new Vector3(200,175,1); colCount = 8; rowCount = 7; colNumber = 0; rowNumber = 0; totalCells = 53; fps = 30; if(celebrationFrames == null || celebrationFrames.Count == 0) createAnimations(); setCurrentFrame((int)celebrationFrames[0]); celebrationFrames.RemoveAt(0); if(celebrationFrames.Count == 0) { fps = 30; currentFrame = 0; animState = MAIckyAnimationState.unknown; createAnimations(); } } else if (animState == MAIckyAnimationState.want){ renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_Wants"); transform.localScale = new Vector3(-145,160,1); colCount = 5; rowCount = 5; colNumber = 0; rowNumber = 0; totalCells = 25; fps = 30; if(wantFrames == null || wantFrames.Count == 0) createAnimations(); setCurrentFrame((int)wantFrames[0]); wantFrames.RemoveAt(0); if(wantFrames.Count == 0) { currentFrame=0; fps = 30; animState = MAIckyAnimationState.idle; createAnimations(); } } else if (animState == MAIckyAnimationState.idle){ renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_Idle_1"); transform.localScale = new Vector3(140,165,1); colCount = 10; rowCount = 6; colNumber = 0; rowNumber = 0; totalCells = 59; fps = 30; if(idleFrames == null || idleFrames.Count == 0) createAnimations(); setCurrentFrame((int)idleFrames[0]); idleFrames.RemoveAt(0); if(idleFrames.Count == 0) { currentFrame=0; fps = 30; animState = MAIckyAnimationState.want; createAnimations(); } } else if (animState == MAIckyAnimationState.wrong) { renderer.material.mainTexture = (Texture2D)Resources.Load("JWMemoryAnimals/Sprites/Icky/MA_Icky_NoNo"); transform.localScale = new Vector3(115, 145,1); colCount = 8; rowCount = 2; colNumber = 0; rowNumber = 0; totalCells = 24; fps = 30; if(wrongFrames == null || wrongFrames.Count == 0) createAnimations(); setCurrentFrame((int)wrongFrames[0]); wrongFrames.RemoveAt(0); if(wrongFrames.Count == 0) { fps = 30; currentFrame = 0; animState = MAIckyAnimationState.unknown; createAnimations(); } } }
void Update() { if(animState == MAIckyAnimationState.unknown) { animState = MAIckyAnimationState.idle; } int index = (int)(Time.time * fps); if(index > currentFrame) { currentFrame = index; playAnimations(); } }