From 9f6126e88f9c3a55736ab34f25a32656bb472307 Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期三, 15 五月 2019 17:47:06 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts

---
 System/MainInterfacePanel/TaskFeedbackModel.cs |  106 ++++++++++++++++++++++++++++-------------------------
 1 files changed, 56 insertions(+), 50 deletions(-)

diff --git a/System/MainInterfacePanel/TaskFeedbackModel.cs b/System/MainInterfacePanel/TaskFeedbackModel.cs
index 2e62b74..7d63a9b 100644
--- a/System/MainInterfacePanel/TaskFeedbackModel.cs
+++ b/System/MainInterfacePanel/TaskFeedbackModel.cs
@@ -38,14 +38,10 @@
 
                 switch (feedback.type)
                 {
-                    case TaskFeedbackType.FightPower:
-                    case TaskFeedbackType.ReikiPoint:
-                    case TaskFeedbackType.Copper:
-                        feedback.condition = int.Parse(config.condition);
-                        break;
                     case TaskFeedbackType.SideTask:
+                    case TaskFeedbackType.FightPowerSideTask:
                         {
-                            var array = LitJson.JsonMapper.ToObject<int[][]>(config.condition);
+                            var array = LitJson.JsonMapper.ToObject<int[][]>(config.sideTasks);
                             if (array != null)
                             {
                                 List<int[]> sideTasks = new List<int[]>(array.Length);
@@ -59,29 +55,13 @@
                         break;
                     case TaskFeedbackType.Equip:
                         {
-                            var array = ConfigParse.GetMultipleStr<int>(config.condition);
+                            var array = LitJson.JsonMapper.ToObject<int[]>(config.equips);
                             feedback.equipCondition = array;
-                        }
-                        break;
-                    case TaskFeedbackType.FightPowerSideTask:
-                        {
-                            var stringArray = config.condition.Split('|');
-                            feedback.condition = int.Parse(stringArray[0]);
-                            var array = LitJson.JsonMapper.ToObject<int[][]>(stringArray[1]);
-                            if (array != null)
-                            {
-                                List<int[]> sideTasks = new List<int[]>(array.Length);
-                                for (int i = 0; i < array.Length; i++)
-                                {
-                                    sideTasks.Add(array[i]);
-                                }
-                                feedback.sideTasks = sideTasks;
-                            }
                         }
                         break;
                     case TaskFeedbackType.ItemCount:
                         {
-                            var array = LitJson.JsonMapper.ToObject<int[][]>(config.condition);
+                            var array = LitJson.JsonMapper.ToObject<int[][]>(config.items);
                             if (array != null)
                             {
                                 List<Item> items = new List<Item>();
@@ -126,9 +106,10 @@
                             int condition = 0;
                             if (IsSatisfyCondition(feedback, out condition))
                             {
-                                if (config.succGuide != 0)
+                                if (config.succGuide != null
+                                    && config.succGuide.Length > 0)
                                 {
-                                    ExecuteGuide(config.succGuide);
+                                    ExecuteGuide(config.succGuide[0]);
                                 }
                             }
                             else
@@ -137,9 +118,10 @@
                                 {
                                     SysNotifyMgr.Instance.ShowTip(config.remind);
                                 }
-                                if (config.failGuide != 0)
+                                if (config.failGuide != null
+                                    && config.failGuide.Length > 0)
                                 {
-                                    ExecuteGuide(config.succGuide);
+                                    ExecuteGuide(config.failGuide[0]);
                                 }
                             }
                         }
@@ -149,21 +131,23 @@
                             int condition = 0;
                             if (IsSatisfyCondition(feedback, out condition))
                             {
-                                if (config.succGuide != 0)
+                                if (config.succGuide != null
+                                    && config.succGuide.Length > 0)
                                 {
-                                    ExecuteGuide(config.succGuide);
+                                    ExecuteGuide(config.succGuide[0]);
                                 }
                             }
                             else
                             {
-                                var sideFeedbackConfig = TaskFeedbackConfig.Get(condition);
-                                if (!string.IsNullOrEmpty(sideFeedbackConfig.remind))
+                                if (!string.IsNullOrEmpty(config.remind))
                                 {
-                                    SysNotifyMgr.Instance.ShowTip(sideFeedbackConfig.remind);
+                                    SysNotifyMgr.Instance.ShowTip(config.remind);
                                 }
-                                if (sideFeedbackConfig != null && sideFeedbackConfig.failGuide != 0)
+                                var index = feedback.IndexOfSideTasks(condition);
+                                if (config.failGuide != null
+                                    && index >= 0 && index < config.failGuide.Length)
                                 {
-                                    ExecuteGuide(sideFeedbackConfig.failGuide);
+                                    ExecuteGuide(config.failGuide[index]);
                                 }
                             }
                         }
@@ -173,23 +157,25 @@
                             int condition = 0;
                             if (IsSatisfyCondition(feedback, out condition))
                             {
-                                if (config.succGuide != 0)
+                                if (config.succGuide != null
+                                    && config.succGuide.Length > 0)
                                 {
-                                    ExecuteGuide(config.succGuide);
+                                    ExecuteGuide(config.succGuide[0]);
                                 }
                             }
                             else
                             {
+                                if (!string.IsNullOrEmpty(config.remind))
+                                {
+                                    SysNotifyMgr.Instance.ShowTip(config.remind);
+                                }
                                 if (!IsSatisfySideTask(feedback.sideTasks, out condition))
                                 {
-                                    var sideFeedbackConfig = TaskFeedbackConfig.Get(condition);
-                                    if (!string.IsNullOrEmpty(sideFeedbackConfig.remind))
+                                    var index = feedback.IndexOfSideTasks(condition);
+                                    if (config.failGuide != null
+                                        && index >= 0 && index < config.failGuide.Length)
                                     {
-                                        SysNotifyMgr.Instance.ShowTip(sideFeedbackConfig.remind);
-                                    }
-                                    if (sideFeedbackConfig != null && sideFeedbackConfig.failGuide != 0)
-                                    {
-                                        ExecuteGuide(sideFeedbackConfig.failGuide);
+                                        ExecuteGuide(config.failGuide[index]);
                                     }
                                 }
                             }
@@ -201,6 +187,10 @@
 
         public void ExecuteGuide(int id)
         {
+            if (id == 0)
+            {
+                return;
+            }
             var config = GuideConfig.Get(id);
             if (config == null)
             {
@@ -220,15 +210,16 @@
 
         public bool IsSatisfyCondition(TaskFeedback feedback, out int condition)
         {
-            condition = feedback.condition;
+            var config = TaskFeedbackConfig.Get(feedback.taskId);
+            condition = 0;
             switch (feedback.type)
             {
                 case TaskFeedbackType.FightPower:
-                    return PlayerDatas.Instance.baseData.FightPoint >= feedback.condition;
+                    return PlayerDatas.Instance.baseData.FightPoint >= config.condition;
                 case TaskFeedbackType.SideTask:
                     return IsSatisfySideTask(feedback.sideTasks, out condition);
                 case TaskFeedbackType.ReikiPoint:
-                    return reikiRootModel.GetReikiRootTotalPoint() >= feedback.condition;
+                    return reikiRootModel.GetReikiRootTotalPoint() >= config.condition;
                 case TaskFeedbackType.Equip:
                     {
                         var items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams()
@@ -241,11 +232,11 @@
                         return items != null && items.Count > 0;
                     }
                 case TaskFeedbackType.Copper:
-                    return PlayerDatas.Instance.baseData.allCopper >= (ulong)feedback.condition;
+                    return PlayerDatas.Instance.baseData.allCopper >= (ulong)config.condition;
                 case TaskFeedbackType.Guide:
                     return true;
                 case TaskFeedbackType.FightPowerSideTask:
-                    return PlayerDatas.Instance.baseData.FightPoint >= feedback.condition;
+                    return PlayerDatas.Instance.baseData.FightPoint >= config.condition;
                 case TaskFeedbackType.ItemCount:
                     {
                         if (feedback.items != null)
@@ -287,10 +278,25 @@
     {
         public int taskId;
         public TaskFeedbackType type;
-        public int condition;
         public List<int[]> sideTasks;
         public int[] equipCondition;
         public List<Item> items;
+
+        public int IndexOfSideTasks(int taskId)
+        {
+            var index = 0;
+            for (int i = 0; i < sideTasks.Count; i++)
+            {
+                if (taskId >= sideTasks[i][0]
+                   && taskId <= sideTasks[i][1])
+                {
+                    index += taskId - sideTasks[i][0];
+                    break;
+                }
+                index += (sideTasks[i][1] - sideTasks[i][0] + 1);
+            }
+            return index;
+        }
     }
 
     public enum TaskFeedbackType

--
Gitblit v1.8.0