Exemple #1
0
        public Character()
        {
            _class = CharacterEnums.CharacterClass.Explorer;
            _race = CharacterEnums.CharacterRace.Human;
            _gender = CharacterEnums.Genders.Female;
            _skinColor = CharacterEnums.SkinColors.Fair;
            _skinType = CharacterEnums.SkinType.Flesh;
            _hairColor = CharacterEnums.HairColors.Black;
            _eyeColor = CharacterEnums.EyeColors.Brown;
            _build = CharacterEnums.BodyBuild.Medium;

            _koCount = new Tuple<int, DateTime>(0, DateTime.Now);
            _actionState = CharacterActionState.None;
            _stanceState = CharacterStanceState.Standing;

            _primaryLanguage = CharacterEnums.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 = "A1";
            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 StatBonuses();

            Inventory.playerID = this.ID;
            Equipment.playerID = this.ID;

            Attributes = new Dictionary<string, Attribute>();

            Attributes.Add("Hitpoints", new Attribute(150, "Hitpoints", 150, 0.1, 1));
            Attributes.Add("Dexterity", new Attribute(10, "Dexterity", 5, 0, 1));
            Attributes.Add("Strength", new Attribute(10, "Strength", 5, 0, 1));
            Attributes.Add("Intelligence", new Attribute(10, "Intelligence", 5, 0, 1));
            Attributes.Add("Endurance", new Attribute(10, "Endurance", 5, 0, 1));
            Attributes.Add("Charisma", 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);
        }
Exemple #2
0
        public Character()
        {
            _class     = CharacterEnums.CharacterClass.Explorer;
            _race      = CharacterEnums.CharacterRace.Human;
            _gender    = CharacterEnums.Genders.Female;
            _skinColor = CharacterEnums.SkinColors.Fair;
            _skinType  = CharacterEnums.SkinType.Flesh;
            _hairColor = CharacterEnums.HairColors.Black;
            _eyeColor  = CharacterEnums.EyeColors.Brown;
            _build     = CharacterEnums.BodyBuild.Medium;

            _koCount     = new Tuple <int, DateTime>(0, DateTime.Now);
            _actionState = CharacterActionState.None;
            _stanceState = CharacterStanceState.Standing;

            _primaryLanguage = CharacterEnums.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            = "A1";
            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 StatBonuses();

            Inventory.playerID = this.ID;
            Equipment.playerID = this.ID;

            Attributes = new Dictionary <string, Attribute>();

            Attributes.Add("Hitpoints", new Attribute(150, "Hitpoints", 150, 0.1, 1));
            Attributes.Add("Dexterity", new Attribute(10, "Dexterity", 5, 0, 1));
            Attributes.Add("Strength", new Attribute(10, "Strength", 5, 0, 1));
            Attributes.Add("Intelligence", new Attribute(10, "Intelligence", 5, 0, 1));
            Attributes.Add("Endurance", new Attribute(10, "Endurance", 5, 0, 1));
            Attributes.Add("Charisma", 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);
        }
Exemple #3
0
        /// <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 (CharacterEnums.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            = "A1";
            InCombat            = false;
            LastCombatTime      = DateTime.MinValue.ToUniversalTime();
            IsNPC               = false;
            Leveled             = false;
            NextLevelExperience = 300;
            Level               = 1;
            Experience          = 0;
            PointsToSpend       = 0;
            MainHand            = "WIELD_RIGHT";


            Attributes = new Dictionary <string, Attribute>();

            foreach (KeyValuePair <string, Attribute> attrib in copy.Attributes)
            {
                Attributes.Add(attrib.Key, attrib.Value);
            }

            SubAttributes = new Dictionary <string, double>();

            foreach (KeyValuePair <string, double> subAttrib in copy.SubAttributes)
            {
                SubAttributes.Add(subAttrib.Key, subAttrib.Value);
            }

            Inventory = new Inventory();


            this.Save();
        }
