浏览代码

田野调查

zhaoyang 3 年之前
父节点
当前提交
784786c1cb

+ 84 - 21
GameClient/Assets/Game/HotUpdate/Data/FieldDataManager.cs

@@ -2,30 +2,100 @@ using System.Collections.Generic;
 
 namespace GFGGame
 {
+    public struct FieldInfos
+    {
+        public int theme;
+        public List<int> highestLvls;
+        public int bonusWeekly;
+        public int bonusMaxLimit;
+        public Dictionary<int, int> taskDic;
+        public bool hasBonus;
+    };
+    public struct FieldResult
+    {
+        public int passLvl;//完成关数
+        public  List<ItemData> bonusList;
+        public int costNum; //体力消耗
+        public int hardLvl; //难度,由ConstInstanceZonesSubType定义
+
+    }
     public class FieldDataManager : SingletonBase<FieldDataManager>
     {
-        /// <summary>
-        /// 本期主题
-        /// </summary>
-        public int scoreType = 1;
-        public Dictionary<int, int> _levelIdDic = new Dictionary<int, int>();
-        private Dictionary<int, int> _taskDic = new Dictionary<int, int>();
+        // private int _theme = 1; //当前主题 由ConstItemAttributeType定义
+        // /// <summary>
+        // /// 本期主题
+        // /// </summary>
+        // public int Theme
+        // {
+        //     get { return _theme; }
+        //     set { _theme = value; }
+        // }
+
+        // private int _bonusWeekly = 0;//每周已领奖励
+        // /// <summary>
+        // /// 每周已领奖励
+        // /// </summary>
+        // /// <value></value>
+        // public int BonusWeekly
+        // {
+        //     get { return _bonusWeekly; }
+        //     set { _bonusWeekly = value; }
+        // }
+
+        // private int _bonusMaxLimit = 0;//奖励上限
+        // /// <summary>
+        // /// 奖励上限
+        // /// </summary>
+        // /// <value></value>
+        // public int BonusMaxLimit
+        // {
+        //     get { return _bonusMaxLimit; }
+        //     set { _bonusMaxLimit = value; }
+        // }
+
+
+        // private List<int> _highestLvls = new List<int>();//最高关卡记录列表,由简单到难
+        // private Dictionary<int, int> _taskDic = new Dictionary<int, int>();//任务奖励状态 由ConstBonusStatus定义
+        // private bool hasBonus = false;//仅在上线时判断是否有奖励未结算
+
+
+        public FieldInfos fieldInfos = new FieldInfos();
+        public FieldResult fieldResult = new FieldResult();
 
         /// <summary>
         /// 当前难度
         /// </summary>
-        public int difficulty = 0;
-
+        public int c_difficulty = 0;
 
+        // public void UpdateHighestLvls(List<int> highestLvls)
+        // {
+        //     _highestLvls = highestLvls;
+        // }
         public void UpdateTask(int taskId, int state)
         {
-            if (!_taskDic.ContainsKey(taskId))
+            if (!fieldInfos.taskDic.ContainsKey(taskId))
             {
-                _taskDic.Add(taskId, state);
+                fieldInfos.taskDic.Add(taskId, state);
             }
             else
             {
-                _taskDic[taskId] = state;
+                fieldInfos.taskDic[taskId] = state;
+            }
+        }
+        /// <summary>
+        /// 根据挑战难度获取最高记录
+        /// </summary>
+        /// <param name="difficulty"></param>
+        /// <returns></returns>
+        public int GetHighestLvByDifficulty(int difficulty)
+        {
+            if (fieldInfos.highestLvls.IndexOf(difficulty) < 0)
+            {
+                return 0;
+            }
+            else
+            {
+                return fieldInfos.highestLvls[difficulty];
             }
         }
         /// <summary>
@@ -44,15 +114,8 @@ namespace GFGGame
         /// <returns></returns>
         public int GetLevelIdByDifficulty(int difficulty)
         {
-            if (_levelIdDic.ContainsKey(difficulty))
-            {
-                return _levelIdDic[difficulty];
-            }
-            else
-            {
-                FieldCfg cfg = GetFieldCfgByDifficulty(difficulty);
-                return StoryLevelCfgArray.Instance.GetCfgs(cfg.type, cfg.subType, cfg.id)[0].id;
-            }
+            FieldCfg cfg = GetFieldCfgByDifficulty(difficulty);
+            return StoryLevelCfgArray.Instance.GetCfgs(cfg.type, cfg.subType, cfg.id)[0].id;
         }
         /// <summary>
         /// 获取任务列表
@@ -78,7 +141,7 @@ namespace GFGGame
         /// <returns></returns>
         public int GetTaskState(int taskId)
         {
-            return _taskDic.ContainsKey(taskId) ? _taskDic[taskId] : 1;
+            return fieldInfos.taskDic.ContainsKey(taskId) ? fieldInfos.taskDic[taskId] : 1;
         }
     }
 }

