//播放动画序列 void PlayOrder() { //if (animationHolder == null) animationHolder = Selection.activeGameObject; ani = animationHolder.GetComponent <Animation>(); string[] names = animationName.Trim().Split(new char[] { '\n', '\r' }, System.StringSplitOptions.RemoveEmptyEntries); if (names.Length == 0) { return; } animationList = new AnimationClip[names.Length]; int i = 0; foreach (string name in names) { animationList[i] = ani.GetClip(name); i++; } clip = animationList[0]; previewStartTime = EditorApplication.timeSinceStartup; EditorApplication.update = null; EditorApplication.update += DoPlayOrder; animationIndex = AnimationIndex.One; }
public override void Update(GameObject gameObject, GameTime gameTime) { _physics = gameObject.GetComponent <APhysics>(); if (_physics == null) { return; } AnimationIndex nextIndex = currentlyPlaying; var physics = gameObject.GetComponent <TopDownPhysics>(); Vector2 facingDir = new Vector2(physics.facingDirection.X, physics.facingDirection.Y); // Only update the variable if the X facing side changes. _previousSide = facingDir.X != 0 ? facingDir.X : _previousSide; // Running animation. if (_physics.movingDirection.X < 0) { nextIndex = AnimationIndex.RUN_LEFT; } else if (_physics.movingDirection.X > 0) { nextIndex = AnimationIndex.RUN_RIGHT; } else if (_physics.movingDirection.Y < 0) { nextIndex = AnimationIndex.RUN_UP; } else if (_physics.movingDirection.Y > 0) { nextIndex = AnimationIndex.RUN_DOWN; } // Idle animation. else if (_physics.facingDirection.X < 0 && _physics.movingDirection.X == 0) { nextIndex = AnimationIndex.IDLE_LEFT; } else if (_physics.facingDirection.X > 0 && _physics.movingDirection.X == 0) { nextIndex = AnimationIndex.IDLE_RIGHT; } else if (_physics.facingDirection.Y < 0 && _physics.movingDirection.Y == 0) { nextIndex = AnimationIndex.IDLE_UP; } else if (_physics.facingDirection.Y > 0 && _physics.movingDirection.Y == 0) { nextIndex = AnimationIndex.IDLE_DOWN; } if (GetRealValue(nextIndex) != currentlyPlaying) { currentlyPlaying = GetRealValue(nextIndex); _animations[(int)GetRealValue(currentlyPlaying)]?.Reset(); } _animations[(int)GetRealValue(currentlyPlaying)]?.Update(gameObject, gameTime); }
private void comboSubanim_SelectedIndexChanged(object sender, EventArgs e) { curSub = comboSubanim.SelectedIndex; textAnimID.Text = AnimationIndex.ToString("X04"); if (OnSelectedAnimation != null) { OnSelectedAnimation(AnimationIndex); } }
private void listAnimations_SelectedIndexChanged(object sender, EventArgs e) { SelectedAnimation = listAnimations.SelectedIndex; textAnimID.Text = AnimationIndex.ToString("X04"); if (OnSelectedAnimation != null) { OnSelectedAnimation(AnimationIndex); } }
public P8TopDownAnimator(AnimationMode mode) { // Create animations for side, up and down directions. _animations = new SpriteAnimation[(int)AnimationIndex.MAX_VALUE]; currentlyPlaying = AnimationIndex.IDLE_LEFT; _mode = mode; // Always start facing left _previousSide = -1; }
public AnimationIndex GetRealValue(AnimationIndex index) { if (_mode == AnimationMode.FOUR_SIDES) { return(index); } if (IsRunning(index)) { return(_previousSide < 0 ? AnimationIndex.RUN_LEFT : AnimationIndex.RUN_RIGHT); } else { return(_previousSide < 0 ? AnimationIndex.IDLE_LEFT : AnimationIndex.IDLE_RIGHT); } }
public bool PlayAnimationSequence(AnimationIndex index, DialogueWindow.CharacterTexture characterTexture) { NPCAnimations.AnimationSequence playerAnim = RetrieveAnimationSequence(index); List<Texture> playerTex = playerAnim.textures; if (playerTex.Count > 0) { characterTexture.animation.StopAnimation(); characterTexture.animation.SetAnimationList(playerTex); characterTexture.animation.PlayAnimation(); characterTexture.animation.SetSpeed(playerAnim.speed); characterTexture.stretch.initialSize = new Vector2 (playerTex[0].width, playerTex[0].height); return true; } else { Debug.LogError("No texures were found for index " + index.ToString()); return false; } }
public AnimationSequence RetrieveAnimationSequence(AnimationIndex index) { if (animations == null || animations.Count == 0) return null; AnimationSequence prevSequence = null; foreach (AnimationSequence sequence in animations) { if (sequence.animationIndex == index) return sequence; else if (prevSequence == null && (int)sequence.animationIndex > (int)index) prevSequence = sequence; } if (prevSequence == null) prevSequence = animations [0]; return prevSequence; }
public void AddAnimationIndex(AnimationIndex ai) { animationIndexes.Add(ai); }
public bool IsRunning(AnimationIndex index) { return((int)index < 4); }
void DoPlayOrder() { timeElapsed = EditorApplication.timeSinceStartup - previewStartTime; switch (animationList.Length) { case 2: if (timeElapsed < animationList[0].length) { animationIndex = AnimationIndex.One; } else if (timeElapsed < animationList[0].length + animationList[1].length) { animationIndex = AnimationIndex.Two; } break; case 3: if (timeElapsed < animationList[0].length) { animationIndex = AnimationIndex.One; } else if (timeElapsed < animationList[0].length + animationList[1].length) { animationIndex = AnimationIndex.Two; } else { animationIndex = AnimationIndex.Three; } break; case 4: if (timeElapsed < animationList[0].length) { animationIndex = AnimationIndex.One; } else if (timeElapsed < animationList[0].length + animationList[1].length) { animationIndex = AnimationIndex.Two; } else if (timeElapsed < animationList[0].length + animationList[1].length + animationList[2].length) { animationIndex = AnimationIndex.Three; } else { animationIndex = AnimationIndex.Four; } break; case 5: break; case 6: break; default: break; } switch (animationIndex) { case AnimationIndex.One: animationList[0].SampleAnimation(ani.gameObject, (float)timeElapsed); break; case AnimationIndex.Two: animationList[1].SampleAnimation(ani.gameObject, (float)timeElapsed - animationList[0].length); break; case AnimationIndex.Three: animationList[1].SampleAnimation(ani.gameObject, (float)timeElapsed - animationList[1].length - animationList[0].length); break; case AnimationIndex.Four: animationList[1].SampleAnimation(ani.gameObject, (float)timeElapsed - animationList[1].length - animationList[0].length - animationList[2].length); break; case AnimationIndex.Five: break; case AnimationIndex.Six: break; default: break; } }
private void listCategories_SelectedIndexChanged(object sender, EventArgs e) { SelectedCategory = listCategories.SelectedIndex; textAnimID.Text = AnimationIndex.ToString("X04"); }