Exemple #4
0
        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            = "A1";
            InCombat            = false;
            LastCombatTime      = DateTime.MinValue.ToUniversalTime();
            IsNPC               = false;
            Leveled             = false;
            MainHand            = "WIELD_RIGHT";
            NextLevelExperience = 300;
            Level               = 1;
            Experience          = 0;
            PointsToSpend       = 0;

            Inventory = new Inventory();
            Bonuses   = new StatBonuses();

            Attributes = new Dictionary <string, Attribute>();

            Attributes.Add("Hitpoints", new Attribute(150, "Hitpoints", 150, 0.1, 1));
            Attributes.Add("Dexterity", new Attribute(10, "Dexterity", 5, 0, 1));
            Attributes.Add("Strength", new Attribute(10, "Strength", 5, 0, 1));
            Attributes.Add("Intelligence", new Attribute(10, "Intelligence", 5, 0, 1));
            Attributes.Add("Endurance", new Attribute(10, "Endurance", 5, 0, 1));
            Attributes.Add("Charisma", 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);
        }
Exemple #5
0
		public async void Load(ObjectId id) {
			var characterCollection = MongoUtils.MongoData.GetCollection<Character>("Characters", "PlayerCharacter");
			var found = await MongoUtils.MongoData.RetrieveObjectAsync<Character>(characterCollection, c => c.Id == this.Id);

			Id = found.Id;
			FirstName = found.FirstName.CamelCaseWord();
			LastName = found.LastName.CamelCaseWord();
            Build = found.Build;
            Class = found.Class;
            Race = found.Race;
            Gender = found.Gender;
            SkinType = found.SkinType;
            SkinColor = found.SkinColor;
            HairColor = found.HairColor;
            EyeColor = found.EyeColor;
            Height = found.Height;
            Weight = found.Weight;
            _stanceState = found.StanceState;
            _actionState = found.ActionState;
			Description = found.Description;
			Location = found.Location;
            Password = found.Password;
            IsNPC = found.IsNPC;
            Experience = found.Experience;
            NextLevelExperience = found.NextLevelExperience;
            Level = found.Level;
            Leveled = found.Leveled;
            PointsToSpend = found.PointsToSpend;
            MainHand = found.MainHand;
			Title = found.Title;
			KillerID = found.KillerID;

			Attributes = found.Attributes;
            Inventory = found.Inventory;
            Equipment = found.Equipment;
            Bonuses = found.Bonuses;
           
			//if (playerAttributes != null) {
			//	foreach (BsonDocument attrib in playerAttributes) {
				
			//		if (!this.Attributes.ContainsKey(attrib["Name"].ToString())) {
			//			Attribute tempAttrib = new Attribute();
			//			tempAttrib.Name = attrib["Name"].ToString();
			//			tempAttrib.Value = attrib["Value"].AsDouble;
			//			tempAttrib.Max = attrib["Max"].AsDouble ;
			//			tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;
   //                     tempAttrib.Rank = attrib["Rank"].AsInt32;

			//			this.Attributes.Add(tempAttrib.Name, tempAttrib);
			//		}
			//		else {
			//			this.Attributes[attrib["Name"].ToString()].Max = attrib["Max"].AsDouble;
			//			this.Attributes[attrib["Name"].ToString()].Value = attrib["Value"].AsDouble;
			//			this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
   //                     this.Attributes[attrib["Name"].ToString()].Rank = attrib["Rank"].AsInt32;
			//		}
			//	}
			//}

   //         if (inventoryList.Count > 0) {
   //             foreach (BsonDocument item in inventoryList) {
   //                 IItem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
   //                 if (!Inventory.inventory.Contains(fullItem)) {
   //                     Inventory.AddItemToInventory(fullItem);
   //                 }
   //             }
   //         }

   //         if (equipmentList.Count > 0) {
   //             foreach (BsonDocument item in equipmentList) {
   //                 IItem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
   //                 if (!Equipment.equipped.ContainsKey(fullItem.WornOn)) {
   //                     Equipment.EquipItem(fullItem, this.Inventory);
   //                 }
   //             }
   //         }

   //         if (bonusesList.Count > 0) {
   //             Bonuses.LoadFromBson(bonusesList);
   //         }

			Inventory.playerID = Id;
			Equipment.playerID = Id;

		}
