ソースを参照

提取公用字符串

LiuQilin 7 年 前
コミット
8e81f3e58a

+ 47 - 35
Assets/Script/Function/ThanksGift.cs

@@ -4,9 +4,30 @@ using System.Collections.Generic;
 using LitJson;
 using UnityEngine;
 
+public class ThanksGiftJson
+{
+    public static string PackID = "packid";
+    public static string StartTime = "starttime";
+    public static string EndTime = "endtime";
+
+    public static int UnvalidValue = 0;
+    public static string UnvalidValues = "0";
+
+    public static Dictionary<Gift.GiftType, string> TypeDictionary = new Dictionary<Gift.GiftType, string>
+    {
+        {Gift.GiftType.金币,"g"},
+        {Gift.GiftType.钻石,"d"},
+        {Gift.GiftType.礼包,"p"},
+        {Gift.GiftType.花朵,"f"},
+        {Gift.GiftType.服装,"c"},
+        {Gift.GiftType.开垦土地,"s"},
+        {Gift.GiftType.精灵,"a"},
+    };
+}
+
 public class Gift
 {
-    private enum GiftType
+    public enum GiftType
     {
         金币 = 0,
         钻石 = 1,
@@ -17,24 +38,8 @@ public class Gift
         精灵 = 6,
     }
 
-    private static Dictionary<GiftType, string> TypeLabelDictionary = new Dictionary<GiftType, string>
-    {
-        {GiftType.金币,"g"},
-        {GiftType.钻石,"d"},
-        {GiftType.礼包,"p"},
-        {GiftType.花朵,"f"},
-        {GiftType.服装,"c"},
-        {GiftType.开垦土地,"s"},
-        {GiftType.精灵,"a"},
-    };
-
     #region Config
 
-    private static int UnvalidValue = 0;
-    private static string UnvalidValues = "0";
-    private static string StartTimeLabel = "starttime";
-    private static string EndTimeLabel = "endtime";
-
     private List<List<int>> Values = new List<List<int>>();
     private List<GiftType> Types = new List<GiftType>();
     private DateTime StartDate;
@@ -45,50 +50,57 @@ public class Gift
     public Gift(JsonData jsonData)
     {
         //Debug.Log(jsonData.ToJson());
-        int value = (int) jsonData[TypeLabelDictionary[GiftType.金币]];
-        if (value != UnvalidValue)
+        string label = ThanksGiftJson.TypeDictionary[GiftType.金币];
+        int value = (int) jsonData[label];
+        if (value != ThanksGiftJson.UnvalidValue)
         {
             Types.Add(GiftType.金币);
             Values.Add(new List<int> {value});
         }
-        value = (int)jsonData[TypeLabelDictionary[GiftType.钻石]];
-        if (value != UnvalidValue)
+        label = ThanksGiftJson.TypeDictionary[GiftType.钻石];
+        value = (int)jsonData[label];
+        if (value != ThanksGiftJson.UnvalidValue)
         {
             Types.Add(GiftType.钻石);
             Values.Add(new List<int> { value });
         }
-        string values = (string)jsonData[TypeLabelDictionary[GiftType.礼包]];
-        if (values != UnvalidValues)
+        label = ThanksGiftJson.TypeDictionary[GiftType.礼包];
+        string values = (string)jsonData[label];
+        if (values != ThanksGiftJson.UnvalidValues)
         {
             Types.Add(GiftType.礼包);
             Values.Add(Auxiliary.StringToInts(' ', values, new List<int>()));
         }
-        values = (string)jsonData[TypeLabelDictionary[GiftType.花朵]];
-        if (values != UnvalidValues)
+        label = ThanksGiftJson.TypeDictionary[GiftType.花朵];
+        values = (string)jsonData[label];
+        if (values != ThanksGiftJson.UnvalidValues)
         {
             Types.Add(GiftType.花朵);
             Values.Add(Auxiliary.StringToInts(' ', values, new List<int>()));
         }
-        values = (string)jsonData[TypeLabelDictionary[GiftType.服装]];
-        if (values != UnvalidValues)
+        label = ThanksGiftJson.TypeDictionary[GiftType.服装];
+        values = (string)jsonData[label];
+        if (values != ThanksGiftJson.UnvalidValues)
         {
             Types.Add(GiftType.服装);
             Values.Add(Auxiliary.StringToInts(' ', values, new List<int>()));
         }
-        value = (int)jsonData[TypeLabelDictionary[GiftType.开垦土地]];
-        if (value != UnvalidValue)
+        label = ThanksGiftJson.TypeDictionary[GiftType.开垦土地];
+        value = (int)jsonData[label];
+        if (value != ThanksGiftJson.UnvalidValue)
         {
             Types.Add(GiftType.开垦土地);
             Values.Add(new List<int> { value });
         }
-        values = (string)jsonData[TypeLabelDictionary[GiftType.精灵]];
-        if (values != UnvalidValues)
+        label = ThanksGiftJson.TypeDictionary[GiftType.精灵];
+        values = (string)jsonData[label];
+        if (values != ThanksGiftJson.UnvalidValues)
         {
             Types.Add(GiftType.精灵);
             Values.Add(Auxiliary.StringToInts(' ', values, new List<int>()));
         }
-        StartDate = DateTime.Parse(jsonData[StartTimeLabel].ToString());
-        EndDate = DateTime.Parse(jsonData[EndTimeLabel].ToString());
+        StartDate = DateTime.Parse(jsonData[ThanksGiftJson.StartTime].ToString());
+        EndDate = DateTime.Parse(jsonData[ThanksGiftJson.EndTime].ToString());
         //for (int i = 0; i < Types.Count; i++)
         //{
         //    Debug.LogWarning(Types[i]);
@@ -212,7 +224,7 @@ public class ThanksGift
 
     private static bool Inited;
     private static Dictionary<int, Gift> GiftDictionary = new Dictionary<int, Gift>();
-    
+
     #endregion
 
     public static void Init(JsonData jsonData)
@@ -221,7 +233,7 @@ public class ThanksGift
         Inited = true;
         for (int i = 0; i < jsonData.Count; i++)
         {
-            int packID = (int) jsonData[i]["packid"];
+            int packID = (int) jsonData[i][ThanksGiftJson.PackID];
             Gift gift = new Gift(jsonData[i]);
             GiftDictionary.Add(packID, gift);
         }

+ 3 - 0
Assets/Script/Label/PlayerConfigLabel.cs

@@ -5,6 +5,9 @@ using UnityEngine;
 
 public class PlayerConfigLabel
 {
+    public static string DefaultID = "Default";
+    public static string DefaultSerialNumber = "Default";
+
     public static string RefundNode = "Refund";
     public static string ReceivedNode = "Received";
     public static string RootNode = "PlayerConfig";

+ 2 - 0
Assets/Script/Label/ResourceLabel.cs

@@ -14,6 +14,8 @@ public class ResourceLabel
     public static string Canvas = "Canvas";
     public static string UI = "UI";
 
+    public static string LOGO0005 = "LOGO0005";
+    public static string NotifyItem = "NotifyItem";
     public static string Music = "Music";
     public static string MessageBox = "MessageBox";
     public static string NickName = "NickName";

+ 3 - 2
Assets/Script/Manage/AnnounceManager.cs

@@ -79,6 +79,7 @@ public class AnnounceManager
         );
     }
 
+    private static int AnnounceImageSize = 300;
     public static void Initialize(string language)
     {
         Initialized = true;
@@ -87,11 +88,11 @@ public class AnnounceManager
 
         for (int i = 0; i < contents.Count; i++)
         {
-            Transform transform = ResourceManager.Get("NotifyItem", Folder.UI, false, ResourceManager.Get(ObjectLabel.R_Grid), false);
+            Transform transform = ResourceManager.Get(ResourceLabel.NotifyItem, Folder.UI, false, ResourceManager.Get(ObjectLabel.R_Grid), false);
 
             if (contents[i].IsImage)
             {
-                transform.GetComponent<Text>().fontSize = 300;
+                transform.GetComponent<Text>().fontSize = AnnounceImageSize;
                 transform.GetComponent<Text>().verticalOverflow = VerticalWrapMode.Overflow;
                 transform.GetComponent<Text>().horizontalOverflow = HorizontalWrapMode.Overflow;
                 transform.GetComponent<Text>().resizeTextForBestFit = false;

+ 16 - 15
Assets/Script/Manage/AudioManager.cs

@@ -18,7 +18,7 @@ public enum Clip
 
 public class AudioManager : Regist
 {
-    #region 变量
+    #region Config
 
     public static bool Audio = true;
     public static bool Music = true;
@@ -47,17 +47,17 @@ public class AudioManager : Regist
 
     public override void InstantiatePrefabs()
     {
-        BtnClip = ResourceManager.Load<AudioClip>("BtnClip", Folder.Audio);
-        SkillClip = ResourceManager.Load<AudioClip>("SkillClip", Folder.Audio);
-        ErrorClip = ResourceManager.Load<AudioClip>("ErrorClip", Folder.Audio);
-        DropClip = ResourceManager.Load<AudioClip>("DropClip", Folder.Audio);
-        CloseClip = ResourceManager.Load<AudioClip>("CloseClip", Folder.Audio);
-        FlowerClip = ResourceManager.Load<AudioClip>("FlowerClip", Folder.Audio);
-        BubbleClip = ResourceManager.Load<AudioClip>("BubbleClip", Folder.Audio);
-        CurrentClip = ResourceManager.Load<AudioClip>("CurrentClip", Folder.Audio);
-        MiniEndClip = ResourceManager.Load<AudioClip>("MiniEndClip", Folder.Audio);
-
-        ResourceManager.Get("Music", Folder.Audio, true, transform, true, ObjType.Music);
+        BtnClip = ResourceManager.Load<AudioClip>(ResourceLabel.BtnClip, Folder.Audio);
+        SkillClip = ResourceManager.Load<AudioClip>(ResourceLabel.SkillClip, Folder.Audio);
+        ErrorClip = ResourceManager.Load<AudioClip>(ResourceLabel.ErrorClip, Folder.Audio);
+        DropClip = ResourceManager.Load<AudioClip>(ResourceLabel.DropClip, Folder.Audio);
+        CloseClip = ResourceManager.Load<AudioClip>(ResourceLabel.CloseClip, Folder.Audio);
+        FlowerClip = ResourceManager.Load<AudioClip>(ResourceLabel.FlowerClip, Folder.Audio);
+        BubbleClip = ResourceManager.Load<AudioClip>(ResourceLabel.BubbleClip, Folder.Audio);
+        CurrentClip = ResourceManager.Load<AudioClip>(ResourceLabel.CurrentClip, Folder.Audio);
+        MiniEndClip = ResourceManager.Load<AudioClip>(ResourceLabel.MiniEndClip, Folder.Audio);
+
+        ResourceManager.Get(ResourceLabel.Music, Folder.Audio, true, transform, true, ObjType.Music);
     }
 
     public override void FirstInit()
@@ -165,7 +165,7 @@ public class AudioManager : Regist
 
     public override void RegistReference()
     {
-        AudioSource[] audioSources = ResourceManager.Gets<AudioSource>("Music");
+        AudioSource[] audioSources = ResourceManager.Gets<AudioSource>(ResourceLabel.Music);
 
         MusicClip = audioSources[2];
         MusicMini = audioSources[1];
@@ -195,7 +195,7 @@ public class AudioManager : Regist
     {
         if (!Audio || !Music)
         {
-            GameObject.Find("LOGO0005").GetComponent<AudioSource>().volume = 0;
+            GameObject.Find(ResourceLabel.LOGO0005).GetComponent<AudioSource>().volume = 0;
         }
     }
 
@@ -261,6 +261,7 @@ public class AudioManager : Regist
     }
 
 
+    private float LoopDelay = 1.5f;
     public IEnumerator Loop(AudioSource audioSource)
     {
         while (true)
@@ -287,7 +288,7 @@ public class AudioManager : Regist
                 goto Mark;
             }
 
-            yield return new WaitForSeconds(1.5f);
+            yield return new WaitForSeconds(LoopDelay);
 
             audioSource.Play();
         }

+ 23 - 14
Assets/Script/Manage/ConfigManager.cs

@@ -14,6 +14,11 @@ using Sfs2X.Entities;
 using Sfs2X.Entities.Data;
 using Random = UnityEngine.Random;
 
+public class DownloadJson
+{
+    public static string Config = "l";
+}
+
 public class ConfigManager : Regist
 {
     #region Config
@@ -71,6 +76,7 @@ public class ConfigManager : Regist
 
     #endregion
 
+    private static string UnvalidConfigMD5 = "";
     private static void GetPlayerDoc()
     {
         int defaultVersion;
@@ -147,7 +153,7 @@ public class ConfigManager : Regist
                         bytes = File.ReadAllBytes(PlayerConfigPath);
                     }
 
-                    if (PlayerPrefs.GetString(Lib.ConfigPrefs) != "" && PlayerPrefs.GetString(Lib.ConfigPrefs) != Auxiliary.ToString(md5.ComputeHash(bytes)))
+                    if (PlayerPrefs.GetString(Lib.ConfigPrefs) != UnvalidConfigMD5 && PlayerPrefs.GetString(Lib.ConfigPrefs) != Auxiliary.ToString(md5.ComputeHash(bytes)))
                     {
                         Debug.LogWarning("Download Archive : MD5 doesn't match");
                         //ManaDebug.Log("Download Archive");
@@ -174,7 +180,7 @@ public class ConfigManager : Regist
 
                     MD5 md5 = new MD5CryptoServiceProvider();
 
-                    if (PlayerPrefs.GetString(Lib.ConfigPrefs) != "" && PlayerPrefs.GetString(Lib.ConfigPrefs) != Auxiliary.ToString(md5.ComputeHash(bytes)))
+                    if (PlayerPrefs.GetString(Lib.ConfigPrefs) != UnvalidConfigMD5 && PlayerPrefs.GetString(Lib.ConfigPrefs) != Auxiliary.ToString(md5.ComputeHash(bytes)))
                     {
                         Debug.LogWarning("Download Archive : MD5 doesn't match");
                         //ManaDebug.Log("Download Archive");
@@ -206,13 +212,14 @@ public class ConfigManager : Regist
     }
 
 
+    private float MaxWaitTime = 30;
     public void Update()
     {
         if (DamageLock)
         {
             Timer += Time.deltaTime;
 
-            if (Timer >= 30)
+            if (Timer >= MaxWaitTime)
             {
                 DamageLock = false;
 
@@ -228,7 +235,7 @@ public class ConfigManager : Regist
 
         if (!SerialNumberDownloadLock)
         {   
-            if (HttpManager.SerialNumber != "Default")
+            if (HttpManager.SerialNumber != PlayerConfigLabel.DefaultSerialNumber)
             {
                 SerialNumberDownloadLock = true;
 
@@ -286,11 +293,11 @@ public class ConfigManager : Regist
 
         DefaultDoc.LoadXml(textAsset.text);
 
-        if (jsonData.Inst_Object.Keys.Contains("l"))
+        if (jsonData.Inst_Object.Keys.Contains(DownloadJson.Config))
         {
             PlayerDoc_ = new XmlDocument();
 
-            PlayerDoc_.LoadXml(jsonData["l"].ToString());
+            PlayerDoc_.LoadXml(jsonData[DownloadJson.Config].ToString());
 
             int nativeVersion = int.Parse(PlayerDoc_.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value);
             int defaultVersion = int.Parse(DefaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value);
@@ -312,7 +319,7 @@ public class ConfigManager : Regist
         {
             if (!IDDownloadLock)
             {
-                if (HttpManager.ID != "Default")
+                if (HttpManager.ID != PlayerConfigLabel.DefaultID)
                 {
                     IDDownloadLock = true;
                     Debug.LogWarning("DownloadByID");
@@ -1442,6 +1449,7 @@ public class ConfigManager : Regist
         return nativeDoc;
     }
 
+    private static int DefaultFlowerAmt = 1;
     public static XmlDocument To7(XmlDocument nativeDoc, XmlDocument defaultDoc)
     {
         nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 7.ToString();
@@ -1453,7 +1461,7 @@ public class ConfigManager : Regist
         xmlNode1.Attributes[0].Value = "";
         foreach (var flowerID in flowerIDs)
         {
-            xmlNode1.Attributes[0].Value += " " + "1";
+            xmlNode1.Attributes[0].Value += " " + DefaultFlowerAmt;
         }
         xmlNode1.Attributes[0].Value = xmlNode1.Attributes[0].Value.TrimStart();
 
@@ -1475,6 +1483,7 @@ public class ConfigManager : Regist
         return nativeDoc;
     }
 
+    private static int DefaultAchieveValue = 0;
     public static XmlDocument To9(XmlDocument nativeDoc, XmlDocument defaultDoc)
     {
         nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 9.ToString();
@@ -1485,12 +1494,12 @@ public class ConfigManager : Regist
         xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateGuessColorChestAmt));
         xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateGuessNumberChestAmt));
         xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.GetChestAwardAmt));
-        xmlNode.Attributes[9].Value = "0";
-        xmlNode.Attributes[10].Value = "0";
-        xmlNode.Attributes[11].Value = "0";
-        xmlNode.Attributes[12].Value = "0";
-        xmlNode.Attributes[13].Value = "0";
-        xmlNode.Attributes[14].Value = "0";
+        xmlNode.Attributes[9].Value = DefaultAchieveValue.ToString();
+        xmlNode.Attributes[10].Value = DefaultAchieveValue.ToString();
+        xmlNode.Attributes[11].Value = DefaultAchieveValue.ToString();
+        xmlNode.Attributes[12].Value = DefaultAchieveValue.ToString();
+        xmlNode.Attributes[13].Value = DefaultAchieveValue.ToString();
+        xmlNode.Attributes[14].Value = DefaultAchieveValue.ToString();
         return nativeDoc;
     }
 

+ 1 - 1
Assets/Script/Manage/GardenManager.cs

@@ -46,7 +46,7 @@ public class GardenManager : Regist
         {
             Slot_ = value;
 
-            ResourceManager.SetText(ObjectLabel.G_CollectLab2, string.Format("{0}/{1}", Slot_, Page * 9));
+            ResourceManager.SetText(ObjectLabel.G_CollectLab2, string.Format("{0}/{1}", Slot_, Page * TotalSlotAmtInOnePage));
         }
     }
     public static int Page