Пример #1
0
        public void RunAreaLuaFile(GameMap gameMap, int areaLuaID, string functionName)
        {
            GAreaLua areaLua = gameMap.GetAreaLuaByID(areaLuaID);

            if (null != areaLua)
            {
                string fileName = areaLua.LuaScriptFileName;
                if (!string.IsNullOrEmpty(fileName))
                {
                    ProcessAreaScripts.ProcessScripts(this, fileName, functionName, areaLuaID);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 执行区域脚本
        /// </summary>
        /// <param name="areaLuaID"></param>
        /// <param name="functionName"></param>
        private void RunAreaLuaFile(GameMap gameMap, int areaLuaID, string functionName)
        {
            GAreaLua areaLua = gameMap.GetAreaLuaByID(areaLuaID);

            if (null == areaLua)
            {
                return;
            }

            string fileName = areaLua.LuaScriptFileName;

            if (!string.IsNullOrEmpty(fileName))
            {
                /*string luaFileName = Global.GetAreaLuaScriptFile(fileName);
                 * if (!string.IsNullOrEmpty(luaFileName))
                 * {
                 *  ////执行对话脚本
                 *  Global.ExcuteLuaFunction(this, luaFileName, functionName, null, null);
                 * }*/

                ProcessAreaScripts.ProcessScripts(this, fileName, functionName);
            }
        }
Пример #3
0
        public void RunAreaLuaFile(GameMap gameMap, RunAreaLuaType runAreaLuaType, List <int> areaLuaIDList, string functionName, int taskId = 0)
        {
            List <GAreaLua> GAreaLuaList = null;

            if (RunAreaLuaType.SelfPoint == runAreaLuaType)
            {
                int newGridX = this._ClientData.PosX / gameMap.MapGridWidth;
                int newGridY = this._ClientData.PosY / gameMap.MapGridHeight;
                GAreaLuaList = gameMap.GetAreaLuaListByPoint(new Point((double)newGridX, (double)newGridY));
            }
            else if (RunAreaLuaType.AreaLuaIDList == runAreaLuaType)
            {
                if (areaLuaIDList == null || areaLuaIDList.Count == 0)
                {
                    return;
                }
                foreach (int areaLuaID in areaLuaIDList)
                {
                    GAreaLua areaLua = gameMap.GetAreaLuaByID(areaLuaID);
                    if (areaLua != null)
                    {
                        if (GAreaLuaList == null)
                        {
                            GAreaLuaList = new List <GAreaLua>();
                        }
                        GAreaLuaList.Add(areaLua);
                    }
                }
            }
            if (GAreaLuaList != null)
            {
                using (List <GAreaLua> .Enumerator enumerator2 = GAreaLuaList.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        GAreaLua areaLuaEv = enumerator2.Current;
                        bool     isTrigger = false;
                        if (areaLuaEv.AddtionType != AddtionType.NowTrigger)
                        {
                            switch (areaLuaEv.AddtionType)
                            {
                            case AddtionType.AccessTask:
                            {
                                TaskData taskData;
                                lock (this.ClientData.TaskDataList)
                                {
                                    taskData = this.ClientData.TaskDataList.Find((TaskData x) => x.DoingTaskID == areaLuaEv.TaskId);
                                    if (taskData == null)
                                    {
                                        break;
                                    }
                                }
                                SystemXmlItem systemTask = null;
                                if (GameManager.SystemTasksMgr.SystemXmlItemDict.TryGetValue(areaLuaEv.TaskId, out systemTask))
                                {
                                    if (taskData.DoingTaskVal1 < systemTask.GetIntValue(string.Format("TargetNum1", new object[0]), -1) || taskData.DoingTaskVal2 < systemTask.GetIntValue(string.Format("TargetNum2", new object[0]), -1))
                                    {
                                        isTrigger = true;
                                    }
                                }
                                break;
                            }

                            case AddtionType.FinishTask:
                            {
                                TaskData taskData;
                                lock (this.ClientData.TaskDataList)
                                {
                                    taskData = this.ClientData.TaskDataList.Find((TaskData x) => x.DoingTaskID == areaLuaEv.TaskId);
                                    if (taskData == null)
                                    {
                                        break;
                                    }
                                }
                                if (Global.JugeTaskComplete(this, areaLuaEv.TaskId, taskData.DoingTaskVal1, taskData.DoingTaskVal2))
                                {
                                    isTrigger = true;
                                }
                                break;
                            }

                            case AddtionType.BackTask:
                                if (taskId != 0)
                                {
                                    if (areaLuaEv.TaskId == taskId)
                                    {
                                        isTrigger = true;
                                    }
                                }
                                break;

                            case AddtionType.NewMainTask:
                                if (functionName == "takeNewMainTask" && taskId == areaLuaEv.TaskId)
                                {
                                    isTrigger = true;
                                }
                                break;
                            }
                            if (!isTrigger)
                            {
                                continue;
                            }
                        }
                        foreach (KeyValuePair <AreaEventType, List <int> > areaEvent in areaLuaEv.AreaEventDict)
                        {
                            if (areaEvent.Key == AreaEventType.FinishTask)
                            {
                                int           eventTaskId = areaEvent.Value[0];
                                TaskData      taskData    = this.ClientData.TaskDataList.Find((TaskData x) => x.DoingTaskID == eventTaskId);
                                SystemXmlItem systemTask  = null;
                                if (GameManager.SystemTasksMgr.SystemXmlItemDict.TryGetValue(eventTaskId, out systemTask))
                                {
                                    if (taskData.DoingTaskVal1 < systemTask.GetIntValue("TargetNum1", -1))
                                    {
                                        taskData.DoingTaskVal1 = systemTask.GetIntValue("TargetNum1", -1);
                                    }
                                    if (taskData.DoingTaskVal2 < systemTask.GetIntValue("TargetNum2", -1))
                                    {
                                        taskData.DoingTaskVal2 = systemTask.GetIntValue("TargetNum2", -1);
                                    }
                                    GameManager.DBCmdMgr.AddDBCmd(10007, string.Format("{0}:{1}:{2}:{3}:{4}:{5}", new object[]
                                    {
                                        this.ClientData.RoleID,
                                        taskData.DoingTaskID,
                                        taskData.DbID,
                                        taskData.DoingTaskFocus,
                                        taskData.DoingTaskVal1,
                                        taskData.DoingTaskVal2
                                    }), null, this.ServerId);
                                    GameManager.ClientMgr.NotifyUpdateTask(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, this, taskData.DbID, taskData.DoingTaskID, taskData.DoingTaskVal1, taskData.DoingTaskVal2, taskData.DoingTaskFocus, taskData.ChengJiuVal);
                                    int destNPC = systemTask.GetIntValue("DestNPC", -1);
                                    if (-1 != destNPC)
                                    {
                                        int state = Global.ComputeNPCTaskState(this, this.ClientData.TaskDataList, destNPC, 0);
                                        GameManager.ClientMgr.NotifyUpdateNPCTaskSate(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, this, destNPC + 2130706432, state);
                                    }
                                    ProcessTask.CheckAutoCompleteTask(this);
                                }
                            }
                            else if (areaEvent.Key == AreaEventType.CallMonsters && functionName == "enterArea")
                            {
                                int monsterID = areaEvent.Value[0];
                                Global.SystemKillSummonMonster(this, MonsterTypes.AreaCallMonster);
                                GameManager.LuaMgr.CallMonstersForGameClient(this, monsterID, 1, 0, 1002, 1);
                            }
                            else if (areaEvent.Key == AreaEventType.RemoveMonsters && functionName == "enterArea")
                            {
                                int monsterid = areaEvent.Value[0];
                                Global.SystemKillSummonMonster(this, monsterid);
                            }
                            else
                            {
                                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    (int)areaEvent.Key,
                                    areaEvent.Value[0],
                                    areaLuaEv.CenterPoint.X,
                                    areaLuaEv.CenterPoint.Y
                                });
                                this.sendCmd(3000, strCmd, false);
                            }
                        }
                        string fileName = areaLuaEv.LuaScriptFileName;
                        if (!string.IsNullOrEmpty(fileName))
                        {
                            ProcessAreaScripts.ProcessScripts(this, fileName, functionName, areaLuaEv.ID);
                        }
                    }
                }
            }
        }