コード例 #1
0
ファイル: Task.cs プロジェクト: KangLLL/century_war
 public void OpenChildrenTask()
 {
     foreach (int childID in this.TaskConfigData.Children)
     {
         TaskInformation info = new TaskInformation();
         info.Status = TaskStatus.Opened;
         info.TaskID = childID;
         info.ConditionProgresses = new Dictionary <int, TaskProgressInformation>();
         TaskConfigData configData = ConfigInterface.Instance.TaskConfigHelper.GetTaskData(childID);
         if (configData.ValidSeconds > 0)
         {
             info.RemainingSeconds = configData.ValidSeconds;
         }
         foreach (KeyValuePair <int, TaskConditionConfigData> condition in configData.Conditions)
         {
             if (!condition.Value.IsGlobal)
             {
                 info.ConditionProgresses.Add(condition.Key, new TaskProgressInformation()
                 {
                     StartValue = TaskProgressFactory.GetCurrentValueFromConfig(condition.Value)
                 });
             }
         }
         TaskProgressFactory.PopulateTaskInformation(info);
         Task childTask = new Task(info, this.m_Manager);
         LogicController.Instance.TaskManager.AddTask(childTask);
     }
 }
コード例 #2
0
    public static void PopulateTaskInformation(TaskInformation information)
    {
        if (information.Status == TaskStatus.Completed)
        {
            return;
        }
        else
        {
            TaskConfigData taskData = ConfigInterface.Instance.TaskConfigHelper.GetTaskData(information.TaskID);

            foreach (KeyValuePair <int, TaskConditionConfigData> condition in taskData.Conditions)
            {
                if (information.ConditionProgresses == null)
                {
                    information.ConditionProgresses = new Dictionary <int, TaskProgressInformation>();
                }
                if (!information.ConditionProgresses.ContainsKey(condition.Key))
                {
                    information.ConditionProgresses.Add(condition.Key, new TaskProgressInformation()
                    {
                        StartValue = 0, CurrentValue = GetCurrentValueFromConfig(condition.Value)
                    });
                }
                else
                {
                    information.ConditionProgresses[condition.Key].CurrentValue = GetCurrentValueFromConfig(condition.Value);
                }
            }
        }
    }
コード例 #3
0
ファイル: Objectiver.cs プロジェクト: chengyimingvb/CYMUni
        //添加任务配置
        protected void AddConfig(TEnum type, TaskConfigData config)
        {
            int enumIndex = Enum <TEnum> .Int(type);

            if (ConfigData.ContainsKey(enumIndex))
            {
                CLog.Error("错误!重复AddConfig:{0}", type.ToString());
                return;
            }
            ConfigData.Add(enumIndex, config);
        }
コード例 #4
0
    public void AwardTask(Task task)
    {
        int            taskID     = task.TaskID;
        TaskConfigData configData = ConfigInterface.Instance.TaskConfigHelper.GetTaskData(taskID);

        this.RewardResource(configData.RewardGold, configData.RewardFood, configData.RewardOil, configData.RewardGem, configData.RewardExp);

        AwardTaskRequestParameter request = new AwardTaskRequestParameter();

        request.TaskID      = taskID;
        request.OperateTick = LogicTimer.Instance.GetServerTick();
        CommunicationUtility.Instance.AwardTask(request);

        this.m_TaskModule.AwardTask(task);
    }
