示例#1
0
 public Rabbit(int year, int month, int day, EyeColors eyeColor, FurColors furColor, Gender gender) : base()
 {
     birthDayDate        = new DateTime(year, month, day);
     this.rabbitEyeColor = eyeColor;
     this.rabbitFurColor = furColor;
     this.rabbitGender   = gender;
 }
示例#2
0
文件: Character.cs 项目: vadian/Novus
        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);
        }
示例#3
0
文件: Character.cs 项目: vadian/Novus
        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);
        }
示例#4
0
文件: Character.cs 项目: vadian/Novus
        /// <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();
        }
示例#5
0
 public Rabbit(String name, FurColors furColor, EyeColors eyeColor, Genders gender, int age, int id)
 {
     Name     = name;
     FurColor = furColor;
     EyeColor = eyeColor;
     Gender   = gender;
     Age      = age;
     Id       = id;
 }
 public Rabbit(string name, int age, FurColors furcolor, EyeColors eyecolor, Genders gender)
 {
     Name     = name;
     Age      = age;
     FurColor = furcolor;
     EyeColor = eyecolor;
     Gender   = gender;
     Id       = Convert.ToInt32(randomNumber.Next());
 }
示例#7
0
文件: Character.cs 项目: vadian/Novus
        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);
        }
示例#8
0
    public void ChangeEyeColor(EyeColors newEyeColor)
    {
        switch (newEyeColor)
        {
        case EyeColors.green: SetEyeColors(Color.green); break;

        case EyeColors.red: SetEyeColors(Color.red); break;

        case EyeColors.yellow: SetEyeColors(Color.yellow); break;
        }
    }
            public void GenerateBodyStats()
            {
                height             = UnityEngine.Random.Range(60f, 80f);
                heightScale        = height / defaultHeight * height / defaultHeight;
                inverseHeightScale = 1 / heightScale;
                baseWeight         = heightScale * defaultBaseWeight;

                // Random BF % to determine starting total weight
                float percentBodyFat = UnityEngine.Random.Range(12f, 30f) / 100;

                fatWeight = baseWeight / (1 - percentBodyFat) - baseWeight;

                int bodyTypeCount = Enum.GetNames(typeof(BodyTypes)).Length;
                int randomType    = UnityEngine.Random.Range(0, bodyTypeCount);

                bodyType = (BodyTypes)randomType;

                randomType = UnityEngine.Random.Range(0, Enum.GetNames(typeof(EyeColors)).Length);
                eyeColor   = (EyeColors)randomType;

                randomType = UnityEngine.Random.Range(0, Enum.GetNames(typeof(HairColors)).Length);
                hairColor  = (HairColors)randomType;
                hairLength = UnityEngine.Random.Range(3, 24);
            }
示例#10
0
文件: NPC.cs 项目: vadian/Novus
        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);
        }
示例#11
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);
		}
示例#12
0
 public Rabbit(FurColors furColors, EyeColors eyeColor, Gender gender)
 {
     dateOfBirth = DateTime.Now;
 }
示例#13
0
文件: Character.cs 项目: vadian/Novus
        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);
            }
        }
示例#14
0
文件: Character.cs 项目: vadian/Novus
        /// <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();
        }
示例#15
0
文件: Character.cs 项目: vadian/Novus
        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);
            }
        }
示例#16
0
文件: NPC.cs 项目: vadian/Novus
        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);
            }
        }
示例#17
0
文件: NPC.cs 项目: vadian/Novus
        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);
        }
示例#18
0
文件: NPC.cs 项目: jandar78/Novus
		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;
		}
示例#19
0
文件: Day4.cs 项目: Quarris/AOC2020
            public bool IsValidated()
            {
                try {
                    // Check Birth Year
                    int byr = int.Parse(this._fields["byr"]);
                    if (byr < 1920 || byr > 2002)
                    {
                        return(false);
                    }

                    // Check Issue Year
                    int iyr = int.Parse(this._fields["iyr"]);
                    if (iyr < 2010 || iyr > 2020)
                    {
                        return(false);
                    }

                    // Check Expiration Year
                    int eyr = int.Parse(this._fields["eyr"]);
                    if (eyr < 2020 || eyr > 2030)
                    {
                        return(false);
                    }

                    // Check Height
                    string heightField = this._fields["hgt"];
                    if (!heightField.Contains("cm") && !heightField.Contains("in"))
                    {
                        return(false);
                    }
                    int    typeIndex = heightField.Length - 2;
                    string type      = heightField.Substring(typeIndex);
                    int    height    = int.Parse(heightField.Remove(typeIndex));
                    if (type == "cm" && (height < 150 || height > 193))
                    {
                        return(false);
                    }

                    if (type == "in" && (height < 59 || height > 76))
                    {
                        return(false);
                    }

                    // Check Hair Color
                    string hairColorField = this._fields["hcl"];
                    if (hairColorField.Length != 7 || hairColorField[0] != '#')
                    {
                        return(false);
                    }
                    if (!int.TryParse(hairColorField.Substring(1), NumberStyles.HexNumber, new NumberFormatInfo(), out int hairColor))
                    {
                        return(false);
                    }

                    // Check Eye Color
                    if (!EyeColors.Contains(this._fields["ecl"]))
                    {
                        return(false);
                    }

                    // Check Passport ID
                    string pid = this._fields["pid"];
                    if (pid.Count(char.IsDigit) != 9)
                    {
                        return(false);
                    }
                } catch (IndexOutOfRangeException exp) {
                    return(false);
                } catch (KeyNotFoundException exp) {
                    return(false);
                } catch (FormatException exp) {
                    return(false);
                }

                return(true);
            }
示例#20
0
文件: NPC.cs 项目: vadian/Novus
        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);
            }
        }