public virtual bool AddNPC(bool isNpcCodeLine, CString lvlDat, CStringList words, string type) { if (isNpcCodeLine) { if (type == "NPCEND") { isNpcCodeLine = false; } else { GraalLevelNPC npc = this.NpcList[this.NpcList.Count]; npc.Script += lvlDat.Text; npc.Script += "\n"; this.NpcList[this.NpcList.Count] = npc; } } else { GraalLevelNPC npc = new GraalLevelNPC(this, this.NpcList.Count + 1); npc.Image = words.Get(1).Text; if (npc.Image == "-") npc.Image = ""; float rx, ry; float.TryParse(words.Get(2).Text, out rx); float.TryParse(words.Get(3).Text, out ry); npc.GMapX = (byte)rx; npc.GMapY = (byte)ry; npc.PixelX = Convert.ToInt32(npc.GMapX * 16.0); npc.PixelY = Convert.ToInt32(npc.GMapY * 16.0); isNpcCodeLine = true; this.NpcList.Add(this.NpcList.Count + 1, npc); } return isNpcCodeLine; }
/// <summary> /// Gets a npc from the level with the specified level id. /// </summary> public GraalLevelNPC GetNPC(CSocket socket, int Id) { GraalLevelNPC npc = null; if (!NpcList.TryGetValue(Id, out npc)) { npc = new GraalLevelNPC(socket, this, Id); lock (this.TimerLock) { NpcList[Id] = npc; } } return npc; }
public int Generate(string TemplateFileName = "") { int GmapLevelArea = ((this.MapWidth) * (this.MapHeight)); // Create MapLevels Array this.MapLevels = new GraalLevel[GmapLevelArea]; int gx = 1, gy = 1; String GeneratedLevelName; for (int i = 0; i < (GmapLevelArea - 1); i++) { for (gx = 1; gx <= this.MapWidth; gx++) { int pos = (gx - 1) + (gy - 1) * this.MapWidth; if (pos < this.MapLevels.Length) { GeneratedLevelName = (this.MapName + "_" + gx + "_" + gy + ".nw"); this.MapLevels[pos] = new GraalLevel(GeneratedLevelName, new object()); #region Adding links for old formats sake if (gx > 1) this.MapLevels[pos].LinkList.Add(this.MapLevels[pos].LinkList.Count + 1, new GraalLevelLink(this.MapName + "_" + (gx - 1) + "_" + gy + ".nw", 0, 0, 1, 64, "64", "playery")); if (gx < this.MapWidth) this.MapLevels[pos].LinkList.Add(this.MapLevels[pos].LinkList.Count + 1, new GraalLevelLink(this.MapName + "_" + (gx + 1) + "_" + gy + ".nw", 63, 0, 1, 64, "0", "playery")); if (gy > 1) this.MapLevels[pos].LinkList.Add(this.MapLevels[pos].LinkList.Count + 1, new GraalLevelLink(this.MapName + "_" + (gx) + "_" + (gy - 1) + ".nw", 0, 0, 64, 1, "playerx", "63")); if (gy < this.MapHeight) this.MapLevels[pos].LinkList.Add(this.MapLevels[pos].LinkList.Count + 1, new GraalLevelLink(this.MapName + "_" + (gx) + "_" + (gy + 1) + ".nw", 0, 63, 64, 1, "playerx", "0")); #endregion #region Add a loadmap npc to the level GraalLevelNPC loadMapNpc = new GraalLevelNPC(this.MapLevels[pos], this.MapLevels[pos].NpcList.Count + 1); loadMapNpc.GMapX = 0; loadMapNpc.GMapY = 0; loadMapNpc.Script = "// NPC generated by OpenGraal software\n" + "if (created)\n{\n" + "\tloadmap " + this.MapName + ";\n" + "}\n"; this.MapLevels[pos].NpcList.Add(this.MapLevels[pos].NpcList.Count + 1, loadMapNpc); #endregion if (TemplateFileName.Length != 0) if (!this.MapLevels[pos].Load(new CString() + TemplateFileName)) return 2; } } gy++; } return 1; }
public ScriptLevelNpc(CSocket socket, IRefObject Ref) : base(socket) { this.Ref = (GraalLevelNPC)Ref; this.Server = this.Ref.Server; }
public ScriptLevelNpc(IRefObject Ref) { this.Ref = (GraalLevelNPC)Ref; this.Server = this.Ref.Server; }
public SaveIndex(GraalLevelNPC LevelNpc, int size) { this.LevelNpc = LevelNpc; SaveData = new byte[size]; for (int i = 0; i < size; i++) SaveData[i] = 0; }