Exemple #6
0
		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);
		}
Exemple #7
0
        /// <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();
        }
Exemple #8
0
        public void Load(string id)
        {
            MongoUtils.MongoData.ConnectToDatabase();
            MongoDatabase characterDB = MongoUtils.MongoData.GetDatabase("Characters");
            MongoCollection characterCollection = characterDB.GetCollection<BsonDocument>("PlayerCharacter");
            IMongoQuery query = Query.EQ("_id", ObjectId.Parse(id));
            BsonDocument found = characterCollection.FindOneAs<BsonDocument>(query);

            ID = found["_id"].AsObjectId.ToString();
            FirstName = found["FirstName"].AsString.CamelCaseWord();
            LastName = found["LastName"].AsString.CamelCaseWord();
            _class = (CharacterClass)Enum.Parse(typeof(CharacterClass), found["Class"].AsString.CamelCaseWord());
            _race = (CharacterRace)Enum.Parse(typeof(CharacterRace), found["Race"].AsString.CamelCaseWord());
            _gender = (Genders)Enum.Parse(typeof(Genders), found["Gender"].AsString.CamelCaseWord());
            _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _skinColor = (SkinColors)Enum.Parse(typeof(SkinColors), found["SkinColor"].AsString.CamelCaseWord());
            _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _hairColor = (HairColors)Enum.Parse(typeof(HairColors), found["HairColor"].AsString.CamelCaseWord());
            _eyeColor = (EyeColors)Enum.Parse(typeof(EyeColors), found["EyeColor"].AsString.CamelCaseWord());
            Height = found["Height"].AsDouble;
            Weight = found["Weight"].AsDouble;
            _stanceState = (CharacterStanceState)Enum.Parse(typeof(CharacterStanceState), found["StanceState"].AsString.CamelCaseWord());
            _actionState = (CharacterActionState)Enum.Parse(typeof(CharacterActionState), found["ActionState"].AsString.CamelCaseWord());
            Description = found["Description"].AsString;
            Location = found["Location"].AsString;
            Password = found["Password"].AsString;
            IsNPC = found["IsNPC"].AsBoolean;
            Experience = found["Experience"].AsInt64;
            NextLevelExperience = found["NextLevelExperience"].AsInt64;
            Level = found["Level"].AsInt32;
            Leveled = found["Leveled"].AsBoolean;
            PointsToSpend = found["PointsToSpend"].AsInt32;
            MainHand = found["MainHand"].AsString != "" ? found["MainHand"].AsString : null;
            Title = found.Contains("Title") ? found["Title"].AsString : "";
            KillerID = found.Contains("KillerID") ? found["KillerID"].AsString : "";

            BsonArray playerAttributes = found["Attributes"].AsBsonArray;
            BsonArray inventoryList = found["Inventory"].AsBsonArray;
            BsonArray equipmentList = found["Equipment"].AsBsonArray;
            BsonArray bonusesList = found["Bonuses"].AsBsonArray;

            if (playerAttributes != null) {
                foreach (BsonDocument attrib in playerAttributes) {

                    if (!this.Attributes.ContainsKey(attrib["Name"].ToString())) {
                        Attribute tempAttrib = new Attribute();
                        tempAttrib.Name = attrib["Name"].ToString();
                        tempAttrib.Value = attrib["Value"].AsDouble;
                        tempAttrib.Max = attrib["Max"].AsDouble ;
                        tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;
                        tempAttrib.Rank = attrib["Rank"].AsInt32;

                        this.Attributes.Add(tempAttrib.Name, tempAttrib);
                    }
                    else {
                        this.Attributes[attrib["Name"].ToString()].Max = attrib["Max"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].Value = attrib["Value"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].Rank = attrib["Rank"].AsInt32;
                    }
                }
            }

            if (inventoryList.Count > 0) {
                foreach (BsonDocument item in inventoryList) {
                    Items.Iitem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
                    if (!Inventory.inventory.Contains(fullItem)) {
                        Inventory.AddItemToInventory(fullItem);
                    }
                }
            }

            if (equipmentList.Count > 0) {
                foreach (BsonDocument item in equipmentList) {
                    Items.Iitem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
                    if (!Equipment.equipped.ContainsKey(fullItem.WornOn)) {
                        Equipment.EquipItem(fullItem, this.Inventory);
                    }
                }
            }

            if (bonusesList.Count > 0) {
                Bonuses.LoadFromBson(bonusesList);
            }
        }
