lvjincheng 4 лет назад
Родитель
Сommit
41022ddd0b

+ 1 - 1
Assets/BowArrow/Resources/Prefabs/Views/DeviceCalibrateView.prefab

@@ -1727,7 +1727,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_Color: {r: 0, g: 0.3529412, b: 0.7137255, a: 1}
   m_RaycastTarget: 1
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1

Разница между файлами не показана из-за своего большого размера
+ 870 - 49
Assets/BowArrow/Resources/Prefabs/Views/DeviceView.prefab


+ 8 - 0
Assets/BowArrow/Resources/Textures/Device.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c5b09d81e55de7e41ad69f821e0f467f
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 0
Assets/BowArrow/Textures/Home/CenterPanel/弓.png → Assets/BowArrow/Resources/Textures/Device/1.png


+ 0 - 0
Assets/BowArrow/Textures/Home/CenterPanel/弓.png.meta → Assets/BowArrow/Resources/Textures/Device/1.png.meta


+ 0 - 0
Assets/BowArrow/Textures/Home/CenterPanel/箭.png → Assets/BowArrow/Resources/Textures/Device/2.png


+ 0 - 0
Assets/BowArrow/Textures/Home/CenterPanel/箭.png.meta → Assets/BowArrow/Resources/Textures/Device/2.png.meta


+ 1 - 1
Assets/BowArrow/Scripts/Bluetooth/ShootCheck.cs

@@ -145,7 +145,7 @@ public class ShootCheck : MonoBehaviour
     float ToAcceleratedSpeed(byte b1, byte b2)
     {
         int value = TwoByteToInt(b1, b2);
-        return (float)value / 32768 * 16;
+        return (float)value / 32768 * LoginMgr.myUserInfo.deviceAccValue;
         //  return (float)value;
     }
     

+ 14 - 2
Assets/BowArrow/Scripts/Components/TextAutoLanguage.cs

