瀏覽代碼

商店物品类型自动填写

zhaoyang 3 年之前
父節點
當前提交
6b5b3d33af

+ 9 - 8
GameClient/Assets/Editor/Excel/CodeBuilder.cs

@@ -64,18 +64,18 @@ namespace GFGEditor
                     groupNames.Add(name);
                     groupTypes.Add(type);
                 }
-                if(nameWhole.Contains("#a"))
+                if (nameWhole.Contains("#a"))
                 {
                     needAll = true;
                 }
                 ParseDataColumn(annotation, type, name, i);
             }
-            if(keyNames.Count == groupNames.Count)
+            if (keyNames.Count == groupNames.Count)
             {
                 bool isSame = true;
-                for(var i = 0; i < keyNames.Count; i++)
+                for (var i = 0; i < keyNames.Count; i++)
                 {
-                    if(keyNames[i] != groupNames[i])
+                    if (keyNames[i] != groupNames[i])
                     {
                         isSame = false;
                     }
@@ -100,7 +100,7 @@ namespace GFGEditor
                 FunctionSingleStr = FunctionSingleStr.Replace("{colNames}", colNames);
                 FunctionSingleStr = FunctionSingleStr.Replace("{colValues}", colValues);
                 configArrayStr = configArrayStr.Replace("{singleFunction}", FunctionSingleStr);
-                if(groupNames.Count > 0)
+                if (groupNames.Count > 0)
                 {
 
                     _declarationBuilder.AppendFormat("\t\t//{0}", "组合key");
@@ -119,7 +119,7 @@ namespace GFGEditor
             //处理查询多条数据函数
             if (groupNames.Count > 0)
             {
-                string FunctionGroupStr = groupOnly? CodeTemplateFactory.FunctionGroupOnlyTemplate : CodeTemplateFactory.FunctionGroupTemplate;
+                string FunctionGroupStr = groupOnly ? CodeTemplateFactory.FunctionGroupOnlyTemplate : CodeTemplateFactory.FunctionGroupTemplate;
                 CreateParamsString(groupNames, groupTypes, out paramsStr, out colNames, out colValues);
                 FunctionGroupStr = FunctionGroupStr.Replace("{params}", paramsStr);
                 FunctionGroupStr = FunctionGroupStr.Replace("{colNames}", colNames);
@@ -132,7 +132,7 @@ namespace GFGEditor
                 configArrayStr = configArrayStr.Replace("{groupFunction}", "");
             }
             //处理全部数据函数
-            if(needAll)
+            if (needAll)
             {
                 configArrayStr = configArrayStr.Replace("{editorConditionStart}", "");
                 configArrayStr = configArrayStr.Replace("{editorConditionEnd}", "");
@@ -268,6 +268,7 @@ namespace GFGEditor
                 {
                     HandleItemCfgField(keyValue, fieldName, ref value);
                 }
+
                 //value = Regex.Replace(value, ":", "/:");
                 values.Add(value);
             }
@@ -339,6 +340,6 @@ namespace GFGEditor
                 }
             }
         }
-        
+
     }
 }

+ 239 - 0
GameClient/Assets/Editor/Excel/Scanner/ShopScanner.cs

