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(); }
public bool Move(Scene s, NPC n, int stepPixel) { if (CanMove == false) { return false; } if (s.IsInScene(FrontLocation) == false) { return false; } if (n != null) { if (n.IsDoor == false) { return false; } } try { if (s[FrontLocation].CHRCanRch == false) { return false; } } catch { //return false; } LastLocation = RealLocation; RealLocation = NextLocation = FrontLocation; NeedMoveStep = 1; NeedMovePixel += 1 * stepPixel; return true; }
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(); }
void draw_npc(NPC npc) { if (npc == null) { return; } if (npc.TextureName == null) { return; } if (npc.Invisible) { return; } //if (npc.TextureIndex < 0) { npc.TextureIndex = game.Textures.GetIndex(npc.TextureName); } if (npc.TextureIndex < 0) { return; } Rectangle dz = new Rectangle(); dz.Y = (int)npc.RealDirection * game.Textures[npc.TextureIndex].TileSize.Height; if (npc.NeedMovePixel > 0) { dz.X = (((int)((float)game.Options.TilePixelX - npc.NeedMovePixel)) / (game.Options.TileSizePixelX.Width / 4) + 1) * game.Textures[npc.TextureIndex].TileSize.Width; } else { dz.X = 0; } dz.Size = game.Textures[npc.TextureIndex].TileSize; Vector3 v31 = npc.RealLocationPixel; v31.Y += game.Options.SpriteOffsetPixel; v31.X += game.SCN.RealLocationPixel.X; v31.Y += game.SCN.RealLocationPixel.Y; v31.Z += game.SCN.RealLocationPixel.Z; v31 = Util.Vector3AddVector3(v31, ScreenOffsetPixel); game.DrawMetalXTexture( game.Textures[npc.TextureIndex], dz, v31, game.Options.TileSizePixelX, 0, Color.White); }