コード例 #5
0
    private static void TaskConfigPostprocess()
    {
        string     path = System.IO.Path.Combine(RESOURCE_TASK_CONFIG_FOLDER, "TaskConfig.xml");
        TextReader tr   = new StreamReader(path);
        string     text = tr.ReadToEnd();

        if (text == null)
        {
            Debug.LogError("newbie guide config file not exist");
            return;
        }
        else
        {
            XmlSpreadSheetReader.ReadSheet(text);
            XmlSpreadSheet sheet = XmlSpreadSheetReader.Output;
            string[]       keys  = XmlSpreadSheetReader.Keys;

            object[] levelIds = sheet[keys[0]];

            List <TaskConfigData> tempList = new List <TaskConfigData>();

            for (int i = 0; i < levelIds.Length; i++)
            {
                if (0 == i || 1 == i)
                {
                    continue;
                }
                TaskConfigData data = new TaskConfigData();
                data._TaskID    = Convert.ToInt32(sheet["TaskID"][i]);
                data._TaskTitle = Convert.ToString(sheet["TaskTitle"][i]);
                data._TaskType  = Convert.ToInt32(sheet["TaskType"][i]);
                data._TaskDesc  = Convert.ToString(sheet["TaskDescription"][i]);
                data._TaskGoals = Convert.ToString(sheet["TaskGoals"][i]);
                data._AwardType = Convert.ToInt32(sheet["AwardType"][i]);
                string[] awardItemListStr = Convert.ToString(sheet["AwardItem"][i]).Split('|');
                data._AwardItemList = new AwardItem[awardItemListStr.Length];
                for (int k = 0; k < awardItemListStr.Length; k++)
                {
                    string[] awardItemStr = Convert.ToString(awardItemListStr[k]).Split('+');
                    if (awardItemStr.Length == 3)
                    {
                        data._AwardItemList[k]           = new AwardItem();
                        data._AwardItemList[k]._Vocation = Convert.ToInt32(awardItemStr[0]);
                        data._AwardItemList[k]._PropID   = Convert.ToInt32(awardItemStr[1]);
                        data._AwardItemList[k]._PropNum  = Convert.ToInt32(awardItemStr[2]);
                    }
                }

                string[] awardMoneyStr = Convert.ToString(sheet["AwardMoney"][i]).Split('+');
                if (awardMoneyStr.Length == 2)
                {
                    data._AwardMoney = Convert.ToInt32(awardMoneyStr[1]);
                }

                string[] awardExpStr = Convert.ToString(sheet["AwardExp"][i]).Split('+');
                if (awardExpStr.Length == 2)
                {
                    data._AwardExp = Convert.ToInt32(awardExpStr[1]);
                }
                data._AwardActive = Convert.ToInt32(sheet["AwardActive"][i]);
                data._AwardXiuWei = Convert.ToInt32(sheet["AwardXiuwei"][i]);
                data._GuideType   = Convert.ToInt32(sheet["GuideType"][i]);
                string[] townGuideStr = Convert.ToString(sheet["GuideGroup"][i]).Split('+');
                data._TownGuideList = new int[townGuideStr.Length];
                for (int k = 0; k < townGuideStr.Length; k++)
                {
                    data._TownGuideList[k] = Convert.ToInt32(townGuideStr[k]);
                }


                data._CloseUI          = Convert.ToInt32(sheet["CloseUI"][i]);
                data._IsEnableLvTips   = Convert.ToBoolean(sheet["FunctionTips"][i]);
                data._EnableLevel      = Convert.ToInt32(sheet["FunctionOpenLevel"][i]);
                data._FunctionIconName = Convert.ToString(sheet["FunctionIcon"][i]);
                data._FunctionName     = Convert.ToString(sheet["FunctionName"][i]);
                data._NewFunDelayTime  = Convert.ToInt32(sheet["DelayTime"][i]);

                tempList.Add(data);
            }

            CreateTaskConfigDataBase(tempList);
        }
    }
