public bool SetObjectValue_User_Missions(User user, string key, object objectValue, bool isAdd)
        {
            bool isBreak = false;

            if (key.StartsWith(StringConst.String_missions_dot))             //任务对象
            {
                key = key.Substring(StringConst.String_missions_dot.Length);
                int pos = key.IndexOf(CharConst.Char_Dot);
                if (pos != -1)
                {
                    string missionId = key.Substring(0, pos);
                    key = key.Substring(pos);
                    if (missionId.EndsWith(StringConst.String_t))                     //改变tmpValue
                    {
                        missionId = missionId.Substring(0, missionId.Length - 1);
                        key       = StringConst.String_t + key;
                    }

                    var mission = user.GetMission(missionId);
                    if (mission != null)
                    {
                        DoerAttrSetter doerAttrSetter = new DoerAttrSetter(desc);
                        doerAttrSetter.SetU(mission);
                        doerAttrSetter.SetObject(StringConst.String_u + key, objectValue, isAdd);
                    }
                }

                return(true);
            }

            return(isBreak);
        }
Ejemplo n.º 2
0
        public bool SetObjectValue_User_Items(User user, string key, string objectValue, bool isAdd)
        {
            bool isBreak = false;

            if (key.StartsWith(StringConst.String_items_dot))             //物品对象
            {
                key = key.Substring(StringConst.String_items_dot.Length);
                int pos = key.IndexOf(CharConst.Char_Dot);
                if (pos != -1)
                {
                    string itemId = key.Substring(0, pos);
                    key = key.Substring(pos);
                    if (itemId.EndsWith(StringConst.String_t))                     //改变tmpValue
                    {
                        itemId = itemId.Substring(0, itemId.Length - 1);
                        key    = StringConst.String_t + key;
                    }

                    var item = user.GetItem(itemId);
                    if (item != null)
                    {
                        DoerAttrSetter doerAttrSetter = new DoerAttrSetter(desc);
                        doerAttrSetter.SetU(item);
                        doerAttrSetter.SetObject(StringConst.String_u + key, objectValue, isAdd);
                    }
                }

                return(true);
            }

            return(isBreak);
        }
        public bool SetObjectValue_Doer(Doer doer, string key, object objectValue, bool isAdd)
        {
            bool isBreak = false;

            if (doer is Doer)
            {
                if (key.StartsWith(StringConst.String_env_dot) || key.StartsWith(StringConst.String_envt_dot))                 //获得属性所在的环境
                {
                    Doer env = doer.GetEnv();
                    if (env != null)
                    {
                        key = key.Substring(StringConst.String_env.Length);
                        DoerAttrSetter attrAttrSetter = new DoerAttrSetter(desc);
                        attrAttrSetter.SetU(env);
                        attrAttrSetter.SetObject(StringConst.String_u + key, objectValue, isAdd);
                    }

                    return(true);
                }

                if (key.StartsWith(StringConst.String_ownerDot) ||
                    key.StartsWith(StringConst.String_ownertDot))                     //获得属性所在的环境
                {
                    Doer owner = doer.GetOwner();
                    if (owner != null)
                    {
                        key = key.Substring(StringConst.String_owner.Length);
                        DoerAttrSetter attrAttrSetter = new DoerAttrSetter(desc);
                        attrAttrSetter.SetU(owner);
                        attrAttrSetter.SetObject(StringConst.String_u + key, objectValue, isAdd);
                    }

                    return(true);
                }
            }

            return(isBreak);
        }