public NPCWindow(GUI.WindowManager WM, GameObject.MapEntities.Actors.NPC NPC, GameObject.MapEntities.Actors.Player Player) { this.Player = Player; this.Width = 320; this.Height = 512; GUI.Controls.RichTextDisplay greeting = new GUI.Controls.RichTextDisplay(NPC.Greeting, 180, 200, WM); this.Controls.Add(greeting); this.Title = NPC.DisplayName; int yoffset = greeting.Height + 2; if (NPC.Commands != null && NPC.Commands.Count > 0) { for (int i = 0; i < NPC.Commands.Count; i++) { NPCMenuItem mi = new NPCMenuItem(Player, NPC.Commands[i]) { Y = yoffset }; yoffset += mi.Height; AddControl(mi); } } NPCMenuItem end = NPCMenuItem.Close(); end.Y = yoffset; AddControl(end); }
public NPCWindow(GUI.WindowManager WM, GameObject.MapEntities.Actors.NPC NPC) { this.Width = 320; this.Height = 512; GUI.Controls.RichTextDisplay greeting = new GUI.Controls.RichTextDisplay(NPC.Greeting, 180, 200, WM); this.Controls.Add(greeting); this.Title = NPC.DisplayName; }
/// <summary> /// Processes the block queue /// </summary> public void ProcessQueue() { //I am not sure why the function never exits, however, this is the intended behaviour. while (WorldRef.Terrain.Queue.Count > 0) { Vector2 b = WorldRef.Terrain.Queue.Dequeue(); int rd = WorldRef.Terrain.RenderDistance == 0 ? 8 : WorldRef.Terrain.RenderDistance; // Unit blk = WorldLoader.Load((int)b.X, (int)b.Y); // blk = WorldGenerator.GenerateBlock((int)b.X, (int)b.Y, 64); //Math.Abs(blk.Value.X - X) > rd || Math.Abs(blk.Value.Y - Y) > rd Unit blk = null; WinRNG rng = new WinRNG(this.Seed); NPCGenerator npcgen = new NPCGenerator(rng); if (Map == null) { continue; } Location l = Map.Locations[Map.LocationData[(int)b.X, (int)b.Y]]; if (blk == null) { if (Math.Abs(b.X - LastX) > rd || Math.Abs(b.Y - LastY) > rd) { continue; } if (b.X < 0 || b.Y < 0) { continue; } //create terrain block blk = GenerateBlock((int)b.X, (int)b.Y); Terrain.Console.Write("^00FF00 Generated " + ((int)b.X).ToString() + "." + ((int)b.Y).ToString()); //code to place NPCs and other crap goes here!! if (l.Type == Location.LocationType.Town) { int amount = rng.NextInt(5, 20); for (int i = 0; i < amount; i++) { GameObject.MapEntities.Actors.NPC npc = npcgen.GenerateOneNPC(); npc.Position.BX = (int)b.X; npc.Position.BY = (int)b.Y; npc.Position += new Vector3(rng.NextInt(1, BlockSize - 1), -1, rng.NextInt(1, BlockSize - 1)); npc.WorldSpawn = WorldRef; npc.Greeting = "Hello, I live in " + l.Name; WorldRef.Entities.Add(npc); } } } else { // Volatile.Console.Write("^00FF00 Loaded " + ((int)b.X).ToString() + "." + ((int)b.Y).ToString()); } lock (blk) { WorldRef.Terrain.Blocks.GetOrAdd(blk.X + blk.Y * BlockSize, blk); } } }
public GameObject.MapEntities.Actors.NPC GenerateOneNPC() { GameObject.MapEntities.Actors.NPC npc = new GameObject.MapEntities.Actors.NPC("Hello. I am an NPC."); npc.Commands = new List <GameObject.Interactions.NPCCommand>(); npc.Commands.Add(new GameObject.Interactions.NPCCommands.OpenShop() { Label = "Shop" }); Vector3 pos = new Vector3(RNG.NextInt(63), 0, RNG.NextInt(63)); npc.Position = pos; npc.Heading = RNG.NextInt(350); npc.DisplayName = "npc"; return(npc); }