コード例 #6
0
        void CreateRole(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters)
        {
            Dictionary <byte, object> m_dic = request.Parameters;
            object value;

            response.ReturnCode = (short)ReturnCode.Fail;
            if (m_dic.TryGetValue((byte)ParameterCode.RoleInfo, out value))
            {
                //只需要传送:名称 + 性别 + 用户ID + 服务器ID
                Helper.Log("RoleHandler Create Role:" + value.ToString());
                string[] p = value.ToString().Split(',');
                if (p.Length == 4)
                {
                    RoleData newRole = new RoleData();
                    newRole.Name = p[0];
                    newRole.Lv   = 1;
                    bool   bMan     = true;
                    string strOccup = "Man";
                    if (p[1].Equals("0"))
                    {
                        bMan     = false;
                        strOccup = "Girl";
                    }
                    newRole.IsMan = bMan;
                    newRole.Occup = strOccup;

                    Helper.Log("当前服务器ID:" + p[3]);
                    int nServerId = Helper.IntParse(p[3]);
                    List <ServerProperty> pServer = m_serverMgr.GetServerByID(Helper.IntParse(p[3]));
                    if (pServer == null || pServer.Count < 1)
                    {
                        Helper.Log("获取服务器失败!");
                        response.ReturnCode = (short)ReturnCode.Fail;
                        return;
                    }

                    newRole.Server = pServer[0];

                    List <UserLoginData> pUser = m_userMgr.GetUserByID(Helper.IntParse(p[2]));
                    Helper.Log("当前用户ID:" + p[2]);
                    if (pUser == null || pUser.Count < 1)
                    {
                        Helper.Log("获取用户失败!");
                        response.ReturnCode = (short)ReturnCode.Fail;
                        return;
                    }

                    // 同一服务器一个名称只能存在一个角色
                    List <RoleData> pRoleData = m_mgr.GetServerRole(nServerId);
                    if (pRoleData != null)
                    {
                        for (int i = 0; i < pRoleData.Count; ++i)
                        {
                            RoleData curRole = pRoleData[i];
                            if (curRole.Name == newRole.Name)
                            {
                                Helper.Log("获取用户失败!");
                                response.ReturnCode   = (short)ReturnCode.Fail;
                                response.DebugMessage = "用户名已经存在,请重新输入!";
                                return;
                            }
                        }
                    }

                    newRole.User = pUser[0];
                    m_mgr.SaveRole(newRole);

                    // 为新角色创建:roleinfo,goodslist、task、skill表
                    RoleInfoData newInforData = new RoleInfoData();
                    newInforData.Role    = newRole;
                    newInforData.Exp     = 0;
                    newInforData.Gold    = 100;
                    newInforData.Gem     = 100;
                    newInforData.Energy  = 80;
                    newInforData.Toughen = 40;
                    m_roleinfoMgr.AddRoleInfo(newInforData);

                    GoodsData newGoodsList = new GoodsData();
                    newGoodsList.Role    = newRole;
                    newGoodsList.GoodsID = 1018;
                    newGoodsList.Num     = 10;
                    newGoodsList.Lv      = 1;
                    newGoodsList.Drs     = 0;
                    m_goodsListMgr.AddGoodsList(newGoodsList);

                    // 任务表读XML配置把
                    string          strBinaryPath = MyGameApplication.MyInstance.m_strBinaryPath;
                    string          strTaskPath   = (Path.Combine(strBinaryPath, "TaskConfig.xml"));
                    TaskConfigData  taskdata      = Helper.LoadXML <TaskConfigData>(strTaskPath);
                    List <TaskItem> m_pTask;
                    if (taskdata != null)
                    {
                        m_pTask = taskdata.m_task.m_pTaskList;
                        for (int i = 0; i < m_pTask.Count; ++i)
                        {
                            TaskData newTask = new TaskData();
                            newTask.TaskID         = m_pTask[i].ID;
                            newTask.TaskPro        = 0;
                            newTask.TaskType       = m_pTask[i].Type;
                            newTask.Role           = newRole;
                            newTask.LastupdateTime = DateTime.Now.ToShortDateString();
                            m_taskMgr.AddTask(newTask);
                        }
                    }

                    // 技能配置
                    strTaskPath = (Path.Combine(strBinaryPath, "SkillConfig.xml"));
                    SkillConfigData  data = Helper.LoadXML <SkillConfigData>(strTaskPath);
                    List <RoleSkill> pSkillData;
                    if (data != null)
                    {
                        pSkillData = data.m_pSkillList;
                        RoleSkill skill = null;
                        for (int i = 0; i < pSkillData.Count; ++i)
                        {
                            if (pSkillData[i].Sex == 1 && newRole.IsMan)
                            {
                                skill = pSkillData[i];
                                break;
                            }
                            else if (pSkillData[i].Sex == 0 && !newRole.IsMan)
                            {
                                skill = pSkillData[i];
                                break;
                            }
                        }
                        List <int> m_pSkillID = new List <int>();
                        m_pSkillID.Add(skill.SkillBase);
                        m_pSkillID.Add(skill.SkillOne);
                        m_pSkillID.Add(skill.SkillTwo);
                        m_pSkillID.Add(skill.SkillThere);
                        for (int i = 0; i < 4; ++i)
                        {
                            SkillData newSkill = new SkillData();
                            newSkill.Lv  = 1;
                            newSkill.Pos = i;

                            newSkill.SkillID = m_pSkillID[i];
                            newSkill.Role    = newRole;
                            m_skillMgr.AddSkill(newSkill);
                        }
                    }

                    // 保存当前选择的角色
                    List <RoleData> pChooseRole = m_mgr.GetRoleByName(newRole.Name, newRole.Server.ID);
                    if (pChooseRole != null && pChooseRole.Count == 1)
                    {
                        peer.m_curRole = pChooseRole[0];
                        Helper.Log("当前选择角色:" + peer.m_curRole.Name);
                    }

                    // 返回角色列表
                    List <RoleData> pData = m_mgr.GetUserRole(newRole.User.Id, newRole.Server.ID);
                    // 获取角色列表时候,第一个角色就是默认角色
                    string strRes = "";
                    for (int i = 0; i < pData.Count; ++i)
                    {
                        RoleData curRole = pData[i];
                        strRes += curRole.Id + "," + curRole.Name + "," + curRole.Lv + "," + curRole.IsMan + "," + curRole.Occup + "," + curRole.User.Id + "," + curRole.Server.ID + "|";
                    }
                    Dictionary <byte, object> dic = new Dictionary <byte, object>();
                    dic.Add((byte)ParameterCode.RoleInfo, strRes);
                    response.Parameters = dic;

                    response.ReturnCode = (short)ReturnCode.Success;
                    Helper.Log("RoleHandler Create Role Success");
                    return;
                }
            }
            response.ReturnCode = (short)ReturnCode.Fail;
            return;
        }