public void Read() { BinaryReader b = new BinaryReader(File.Open(@"data/" + Path + ".zmx", FileMode.Open, FileAccess.Read)); Path = b.ReadString(); HeadIndex = b.ReadInt32(); TorsoIndex = b.ReadInt32(); LegsIndex = b.ReadInt32(); WeaponIndex = b.ReadInt32(); for (int i = 0; i < animation.Length; i++) { animation[i].name = b.ReadString(); for (int j = 0; j < animation[i].getKeyFrameArray().Length; j++) { KeyFrame keyframe = animation[i].GetKeyFrame(j); keyframe.FrameRef = b.ReadInt32(); keyframe.Duration = b.ReadInt32(); ScriptLine[] script = keyframe.GetScriptArray(); for (int s = 0; s < script.Length; s++) { script[s] = new ScriptLine(b.ReadString()); } } } for (int i = 0; i < frame.Length; i++) { frame[i].Name = b.ReadString(); for (int j = 0; j < frame[i].GetPartArray().Length; j++) { Part p = frame[i].GetPart(j); p.Index = b.ReadInt32(); p.Location.X = b.ReadSingle(); p.Location.Y = b.ReadSingle(); p.Rotation = b.ReadSingle(); p.Scaling.X = b.ReadSingle(); p.Scaling.Y = b.ReadSingle(); p.Flip = b.ReadInt32(); } } b.Close(); Console.WriteLine("Loaded."); }
public void Read() { BinaryReader b = new BinaryReader(File.Open(@"data/" + Path + ".zmx", FileMode.Open, FileAccess.Read)); Path = b.ReadString(); HeadIndex = b.ReadInt32(); TorsoIndex = b.ReadInt32(); LegsIndex = b.ReadInt32(); WeaponIndex = b.ReadInt32(); for (int i = 0; i < animation.Length; i++) { animation[i].name = b.ReadString(); for (int j = 0; j < animation[i].getKeyFrameArray().Length; j++) { KeyFrame keyframe = animation[i].GetKeyFrame(j); keyframe.FrameRef = b.ReadInt32(); keyframe.Duration = b.ReadInt32(); ScriptLine[] script = keyframe.GetScriptArray(); for (int s = 0; s < script.Length; s++) script[s] = new ScriptLine(b.ReadString()); } } for (int i = 0; i < frame.Length; i++) { frame[i].Name = b.ReadString(); for (int j = 0; j < frame[i].GetPartArray().Length; j++) { Part p = frame[i].GetPart(j); p.Index = b.ReadInt32(); p.Location.X = b.ReadSingle(); p.Location.Y = b.ReadSingle(); p.Rotation = b.ReadSingle(); p.Scaling.X = b.ReadSingle(); p.Scaling.Y = b.ReadSingle(); p.Flip = b.ReadInt32(); } } b.Close(); Console.WriteLine("Loaded."); }
public void DoScript(int animIdx, int keyFrameIdx) { CharDef 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.IfUpGoto: if (character.KeyUp) { character.SetFrame(line.GetIParam()); done = true; } break; case Commands.IfDownGoto: if (character.KeyDown) { character.SetFrame(line.GetIParam()); done = true; } break; case Commands.Float: character.Floating = true; break; case Commands.UnFloat: character.Floating = false; break; case Commands.Slide: character.Slide((float)line.GetIParam()); break; case Commands.Backup: character.Slide((float)-line.GetIParam()); break; case Commands.SetJump: character.SetJump((float)line.GetIParam()); break; case Commands.JoyMove: if (character.KeyLeft) { character.Trajectory.X = -character.Speed; } if (character.KeyRight) { character.Trajectory.X = character.Speed; } break; case Commands.ClearKeys: character.PressedKey = PressedKeys.None; break; case Commands.SetUpperGoto: character.GotoGoal[(int)PressedKeys.Upper] = line.GetIParam(); break; case Commands.SetLowerGoto: character.GotoGoal[(int)PressedKeys.Lower] = line.GetIParam(); break; case Commands.SetAtkGoto: character.GotoGoal[(int)PressedKeys.Attack] = line.GetIParam(); break; case Commands.SetAnyGoto: character.GotoGoal[(int)PressedKeys.Upper] = line.GetIParam(); character.GotoGoal[(int)PressedKeys.Lower] = line.GetIParam(); character.GotoGoal[(int)PressedKeys.Attack] = line.GetIParam(); break; case Commands.SetSecondaryGoto: character.GotoGoal[(int)PressedKeys.Secondary] = line.GetIParam(); character.GotoGoal[(int)PressedKeys.SecUp] = line.GetIParam(); character.GotoGoal[(int)PressedKeys.SecDown] = line.GetIParam(); break; case Commands.SetSecUpGoto: character.GotoGoal[(int)PressedKeys.SecUp] = line.GetIParam(); break; case Commands.SetSecDownGoto: character.GotoGoal[(int)PressedKeys.SecDown] = line.GetIParam(); break; case Commands.CanCancel: character.CanCancel = true; break; case Commands.PlaySound: Sound.PlayCue(line.GetSParam()); break; case Commands.Ethereal: character.ethereal = true; break; case Commands.Solid: character.ethereal = false; break; case Commands.Speed: character.Speed = (float)line.GetIParam(); break; case Commands.HP: character.HP = character.MHP = line.GetIParam(); break; case Commands.DeathCheck: if (character.HP < 0) { character.KillMe(); } break; case Commands.IfDyingGoto: if (character.HP < 0) { character.SetFrame(line.GetIParam()); done = true; } break; case Commands.KillMe: character.KillMe(); break; case Commands.AI: switch (line.GetSParam()) { case "zombie": character.Ai = new Zombie(); break; case "wraith": character.Ai = new Wraith(); break; case "carlos": character.Ai = new Carlos(); break; default: character.Ai = new Zombie(); break; } break; case Commands.Size: character.Scale = (float)(line.GetIParam()) / 200f; break; case Commands.NoLifty: character.NoLifty = true; break; } } } } }
public void SetScript(int idx, String val) { scripts[idx] = new ScriptLine(val); }