+ 56 - 4
GameClient/Assets/Game/HotUpdate/ServerProxy/FieldSProxy.cs

@@ -7,15 +7,67 @@ namespace GFGGame
 {
     public static class FieldSProxy
     {
-        public static async ETTask<bool> ClothingDecompose(List<int> itemIds, List<int> itemNums)
+        public static async ETTask<bool> ReqFieldInstanceInfos(List<int> itemIds, List<int> itemNums)
         {
-            M2C_ClothingDecompose response = null;
-            response = (M2C_ClothingDecompose)await MessageHelper.SendToServer(new C2M_ClothingDecompose() { itemIds = itemIds, itemNums = itemNums });
+            M2C_GetFieldInstanceInfos response = null;
+            response = (M2C_GetFieldInstanceInfos)await MessageHelper.SendToServer(new C2M_GetFieldInstanceInfos());
             if (response != null)
             {
                 if (response.Error == ErrorCode.ERR_Success)
                 {
-                    BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.bonusList));
+                    FieldInfos fieldInfos = FieldDataManager.Instance.fieldInfos;
+                    fieldInfos.theme = response.Theme;
+                    fieldInfos.highestLvls = response.HighestLvls;
+                    fieldInfos.bonusWeekly = response.BonusWeekly;
+                    fieldInfos.bonusMaxLimit = response.BonusMaxLimit;
+                    fieldInfos.hasBonus = response.HasBonus;
+                    fieldInfos.taskDic = new Dictionary<int, int>();
+                    for (int i = 0; i < response.kTaskIds.Count; i++)
+                    {
+                        fieldInfos.taskDic.Add(response.kTaskIds[i], response.vTaskStatus[i]);
+                    }
+                    return true;
+                }
+            }
+            return false;
+        }
+        public static async ETTask<bool> ReqFieldInstanceResult()
+        {
+            M2C_GetFieldInstanceResult response = null;
+            response = (M2C_GetFieldInstanceResult)await MessageHelper.SendToServer(new C2M_GetFieldInstanceResult());
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    FieldResult fieldResult = FieldDataManager.Instance.fieldResult;
+                    fieldResult.passLvl = response.PassLvl;
+                    fieldResult.bonusList = ItemUtil.CreateItemDataList(response.BonusList);
+                    fieldResult.costNum = response.CostNum;
+                    fieldResult.hardLvl = response.HardLvl;
+
+                    FieldInfos fieldInfos = FieldDataManager.Instance.fieldInfos;
+                    fieldInfos.highestLvls[response.HardLvl] = response.HighestLvl;
+                    fieldInfos.bonusWeekly = response.BonusWeekly;
+                    for (int i = 0; i < response.kTaskIds.Count; i++)
+                    {
+                        fieldInfos.taskDic.Add(response.kTaskIds[i], response.vTaskStatus[i]);
+                    }
+                    return true;
+                }
+            }
+            return false;
+        }
+        public static async ETTask<bool> ReqFieldTaskBonus(int taskId)
+        {
+            M2C_GetFieldTaskBonus response = null;
+            response = (M2C_GetFieldTaskBonus)await MessageHelper.SendToServer(new GetFieldTaskBonus() { TaskId = taskId });
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    FieldInfos fieldInfos = FieldDataManager.Instance.fieldInfos;
+                    fieldInfos.bonusMaxLimit = response.BonusMaxLimit;
+                    // fieldInfos.taskDic[]
                     return true;
                 }
             }

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpFightView.cs

