Esempio n. 1
0
        public TaskTemplate GetTask(int id)
        {
            TaskTemplate task = new TaskTemplate();

            task.task_id = id;
            int index = System.Array.BinarySearch <TaskTemplate>(mTasks, task, TaskTemplate.Comparer);

            if (index >= 0)
            {
                return(mTasks[index]);
            }
            else
            {
                EB.Debug.LogWarning("GetTask: task not found, id = {0}", id);
                return(null);
            }
        }
Esempio n. 2
0
        private TaskTemplate ParseTask(GM.DataCache.TaskInfo obj)
        {
            TaskTemplate tpl = new TaskTemplate();

            tpl.task_id = int.Parse(obj.TaskId);
            using (ZString.Block())
            {
                ZString strID = ZString.Format("ID_task_tasks_{0}_task_name", tpl.task_id);
                tpl.task_name = EB.Localizer.GetTableString(strID, obj.TaskName);;                 //tpl.TaskName;

                strID           = ZString.Format("ID_task_tasks_{0}_target_tips", tpl.task_id);
                tpl.target_tips = EB.Localizer.GetTableString(strID, obj.TargetTips);;                 //tpl.TargetTips;
            };
            tpl.scene_id           = obj.SceneId;
            tpl.npc_id             = obj.NpcId;
            tpl.tips               = obj.Tips;
            tpl.commit_scene_id    = obj.CommitSceneId;
            tpl.commit_npc_id      = obj.CommitNpcId;
            tpl.task_type          = obj.TaskType;
            tpl.target_type        = obj.TargetType;
            tpl.target_parameter_1 = obj.TargetParameter1;
            tpl.target_parameter_2 = obj.TargetParameter2;
            tpl.target_parameter_3 = obj.TargetParameter3;
            tpl.xp = new int[obj.XpLength];
            for (int i = 0; i < obj.XpLength; ++i)
            {
                tpl.xp[i] = obj.GetXp(i);
            }
            tpl.gold = new int[obj.GoldLength];
            for (int i = 0; i < obj.GoldLength; ++i)
            {
                tpl.gold[i] = obj.GetGold(i);
            }
            tpl.hc        = obj.Hc;
            tpl.res_type  = obj.ResType;
            tpl.res_count = obj.ResCount;

            tpl.rewards = new ResourceContainer();
            do
            {
                int id = 0, amount = 0;

                int.TryParse(obj.Reward1, out id);
                amount = obj.Count1;
                if (id <= 0 || amount <= 0)
                {
                    break;
                }
                if (tpl.rewards.Items.ContainsKey(id))
                {
                    EB.Debug.LogError("ParseTask: reward {0} exists");
                    tpl.rewards.Items.Remove(id);
                }
                tpl.rewards.Items.Add(id, amount);

                int.TryParse(obj.Reward2, out id);
                amount = obj.Count2;
                if (id <= 0 || amount <= 0)
                {
                    break;
                }
                if (tpl.rewards.Items.ContainsKey(id))
                {
                    EB.Debug.LogError("ParseTask: reward {0} exists");
                    tpl.rewards.Items.Remove(id);
                }
                tpl.rewards.Items.Add(id, amount);

                int.TryParse(obj.Reward3, out id);
                amount = obj.Count3;
                if (id <= 0 || amount <= 0)
                {
                    break;
                }
                if (tpl.rewards.Items.ContainsKey(id))
                {
                    EB.Debug.LogError("ParseTask: reward {0} exists");
                    tpl.rewards.Items.Remove(id);
                }
                tpl.rewards.Items.Add(id, amount);
            } while (false);

            int.TryParse(obj.HeroShard, out tpl.hero_shard);
            tpl.shard_count = obj.ShardCount;
            //tpl.accept_dialogue = obj.AcceptDialogue;
            //tpl.complete_dialogue = obj.CompleteDialogue;
            tpl.achievement_point = obj.AchievementPoint;
            tpl.activity_point    = obj.ActivityPoint;
            tpl.function_limit    = obj.FunctionLimit;
            return(tpl);
        }