public NPC(int x, int y, Species species) { this.x = x; this.y = y; this.species = species; this.attack = species.attack; this.defense = species.defense; this.face = this.species.face; this.foregroundcolor = this.species.foregroundcolor; this.backgroundcolor = this.species.backgroundcolor; if (this.species.gendered) { if (Program.random.Next(0, 2) == 0) this.gender = genders.Female; else this.gender = genders.Male; } else this.gender = genders.None; this.ai = this.species.getAI(this); if (this.species.droprate != 0) { int rand = Program.random.Next(0, this.species.droplist.Count); if (this.species.droprate > Program.random.NextDouble()) this.dropitem = this.species.droplist[rand]; } }
public void setSpecies(string name) { foreach (Species u in Program.species) { if (u.name == name) { this.NewSpecies = u; break; } } }
public Entity(int x, int y, string face, Species species, ConsoleColor fgcolor, ConsoleColor bgcolor, genders gender = genders.Female) { this.x = x; this.y = y; this.face = face; this.species = species; this.attack = species.attack; this.defense = species.defense; this.foregroundcolor = fgcolor; this.backgroundcolor = bgcolor; if (this.species.gendered) this.gender = gender; else this.gender = genders.None; this.inventory = new List<InventoryItem>(); this.spells = new List<LearnedSpell>(); }
public static Species FromXmlElement(XmlElement element) { var species = new Species(); species.name = element.GetElementsByTagName("Name")[0].InnerText.Trim(); species.face = element.GetElementsByTagName("Face")[0].InnerText.Trim(); species.attack = int.Parse(element.GetElementsByTagName("Attack")[0].InnerText.Trim()); species.defense = int.Parse(element.GetElementsByTagName("Defense")[0].InnerText.Trim()); //species.foregroundcolor = (ConsoleColor)int.Parse(element.GetElementsByTagName("ForegroundColor")[0].InnerText.Trim()); //species.backgroundcolor = (ConsoleColor)int.Parse(element.GetElementsByTagName("BackgroundColor")[0].InnerText.Trim()); species.foregroundcolor = Colors.getColor(element.GetElementsByTagName("ForegroundColor")[0].InnerText.Trim()); species.backgroundcolor = Colors.getColor(element.GetElementsByTagName("BackgroundColor")[0].InnerText.Trim()); species.gendered = element.GetElementsByTagName("Gendered").Count == 1; species.eatingrate = int.Parse(element.GetElementsByTagName("EatingRate")[0].InnerText.Trim()); species.cantequip = element.GetElementsByTagName("CantEquip").Count == 1; species.throwingrange = double.Parse(element.GetElementsByTagName("ThrowingRange")[0].InnerText.Trim()); species.charmer = element.GetElementsByTagName("Charmer").Count == 1; species.easilycharmed = element.GetElementsByTagName("EasilyCharmed").Count == 1; species.ghost = element.GetElementsByTagName("Ghost").Count == 1; species.undead = element.GetElementsByTagName("Undead").Count == 1; if (element.GetElementsByTagName("Resist").Count == 1) { string resist = element.GetElementsByTagName("Resist")[0].InnerText.Trim(); switch (resist) { case "Paralyze": { species.resistance = Entity.statuses.Paralyzed; break; } case "Poison": { species.resistance = Entity.statuses.Poison; break; } case "Charm": { species.resistance = Entity.statuses.Charmed; break; } default: { species.resistance = Entity.statuses.Null; break; } } } else species.resistance = Entity.statuses.Null; if (element.GetElementsByTagName("Guarantee").Count == 1) { species.guarantee = true; species.unique = true; } else species.guarantee = false; if (element.GetElementsByTagName("CantSpawn").Count == 1) species.minlevel = 9999; else species.minlevel = int.Parse(element.GetElementsByTagName("MinLevel")[0].InnerText.Trim()); if (element.GetElementsByTagName("MaxLevel").Count == 1) species.maxlevel = int.Parse(element.GetElementsByTagName("MaxLevel")[0].InnerText.Trim()); else species.maxlevel = 9999; if (element.GetElementsByTagName("Rarity").Count == 1) species.rarity = double.Parse(element.GetElementsByTagName("Rarity")[0].InnerText.Trim()); else species.rarity = 1; species.unique = element.GetElementsByTagName("Unique").Count == 1; if (element.GetElementsByTagName("AI").Count == 1) species.ai = element.GetElementsByTagName("AI")[0].InnerText.Trim(); else species.ai = "Still"; if (element.GetElementsByTagName("Drops").Count == 1) { species._droplist = element.GetElementsByTagName("Drops")[0].InnerText.Trim(); if (element.GetElementsByTagName("DropRate").Count == 1) species.droprate = double.Parse(element.GetElementsByTagName("DropRate")[0].InnerText.Trim()); else species.droprate = 1; } else species.droprate = 0; return species; }
public void ChangeSpecies(Species NewSpecies) { Species oldSpecies = this.species; this.species = NewSpecies; this.foregroundcolor = this.species.foregroundcolor; this.backgroundcolor = this.species.backgroundcolor; this.attack = species.attack; this.defense = species.defense; if (this != Program.entities[0]) this.face = this.species.face; if (this.species.cantequip) { foreach (InventoryItem u in this.inventory) u.equipped = false; } if (!(oldSpecies.gendered) && NewSpecies.gendered && (this.gender == genders.None)) if (Program.random.Next(0, 2) > 0) this.gender = genders.Female; else this.gender = genders.Male; }