@@ -120,7 +120,7 @@ namespace GFGGame
             _fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID);
             if (_levelCfg.type == ConstInstanceZonesType.Field)
             {
-                _fightCfg.scoreType = FieldDataManager.Instance.scoreType;
+                _fightCfg.scoreType = FieldDataManager.Instance.Theme;
             }
             if (!string.IsNullOrEmpty(_fightCfg.music))
             {

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Field/FieldFightEndView.cs

@@ -34,7 +34,7 @@ namespace GFGGame
         }
         private void UpdateView()
         {
-            FieldCfg fieldCfg = FieldCfgArray.Instance.GetCfgs(FieldDataManager.Instance.difficulty)[0];
+            FieldCfg fieldCfg = FieldCfgArray.Instance.GetCfgs(FieldDataManager.Instance.c_difficulty)[0];
             string num = StringUtil.GetColorText(string.Format("{0}/{1}", 0, fieldCfg.num), "#BB674E");
             _ui.m_txtNum.text = string.Format("第{0}轮", num);
         }

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Field/FieldFightInfoView.cs

@@ -39,7 +39,7 @@ namespace GFGGame
         {
             _ui.m_txtName.text = _storyFightCfg.targetName;
             _ui.m_txtDesc.text = _storyLevelCfg.desc;
-            FieldCfg fieldCfg = FieldCfgArray.Instance.GetCfgs(FieldDataManager.Instance.difficulty)[0];
+            FieldCfg fieldCfg = FieldCfgArray.Instance.GetCfgs(FieldDataManager.Instance.c_difficulty)[0];
             string num = StringUtil.GetColorText(string.Format("{0}/{1}", 0, fieldCfg.num), "#BB674E");
             _ui.m_txtNum.text = string.Format("第{0}轮", num);
             _ui.m_loaNpc.url = ResPathUtil.GetNpcHeadPath(_storyFightCfg.targetRes);

+ 3 - 3
GameClient/Assets/Game/HotUpdate/Views/Field/FieldView.cs

@@ -34,7 +34,7 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
-            FieldDataManager.Instance.difficulty = _ui.m_c1.selectedIndex;
+            FieldDataManager.Instance.c_difficulty = _ui.m_c1.selectedIndex;
             _curCfg = FieldDataManager.Instance.GetFieldCfgByDifficulty(_ui.m_c1.selectedIndex);
             _curLevelId = FieldDataManager.Instance.GetLevelIdByDifficulty(_ui.m_c1.selectedIndex);
             FieldCfg[] cfgs = FieldCfgArray.Instance.dataArray;
@@ -61,14 +61,14 @@ namespace GFGGame
 
         private void OnDifficultyChange()
         {
-            FieldDataManager.Instance.difficulty = _ui.m_c1.selectedIndex;
+            FieldDataManager.Instance.c_difficulty = _ui.m_c1.selectedIndex;
             _curCfg = FieldDataManager.Instance.GetFieldCfgByDifficulty(_ui.m_c1.selectedIndex);
             _curLevelId = FieldDataManager.Instance.GetLevelIdByDifficulty(_ui.m_c1.selectedIndex);
             UpdateView();
         }
         private void UpdateView()
         {
-            _ui.m_txtScore.text = ConstDressUpScoreType.scoreTypeList()[FieldDataManager.Instance.scoreType].ToString();
+            _ui.m_txtScore.text = ConstDressUpScoreType.scoreTypeList()[FieldDataManager.Instance.Theme].ToString();
             _ui.m_txtMaxLv.text = string.Format("最高记录:{0}/{1}", 0, _curCfg.num);
             _ui.m_txtConsume.text = string.Format("x{0}", _curCfg.needPower);
         }

二进制
GameClient/Assets/ResIn/Config/excelConfig.sqlite.bytes