コード例 #1
0
ファイル: Exits.cs プロジェクト: vadian/Novus
 private void LoadTriggers()
 {
     foreach (BsonDocument doc in Triggers)
     {
         Triggers.GeneralTrigger trigger = new Triggers.GeneralTrigger(doc, "Door");
         trigger.script.AddVariable(this, "door");
         if (trigger.script.ScriptType == ScriptFactory.ScriptTypes.Lua)
         {
             LuaScript luaScript = trigger.script as LuaScript;
             luaScript.RegisterMarkedMethodsOf(new DoorHelpers());
         }
         _exitTriggers.Add(trigger);
     }
 }
コード例 #2
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);
            }
        }
コード例 #3
0
ファイル: Exits.cs プロジェクト: vadian/Novus
        private void LoadTriggers()
        {
            foreach (BsonDocument doc in Triggers) {
                Triggers.GeneralTrigger trigger = new Triggers.GeneralTrigger(doc, "Door");
                trigger.script.AddVariable(this, "door");
                if (trigger.script.ScriptType == ScriptFactory.ScriptTypes.Lua) {
                    LuaScript luaScript = trigger.script as LuaScript;
                    luaScript.RegisterMarkedMethodsOf(new DoorHelpers());

                }
                _exitTriggers.Add(trigger);
            }
        }
コード例 #4
0
ファイル: Exits.cs プロジェクト: jandar78/Novus
		public void LoadTriggers() {
            if (_exitTriggers == null)
            {
                _exitTriggers = new List<ITrigger>();
            }

            if (Triggers != null) {
                foreach (BsonDocument doc in Triggers) {
                    Triggers.GeneralTrigger trigger = new Triggers.GeneralTrigger(doc, TriggerType.Door);
                    trigger.script.AddVariable(this, "door");
                    if (trigger.script.ScriptType == ScriptTypes.Lua) {
                        LuaScript luaScript = trigger.script as LuaScript;
                        luaScript.RegisterMarkedMethodsOf(new DoorHelpers());

                    }
                    _exitTriggers.Add(trigger);
                }
            }
		}