private void InitScript() { SetAnim("init"); if (AnimName == "init") { for (int i = 0; i < charDef.GetAnimation(Anim).getKeyFrameArray().Length; i++) { if (charDef.GetAnimation(Anim).GetKeyFrame(i).Frame > -1) { script.DoScript(Anim, i); } } } }
public void DoScript(int animIdx, int keyFrameIdx) { CharacterDefinition charDef = character.GetCharDef(); Animation animation = charDef.GetAnimation(animIdx); KeyFrame keyFrame = animation.GetKeyFrame(keyFrameIdx); bool done = false; for (int i = 0; i < keyFrame.GetScriptArray().Length; i++) { if (done) { break; } else { ScriptLine line = keyFrame.GetScript(i); if (line != null) { switch (line.GetCommand()) { case Commands.SetAnim: character.SetAnim(line.GetSParam()); break; case Commands.Goto: character.SetFrame(line.GetIParam()); done = true; break; case Commands.PlaySound: SoundManager.PlaySound(line.GetSParam(), false); break; case Commands.IfDyingGoto: break; case Commands.KillMe: break; } } } } }