private void ui_npcmodify_Click(object sender, EventArgs e) { int i = ui_npclist.SelectedIndex; if (i < 0) { return; } NPC npc = new NPC(); npc.CanMove = ui_canmove.Checked; npc.CanTurn = ui_canturn.Checked; npc.IsBox = ui_npcisbox.Checked; npc.Script = ui_npccode.Text; npc.TextureName = ui_npctexturename.Text; npc.Name = ui_npcname.Text; npc.IsBox = ui_npcisbox.Checked; npc.IsDoor = ui_npcisdoor.Checked; npc.SetRealLocation(int.Parse(ui_npcx.Text), int.Parse(ui_npcy.Text), 0, game.Options.TilePixelX); npc.Size = new Size(int.Parse(ui_npcw.Text), int.Parse(ui_npch.Text)); Direction dir = Direction.U; if (ui_npcdir.Text == "U") { dir = Direction.U; } else if (ui_npcdir.Text == "L") { dir = Direction.L; } else if (ui_npcdir.Text == "D") { dir = Direction.D; } else if (ui_npcdir.Text == "R") { dir = Direction.R; } npc.DefaultDirection = npc.RealDirection = dir; //npc.DialogText = ui_npctxt.Text; if (game.NPCs == null) { game.NPCs = new List<NPC>(); } game.NPCs[i] = npc; System.IO.File.Delete(game.Options.RootPath + "npcs\\" + game.SCN.NPCNames[i] + ".MXNPC"); game.SCN.NPCNames[i] = npc.Name; System.IO.File.WriteAllText(game.Options.RootPath + "npcs\\" + npc.Name + ".MXScript", npc.Script); Util.SaveObject(game.Options.RootPath + "npcs\\" + npc.Name + ".MXNPC", npc); update_npc_list(); }
private void ui_npcadd_Click(object sender, EventArgs e) { string fn = System.IO.Path.GetFileNameWithoutExtension(openFileName); NPC npc = new NPC(); npc.CanMove = ui_canmove.Checked; npc.CanTurn = ui_canturn.Checked; npc.TextureName = ui_npctexturename.Text; string npcname = ui_npcname.Text; try { if (ui_npcname.Text.Substring(0, fn.Length) != fn) { npcname = fn + "_" + ui_npcname.Text; } } catch { npcname = fn + "_" + ui_npcname.Text; } npc.Name = npcname; npc.Script = ui_npccode.Text; npc.IsBox = ui_npcisbox.Checked; npc.IsDoor = ui_npcisdoor.Checked; npc.Size = new Size(int.Parse(ui_npcw.Text), int.Parse(ui_npch.Text)); npc.SetRealLocation(int.Parse(ui_npcx.Text), int.Parse(ui_npcy.Text), 0, game.Options.TilePixelX); Direction dir = Direction.U; if (ui_npcdir.Text == "U") { dir = Direction.U; } else if (ui_npcdir.Text == "L") { dir = Direction.L; } else if (ui_npcdir.Text == "D") { dir = Direction.D; } else if (ui_npcdir.Text == "R") { dir = Direction.R; } npc.DefaultDirection = npc.RealDirection = dir; //npc.Dialog = ui_npctxt.Text; if (game.NPCs == null) { game.NPCs = new List<NPC>(); } game.NPCs.Add(npc); if (game.SCN.NPCNames == null) { game.SCN.NPCNames = new List<string>(); } game.SCN.NPCNames.Add(npc.Name); //game.LoadAllDotMXNPC(); //string fn = Guid.NewGuid().ToString(); System.IO.File.WriteAllText(game.Options.RootPath + "npcs\\" + npc.Name + ".MXScript", npc.Script); Util.SaveObject(game.Options.RootPath + "npcs\\" + npc.Name + ".MXNPC", npc); update_npc_list(); }