@@ -0,0 +1,239 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using GFGGame;
+using UnityEngine;
+
+namespace GFGEditor
+{
+    public class ShopScanner
+    {
+        //计算每个副本的关卡数
+        private static Dictionary<int, int> levelCountDIc = new Dictionary<int, int>();
+        // private static string[] _shopItemType = new string[] { "推荐", "发型", "连衣裙", "内搭", "上衣", "下装", "外套", "袜子", "鞋子", "饰品" };
+        private static string[] _shopItemType = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+
+        public static void StartScan()
+        {
+
+            WriteClothingShop();
+            WriteCJShop();
+            WriteCJAShop();
+
+        }
+
+        public static void WriteClothingShop()
+        {
+            Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
+            SQLiteHelper.Instance.OpenConnection();
+            try
+            {
+                string typeIndex = "";
+                int itemId;
+                int id;
+                var reader = SQLiteHelper.Instance.ReadLine("ShopCfgClothingArray");
+                while (reader.Read())
+                {
+                    typeIndex = reader["_typeIndex"].ToString();
+                    itemId = int.Parse(reader["_itemId"].ToString());
+                    id = int.Parse(reader["_id"].ToString());
+
+                    int count;
+                    if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
+                    {
+                        count = Array.IndexOf(_shopItemType, typeIndex);
+                    }
+                    else
+                    {
+                        ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
+                        string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
+
+                        if (Array.IndexOf(_shopItemType, itemType) >= 0)
+                        {
+                            count = Array.IndexOf(_shopItemType, itemType);
+                        }
+                        else
+                        {
+                            count = _shopItemType.Length - 1;
+                        }
+                    }
+                    _typeIndexDic.Add(id, count.ToString());
+                }
+            }
+            catch (System.Exception e)
+            {
+                ET.Log.Error(e);
+            }
+            finally
+            {
+                SQLiteHelper.Instance.CloseConnection();
+            }
+
+
+            SQLiteHelper.Instance.OpenConnection();
+            try
+            {
+                ICollection keys = _typeIndexDic.Keys;
+                foreach (int key in keys)
+                {
+                    var names = new string[] { "typeIndex" };
+                    var values = new string[] { "" + _typeIndexDic[key] };
+                    SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgClothingArray), names, values, "id", key.ToString());
+                }
+            }
+            catch (Exception e)
+            {
+                ET.Log.Error(e.ToString());
+            }
+            finally
+            {
+                SQLiteHelper.Instance.CloseConnection();
+            }
+
+        }
+
+        public static void WriteCJShop()
+        {
+            Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
+            SQLiteHelper.Instance.OpenConnection();
+            try
+            {
+                string typeIndex = "";
+                int itemId;
+                int id;
+                var reader = SQLiteHelper.Instance.ReadLine("ShopCfgCJArray");
+                while (reader.Read())
+                {
+                    typeIndex = reader["_typeIndex"].ToString();
+                    itemId = int.Parse(reader["_itemId"].ToString());
+                    id = int.Parse(reader["_id"].ToString());
+
+                    int count;
+                    if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
+                    {
+                        count = Array.IndexOf(_shopItemType, typeIndex);
+                    }
+                    else
+                    {
+                        ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
+                        string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
+
+                        if (Array.IndexOf(_shopItemType, itemType) >= 0)
+                        {
+                            count = Array.IndexOf(_shopItemType, itemType);
+                        }
+                        else
+                        {
+                            count = _shopItemType.Length - 1;
+                        }
+                    }
+                    _typeIndexDic.Add(id, count.ToString());
+                }
+            }
+            catch (System.Exception e)
+            {
+                ET.Log.Error(e);
+            }
+            finally
+            {
+                SQLiteHelper.Instance.CloseConnection();
+            }
+
+
+            SQLiteHelper.Instance.OpenConnection();
+            try
+            {
+                ICollection keys = _typeIndexDic.Keys;
+                foreach (int key in keys)
+                {
+
+                    var names = new string[] { "typeIndex" };
+                    var values = new string[] { "" + _typeIndexDic[key] };
+                    SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJArray), names, values, "id", key.ToString());
+                }
+            }
+            catch (Exception e)
+            {
+                ET.Log.Error(e.ToString());
+            }
+            finally
+            {
+                SQLiteHelper.Instance.CloseConnection();
+            }
+
+        }
+
+        public static void WriteCJAShop()
+        {
+            Dictionary<int, string> _typeIndexDic = new Dictionary<int, string>();
+
+            SQLiteHelper.Instance.OpenConnection();
+            try
+            {
+                string typeIndex = "";
+                int itemId;
+                int id;
+                var reader = SQLiteHelper.Instance.ReadLine("ShopCfgCJAArray");
+                while (reader.Read())
+                {
+                    typeIndex = reader["_typeIndex"].ToString();
+                    itemId = int.Parse(reader["_itemId"].ToString());
+                    id = int.Parse(reader["_id"].ToString());
+
+                    int count;
+                    if (Array.IndexOf(_shopItemType, typeIndex) >= 0)
+                    {
+                        count = Array.IndexOf(_shopItemType, typeIndex);
+                    }
+                    else
+                    {
+                        ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
+                        string itemType = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).type.ToString();
+
+                        if (Array.IndexOf(_shopItemType, itemType) >= 0)
+                        {
+                            count = Array.IndexOf(_shopItemType, itemType);
+                        }
+                        else
+                        {
+                            count = _shopItemType.Length - 1;
+                        }
+                    }
+                    _typeIndexDic.Add(id, count.ToString());
+                }
+            }
+            catch (System.Exception e)
+            {
+                ET.Log.Error(e);
+            }
+            finally
+            {
+                SQLiteHelper.Instance.CloseConnection();
+            }
+
+
+            SQLiteHelper.Instance.OpenConnection();
+            try
+            {
+                ICollection keys = _typeIndexDic.Keys;
+                foreach (int key in keys)
+                {
+
+                    var names = new string[] { "typeIndex" };
+                    var values = new string[] { "" + _typeIndexDic[key] };
+                    SQLiteHelper.Instance.UpdateValues(nameof(ShopCfgCJAArray), names, values, "id", key.ToString());
+                }
+            }
+            catch (Exception e)
+            {
+                ET.Log.Error(e.ToString());
+            }
+            finally
+            {
+                SQLiteHelper.Instance.CloseConnection();
+            }
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Editor/Excel/Scanner/ShopScanner.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0d7a22cc9398507498d650818b15cf10
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 0
GameClient/Assets/Editor/ToolsMenu.cs

@@ -127,6 +127,7 @@ namespace GFGEditor
             {
                 SQLiteHelper.Instance.CloseConnection();
             }
+            ShopScanner.StartScan();
             //扫描物品表获取途径并更新数据库
             ItemApproachScanner.startScan();
             //扫描副本

+ 1 - 1
GameClient/Assets/Game/CSShare

@@ -1 +1 @@
-Subproject commit a7f5d2fe655205e6415b61300e8766c7fc10e528
+Subproject commit 0189864671f6a536cc933657fa7585307a63eb4b

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