diff options
Diffstat (limited to 'SurvivalTest/Assets/Scripts/UI/Panel')
13 files changed, 297 insertions, 1 deletions
diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelDecorationBar.meta b/SurvivalTest/Assets/Scripts/UI/Panel/PanelDecorationBar.meta new file mode 100644 index 0000000..01fa061 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelDecorationBar.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fb019ee665a1bd64fab6f1cbf9a8c98c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelDecorationBar/UIDecorationWidget.cs b/SurvivalTest/Assets/Scripts/UI/Panel/PanelDecorationBar/UIDecorationWidget.cs new file mode 100644 index 0000000..57a4071 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelDecorationBar/UIDecorationWidget.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public struct UIDecorationWidgetParam +{ + public DecorationBase decoration; +} + +public class UIDecorationWidget : UIGridItemBase +{ + public Image Image_Icon; + + public DecorationBase decoration { get { return m_Decoration; } } + private DecorationBase m_Decoration; + + public override void Set(object param) + { + UIDecorationWidgetParam info = (UIDecorationWidgetParam)param; + m_Decoration = info.decoration; + + Image_Icon.sprite = ResourceManager.Instance.Load<Sprite>(info.decoration.iconPath); + } + + private void Update() + { + } + +}
\ No newline at end of file diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelDecorationBar/UIDecorationWidget.cs.meta b/SurvivalTest/Assets/Scripts/UI/Panel/PanelDecorationBar/UIDecorationWidget.cs.meta new file mode 100644 index 0000000..893e695 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelDecorationBar/UIDecorationWidget.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 686d7a38ee74b0d4489402f2727a1765 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelItemBar/ItemWidget.cs b/SurvivalTest/Assets/Scripts/UI/Panel/PanelItemBar/ItemWidget.cs index 552672a..3227bd8 100644 --- a/SurvivalTest/Assets/Scripts/UI/Panel/PanelItemBar/ItemWidget.cs +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelItemBar/ItemWidget.cs @@ -70,7 +70,7 @@ public class ItemWidget : UIGridItemBase IEnumerator CoUseAnimation() { - float speed = 5f; + float speed = 7f; while(m_PendingUse > 0) { diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar.meta b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar.meta new file mode 100644 index 0000000..f57d336 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e369b816220311a479b64dffd9f3b5a5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/PanelTopStuffBar.cs b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/PanelTopStuffBar.cs new file mode 100644 index 0000000..2d1e02b --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/PanelTopStuffBar.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PanelTopStuffBar : PanelBase +{ + public UIEquipBar m_EquipBar; + public UIItemBar m_ItemBar; + public UIDecorationBar m_DecorationBar; + + public override void Set(object param) + { + m_EquipBar.Set(); + m_ItemBar.Set(); + m_DecorationBar.Set(); + } +}
\ No newline at end of file diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/PanelTopStuffBar.cs.meta b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/PanelTopStuffBar.cs.meta new file mode 100644 index 0000000..ba0424f --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/PanelTopStuffBar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c7a0239a22d86847b5806d7e4f2e500 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIDecorationBar.cs b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIDecorationBar.cs new file mode 100644 index 0000000..6dce384 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIDecorationBar.cs @@ -0,0 +1,42 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class UIDecorationBar : MonoBehaviour +{ + public UIDecorationWidget m_DecorationTemplate; + + public UISimpleGrid m_DecorationGrid; + + private List<UIDecorationWidget> m_Decorations = new List<UIDecorationWidget>(); + + public void Set() + { + m_DecorationTemplate.gameObject.SetActive(false); + + for (int i = 0; i < PlayerManager.Instance.decorations.Count; ++i) + { + UIDecorationWidget widget = MakeDecorationWidget(PlayerManager.Instance.decorations[i]); + m_Decorations.Add(widget); + } + } + + UIDecorationWidget MakeDecorationWidget(DecorationBase decoration) + { + UIDecorationWidget widget = Instantiate<UIDecorationWidget>(m_DecorationTemplate); + widget.transform.SetParent(m_DecorationGrid.transform); + widget.gameObject.SetActive(true); + widget.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, 0); +#if UNITY_EDITOR + widget.name = "decoration (" + decoration.name + ")"; +#endif + + UIDecorationWidgetParam param = new UIDecorationWidgetParam(); + param.decoration = decoration; + widget.Set(param); + return widget; + } + + + +}
\ No newline at end of file diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIDecorationBar.cs.meta b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIDecorationBar.cs.meta new file mode 100644 index 0000000..ac771c3 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIDecorationBar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d41adc469fe729a488b68790c33b6856 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIEquipBar.cs b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIEquipBar.cs new file mode 100644 index 0000000..d658663 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIEquipBar.cs @@ -0,0 +1,41 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class UIEquipBar : MonoBehaviour +{ + public UIEquipWidget m_EquipTemplate; + + public UISimpleGrid m_EquipGrid; + + private List<UIEquipWidget> m_Equips = new List<UIEquipWidget>(); + + public void Set() + { + m_EquipTemplate.gameObject.SetActive(false); + + for (int i = 0; i < PlayerManager.Instance.equips.Count; ++i) + { + UIEquipWidget widget = MakeEquipWidget(PlayerManager.Instance.equips[i]); + m_Equips.Add(widget); + } + } + + UIEquipWidget MakeEquipWidget(EquipBase equip) + { + UIEquipWidget widget = Instantiate<UIEquipWidget>(m_EquipTemplate); + widget.transform.SetParent(m_EquipGrid.transform); + widget.gameObject.SetActive(true); + widget.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, 0); +#if UNITY_EDITOR + widget.name = "equip (" + equip.name + ")"; +#endif + + UIEquipWidgetParam param = new UIEquipWidgetParam(); + param.equip = equip; + widget.Set(param); + return widget; + } + + +} diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIEquipBar.cs.meta b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIEquipBar.cs.meta new file mode 100644 index 0000000..68bf843 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIEquipBar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3eefcc4321abff24e88f7cbb843e3fda +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIItemBar.cs b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIItemBar.cs new file mode 100644 index 0000000..ecb6ea1 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIItemBar.cs @@ -0,0 +1,95 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class UIItemBar : MonoBehaviour +{ + public ItemWidget m_ItemTempalte; + + public UISimpleGrid m_ItemGrid; + + public Text m_TextName; + + private List<ItemWidget> m_Items = new List<ItemWidget>(); + + private int m_CurrentIndex = 0; + + public void Set() + { + for (int i = 0; i < PlayerManager.Instance.items.Count; ++i) + { + ItemWidget widget = MakeItemWidget(PlayerManager.Instance.items[i]); + m_Items.Add(widget); + } + + SelectItemWidget(0); + } + + bool SwitchToLeft() + { + return Input.GetButtonDown("LeftItem"); + } + + bool SwitchToRight() + { + return Input.GetButtonDown("RightItem"); + } + + bool UseItem() + { + return Input.GetButtonDown("Fire3"); + } + + ItemWidget MakeItemWidget(ItemBase item) + { + ItemWidget widget = Instantiate<ItemWidget>(m_ItemTempalte); + widget.transform.SetParent(m_ItemGrid.transform); + widget.gameObject.SetActive(true); + widget.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, 0); +#if UNITY_EDITOR + widget.name = "item (" + item.name + ")"; +#endif + + ItemWidgetParam param = new ItemWidgetParam(); + //param.onSelected = OnSelectItemWidget; + param.item = item; + widget.Set(param); + return widget; + } + + protected void Update() + { + if (SwitchToLeft()) + { + int newIndex = Mathf.Clamp(m_CurrentIndex - 1, 0, m_Items.Count - 1); + SelectItemWidget(newIndex); + } + if (SwitchToRight()) + { + int newIndex = Mathf.Clamp(m_CurrentIndex + 1, 0, m_Items.Count - 1); + SelectItemWidget(newIndex); + } + if (UseItem()) + { + m_Items[m_CurrentIndex].OnUseCallback(); + PlayerManager.Instance.UseItem(m_Items[m_CurrentIndex].item); + } + } + + void SelectItemWidget(int index) + { + if (index < 0 || index > m_Items.Count - 1) + { + return; + } + m_Items[m_CurrentIndex].OnDeselectCallback(); + m_Items[index].OnSelectCallback(); + + m_TextName.text = m_Items[index].item.name; + m_TextName.gameObject.SetActive(false); + + m_CurrentIndex = index; + } + +} diff --git a/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIItemBar.cs.meta b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIItemBar.cs.meta new file mode 100644 index 0000000..0e07369 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/UI/Panel/PanelTopStuffBar/UIItemBar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b480696215d6c2a4b8d69edc2946cf3d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |