public bool EquipItem(Items.Iitem item, Inventory inventory) { bool result = false; Items.Iweapon weaponItem = item as Items.Iweapon; if (weaponItem != null && weaponItem.IsWieldable) { //can't equip a wieldable weapon } else { if (!equipped.ContainsKey(item.WornOn)) { equipped.Add(item.WornOn, item); if (inventory.inventory.Any(i => i.Id == item.Id)) {//in case we are adding it from a load and not moving it from the inventory inventory.inventory.RemoveWhere(i => i.Id == item.Id); //we moved the item over to equipped so we need it out of inventory } result = true; } else if (item.WornOn == Items.Wearable.WIELD_LEFT || item.WornOn == Items.Wearable.WIELD_RIGHT) { //this item can go in the free hand Items.Wearable freeHand = Items.Wearable.WIELD_LEFT; //we default to right hand for weapons if (equipped.ContainsKey(freeHand)) freeHand = Items.Wearable.WIELD_RIGHT; //maybe this perosn is left handed if (!equipped.ContainsKey(freeHand)) { //ok let's equip this item.WornOn = freeHand; item.Save(); equipped.Add(freeHand, item); if (inventory.inventory.Any(i => i.Id == item.Id)) {//in case we are adding it from a load and not moving it from the inventory inventory.inventory.RemoveWhere(i => i.Id == item.Id); //we moved the item over to equipped so we need it out of inventory } result = true; } } } return result; }
public Character(CharacterRace race, CharacterClass characterClass, Genders gender, Languages language, SkinColors skinColor, SkinType skinType, HairColors hairColor, EyeColors eyeColor, BodyBuild build) { Class = characterClass; Race = race; Gender = gender; SkinColor = skinColor; SkinType = skinType; HairColor = hairColor; EyeColor = eyeColor; Build = build; _koCount = new Tuple<int, DateTime>(0, DateTime.Now); _actionState = CharacterActionState.None; _stanceState = CharacterStanceState.Standing; _primaryLanguage = language; KnownLanguages = new HashSet<Languages>(); KnownLanguages.Add(_primaryLanguage); FirstName = ""; LastName = ""; Description = ""; Age = 17; //Do we want an age? And are we going to advance it every in game year? Weight = 180.0d; //pounds or kilos? Height = 70.0d; //inches or centimeters? Location = "A1000"; InCombat = false; LastCombatTime = DateTime.MinValue.ToUniversalTime(); IsNPC = false; Leveled = false; MainHand = "WIELD_RIGHT"; NextLevelExperience = 300; Level = 1; Experience = 0; PointsToSpend = 0; Inventory = new Inventory(); Equipment = new Equipment(); Bonuses = new Dictionary<BonusTypes, Bonus>(); StatBonus = new StatBonuses(); StatBonus.Bonuses = Bonuses; Inventory.playerID = Id; Equipment.playerID = Id; Attributes = new List<Attribute>(); Attributes.Add(new Attribute(150, "Hitpoints", 150, 0.1, 1)); Attributes.Add(new Attribute(10, "Dexterity", 5, 0, 1)); Attributes.Add(new Attribute(10, "Strength", 5, 0, 1)); Attributes.Add(new Attribute(10, "Intelligence", 5, 0, 1)); Attributes.Add( new Attribute(10, "Endurance", 5, 0, 1)); Attributes.Add(new Attribute(10, "Charisma", 5, 0, 1)); SubAttributes = new Dictionary<string, double>(); SubAttributes.Add("Agility", 1); SubAttributes.Add("Toughness", 1); SubAttributes.Add("Cunning", 1); SubAttributes.Add("Wisdom", 1); SubAttributes.Add("Leadership", 1); }
/// <summary> /// Deep copy constructor /// </summary> /// <param name="copy"></param> public Character(Character copy) { //copy constructor Class = copy.Class; Race = copy.Race; Gender = copy.Gender; SkinColor = copy.SkinColor; SkinType = copy.SkinType; HairColor = copy.HairColor; EyeColor = copy.EyeColor; Build = copy.Build; _koCount = new Tuple<int, DateTime>(0, DateTime.Now); _actionState = CharacterActionState.None; _stanceState = CharacterStanceState.Standing; _primaryLanguage = copy._primaryLanguage; KnownLanguages = new HashSet<Languages>(); foreach (Languages lang in copy.KnownLanguages) { KnownLanguages.Add(lang); } FirstName = copy.FirstName; LastName = copy.LastName; Description = copy.Description; Age = copy.Age; //Do we want an age? And are we going to advance it every in game year? Players could be 400+ years old rather quick. Weight = copy.Weight; //pounds or kilos? Height = copy.Height; //inches or centimeters? Location = "A1000"; InCombat = false; LastCombatTime = DateTime.MinValue.ToUniversalTime(); IsNPC = false; Leveled = false; NextLevelExperience = 300; Level = 1; Experience = 0; PointsToSpend = 0; MainHand = "WIELD_RIGHT"; Attributes = new List<Attribute>(); foreach (var attrib in copy.Attributes){ Attributes.Add(attrib); } SubAttributes = new Dictionary<string, double>(); foreach (KeyValuePair<string, double> subAttrib in copy.SubAttributes) { SubAttributes.Add(subAttrib.Key, subAttrib.Value); } Inventory = new Inventory(); this.Save(); }
public Character() { Class = CharacterClass.Explorer; Race = CharacterRace.Human; Gender = Genders.Female; SkinColor = SkinColors.Fair; SkinType = Interfaces.SkinType.Flesh; HairColor = HairColors.Black; EyeColor = EyeColors.Brown; Build = BodyBuild.Medium; _koCount = new Tuple<int, DateTime>(0, DateTime.Now); _actionState = CharacterActionState.None; _stanceState = CharacterStanceState.Standing; _primaryLanguage = Languages.Common; KnownLanguages = new HashSet<Languages>(); KnownLanguages.Add(_primaryLanguage); FirstName = ""; LastName = ""; Description = ""; Age = 17; //Do we want an age? And are we going to advance it every in game year? We'll need a birthdate for this. Weight = 180; //pounds or kilos? Height = 70; //inches or centimeters? Location = "A1000"; InCombat = false; LastCombatTime = DateTime.MinValue.ToUniversalTime(); IsNPC = false; Leveled = false; MainHand = "WIELD_RIGHT"; NextLevelExperience = 300; Level = 1; Experience = 0; PointsToSpend = 0; Inventory = new Inventory(); Equipment = new Equipment(); Bonuses = new Dictionary<BonusTypes, Bonus>(); StatBonus = new StatBonuses(); StatBonus.Bonuses = Bonuses; Attributes = new List<Attribute>(); Attributes.Add(new Attribute(150, "Hitpoints", 150, 0.1, 1)); Attributes.Add(new Attribute(10, "Dexterity", 5, 0, 1)); Attributes.Add(new Attribute(10, "Strength", 5, 0, 1)); Attributes.Add(new Attribute(10, "Intelligence", 5, 0, 1)); Attributes.Add(new Attribute(10, "Endurance", 5, 0, 1)); Attributes.Add(new Attribute(10, "Charisma", 5, 0, 1)); SubAttributes = new Dictionary<string, double>(); SubAttributes.Add("Agility", 1); SubAttributes.Add("Toughness", 1); SubAttributes.Add("Cunning", 1); SubAttributes.Add("Wisdom", 1); SubAttributes.Add("Leadership", 1); }
public bool WieldItem(Items.Iitem item, Inventory inventory) { bool wielded = false; if (!equipped.ContainsKey(Items.Wearable.WIELD_RIGHT)) { item.WornOn = Items.Wearable.WIELD_RIGHT; wielded = true; } else if (!equipped.ContainsKey(Items.Wearable.WIELD_LEFT)) { item.WornOn = Items.Wearable.WIELD_LEFT; wielded = true; } if (wielded) { equipped.Add(item.WornOn, item); inventory.inventory.RemoveWhere(i => i.Id == item.Id); return true; } return false; }
public void Wield(Items.Iitem item, Inventory inventory) { WieldItem(item, inventory); }
public NPC(CharacterRace race, CharacterClass characterClass, Genders gender, Languages language, SkinColors skinColor, SkinType skinType, HairColors hairColor, EyeColors eyeColor, BodyBuild build) { Messages = new Queue<string>(); Fsm = AI.FSM.GetInstance(); Fsm.state = Fsm.GetStateFromName("Wander"); _class = characterClass; _race = race; _gender = gender; _skinColor = skinColor; _skinType = skinType; _hairColor = hairColor; _eyeColor = eyeColor; _build = build; _koCount = new Tuple<int, DateTime>(0, DateTime.Now); _actionState = CharacterActionState.None; _stanceState = CharacterStanceState.Standing; _primaryLanguage = language; KnownLanguages = new HashSet<Languages>(); KnownLanguages.Add(_primaryLanguage); Inventory = new Inventory(); damageTracker = new Dictionary<string, double>(); Triggers = new List<ITrigger>(); Bonuses = new StatBonuses(); FirstName = ""; LastName = ""; Description = ""; Age = 17; //Do we want an age? And are we going to advance it every in game year? Players could be 400+ years old rather quick. Weight = 180.0d; //pounds or kilos? Height = 70.0d; //inches or centimeters? Location = "A0"; InCombat = false; LastCombatTime = DateTime.MinValue.ToUniversalTime(); IsNPC = true; Leveled = false; MainHand = "WIELD_RIGHT"; NextLevelExperience = 300; Level = 1; Experience = 0; PointsToSpend = 0; IsMob = false; Inventory = new Inventory(); Equipment = new Equipment(); Inventory.playerID = this.ID; Equipment.playerID = this.ID; Attributes = new Dictionary<string, Attribute>(); Attributes.Add("Hitpoints", new Attribute(200.0d, "Hitpoints", 200.0d, 0.2d, 1)); Attributes.Add("Dexterity", new Attribute(10.0d, "Dexterity", 10.0d, 0.0d, 1)); Attributes.Add("Strength", new Attribute(10.0d, "Strength", 10.0d, 0.0d, 1)); Attributes.Add("Intelligence", new Attribute(10.0d, "Intelligence", 10.0d, 0.0d, 1)); Attributes.Add("Endurance", new Attribute(10.0d, "Endurance", 10.0d, 0.0d, 1)); Attributes.Add("Charisma", new Attribute(10.0d, "Charisma", 10.0d, 0.0d, 1)); SubAttributes = new Dictionary<string, double>(); SubAttributes.Add("Agility", 10.0d); SubAttributes.Add("Toughness", 10.0d); SubAttributes.Add("Cunning", 10.0d); SubAttributes.Add("Wisdom", 10.0d); SubAttributes.Add("Leadership", 10.0d); }