public Actor addDoor(int x, int y, bool open) { TCODRandom rng = TCODRandom.getInstance(); if (rng.getInt(0, 100) < 50) { Actor door = ActorLoader.getActor("Wooden Door"); if (door != null) { Components.Blocks.Door d = (Components.Blocks.Door)door.getComponent(typeof(Components.Blocks.Door)); if (d != null) { d.open = open; } if (door != null) { door.x = x; door.y = y; level.actorHandler.addActor(door); level.actorHandler.sendToBack(door); return(door); } } } return(null); }
public Actor addActor(int x, int y, string name) { Actor actor = ActorLoader.getActor(name); if (actor != null) { actor.x = x; actor.y = y; level.actorHandler.addActor(actor); level.actorHandler.sendToBack(actor); return(actor); } return(null); }
public Container(Actor owner, string[] s) : base(owner) { if (s.Length > 0) { this.size = int.Parse(s[0]); } if (s.Length > 1) { Actor a = ActorLoader.getActor(s[1]); if (a != null) { inventory.Add(a); } } }
public void addMonster(int x, int y) { TCODRandom rng = TCODRandom.getInstance(); if (rng.getInt(0, 100) < 70) { if (rng.getInt(0, 100) < 60) { Actor kobold = ActorLoader.getActor("kobold"); if (kobold != null) { kobold.x = x; kobold.y = y; level.actorHandler.addActor(kobold); } } else if (rng.getInt(0, 100) < 90) { Actor orc = ActorLoader.getActor("orc"); if (orc != null) { orc.x = x; orc.y = y; level.actorHandler.addActor(orc); } } else { Actor troll = ActorLoader.getActor("troll"); if (troll != null) { troll.x = x; troll.y = y; level.actorHandler.addActor(troll); } } } }
public static void getReferenceActors() { foreach (string s in ActorLoader.actorDirectoriesByType.Keys) { if (!referenceList.ContainsKey(s)) { List <string> actorNames = ActorLoader.actorDirectoriesByType[s].Keys.ToList(); SortedList <float, List <Actor> > references = new SortedList <float, List <Actor> >(); for (int i = 0; i < actorNames.Count; i++) { Actor a = ActorLoader.getActor(actorNames[i]); if (!references.ContainsKey(a.rarity)) { references.Add(a.rarity, new List <Actor>()); } references[a.rarity].Add(a); } referenceList.Add(s, references); } } }
public static Actor getRandomActorOfType(string type, float minRarity, float maxRarity) { SortedList <float, List <Actor> > actors = getActorsOfType(type); if (actors != null) { float randInt = getRandomRarity(minRarity > actors.Keys.Min() ? minRarity : actors.Keys.Min(), maxRarity > actors.Keys.Max() ? maxRarity : actors.Keys.Max()); float index = float.MaxValue; foreach (float k in actors.Keys) { if (Math.Abs(randInt - k) < Math.Abs(randInt - index)) { index = k; } } if (actors.ContainsKey(index)) { int randIndex = TCODRandom.getInstance().getInt(0, actors[index].Count - 1); return(ActorLoader.getActor(actors[index][randIndex].name)); } } return(null); }
private void spawn(string[] args) { string name = ""; int number = 1; if (args.Length == 0) { Message.WriteLine("What would you like to spawn?"); Message.WriteLineC(TCODColor.yellow, "(Syntax: \"Name;Number\")"); Message.Write(":"); name = getInput(); name = name.ToLower(); if (name.Contains(';')) { string[] s = name.Split(';'); name = s[0]; if (!int.TryParse(s[1], out number)) { Message.WriteLine("Incorrect number"); number = 1; } if (number == 0) { number = 1; } } } else { for (int i = 0; i < args.Length; i++) { if (!int.TryParse(args[i], out number)) { name += args[i].ToLower() + " "; } } if (name[name.Length - 1] == ' ') { name = name.Remove(name.Length - 1); } if (number == 0) { number = 1; } } if (ActorLoader.actorDirectories.ContainsKey(name)) { List <Actor> actors = new List <Actor>(); for (int i = 0; i < number; i++) { actors.Add(ActorLoader.getActor(ActorLoader.actorDirectories[name], engine.actorHandler.getUniqueId() + i)); } if (actors.Count > 0) { if (number < 2) { Message.WriteLine("Where would you like to spawn the " + actors[0].name + "?"); Message.WriteLine("Position: "); } else { Message.WriteLine("Where would you like to spawn the " + actors[0].pluralName + "?"); Message.WriteLine("Position: "); } Point p = new Point(); if (getInputPos(out p)) { foreach (Actor actor in actors) { actor.x = p.X; actor.y = p.Y; engine.actorHandler.addActor(actor); } Message.unwriteLastLine(); Message.WriteLine("Succeeded spawning"); } } } else { Message.WriteLine("Could not identify the \"" + name + "\""); } }
private void give(string[] args) { string name = ""; int number = 1; if (args.Length == 0) { Message.WriteLine("What would you like to have?"); Message.WriteLineC(TCODColor.yellow, "(Syntax: \"Name;Number\")"); Message.Write(":"); name = getInput(); if (name.Contains(';')) { string[] s = name.Split(';'); name = s[0]; if (!int.TryParse(s[1], out number)) { Message.WriteLine("Incorrect number"); number = 1; } if (number == 0) { number = 1; } } } else { for (int i = 0; i < args.Length; i++) { if (!int.TryParse(args[i], out number)) { name += args[i].ToLower() + " "; } } if (name[name.Length - 1] == ' ') { name = name.Remove(name.Length - 1); } if (number == 0) { number = 1; } } if (ActorLoader.actorDirectories.ContainsKey(name)) { List <Actor> actors = new List <Actor>(); for (int i = 0; i < number; i++) { actors.Add(ActorLoader.getActor(ActorLoader.actorDirectories[name], engine.actorHandler.getUniqueId() + i)); } if (actors.Count > 0) { if (actors[0].getComponent(typeof(Pickable)) != null) { for (int i = 0; i < number; i++) { engine.player.getContainer().add(actors[i]); engine.player.playerAi.tryWear(engine.player, actors[i]); } Message.WriteLine("*Gives you stuff*"); } else { Message.WriteLine("You can't carry that"); } } } else { Message.WriteLine("Could not find the \"" + name + "\""); } }