@@ -142,7 +142,7 @@ class LanguageDefault {
     public string text65 = "已装备";
     public string text66 = "购买";
     public string text67 = "属性";
-    public string text68 = "操作难度 :";
+    public string text68 = "操作难度 : ";
     public string text69 = "设备教程";
     public string text70 = "游戏教程";
     public string text71 = "角色选择";
@@ -178,6 +178,12 @@ class LanguageDefault {
     public string text113 = "弓";
     public string text114 = "箭";
     public string text115 = "第 {0} 回 合";
+    //设备页面
+    public string text500 = "陀螺仪校准";
+    public string text501 = "地磁计校准";
+    public string text502 = "视角回正";
+    public string text503 = "16G加速计";
+    public string text504 = "64G加速计";
     //主页面
     public string text400 = "退出游戏";
     //设置页面
@@ -297,7 +303,7 @@ class LanguageEnglish : LanguageDefault {
     public new string text65 = "Equipped";
     public new string text66 = "Buy";
     public new string text67 = "Property";
-    public new string text68 = "Difficulty :";
+    public new string text68 = "Difficulty : ";
     public new string text69 = "Device Course";
     public new string text70 = "Game Course";
     public new string text71 = "Role Select";
@@ -333,6 +339,12 @@ class LanguageEnglish : LanguageDefault {
     public new string text113 = "Bow";
     public new string text114 = "Arrow";
     public new string text115 = "Round {0}";
+    //设备页面
+    public new string text500 = "GyrCalibrate";
+    public new string text501 = "MagCalibrate";
+    public new string text502 = "Identity";
+    public new string text503 = "16G Acc";
+    public new string text504 = "64G Acc";
     //主页面
     public new string text400 = "Quit Game";
     //设置页面

+ 81 - 2
Assets/BowArrow/Scripts/Manager/DeviceMgr.cs

@@ -1,3 +1,4 @@
+using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
@@ -14,6 +15,49 @@ public class DeviceMgr
             return _ins;
         }
     }
+    Hashtable deviceConfigs = new Hashtable();
+
+    DeviceMgr()
+    {   
+        CacheDeviceConfig<DeviceBow1000>();
+        CacheDeviceConfig<DeviceBow1001>();
+        CacheDeviceConfig<DeviceArrow2000>();
+        //用户数据初始化
+        List<DeviceInfo> deviceInfos = LoginMgr.myUserInfo.deviceList;
+        if (deviceInfos.Count == 0) {
+            // 加入初始设备
+            int[] ids = {1000, 1001, 2000};
+            foreach (var id in ids) {
+                DeviceInfo deviceInfo = new DeviceInfo();
+                deviceInfo.id = id;
+                if (id == 1000 || id == 2000) deviceInfo.inuse = true;
+                deviceInfos.Add(deviceInfo);
+            }
+            LoginMgr.myUserInfo.Save();
+        }
+    }
+    void CacheDeviceConfig<T>() where T : DeviceConfig
+    {
+        DeviceConfig deviceConfig = System.Activator.CreateInstance<T>();
+        deviceConfigs.Add(deviceConfig.id, deviceConfig);
+    }
+    void CacheDeviceConfig(int id, DeviceConfig deviceConfig)
+    {
+        deviceConfigs.Add(id, deviceConfig);
+    }
+    public PropConfig GetDeviceConfig(int id)
+    {
+        return (PropConfig) deviceConfigs[id];
+    }
+    public List<DeviceInfo> GetMyDeviceList()
+    {
+        List<DeviceInfo> list = LoginMgr.myUserInfo.deviceList;
+        foreach (var deviceInfo in list)
+        {
+            deviceInfo.config = (DeviceConfig) deviceConfigs[deviceInfo.id];
+        }
+        return list;
+    }
 }
 public class DeviceInfo
 {
@@ -25,7 +69,42 @@ public class DeviceInfo
 public class DeviceConfig
 {
     public int id = 0;
-    public string name = "";
-    public string detail = "";
+    public int name = 0;
+    public int detail = 0;
     public int difficulty = 0;
+    public int model = 0;
+    public int type = 0;
+}
+public class DeviceBow1000 : DeviceConfig {
+    public DeviceBow1000()
+    {
+        id = 1000;
+        name = 201000;
+        detail = 211000;
+        difficulty = 3;
+        model = 1;
+        type = 1;
+    }
 }
+public class DeviceBow1001 : DeviceConfig {
+    public DeviceBow1001()
+    {
+        id = 1001;
+        name = 201001;
+        detail = 211001;
+        difficulty = 5;
+        model = 1;
+        type = 1;
+    }
+}
+public class DeviceArrow2000 : DeviceConfig {
+    public DeviceArrow2000()
+    {
+        id = 2000;
+        name = 201002;
+        detail = 211002;
+        difficulty = 3;
+        model = 2;
+        type = 2;
+    }
+}

+ 3 - 1
Assets/BowArrow/Scripts/Manager/LoginMgr.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
@@ -252,6 +252,8 @@ public class UserInfo {
     public int coin = 0;
     public int diamond = 1000;
     public List<PropInfo> bagList = new List<PropInfo>();
+    public List<DeviceInfo> deviceList = new List<DeviceInfo>();
+    public float deviceAccValue = 16;
     public int timeLimitGameHighestScore = 0;
     public bool deviceCalibrateGuideFinish = false;
     public bool gameRule1GuideFinish = false;

+ 1 - 1
Assets/BowArrow/Scripts/Manager/PropMgr.cs

@@ -16,7 +16,7 @@ public class PropMgr {
 
     Hashtable propConfigs = new Hashtable();
     List<int> propConfigIds = new List<int>();
-    public PropMgr()
+    PropMgr()
     {
         for (int i = 1; i <= 5; i++) 
         {

+ 6 - 2
Assets/BowArrow/Scripts/View/DeviceCalibrateView.cs

@@ -124,7 +124,9 @@ public class DeviceCalibrateView : MonoBehaviour
             btn.enabled = true;
             btn.GetComponentInChildren<TextAutoLanguage>().SetText(116);
             btn.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonBlue");
-            btn.GetComponentInChildren<Text>().color = Color.white;
+            Color outColor;
+            ColorUtility.TryParseHtmlString("#005AB6", out outColor);
+            btn.GetComponentInChildren<Text>().color = outColor;
         }
         AimHandler.ins.CalibrateGyr(false);
     }
@@ -147,7 +149,9 @@ public class DeviceCalibrateView : MonoBehaviour
                 btn.GetComponentInChildren<Text>().color = Color.gray;
             } else {
                 btn.GetComponentInChildren<TextAutoLanguage>().SetText(116);
-                btn.GetComponentInChildren<Text>().color = new Color(0, 90, 182);
+                Color outColor;
+                ColorUtility.TryParseHtmlString("#005AB6", out outColor);
+                btn.GetComponentInChildren<Text>().color = outColor;
             }
             AimHandler.ins.CalibrateMag(false);
         }

+ 130 - 5
Assets/BowArrow/Scripts/View/DeviceView.cs

@@ -5,16 +5,141 @@ using UnityEngine.UI;
 
 public class DeviceView : MonoBehaviour
 {
+    Transform scrollContent;
+    Transform itemPrefab;
+    GameObject bowOptions;
+    GameObject arrowOptions;
+    List<DeviceInfo> deviceList;
     void Start()
     {
-        Transform t = this.transform.Find("ScrollView/Viewport/Content");
-        for (int i = 0; i < t.childCount; i++)
+        scrollContent = this.transform.Find("ScrollView/Viewport/Content");
+        itemPrefab = scrollContent.GetChild(0);
+        itemPrefab.gameObject.SetActive(false);
+        bowOptions = this.transform.Find("ItemInfo/BowOptions").gameObject;
+        arrowOptions = this.transform.Find("ItemInfo/ArrowOptions").gameObject;
+        deviceList = DeviceMgr.ins.GetMyDeviceList();
+        //初始化设备列表-并默认点开第一个设备
+        foreach (DeviceInfo deviceInfo in deviceList)
         {
-            int k = i;
-            t.GetChild(i).GetComponent<Button>().onClick.AddListener(delegate() {
-                Debug.Log(k);
+            DeviceConfig deviceConfig = deviceInfo.config;
+            GameObject item = GameObject.Instantiate(itemPrefab.gameObject, scrollContent);
+            Image modelImage = item.transform.Find("ModelBG/Model").GetComponent<Image>();
+            modelImage.sprite = Resources.Load<Sprite>("Textures/Device/" + deviceConfig.model);
+            modelImage.SetNativeSize();
+            item.transform.Find("TextBG/Text").GetComponent<TextAutoLanguage>().SetText(deviceConfig.name);
+            item.gameObject.SetActive(true);
+            item.GetComponent<Button>().onClick.AddListener(delegate() {
+                AudioMgr.ins.PlayBtn();
+                SelectItem(deviceInfo);
             });
         }
+        SelectItem(deviceList[0]);
+        //初始化弓的校准按钮
+        Button[] bowOptionBtns = bowOptions.GetComponentsInChildren<Button>();
+        for (int i = 0; i < bowOptionBtns.Length; i++)
+        {
+            int optionID = i;
+            bowOptionBtns[i].onClick.AddListener(delegate() {
+                AudioMgr.ins.PlayBtn();
+                if (optionID == 0) {
+                    DeviceCalibrateView.Create(DeviceCalibrateItem.Gyr);
+                } else if (optionID == 1) {
+                    DeviceCalibrateView.Create(DeviceCalibrateItem.Mag);
+                } else if (optionID == 2) {
+                    AimHandler.ins.DoIdentity();
+                }
+            });
+        }
+        //初始化箭的加速计按钮选项
+        Button[] arrowOptionBtns = arrowOptions.GetComponentsInChildren<Button>();
+        for (int i = 0; i < arrowOptionBtns.Length; i++)
+        {
+            int optionID = i;
+            arrowOptionBtns[i].onClick.AddListener(delegate() {
+                AudioMgr.ins.PlayBtn();
+                //select
+                float acc = 16;
+                if (optionID == 1) {
+                    acc = 64;
+                }
+                SelectAccForArrow(acc);
+                //save
+                LoginMgr.myUserInfo.deviceAccValue = acc;
+                LoginMgr.myUserInfo.Save();
+            });
+        }
+        SelectAccForArrow(LoginMgr.myUserInfo.deviceAccValue);
+    }
+
+    void SelectAccForArrow(float acc)
+    {
+        for (int i = 0; i < arrowOptions.transform.childCount; i++)
+        {
+            Transform t = arrowOptions.transform.GetChild(i);
+            t.GetComponent<Button>().enabled = true;
+            t.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonGray");
+            t.GetComponentInChildren<Text>().color = Color.gray;
+        }
+        Transform optionTransform;
+        Color outColor;
+        if (acc == 16)
+        {
+            optionTransform = arrowOptions.transform.GetChild(0);
+            optionTransform.GetComponent<Button>().enabled = false;
+            ColorUtility.TryParseHtmlString("#3D6B03", out outColor);
+            optionTransform.GetComponentInChildren<Text>().color = outColor;
+            optionTransform.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonGreen");
+        }
+        else if (acc == 64)
+        {
+            optionTransform = arrowOptions.transform.GetChild(1);
+            optionTransform.GetComponent<Button>().enabled = false;
+            ColorUtility.TryParseHtmlString("#B65A00", out outColor);
+            optionTransform.GetComponentInChildren<Text>().color = outColor;
+            optionTransform.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonYellow");
+        }
+    }
+
+    DeviceInfo currentDeviceInfo;
+    void SelectItem(DeviceInfo deviceInfo)
+    {
+        currentDeviceInfo = deviceInfo;
+        Image modelImage = this.transform.Find("ItemShow/Model").GetComponent<Image>();
+        modelImage.sprite = Resources.Load<Sprite>("Textures/Device/" + deviceInfo.config.model);
+        modelImage.SetNativeSize();
+        this.transform.Find("ItemInfo/Name").GetComponent<TextAutoLanguage>().SetText(deviceInfo.config.name);
+        this.transform.Find("ItemInfo/Detail").GetComponent<TextAutoLanguage>().SetText(deviceInfo.config.detail);
+        Transform stars = this.transform.Find("ItemInfo/Stars");
+        Image starLight = stars.GetChild(0).GetComponent<Image>();
+        Image starDark = stars.GetChild(1).GetComponent<Image>();
+        starLight.gameObject.SetActive(false);
+        starDark.gameObject.SetActive(false);
+        for (int i = 1; i <= 5; i++) {
+            stars.GetChild(i + 2).GetComponent<Image>().sprite = 
+                i <= deviceInfo.config.difficulty ? starLight.sprite : starDark.sprite;
+        }
+        bowOptions.SetActive(deviceInfo.config.type == 1);
+        arrowOptions.SetActive(deviceInfo.config.type == 2);
+    }
+
+    public void LeftPointer()
+    {
+        AudioMgr.ins.PlayBtn();
+        int index = deviceList.IndexOf(currentDeviceInfo) - 1;
+        if (index < 0) {
+            index = deviceList.Count - 1;
+        }
+        SelectItem(deviceList[index]);
+    }
+
+    public void RightPointer()
+    {
+        AudioMgr.ins.PlayBtn();
+        int index = deviceList.IndexOf(currentDeviceInfo) + 1;
+        if (index >= deviceList.Count) {
+            index = 0;
+        }
+        SelectItem(deviceList[index]);
     }
 
     public void Back() {

Некоторые файлы не были показаны из-за большого количества измененных файлов