Exemple #9
0
 public void SetStanceStateDouble(double state)
 {
     _stanceState = (CharacterStanceState)(int)state;
 }
Exemple #10
0
        public void Load(string id)
        {
            MongoUtils.MongoData.ConnectToDatabase();
            MongoDatabase   characterDB         = MongoUtils.MongoData.GetDatabase("Characters");
            MongoCollection characterCollection = characterDB.GetCollection <BsonDocument>("NPCCharacters");
            IMongoQuery     query = Query.EQ("_id", ObjectId.Parse(id));
            BsonDocument    found = characterCollection.FindOneAs <BsonDocument>(query);

            ID                = found["_id"].AsObjectId.ToString();
            FirstName         = found["FirstName"].AsString.CamelCaseWord();
            LastName          = found["LastName"].AsString.CamelCaseWord();
            _class            = (CharacterClass)Enum.Parse(typeof(CharacterClass), found["Class"].AsString.CamelCaseWord());
            _race             = (CharacterRace)Enum.Parse(typeof(CharacterRace), found["Race"].AsString.CamelCaseWord());
            _gender           = (Genders)Enum.Parse(typeof(Genders), found["Gender"].AsString.CamelCaseWord());
            _skinType         = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _skinColor        = (SkinColors)Enum.Parse(typeof(SkinColors), found["SkinColor"].AsString.CamelCaseWord());
            _skinType         = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _hairColor        = (HairColors)Enum.Parse(typeof(HairColors), found["HairColor"].AsString.CamelCaseWord());
            _eyeColor         = (EyeColors)Enum.Parse(typeof(EyeColors), found["EyeColor"].AsString.CamelCaseWord());
            _stanceState      = (CharacterStanceState)Enum.Parse(typeof(CharacterStanceState), found["StanceState"].AsString.CamelCaseWord());
            _actionState      = (CharacterActionState)Enum.Parse(typeof(CharacterActionState), found["ActionState"].AsString.CamelCaseWord());
            Description       = found["Description"].AsString;
            Location          = found["Location"].AsString;
            Height            = found["Height"].AsDouble;
            Weight            = found["Weight"].AsDouble;
            IsNPC             = found["IsNPC"].AsBoolean;
            MobTypeID         = found["MobTypeID"].AsInt32;
            NextAiAction      = found["NextAiAction"].ToUniversalTime();
            InCombat          = found["InCombat"].AsBoolean;
            LastCombatTime    = found["LastCombatTime"].ToUniversalTime();
            CurrentTarget     = found["CurrentTarget"].AsString != "" ? found["CurrentTarget"].AsString : null;
            LastTarget        = found["LastTarget"].AsString != "" ? found["LastTarget"].AsString : null;
            Fsm.state         = Fsm.GetStateFromName(found["AiState"].AsString);
            Fsm.previousState = Fsm.GetStateFromName(found["previousAiState"].AsString);
            Fsm.globalState   = Fsm.GetStateFromName(found["AiGlobalState"].AsString);
            Experience        = found["Experience"].AsInt64;
            Level             = found["Level"].AsInt32;
            Title             = found.Contains("Title") ? found["Title"].AsString : "";
            KillerID          = found.Contains("KillerID") ? found["KillerID"].AsString : "";

            //if you just use var instead of casting it like this you will be in a world of pain and suffering when dealing with subdocuments.
            BsonArray    playerAttributes = found["Attributes"].AsBsonArray;
            BsonArray    xpTracker        = found["XpTracker"].AsBsonArray;
            BsonDocument triggers         = found["Triggers"].AsBsonDocument;
            BsonArray    bonusesList      = null;

            if (found.Contains("Bonuses"))
            {
                bonusesList = found["Bonuses"].AsBsonArray;
            }

            if (playerAttributes != null)
            {
                foreach (BsonDocument attrib in playerAttributes)
                {
                    if (!this.Attributes.ContainsKey(attrib["Name"].ToString()))
                    {
                        Attribute tempAttrib = new Attribute();
                        tempAttrib.Name      = attrib["Name"].ToString();
                        tempAttrib.Value     = attrib["Value"].AsDouble;
                        tempAttrib.Max       = attrib["Max"].AsDouble;
                        tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;


                        this.Attributes.Add(tempAttrib.Name, tempAttrib);
                    }
                    else
                    {
                        this.Attributes[attrib["Name"].ToString()].Max       = attrib["Max"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].Value     = attrib["Value"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
                    }
                }
            }

            if (xpTracker != null && xpTracker.Count > 0)
            {
                foreach (BsonDocument track in xpTracker)
                {
                    //we just newed this up so it should always have to be refilled
                    damageTracker.Add(track["ID"].AsString, track["Value"].AsDouble);
                }
            }

            ITrigger trigger = new GeneralTrigger(triggers, "NPC");

            Triggers.Add(trigger);

            if (bonusesList != null && bonusesList.Count > 0)
            {
                Bonuses.LoadFromBson(bonusesList);
            }
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        public void Load(string id)
        {
            MongoUtils.MongoData.ConnectToDatabase();
            MongoDatabase characterDB = MongoUtils.MongoData.GetDatabase("Characters");
            MongoCollection characterCollection = characterDB.GetCollection<BsonDocument>("NPCCharacters");
            IMongoQuery query = Query.EQ("_id", ObjectId.Parse(id));
            BsonDocument found = characterCollection.FindOneAs<BsonDocument>(query);

            ID = found["_id"].AsObjectId.ToString();
            FirstName = found["FirstName"].AsString.CamelCaseWord();
            LastName = found["LastName"].AsString.CamelCaseWord();
            _class = (CharacterClass)Enum.Parse(typeof(CharacterClass), found["Class"].AsString.CamelCaseWord());
            _race = (CharacterRace)Enum.Parse(typeof(CharacterRace), found["Race"].AsString.CamelCaseWord());
            _gender = (Genders)Enum.Parse(typeof(Genders), found["Gender"].AsString.CamelCaseWord());
            _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _skinColor = (SkinColors)Enum.Parse(typeof(SkinColors), found["SkinColor"].AsString.CamelCaseWord());
            _skinType = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _hairColor = (HairColors)Enum.Parse(typeof(HairColors), found["HairColor"].AsString.CamelCaseWord());
            _eyeColor = (EyeColors)Enum.Parse(typeof(EyeColors), found["EyeColor"].AsString.CamelCaseWord());
            _stanceState = (CharacterStanceState)Enum.Parse(typeof(CharacterStanceState), found["StanceState"].AsString.CamelCaseWord());
            _actionState = (CharacterActionState)Enum.Parse(typeof(CharacterActionState), found["ActionState"].AsString.CamelCaseWord());
            Description = found["Description"].AsString;
            Location = found["Location"].AsString;
            Height = found["Height"].AsDouble;
            Weight = found["Weight"].AsDouble;
            IsNPC = found["IsNPC"].AsBoolean;
            MobTypeID = found["MobTypeID"].AsInt32;
            NextAiAction = found["NextAiAction"].ToUniversalTime();
            InCombat = found["InCombat"].AsBoolean;
            LastCombatTime = found["LastCombatTime"].ToUniversalTime();
            CurrentTarget = found["CurrentTarget"].AsString != "" ? found["CurrentTarget"].AsString : null;
            LastTarget = found["LastTarget"].AsString != "" ? found["LastTarget"].AsString : null;
            Fsm.state = Fsm.GetStateFromName(found["AiState"].AsString);
            Fsm.previousState = Fsm.GetStateFromName(found["previousAiState"].AsString);
            Fsm.globalState = Fsm.GetStateFromName(found["AiGlobalState"].AsString);
            Experience = found["Experience"].AsInt64;
            Level = found["Level"].AsInt32;
            Title = found.Contains("Title") ? found["Title"].AsString : "";
            KillerID = found.Contains("KillerID") ? found["KillerID"].AsString : "";

            //if you just use var instead of casting it like this you will be in a world of pain and suffering when dealing with subdocuments.
            BsonArray playerAttributes = found["Attributes"].AsBsonArray;
            BsonArray xpTracker = found["XpTracker"].AsBsonArray;
            BsonDocument triggers = found["Triggers"].AsBsonDocument;
            BsonArray bonusesList = null;
            if (found.Contains("Bonuses")) {
                bonusesList = found["Bonuses"].AsBsonArray;
            }

            if (playerAttributes != null) {
                foreach (BsonDocument attrib in playerAttributes) {

                    if (!this.Attributes.ContainsKey(attrib["Name"].ToString())) {
                        Attribute tempAttrib = new Attribute();
                        tempAttrib.Name = attrib["Name"].ToString();
                        tempAttrib.Value = attrib["Value"].AsDouble;
                        tempAttrib.Max = attrib["Max"].AsDouble;
                        tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;

                        this.Attributes.Add(tempAttrib.Name, tempAttrib);
                    }
                    else {
                        this.Attributes[attrib["Name"].ToString()].Max = attrib["Max"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].Value = attrib["Value"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
                    }
                }
            }

            if (xpTracker != null && xpTracker.Count > 0) {
                foreach (BsonDocument track in xpTracker) {
                    //we just newed this up so it should always have to be refilled
                    damageTracker.Add(track["ID"].AsString, track["Value"].AsDouble);
                }
            }

            ITrigger trigger = new GeneralTrigger(triggers, "NPC");
            Triggers.Add(trigger);

            if (bonusesList != null && bonusesList.Count > 0) {
                Bonuses.LoadFromBson(bonusesList);
            }
        }
Exemple #13
0
        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);
        }
Exemple #14
0
		public async void Load(ObjectId id) {
			var characterCollection = MongoUtils.MongoData.GetCollection<NPC>("Characters", "NPCCharacters");
			var found = await MongoUtils.MongoData.RetrieveObjectAsync<NPC>(characterCollection, n => n.Id == id);
            
			Id = found.Id;
			FirstName = found.FirstName.CamelCaseWord();
			LastName = found.LastName.CamelCaseWord();
            _class = found.Class;
            _race = found.Race;
            _gender = found.Gender;
            _skinType = found.SkinType;
            _skinColor = found.SkinColor;
            _hairColor = found.HairColor;
            _eyeColor = found.EyeColor;
			_stanceState = found.StanceState;
			_actionState = found.ActionState;
			Description = found.Description;
			Location = found.Location;
			Height = found.Height;
			Weight = found.Weight;
			IsNPC = found.IsNPC;
			MobTypeID = found.MobTypeID;
			NextAiAction = found.NextAiAction.ToUniversalTime();
			InCombat = found.InCombat;
			LastCombatTime = found.LastCombatTime.ToUniversalTime();
			CurrentTarget = found.CurrentTarget;
			LastTarget = found.LastTarget;
			Fsm.state = Fsm.GetStateFromName(found.AiState);
			Fsm.previousState = Fsm.GetStateFromName(found.PreviousAiState);
			Fsm.globalState = Fsm.GetStateFromName(found.AiGlobalState);
			Experience = found.Experience;
            Level = found.Level;
            Title = found.Title;
			KillerID = found.KillerID;

			Attributes = found.Attributes;
			XpTracker = found.XpTracker;
			Triggers = found.Triggers;
			Quests = found.Quests;
			Bonuses = found.Bonuses;
			StatBonus.Bonuses = Bonuses;
			
			//if (playerAttributes != null) {
			//	foreach (BsonDocument attrib in playerAttributes) {

			//		if (!this.Attributes.ContainsKey(attrib["Name"].ToString())) {
			//			Attribute tempAttrib = new Attribute();
			//			tempAttrib.Name = attrib["Name"].ToString();
			//			tempAttrib.Value = attrib["Value"].AsDouble;
			//			tempAttrib.Max = attrib["Max"].AsDouble;
			//			tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;


			//			this.Attributes.Add(tempAttrib.Name, tempAttrib);
			//		}
			//		else {
			//			this.Attributes[attrib["Name"].ToString()].Max = attrib["Max"].AsDouble;
			//			this.Attributes[attrib["Name"].ToString()].Value = attrib["Value"].AsDouble;
			//			this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
			//		}
			//	}
			//}

			//if (xpTracker != null && xpTracker.Count > 0) {
			//	foreach (BsonDocument track in xpTracker) {
			//		//we just newed this up so it should always have to be refilled
			//		damageTracker.Add(track["ID"].AsString, track["Value"].AsDouble);
			//	}
			//}

			//foreach (BsonDocument triggerdoc in triggers) {
			//	ITrigger trigger = new GeneralTrigger(triggerdoc, TriggerType.NPC);
			//	Triggers.Add(trigger);
			//}

			//if (questIds != null) {
			//	foreach (BsonDocument questDoc in questIds) {
			//		Dictionary<string, int> playerSteps = new Dictionary<string, int>();

			//		if (questDoc.Contains("PlayerIDs")) {
			//			foreach (var playerStep in questDoc["PlayerIDs"].AsBsonArray) {
			//				playerSteps.Add(playerStep["PlayerID"].AsString, playerStep["Step"].AsInt32);
			//			}
			//		}

			//		var quest = new Quests.Quest(questDoc["QuestID"].AsString, playerSteps);

			//		if (questDoc.Contains("AutoPlayers")) {
			//			foreach (var autoID in questDoc["AutoPlayers"].AsBsonArray) {
			//				quest.AutoProcessPlayer.Enqueue(autoID.AsString);
			//			}
			//		}
					
			//		Quests.Add(quest);
			//	}
			//}

			//if (bonusesList != null && bonusesList.Count > 0) {
			//	Bonuses.LoadFromBson(bonusesList);
			//}

			Inventory.playerID = Id;
			Equipment.playerID = Id;
		}
Exemple #15
0
        public void Load(string id)
        {
            MongoUtils.MongoData.ConnectToDatabase();
            MongoDatabase   characterDB         = MongoUtils.MongoData.GetDatabase("Characters");
            MongoCollection characterCollection = characterDB.GetCollection <BsonDocument>("PlayerCharacter");
            IMongoQuery     query = Query.EQ("_id", ObjectId.Parse(id));
            BsonDocument    found = characterCollection.FindOneAs <BsonDocument>(query);

            ID                  = found["_id"].AsObjectId.ToString();
            FirstName           = found["FirstName"].AsString.CamelCaseWord();
            LastName            = found["LastName"].AsString.CamelCaseWord();
            _class              = (CharacterClass)Enum.Parse(typeof(CharacterClass), found["Class"].AsString.CamelCaseWord());
            _race               = (CharacterRace)Enum.Parse(typeof(CharacterRace), found["Race"].AsString.CamelCaseWord());
            _gender             = (Genders)Enum.Parse(typeof(Genders), found["Gender"].AsString.CamelCaseWord());
            _skinType           = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _skinColor          = (SkinColors)Enum.Parse(typeof(SkinColors), found["SkinColor"].AsString.CamelCaseWord());
            _skinType           = (SkinType)Enum.Parse(typeof(SkinType), found["SkinType"].AsString.CamelCaseWord());
            _hairColor          = (HairColors)Enum.Parse(typeof(HairColors), found["HairColor"].AsString.CamelCaseWord());
            _eyeColor           = (EyeColors)Enum.Parse(typeof(EyeColors), found["EyeColor"].AsString.CamelCaseWord());
            Height              = found["Height"].AsDouble;
            Weight              = found["Weight"].AsDouble;
            _stanceState        = (CharacterStanceState)Enum.Parse(typeof(CharacterStanceState), found["StanceState"].AsString.CamelCaseWord());
            _actionState        = (CharacterActionState)Enum.Parse(typeof(CharacterActionState), found["ActionState"].AsString.CamelCaseWord());
            Description         = found["Description"].AsString;
            Location            = found["Location"].AsString;
            Password            = found["Password"].AsString;
            IsNPC               = found["IsNPC"].AsBoolean;
            Experience          = found["Experience"].AsInt64;
            NextLevelExperience = found["NextLevelExperience"].AsInt64;
            Level               = found["Level"].AsInt32;
            Leveled             = found["Leveled"].AsBoolean;
            PointsToSpend       = found["PointsToSpend"].AsInt32;
            MainHand            = found["MainHand"].AsString != "" ? found["MainHand"].AsString : null;
            Title               = found.Contains("Title") ? found["Title"].AsString : "";
            KillerID            = found.Contains("KillerID") ? found["KillerID"].AsString : "";

            BsonArray playerAttributes = found["Attributes"].AsBsonArray;
            BsonArray inventoryList    = found["Inventory"].AsBsonArray;
            BsonArray equipmentList    = found["Equipment"].AsBsonArray;
            BsonArray bonusesList      = found["Bonuses"].AsBsonArray;

            if (playerAttributes != null)
            {
                foreach (BsonDocument attrib in playerAttributes)
                {
                    if (!this.Attributes.ContainsKey(attrib["Name"].ToString()))
                    {
                        Attribute tempAttrib = new Attribute();
                        tempAttrib.Name      = attrib["Name"].ToString();
                        tempAttrib.Value     = attrib["Value"].AsDouble;
                        tempAttrib.Max       = attrib["Max"].AsDouble;
                        tempAttrib.RegenRate = attrib["RegenRate"].AsDouble;
                        tempAttrib.Rank      = attrib["Rank"].AsInt32;

                        this.Attributes.Add(tempAttrib.Name, tempAttrib);
                    }
                    else
                    {
                        this.Attributes[attrib["Name"].ToString()].Max       = attrib["Max"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].Value     = attrib["Value"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].RegenRate = attrib["RegenRate"].AsDouble;
                        this.Attributes[attrib["Name"].ToString()].Rank      = attrib["Rank"].AsInt32;
                    }
                }
            }

            if (inventoryList.Count > 0)
            {
                foreach (BsonDocument item in inventoryList)
                {
                    Items.Iitem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
                    if (!Inventory.inventory.Contains(fullItem))
                    {
                        Inventory.AddItemToInventory(fullItem);
                    }
                }
            }

            if (equipmentList.Count > 0)
            {
                foreach (BsonDocument item in equipmentList)
                {
                    Items.Iitem fullItem = Items.Items.GetByID(item["_id"].AsObjectId.ToString());
                    if (!Equipment.equipped.ContainsKey(fullItem.WornOn))
                    {
                        Equipment.EquipItem(fullItem, this.Inventory);
                    }
                }
            }

            if (bonusesList.Count > 0)
            {
                Bonuses.LoadFromBson(bonusesList);
            }
        }
Exemple #16
0
 public void SetStanceState(CharacterStanceState state) {
     _stanceState = state;
 }
Exemple #17
0
 public void SetStanceStateDouble(double state) {
     _stanceState = (CharacterStanceState)(int)state;
 }
Exemple #18
0
 public void SetStanceState(CharacterStanceState state)
 {
     _stanceState = state;
 }