Ejemplo n.º 1
0
    public bool ExecCommandWithArgs(StorySystem.StoryInstance instance, StorySystem.StoryMessageHandler handler, System.Int64 delta, System.Object iterator, params object[] args)
    {
        var err = LuaFunctionHelper.BeginCall(m_Cs2Lua_ExecCommandWithArgs);

        LuaFunctionHelper.PushValue(Self);
        LuaFunctionHelper.PushValue(instance);
        LuaFunctionHelper.PushValue(handler);
        LuaFunctionHelper.PushValue(delta);
        LuaFunctionHelper.PushValue(iterator);
        LuaFunctionHelper.PushParams(args);
        var end_call_res = LuaFunctionHelper.EndCall(err);

        if (end_call_res)
        {
            LuaFunctionHelper.BeginGetResult(err);
            bool __cs2lua_ret;
            LuaFunctionHelper.GetResult(out __cs2lua_ret);
            LuaFunctionHelper.EndGetResult();
            return(__cs2lua_ret);
        }
        else
        {
            return(false);
        }
    }
 protected override void Evaluate(StoryInstance instance, object iterator, object[] args)
 {
     m_MsgId.Evaluate(instance, iterator, args);
     for (int i = 0; i < m_MsgArgs.Count; ++i) {
         IStoryValue<object> val = m_MsgArgs[i];
         val.Evaluate(instance, iterator, args);
     }
 }
 protected override void Evaluate(StoryInstance instance, object iterator, object[] args)
 {
     m_ObjPath.Evaluate(instance, iterator, args);
     m_ComponentType.Evaluate(instance, iterator, args);
     if (m_HaveObj) {
         m_ObjVarName.Evaluate(instance, iterator, args);
     }
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     int objId = m_ObjId.Value;
     string value = m_Value.Value;
     EntityInfo charObj = ClientModule.Instance.GetEntityById(objId);
     if (null != charObj) {
         charObj.IsControlByStory = (0 == value.CompareTo("true"));
     }
     return false;
 }
 protected override void Evaluate(StoryInstance instance, object iterator, object[] args)
 {
     m_Pos.Evaluate(instance, iterator, args);
     m_Radius.Evaluate(instance, iterator, args);
     m_Type.Evaluate(instance, iterator, args);
     m_EventName.Evaluate(instance, iterator, args);
     if (m_HaveSet) {
         m_SetVar.Evaluate(instance, iterator, args);
         m_SetVal.Evaluate(instance, iterator, args);
         m_ElseSetVal.Evaluate(instance, iterator, args);
     }
 }
 static public int get_IsTerminated(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.IsTerminated);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_StackVariables(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.StackVariables);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int Start(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         self.Start();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     Scene scene = instance.Context as Scene;
     if (null != scene) {
         int objId = m_ObjId.Value;
         string value = m_Value.Value;
         EntityInfo charObj = scene.SceneContext.GetEntityById(objId);
         if (null != charObj) {
             charObj.IsControlByStory = (0 == value.CompareTo("true"));
         }
     }
     return false;
 }
 static public int constructor(IntPtr l)
 {
     try {
         StorySystem.StoryInstance o;
         o = new StorySystem.StoryInstance();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 11
0
 public bool Execute(StoryInstance instance, long delta, object iterator, object[] args)
 {
     if (IsCompositeCommand) {
         return ExecCommand(instance, delta, iterator, args);
     } else {
         if (!m_LastExecResult) {
             //重复执行时不需要每个tick都更新变量值,每个命令每次执行,变量值只读取一次。
             Evaluate(instance, iterator, args);
         }
         m_LastExecResult = ExecCommand(instance, delta);
         return m_LastExecResult;
     }
 }
 static public int set_Namespace(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         string v;
         checkType(l, 2, out v);
         self.Namespace = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int ClearMessage(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         System.String[]           a1;
         checkParams(l, 2, out a1);
         self.ClearMessage(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_Context(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         System.Object             v;
         checkType(l, 2, out v);
         self.Context = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_IsPaused(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.IsPaused = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_StackVariables(IntPtr l)
 {
     try {
         StorySystem.StoryInstance          self = (StorySystem.StoryInstance)checkSelf(l);
         Dictionary <System.String, object> v;
         checkType(l, 2, out v);
         self.StackVariables = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int Tick(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         System.Int64 a1;
         checkType(l, 2, out a1);
         self.Tick(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 18
0
        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            Scene scene = instance.Context as Scene;
            if (null != scene) {
                int objId = 0;
                if (m_ParamNum >= 5) {
                    Vector3 pos = m_Pos.Value;
                    float dir = m_Dir.Value;
                    int camp = m_Camp.Value;
                    int linkId = m_LinkId.Value;
                    objId = scene.CreateEntity(m_UnitId.Value, pos.X, pos.Y, pos.Z, dir, camp, linkId);
                    if (m_ParamNum > 6) {
                        int aiLogic = m_AiLogic.Value;

                        EntityInfo charObj = scene.SceneContext.GetEntityById(objId);
                        if (null != charObj) {
                            charObj.GetAiStateInfo().Reset();
                            charObj.GetAiStateInfo().AiLogic = aiLogic;
                            if (m_ParamNum > 7) {
                                int leaderId = m_LeaderId.Value;
                                charObj.GetAiStateInfo().LeaderID = leaderId;
                            } else {
                                charObj.GetAiStateInfo().LeaderID = 0;
                            }
                            IEnumerable aiParams = m_AiParams.Value;
                            int ix = 0;
                            foreach (string aiParam in aiParams) {
                                if (ix < AiStateInfo.c_MaxAiParamNum) {
                                    charObj.GetAiStateInfo().AiParam[ix] = aiParam;
                                    ++ix;
                                } else {
                                    break;
                                }
                            }
                        }
                    }
                    EntityInfo obj = scene.GetEntityById(objId);
                    if (null != obj) {
                        Msg_RC_CreateNpc msg = DataSyncUtility.BuildCreateNpcMessage(obj);
                        scene.NotifyAllUser(RoomMessageDefine.Msg_RC_CreateNpc, msg);
                    }
                }
                if (m_HaveObjId) {
                    string varName = m_ObjIdVarName.Value;
                    instance.SetVariable(varName, objId);
                }
            }
            return false;
        }
 static public int GetMessageTriggerTime(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         System.String             a1;
         checkType(l, 2, out a1);
         var ret = self.GetMessageTriggerTime(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         string msgId = m_MsgId.Value;
         ArrayList arglist = new ArrayList();
         for (int i = 0; i < m_MsgArgs.Count; ++i) {
             IStoryValue<object> val = m_MsgArgs[i];
             arglist.Add(val.Value);
         }
         object[] args = arglist.ToArray();
         userThread.StorySystem.SendMessage(msgId, args);
     }
     return false;
 }
 static public int Init(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         Dsl.DslInfo a1;
         checkType(l, 2, out a1);
         var ret = self.Init(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int PauseMessageHandler(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         System.String             a1;
         checkType(l, 2, out a1);
         System.Boolean a2;
         checkType(l, 3, out a2);
         self.PauseMessageHandler(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int SetVariable(IntPtr l)
 {
     try {
         StorySystem.StoryInstance self = (StorySystem.StoryInstance)checkSelf(l);
         System.String             a1;
         checkType(l, 2, out a1);
         System.Object a2;
         checkType(l, 3, out a2);
         self.SetVariable(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    public void Evaluate(StorySystem.StoryInstance instance, StorySystem.StoryMessageHandler handler, StorySystem.StoryValueParams _params)
    {
        var err = LuaFunctionHelper.BeginCall(m_Cs2Lua_Evaluate);

        LuaFunctionHelper.PushValue(Self);
        LuaFunctionHelper.PushValue(instance);
        LuaFunctionHelper.PushValue(handler);
        LuaFunctionHelper.PushValue(_params);
        var end_call_res = LuaFunctionHelper.EndCall(err);

        if (end_call_res)
        {
            LuaFunctionHelper.BeginGetResult(err);
            LuaFunctionHelper.EndGetResult();
        }
        else
        {
        }
    }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     bool triggered = false;
     string name = m_Name.Value;
     float radius = m_Radius.Value;
     string type = m_Type.Value;
     string eventName = m_EventName.Value;
     UnityEngine.GameObject obj = UnityEngine.GameObject.Find(name);
     if (null != obj) {
         UnityEngine.Vector3 pos = obj.transform.position;
         if (type == "myself") {
             EntityViewModel view = EntityController.Instance.GetEntityViewById(ClientModule.Instance.LeaderID);
             if (null != view && null != view.Actor) {
                 if ((view.Actor.transform.position - pos).sqrMagnitude < radius * radius) {
                     GfxStorySystem.Instance.SendMessage(eventName, name, radius, type);
                     triggered = true;
                 }
             }
         } else if (type == "anyenemy" || type == "anyfriend") {
             EntityInfo myself = ClientModule.Instance.GetEntityById(ClientModule.Instance.LeaderID);
             ClientModule.Instance.KdTree.Query(pos.x, pos.y, pos.z, radius, (float distSqr, KdTreeObject kdObj) => {
                 if (type == "anyenemy" && EntityInfo.GetRelation(myself, kdObj.Object) == CharacterRelation.RELATION_ENEMY ||
                     type == "anyfriend" && EntityInfo.GetRelation(myself, kdObj.Object) == CharacterRelation.RELATION_FRIEND) {
                     GfxStorySystem.Instance.SendMessage(eventName, name, radius, type);
                     triggered = true;
                     return false;
                 }
                 return true;
             });
         }
     }
     string varName = m_SetVar.Value;
     object varVal = m_SetVal.Value;
     object elseVal = m_ElseSetVal.Value;
     if (triggered) {
         instance.SetVariable(varName, varVal);
     } else {
         instance.SetVariable(varName, elseVal);
     }
     return false;
 }
Ejemplo n.º 26
0
        protected override void Evaluate(StoryInstance instance, object iterator, object[] args)
        {
            if (m_ParamNum >= 5) {
                m_UnitId.Evaluate(instance, iterator, args);
                m_Pos.Evaluate(instance, iterator, args);
                m_Dir.Evaluate(instance, iterator, args);
                m_Camp.Evaluate(instance, iterator, args);
                m_LinkId.Evaluate(instance, iterator, args);

                if (m_ParamNum > 6) {
                    m_AiLogic.Evaluate(instance, iterator, args);
                    m_AiParams.Evaluate(instance, iterator, args);
                    if (m_ParamNum > 7) {
                        m_LeaderId.Evaluate(instance, iterator, args);
                    }
                }
            }
            if (m_HaveObjId) {
                m_ObjIdVarName.Evaluate(instance, iterator, args);
            }
        }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         string key = m_Key.Value;
         object val = m_Value.Value;
         if (val is int) {
             int v = (int)val;
             GlobalData.Instance.AddInt(key, v);
         } else if (val is float) {
             float v = (float)val;
             GlobalData.Instance.AddFloat(key, v);
         } else {
             string v = val as string;
             if (null == v)
                 v = string.Empty;
             GlobalData.Instance.AddStr(key, v);
         }
     }
     return false;
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     Scene scene = instance.Context as Scene;
     if (null != scene) {
         bool triggered = false;
         Vector3 pos = m_Pos.Value;
         float radius = m_Radius.Value;
         string type = m_Type.Value;
         string eventName = m_EventName.Value;
         if (type == "user") {
             scene.KdTree.Query(pos, radius, (float distSqr, KdTreeObject kdObj) => {
                 if (kdObj.Object.EntityType != (int)EntityTypeEnum.Hero) {
                     scene.StorySystem.SendMessage(eventName, pos, radius, type);
                     triggered = true;
                     return false;
                 }
                 return true;
             });
         } else if (type == "npc") {
             scene.KdTree.Query(pos, radius, (float distSqr, KdTreeObject kdObj) => {
                 if (kdObj.Object.EntityType != (int)EntityTypeEnum.Hero) {
                     scene.StorySystem.SendMessage(eventName, pos, radius, type);
                     triggered = true;
                     return false;
                 }
                 return true;
             });
         }
         string varName = m_SetVar.Value;
         object varVal = m_SetVal.Value;
         object elseVal = m_ElseSetVal.Value;
         if (triggered) {
             instance.SetVariable(varName, varVal);
         } else {
             instance.SetVariable(varName, elseVal);
         }
     }
     return false;
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     string objPath = m_ObjPath.Value;
     object componentType = m_ComponentType.Value;
     UnityEngine.GameObject obj = UnityEngine.GameObject.Find(objPath);
     if (null != obj) {
         UnityEngine.Component component = null;
         Type t = componentType as Type;
         if (null != t) {
             component = obj.AddComponent(t);
         } else {
             string name = componentType as string;
             if (null != name) {
                 t = Type.GetType(name);
                 component = obj.AddComponent(t);
             }
         }
         if (m_HaveObj) {
             string varName = m_ObjVarName.Value;
             instance.SetVariable(varName, component);
         }
     }
     return false;
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     Scene scene = instance.Context as Scene;
     if (null != scene) {
         int sceneId = m_TargetSceneId.Value;
         object idObj = m_ObjId.Value;
         if (idObj is int) {
             int objId = (int)idObj;
             EntityInfo entity = scene.GetEntityById(objId);
             if (null != entity) {
                 User us = entity.CustomData as User;
                 if (null != us) {
                     RoomServer.RoomServer.Instance.PlayerRequestActiveRoom(sceneId, us.Guid);
                 }
             }
         } else {
             IList<int> list = idObj as IList<int>;
             if (null != list) {
                 List<ulong> guids = new List<ulong>();
                 for (int i = 0; i < list.Count; ++i) {
                     EntityInfo entity = scene.GetEntityById(list[i]);
                     if (null != entity) {
                         User us = entity.CustomData as User;
                         if (null != us) {
                             guids.Add(us.Guid);
                         }
                     }
                 }
                 if (guids.Count > 0) {
                     RoomServer.RoomServer.Instance.PlayerRequestActiveRoom(sceneId, guids.ToArray());
                 }
             }
         }
     }
     return false;
 }
 protected override void Evaluate(StoryInstance instance, object iterator, object[] args)
 {
     m_Key.Evaluate(instance, iterator, args);
     m_Type.Evaluate(instance, iterator, args);
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         ulong guid = m_UserGuid.Value;
         int itemId = m_ItemId.Value;
         int itemNum = m_ItemNum.Value;
         UserInfo ui = userThread.GetUserInfo(guid);
         if (null != ui) {
             ui.ItemBag.ReduceItemData(itemId, itemNum);
         }
     }
     return false;
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         ulong guid = m_UserGuid.Value;
         UserInfo ui = userThread.GetUserInfo(guid);
         if (null != ui) {
             ui.IntDatas.Clear();
             ui.FloatDatas.Clear();
             ui.StringDatas.Clear();
         }
     }
     return false;
 }
Ejemplo n.º 34
0
 protected virtual bool ExecCommand(StoryInstance instance, StoryMessageHandler handler, long delta)
 {
     return(false);
 }
 protected override void Evaluate(StoryInstance instance, object iterator, object[] args)
 {
     m_UserGuid.Evaluate(instance, iterator, args);
 }
 private void AddStoryInstance(string storyId, StoryInstance info)
 {
     if (!m_StoryInstancePool.ContainsKey(storyId)) {
         m_StoryInstancePool.Add(storyId, info);
     } else {
         m_StoryInstancePool[storyId] = info;
     }
 }
        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            UserThread userThread = instance.Context as UserThread;
            if (null != userThread) {
                ulong guid = m_UserGuid.Value;
                object id = m_MemberId.Value;
                UserInfo ui = userThread.GetUserInfo(guid);
                if (null != ui) {
                    if (id is ulong) {
                        ulong memberGuid = (ulong)id;
                        MemberInfo mi = ui.MemberInfos.Find(info => info.MemberGuid == memberGuid);
                        if (null != mi) {
                            ui.MemberInfos.Remove(mi);
                        }
                    } else {
                        try {
                            int heroId = (int)id;
                            MemberInfo mi = ui.MemberInfos.Find(info => info.HeroId == heroId);
                            if (null != mi) {
                                ui.MemberInfos.Remove(mi);
                            }
                        } catch {

                        }
                    }
                }
            }
            return false;
        }
 protected override void Evaluate(StoryInstance instance, object iterator, object[] args)
 {
     m_Receiver.Evaluate(instance, iterator, args);
     m_Title.Evaluate(instance, iterator, args);
     m_Content.Evaluate(instance, iterator, args);
     m_Sender.Evaluate(instance, iterator, args);
     m_LevelDemand.Evaluate(instance, iterator, args);
     m_ValidPeriod.Evaluate(instance, iterator, args);
     m_Money.Evaluate(instance, iterator, args);
     m_Gold.Evaluate(instance, iterator, args);
     for (int i = 0; i < m_MailItems.Count; ++i) {
         IStoryValue<int> val = m_MailItems[i];
         val.Evaluate(instance, iterator, args);
     }
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         string key = m_Key.Value;
         string type = m_Type.Value;
         if (type=="int") {
             GlobalData.Instance.RemoveInt(key);
         } else if (type=="float") {
             GlobalData.Instance.RemoveFloat(key);
         } else {
             GlobalData.Instance.RemoveStr(key);
         }
     }
     return false;
 }
Ejemplo n.º 40
0
 protected virtual bool ExecCommand(StoryInstance instance, long delta, object iterator, object[] args)
 {
     return(false);
 }
Ejemplo n.º 41
0
 protected virtual void Evaluate(StoryInstance instance, object iterator, object[] args)
 {
 }
 private void Load(Dsl.DslFile dataFile, int sceneId, string _namespace, string resourceName)
 {
     lock (m_Lock) {
         Dictionary <string, StoryInstance> existStoryInstances;
         if (!m_StoryInstancePool.TryGetValue(resourceName, out existStoryInstances))
         {
             List <Dsl.ISyntaxComponent> cmdOrValList = new List <Dsl.ISyntaxComponent>();
             existStoryInstances = new Dictionary <string, StoryInstance>();
             m_StoryInstancePool.Add(resourceName, existStoryInstances);
             for (int i = 0; i < dataFile.DslInfos.Count; i++)
             {
                 var    comp = dataFile.DslInfos[i];
                 string id   = comp.GetId();
                 if (id == "story" || id == "script")
                 {
                     var funcData = comp as Dsl.FunctionData;
                     if (null != funcData)
                     {
                         Dsl.CallData callData = funcData.Call;
                         if (null != callData && callData.HaveParam())
                         {
                             StoryInstance instance = new StoryInstance();
                             if (!string.IsNullOrEmpty(_namespace))
                             {
                                 instance.Namespace = _namespace;
                             }
                             instance.Init(funcData);
                             string storyId;
                             if (string.IsNullOrEmpty(_namespace))
                             {
                                 storyId = instance.StoryId;
                             }
                             else
                             {
                                 storyId          = string.Format("{0}:{1}", _namespace, instance.StoryId);
                                 instance.StoryId = storyId;
                             }
                             if (!existStoryInstances.ContainsKey(storyId))
                             {
                                 existStoryInstances.Add(storyId, instance);
                             }
                             else
                             {
                                 existStoryInstances[storyId] = instance;
                             }
                             LogSystem.Info("ParseStory {0} {1}", storyId, sceneId);
                         }
                     }
                 }
                 else if (id == "command" || id == "value")
                 {
                     cmdOrValList.Add(comp);
                 }
                 else
                 {
                     LogSystem.Error("[LoadStory] Unknown story keyword '{0}'", id);
                 }
             }
             CustomCommandValueParser.FirstParse(cmdOrValList);
             CustomCommandValueParser.FinalParse(cmdOrValList);
         }
         Dictionary <string, StoryInstance> storyInstances;
         if (!m_StoryInstances.TryGetValue(sceneId, out storyInstances))
         {
             storyInstances = new Dictionary <string, StoryInstance>(existStoryInstances);
             m_StoryInstances.Add(sceneId, storyInstances);
         }
         else
         {
             foreach (var pair in existStoryInstances)
             {
                 if (!storyInstances.ContainsKey(pair.Key))
                 {
                     storyInstances.Add(pair.Key, pair.Value);
                 }
                 else
                 {
                     storyInstances[pair.Key] = pair.Value;
                 }
             }
         }
     }
 }
Ejemplo n.º 43
0
 protected virtual void Evaluate(StoryInstance instance, StoryMessageHandler handler, object iterator, object[] args)
 {
 }
        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            UserThread userThread = instance.Context as UserThread;
            if (null != userThread) {
                ulong guid = m_UserGuid.Value;
                object id = m_ItemId.Value;
                UserInfo ui = userThread.GetUserInfo(guid);
                if (null != ui) {
                    if (id is ulong) {
                        ulong itemGuid = (ulong)id;
                        ui.ItemBag.DelItemData(itemGuid);
                    } else {
                        try {
                            int itemId = (int)id;
                            ui.ItemBag.DelItemData(itemId);
                        } catch {

                        }
                    }
                }
            }
            return false;
        }
Ejemplo n.º 45
0
 protected virtual bool ExecCommand(StoryInstance instance, long delta)
 {
     return(false);
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         ulong guid = m_UserGuid.Value;
         string key = m_Key.Value;
         string type = m_Type.Value;
         UserInfo ui = userThread.GetUserInfo(guid);
         if (null != ui) {
             if (type == "int") {
                 ui.IntDatas.Remove(key);
             } else if (type == "float") {
                 ui.FloatDatas.Remove(key);
             } else {
                 ui.StringDatas.Remove(key);
             }
         }
     }
     return false;
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         ulong guid = m_UserGuid.Value;
         int linkId = m_LinkId.Value;
         int level = m_Level.Value;
         UserInfo ui = userThread.GetUserInfo(guid);
         if (null != ui) {
             MemberInfo mi = new MemberInfo();
             mi.MemberGuid = UserServer.Instance.GlobalProcessThread.GenerateMemberGuid();
             mi.HeroId = linkId;
             mi.Level = level;
             ui.MemberInfos.Add(mi);
         }
     }
     return false;
 }
        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            UserThread userThread = instance.Context as UserThread;
            if (null != userThread) {
                ulong receiver = m_Receiver.Value;
                string title = m_Title.Value;
                string content = m_Content.Value;
                string sender = m_Sender.Value;
                int levelDemand = m_LevelDemand.Value;
                int validPeriod = m_ValidPeriod.Value;
                int money = m_Money.Value;
                int gold = m_Gold.Value;

                MailInfo mailInfo = new MailInfo();
                mailInfo.m_Receiver = receiver;
                mailInfo.m_Title = title;
                mailInfo.m_Text = content;
                mailInfo.m_Sender = sender;
                mailInfo.m_Money = money;
                mailInfo.m_Gold = gold;
                mailInfo.m_LevelDemand = levelDemand;

                for (int i = 0; i < m_MailItems.Count - 1; i += 2) {
                    int itemId = m_MailItems[i].Value;
                    int itemNum = m_MailItems[i + 1].Value;

                    MailItem mailItem = new MailItem();
                    mailItem.m_ItemId = itemId;
                    mailItem.m_ItemNum = itemNum;
                    mailInfo.m_Items.Add(mailItem);
                }
                GlobalProcessThread globalProcess = UserServer.Instance.GlobalProcessThread;
                if (receiver > 0) {
                    globalProcess.QueueAction(globalProcess.SendUserMail, mailInfo, validPeriod);
                } else {
                    globalProcess.QueueAction(globalProcess.SendWholeMail, mailInfo, validPeriod);
                }
            }
            return false;
        }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         ulong guid = m_UserGuid.Value;
         string key = m_Key.Value;
         object val = m_Value.Value;
         UserInfo ui = userThread.GetUserInfo(guid);
         if (null != ui) {
             if (val is int) {
                 int v = (int)val;
                 if (ui.IntDatas.ContainsKey(key))
                     ui.IntDatas[key] = v;
                 else
                     ui.IntDatas.Add(key, v);
             } else if (val is float) {
                 float v = (float)val;
                 if (ui.FloatDatas.ContainsKey(key))
                     ui.FloatDatas[key] = v;
                 else
                     ui.FloatDatas.Add(key, v);
             } else {
                 string v = val as string;
                 if (null == v)
                     v = string.Empty;
                 if (ui.StringDatas.ContainsKey(key))
                     ui.StringDatas[key] = v;
                 else
                     ui.StringDatas.Add(key, v);
             }
         }
     }
     return false;
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         ulong guid = m_UserGuid.Value;
         userThread.SyncItems(guid);
     }
     return false;
 }
 protected override void Evaluate(StoryInstance instance, object iterator, object[] args)
 {
 }
 public void Evaluate(StoryInstance instance, StoryMessageHandler handler, object iterator, object[] args)
 {
 }
 protected override bool ExecCommand(StoryInstance instance, long delta)
 {
     UserThread userThread = instance.Context as UserThread;
     if (null != userThread) {
         GlobalData.Instance.Clear();
     }
     return false;
 }