1
This commit is contained in:
8
unity/Assets/Script/UI/Bag.meta
Normal file
8
unity/Assets/Script/UI/Bag.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3363aa678bc5a3947aeca6018e775f7f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
unity/Assets/Script/UI/Bag/CanUseItem.cs
Normal file
53
unity/Assets/Script/UI/Bag/CanUseItem.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CanUseItem : MonoBehaviour
|
||||
{
|
||||
public Transform rectTransfrom;
|
||||
|
||||
public Text UpItemNum;
|
||||
private void OnEnable()
|
||||
{
|
||||
PlayerInfo.Instance.OnUpdateMainUI += UpdateUI;
|
||||
UpdateUI();
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
PlayerInfo.Instance.OnUpdateMainUI -= UpdateUI;
|
||||
}
|
||||
public void UpdateUI()
|
||||
{
|
||||
foreach (Transform item in rectTransfrom)
|
||||
{
|
||||
Destroy(item.gameObject);
|
||||
}
|
||||
if(PlayerInfo.Instance.info.BagInfo.Count==0|| !PlayerInfo.Instance.info.BagInfo.ContainsKey(0))//背包中没有道具
|
||||
{
|
||||
UpItemNum.text = "0";
|
||||
}
|
||||
foreach (var item in PlayerInfo.Instance.info.BagInfo)
|
||||
{
|
||||
if(item.Key==Date.Instance.ItemDate[0].Id)//背包中道具Id等于道具表中的升级道具
|
||||
{
|
||||
UpItemNum.text = item.Value.ToString();
|
||||
}
|
||||
|
||||
if(Date.Instance.ItemDate[item.Key].type==ItemClass.User)//能够使用的道具
|
||||
{
|
||||
string path = "UI/Perfab/Item";
|
||||
UnityEngine.Object go = Resloader.Load<GameObject>(path);
|
||||
if (go != null)//预制体不为空
|
||||
{
|
||||
GameObject m = (GameObject)Instantiate(go, rectTransfrom);
|
||||
UIItemInfo ui = m.GetComponent<UIItemInfo>();
|
||||
ui.gameObject.SetActive(true);
|
||||
|
||||
ui.SetInfo(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/Bag/CanUseItem.cs.meta
Normal file
11
unity/Assets/Script/UI/Bag/CanUseItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c480308bc5b87dd4193ea0174eb6d6b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
unity/Assets/Script/UI/Bag/Date.cs
Normal file
47
unity/Assets/Script/UI/Bag/Date.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Date:Singleton<Date>
|
||||
{
|
||||
public List<Item> ItemDate = new List<Item>();
|
||||
|
||||
public List<LevelUpDefine> UpDate = new List<LevelUpDefine>();
|
||||
|
||||
}
|
||||
|
||||
public enum ItemClass
|
||||
{
|
||||
User,
|
||||
Up,
|
||||
}
|
||||
[Serializable]
|
||||
public class CharInfo
|
||||
{
|
||||
public string DatePath;
|
||||
|
||||
public string playerName;
|
||||
public int Level;
|
||||
public int exp;
|
||||
|
||||
public float maxHp;
|
||||
public float attack;
|
||||
|
||||
//局内属性
|
||||
public int currentMap;
|
||||
public float currentHp;
|
||||
public float testAttack;
|
||||
|
||||
//背包数据
|
||||
public Dictionary<int, int> BagInfo;//背包字典
|
||||
public List<int> BagKey;
|
||||
public List<int> BagValue;
|
||||
|
||||
//升级数据
|
||||
|
||||
public Dictionary<int, bool> UpInfo;//升级字典
|
||||
public List<int> UpKey;
|
||||
public List<bool> UpValue;
|
||||
}
|
||||
|
||||
11
unity/Assets/Script/UI/Bag/Date.cs.meta
Normal file
11
unity/Assets/Script/UI/Bag/Date.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0af01c0f76595044aa27ad201f2d08b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
unity/Assets/Script/UI/Bag/ItemTip.cs
Normal file
21
unity/Assets/Script/UI/Bag/ItemTip.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ItemTip : MonoBehaviour
|
||||
{
|
||||
public Image icon;
|
||||
public Text itemName;
|
||||
public Text descripte;
|
||||
|
||||
|
||||
public void Init(Item item)
|
||||
{
|
||||
if (item == null) return;
|
||||
itemName.text = item.ItemName;
|
||||
descripte.text = item.Descripte;
|
||||
icon.sprite = PlayerInfo.Instance.GetSprite(item.Path);
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/Bag/ItemTip.cs.meta
Normal file
11
unity/Assets/Script/UI/Bag/ItemTip.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f120710dbd20f65488798761408eddb4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
unity/Assets/Script/UI/Bag/UIBagInfo.cs
Normal file
53
unity/Assets/Script/UI/Bag/UIBagInfo.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIBagInfo : UIWindow
|
||||
{
|
||||
public Transform rectTransfrom;
|
||||
|
||||
public ItemTip tip;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
tip.gameObject.SetActive(false);
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
PlayerInfo.Instance.OnUpdateBagInfo += UpdateUI;
|
||||
UpdateUI();
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
PlayerInfo.Instance.OnUpdateBagInfo -= UpdateUI;
|
||||
tip.gameObject.SetActive(false);
|
||||
}
|
||||
public void UpdateUI()
|
||||
{
|
||||
foreach (Transform item in rectTransfrom)
|
||||
{
|
||||
Destroy(item.gameObject);
|
||||
}
|
||||
foreach (var item in PlayerInfo.Instance.info.BagInfo)
|
||||
{
|
||||
string path = "UI/Perfab/Item";
|
||||
UnityEngine.Object go = Resloader.Load<GameObject>(path);
|
||||
if (go != null)
|
||||
{
|
||||
GameObject m = (GameObject)Instantiate(go, rectTransfrom);
|
||||
UIItemInfo ui = m.GetComponent<UIItemInfo>();
|
||||
ui.gameObject.SetActive(true);
|
||||
|
||||
ui.SetInfo(item.Key, item.Value,this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowItem(Item item)
|
||||
{
|
||||
tip.gameObject.SetActive(true);
|
||||
tip.Init(item);
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/Bag/UIBagInfo.cs.meta
Normal file
11
unity/Assets/Script/UI/Bag/UIBagInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e4c791cc72f9824fa30639aa8129d70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
unity/Assets/Script/UI/Bag/UIItemInfo.cs
Normal file
50
unity/Assets/Script/UI/Bag/UIItemInfo.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIItemInfo : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public Text numText;
|
||||
public Text itemName;
|
||||
public Image icon;
|
||||
|
||||
public UIBagInfo info;
|
||||
public Item item;
|
||||
|
||||
public void SetInfo(int id,int num,UIBagInfo root)
|
||||
{
|
||||
info = root;
|
||||
foreach(var item in Date.Instance.ItemDate)
|
||||
{
|
||||
if(item.Id==id)
|
||||
{
|
||||
this.item = item;
|
||||
itemName.text = item.ItemName;
|
||||
numText.text = num.ToString();
|
||||
icon.sprite = PlayerInfo.Instance.GetSprite(item.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetInfo(int id, int num)
|
||||
{
|
||||
foreach (var item in Date.Instance.ItemDate)
|
||||
{
|
||||
if (item.Id == id)
|
||||
{
|
||||
this.item = item;
|
||||
itemName.text = item.ItemName;
|
||||
numText.text = num.ToString();
|
||||
icon.sprite = PlayerInfo.Instance.GetSprite(item.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("µã»÷");
|
||||
info.ShowItem(item);
|
||||
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/Bag/UIItemInfo.cs.meta
Normal file
11
unity/Assets/Script/UI/Bag/UIItemInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5338ea0901669d409a14b6811dfc1ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
91
unity/Assets/Script/UI/CharacterHp.cs
Normal file
91
unity/Assets/Script/UI/CharacterHp.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CharacterHp : MonoBehaviour
|
||||
{
|
||||
public GameObject EndUI;
|
||||
|
||||
//UI
|
||||
public Image headImage;
|
||||
private float maxHp;
|
||||
public Slider hpBar;
|
||||
public Text bossName;
|
||||
public Text hpText;
|
||||
public Text atk;
|
||||
|
||||
private Animator _animator;
|
||||
private BossAI bossAI;
|
||||
private CharacterCombat charComba;
|
||||
private void Awake()
|
||||
{
|
||||
hpBar.value = 1;
|
||||
}
|
||||
public void Init(BossAI ai)
|
||||
{
|
||||
_animator = ai._animator;
|
||||
headImage.overrideSprite = ai._info.bossHead;
|
||||
maxHp = ai.maxHp;
|
||||
hpText.text = maxHp + "/" + maxHp;
|
||||
|
||||
bossAI = ai;
|
||||
bossName.text = ai._info.bossName;
|
||||
ai.OnHit += OnUpdate;
|
||||
}
|
||||
public void Init(CharacterCombat ch)
|
||||
{
|
||||
_animator = ch._animator;
|
||||
maxHp = ch.maxHp;
|
||||
hpText.text = ch.currentHp + "/" + maxHp;
|
||||
charComba = ch;
|
||||
atk.text = ch.attack.ToString();
|
||||
bossName.text = PlayerInfo.Instance.info.playerName;
|
||||
ch.OnHit += OnUpdate;
|
||||
}
|
||||
|
||||
private void OnUpdate(float hp)
|
||||
{
|
||||
if(bossAI==null)
|
||||
{
|
||||
maxHp = charComba.maxHp;
|
||||
atk.text = charComba.attack.ToString();
|
||||
}
|
||||
hpBar.value = hp/maxHp;
|
||||
hpText.text = hp + "/" + maxHp;
|
||||
if (hp<=0)
|
||||
{
|
||||
_animator.Play("die");
|
||||
hpText.text = "0/" + maxHp;
|
||||
if (charComba==null)//¹ÖÎչʾÖÕ½áUI
|
||||
{
|
||||
EndUI.SetActive(true);
|
||||
StartCoroutine(StartTimer(1f));
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.Instance.Show<UIGameOver>();
|
||||
}
|
||||
}
|
||||
}
|
||||
IEnumerator StartTimer(float t)
|
||||
{
|
||||
yield return new WaitForSeconds(t);
|
||||
|
||||
EndUI.SetActive(false);
|
||||
yield return new WaitForSeconds(t);
|
||||
|
||||
//½±Àø
|
||||
UIManager.Instance.Show<UILottery>();
|
||||
PlayerInfo.Instance.BagMgr.AddItem(1, 2);
|
||||
PlayerInfo.Instance.BagMgr.AddItem(0, 2);
|
||||
PlayerInfo.Instance.info.exp += 2000;
|
||||
PlayerInfo.Instance.LevelUp();
|
||||
PlayerInfo.Instance.OnUpdateLevel?.Invoke();
|
||||
//
|
||||
|
||||
this.gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/CharacterHp.cs.meta
Normal file
11
unity/Assets/Script/UI/CharacterHp.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25181661743cceb4dbeb94494e7f83e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
unity/Assets/Script/UI/EndUI.cs
Normal file
14
unity/Assets/Script/UI/EndUI.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EndUI : UIWindow
|
||||
{
|
||||
public override void OnYesClick()
|
||||
{
|
||||
|
||||
base.OnYesClick();
|
||||
|
||||
Manager.SenceManager.Instance.LoadScene(1);
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/EndUI.cs.meta
Normal file
11
unity/Assets/Script/UI/EndUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbbdcbd0977ffcb4e87f9c692ee13b69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
unity/Assets/Script/UI/SaveItem.cs
Normal file
47
unity/Assets/Script/UI/SaveItem.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SaveItem : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public Text _PlayerName;
|
||||
public Text _PlayerLevel;
|
||||
|
||||
public string DateFileName;
|
||||
|
||||
public Text DateName;
|
||||
|
||||
private CharInfo info;
|
||||
|
||||
public UISaveDate root;
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
|
||||
root.Select(info, DateName.text, DateFileName);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
//初始化存档数据
|
||||
var date = SaveSystem.LoadDate<CharInfo>(DateFileName);
|
||||
if (date != null)
|
||||
{
|
||||
//数据加载
|
||||
info = date;
|
||||
_PlayerName.text = info.playerName;
|
||||
_PlayerLevel.text = "LV " + info.Level.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
_PlayerName.text = "空白存档";
|
||||
_PlayerLevel.text = "LV 1";
|
||||
}
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/SaveItem.cs.meta
Normal file
11
unity/Assets/Script/UI/SaveItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 897a5a659802d994da33b1d1acd76890
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
unity/Assets/Script/UI/UIEnterScene.cs
Normal file
39
unity/Assets/Script/UI/UIEnterScene.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIEnterScene : UIWindow
|
||||
{
|
||||
public Image headImage;
|
||||
public Text bossNameText;
|
||||
|
||||
public GameObject bossHp;
|
||||
public GameObject enterUI;
|
||||
public BossAI Boss;
|
||||
|
||||
public void InitInfo(Sprite head,string bossName)
|
||||
{
|
||||
headImage.overrideSprite = head;
|
||||
bossNameText.text = bossName;
|
||||
|
||||
StartCoroutine(nameof(SetActive));
|
||||
}
|
||||
private IEnumerator SetActive()
|
||||
{
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
|
||||
Boss = GameObject.FindWithTag("Boss").GetComponentInChildren<BossAI>();
|
||||
if (Boss != null)
|
||||
{
|
||||
bossHp.SetActive(true);
|
||||
bossHp.GetComponent<CharacterHp>().Init(Boss);
|
||||
}
|
||||
enterUI.SetActive(false);
|
||||
}
|
||||
|
||||
public void UpdateInfo()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/UIEnterScene.cs.meta
Normal file
11
unity/Assets/Script/UI/UIEnterScene.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9964813250134442b2448c548cd98b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
unity/Assets/Script/UI/UIGameOver.cs
Normal file
39
unity/Assets/Script/UI/UIGameOver.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Manager;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class UIGameOver : UIWindow
|
||||
{
|
||||
public Vector3 oldScal;
|
||||
//public GameObject ContinueButton;
|
||||
private void Awake()
|
||||
{
|
||||
oldScal = transform.localScale;
|
||||
|
||||
}
|
||||
|
||||
public void OnReset()//»Øµ½´óÌü
|
||||
{
|
||||
Debug.Log("UI");
|
||||
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
|
||||
|
||||
SenceManager.Instance.LoadScene(1);
|
||||
|
||||
SoundManager.Instance.PlayMusic(SoundDefine.Map_1Music);
|
||||
|
||||
PlayerInfo.Instance.Resrt();
|
||||
}
|
||||
|
||||
public void OnExit()
|
||||
{
|
||||
SenceManager.Instance.LoadScene(0);
|
||||
|
||||
PlayerInfo.Instance.info.currentMap = 1;
|
||||
SaveSystem.SaveDate(PlayerInfo.Instance.info.DatePath, PlayerInfo.Instance.info);
|
||||
|
||||
SoundManager.Instance.PlayMusic(SoundDefine.LoadingMusic);
|
||||
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/UIGameOver.cs.meta
Normal file
11
unity/Assets/Script/UI/UIGameOver.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 692e1b4614774c64c926ced80d9498a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
unity/Assets/Script/UI/UILevel.cs
Normal file
32
unity/Assets/Script/UI/UILevel.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class UILevel : MonoBehaviour
|
||||
{
|
||||
public Text level;
|
||||
public Scrollbar exp;
|
||||
float needExp;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
PlayerInfo.Instance.OnUpdateLevel += UpdateLevel;
|
||||
UpdateLevel();
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
PlayerInfo.Instance.OnUpdateLevel -= UpdateLevel;
|
||||
}
|
||||
public void UpdateLevel()
|
||||
{
|
||||
needExp = PlayerInfo.Instance.NeedExp();
|
||||
level.text = "Lv " + PlayerInfo.Instance.info.Level.ToString();
|
||||
|
||||
exp.size = (float)PlayerInfo.Instance.info.exp / needExp;
|
||||
if(exp.size==1)
|
||||
{
|
||||
needExp = PlayerInfo.Instance.NeedExp();
|
||||
exp.size = PlayerInfo.Instance.info.exp / needExp;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/UILevel.cs.meta
Normal file
11
unity/Assets/Script/UI/UILevel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b03d31d4afd84c44e80cc74e032cce16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
72
unity/Assets/Script/UI/UILoad.cs
Normal file
72
unity/Assets/Script/UI/UILoad.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Manager;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
|
||||
public class UILoad : MonoBehaviour
|
||||
{
|
||||
public Slider progressBar;
|
||||
public Text progressText;
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
Scene scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
|
||||
|
||||
|
||||
for (float i = 0; i < 100;)
|
||||
{
|
||||
i += Random.Range(0.1f, 1.5f);
|
||||
progressBar.value = i;
|
||||
if (i > 100)
|
||||
{
|
||||
progressText.text = "99%";
|
||||
}
|
||||
else
|
||||
{
|
||||
progressText.text = i + "%";
|
||||
}
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
if (scene.buildIndex == 1)
|
||||
{
|
||||
if (!PlayerInfo.Instance.info.BagInfo.ContainsKey(1))
|
||||
{
|
||||
PlayerInfo.Instance.info.BagInfo.Add(1, 4);
|
||||
}
|
||||
}
|
||||
|
||||
if(scene.buildIndex==3)
|
||||
{
|
||||
UIManager.Instance.Show<EndUI>();
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.SenceManager.Instance.LoadScene(scene.buildIndex + 1);
|
||||
CheckMusic(scene.buildIndex + 1);
|
||||
Destroy(this.gameObject, 2f);
|
||||
}
|
||||
}
|
||||
private void CheckMusic(int idx)
|
||||
{
|
||||
switch (idx)
|
||||
{
|
||||
case 1:
|
||||
SoundManager.Instance.PlayMusic(SoundDefine.Map_1Music);
|
||||
break;
|
||||
case 2:
|
||||
SoundManager.Instance.PlayMusic(SoundDefine.Map_2Music);
|
||||
break;
|
||||
case 3:
|
||||
SoundManager.Instance.PlayMusic(SoundDefine.Map_3Music);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/UILoad.cs.meta
Normal file
11
unity/Assets/Script/UI/UILoad.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c11f116758584564eaaecd2cc1355e92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
73
unity/Assets/Script/UI/UILoading.cs
Normal file
73
unity/Assets/Script/UI/UILoading.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using Manager;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UILoading : MonoBehaviour
|
||||
{
|
||||
public GameObject UIBegin;
|
||||
public GameObject UITip;
|
||||
//public GameObject UISaveDate;
|
||||
// Start is called before the first frame update
|
||||
private void Awake()
|
||||
{
|
||||
DateInit();
|
||||
}
|
||||
IEnumerator Start()
|
||||
{
|
||||
Debug.Log("GameStart");
|
||||
UITip.SetActive(true);
|
||||
UIBegin.SetActive(false);
|
||||
|
||||
yield return new WaitForSeconds(2.5f);
|
||||
SoundManager.Instance.PlayMusic(SoundDefine.LoadingMusic);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
UITip.SetActive(false);
|
||||
UIBegin.SetActive(true);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
UITip.SetActive(false);
|
||||
UIBegin.SetActive(true);
|
||||
}
|
||||
public void ClickSet()
|
||||
{
|
||||
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
|
||||
UIManager.Instance.Show<UISetting>();
|
||||
}
|
||||
public void ClickContinue()
|
||||
{
|
||||
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
|
||||
//UISaveDate.SetActive(true);
|
||||
UIBegin.SetActive(false);
|
||||
UIManager.Instance.Show<UISaveDate>();
|
||||
}
|
||||
|
||||
//所有配置初始化
|
||||
public void DateInit()
|
||||
{
|
||||
Date.Instance.ItemDate.Clear();
|
||||
Date.Instance.UpDate.Clear();
|
||||
//数据初始化
|
||||
Date.Instance.ItemDate.Add(new Item { Id = 0, ItemName = "永恒之心", Descripte = "怪物的心脏,可以用于升级", Path = "Item/01", type = ItemClass.Up });
|
||||
//Date.Instance.ItemDate.Add(new Item { Id = 1, ItemName = "进阶之梯" ,Path= "Item/02", Descripte = "可以用于进阶", type = ItemClass.Up });
|
||||
Date.Instance.ItemDate.Add(new Item { Id = 1, ItemName = "生命女神的血", Path = "Item/03", Descripte = "来自生命女神的体内,可以战斗中回血", type = ItemClass.User, lotteryType = LotteryType.Hp, value = 50 });
|
||||
//Date.Instance.DateDefine.Add(new Item { Id = 2, ItemName = "魔刀千刃" });
|
||||
|
||||
Date.Instance.UpDate.Add(new LevelUpDefine { UpId = 0, PreId=0,Active = false, userId = 0, useNum = 2, type = LotteryType.UpMaxHp, value = 50 });
|
||||
|
||||
Date.Instance.UpDate.Add(new LevelUpDefine { UpId = 1, PreId = 0, Active = false, userId = 0, useNum = 4, type = LotteryType.UpHp, value = 50 });
|
||||
Date.Instance.UpDate.Add(new LevelUpDefine { UpId = 2, PreId = 1, Active = false, userId = 0, useNum = 6, type = LotteryType.UpAttack, value = 20 });
|
||||
|
||||
Date.Instance.UpDate.Add(new LevelUpDefine { UpId = 3, PreId = 0, Active = false, userId = 0, useNum = 4, type = LotteryType.UpHp, value = 50 });
|
||||
Date.Instance.UpDate.Add(new LevelUpDefine { UpId = 4, PreId = 1, Active = false, userId = 0, useNum = 6, type = LotteryType.UpAttack, value = 20 });
|
||||
|
||||
Date.Instance.UpDate.Add(new LevelUpDefine { UpId = 5, PreId = 2, Active = false, userId = 0, useNum = 8 , type = LotteryType.UpAttack, value = 20 });
|
||||
Date.Instance.UpDate.Add(new LevelUpDefine { UpId = 6, PreId = 2, Active = false, userId = 0, useNum = 8, type = LotteryType.UpMaxHp, value = 50 });
|
||||
|
||||
Date.Instance.UpDate.Add(new LevelUpDefine { UpId = 7, PreId = 4, Active = false, userId = 0, useNum = 8, type = LotteryType.UpAttack, value = 20 });
|
||||
Date.Instance.UpDate.Add(new LevelUpDefine { UpId = 8, PreId = 4, Active = false, userId = 0, useNum = 8, type = LotteryType.UpMaxHp, value = 50 });
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/UILoading.cs.meta
Normal file
11
unity/Assets/Script/UI/UILoading.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abaf2b9c464709742a2c9a2c1ed043ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
unity/Assets/Script/UI/UIOpen.cs
Normal file
18
unity/Assets/Script/UI/UIOpen.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIOpen : UIWindow
|
||||
{
|
||||
Door door;
|
||||
private void Awake()
|
||||
{
|
||||
door = GameObject.Find("Door").GetComponent<Door>();
|
||||
}
|
||||
public override void OnYesClick()
|
||||
{
|
||||
door.isOpen = true;
|
||||
|
||||
base.OnYesClick();
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/UIOpen.cs.meta
Normal file
11
unity/Assets/Script/UI/UIOpen.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7d3ebe7cf74b754bb639e32ced040ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
70
unity/Assets/Script/UI/UISaveDate.cs
Normal file
70
unity/Assets/Script/UI/UISaveDate.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Manager;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UISaveDate : UIWindow
|
||||
{
|
||||
CharInfo info;
|
||||
public List<SaveItem> items;
|
||||
public GameObject ui;
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
public void OnLoadDate()
|
||||
{
|
||||
if(info!=null)
|
||||
{
|
||||
PlayerInfo.Instance.Init(info);
|
||||
|
||||
UpdateData();
|
||||
|
||||
SenceManager.Instance.LoadScene(info.currentMap);
|
||||
switch(info.currentMap)
|
||||
{
|
||||
case 1:SoundManager.Instance.PlayMusic(SoundDefine.Map_1Music);
|
||||
break;
|
||||
case 2:
|
||||
SoundManager.Instance.PlayMusic(SoundDefine.Map_2Music);
|
||||
break;
|
||||
case 3:
|
||||
SoundManager.Instance.PlayMusic(SoundDefine.Map_3Music);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void DeleteSaveData()
|
||||
{
|
||||
if(info!=null)
|
||||
{
|
||||
SaveSystem.DeleteDate(info.DatePath);
|
||||
UpdateData();
|
||||
}
|
||||
}
|
||||
public void Select(CharInfo data,string dateName,string dataPath)
|
||||
{
|
||||
if(data!=null)
|
||||
{
|
||||
info = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.Instance.Show<MessageBox>().Init(dateName,dataPath);
|
||||
}
|
||||
}
|
||||
void UpdateData()
|
||||
{
|
||||
Debug.Log("¸üд浵");
|
||||
foreach(var item in items)
|
||||
{
|
||||
item.Init();
|
||||
}
|
||||
}
|
||||
public override void OnCloseClick()
|
||||
{
|
||||
ui = GameObject.Find("UILoading");
|
||||
if (ui == null) return;
|
||||
ui.GetComponent<UILoading>().Init();
|
||||
base.OnCloseClick();
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/UISaveDate.cs.meta
Normal file
11
unity/Assets/Script/UI/UISaveDate.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a2bbddeb4770874d987fc236cb3481e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
unity/Assets/Script/UI/UISetting.cs
Normal file
63
unity/Assets/Script/UI/UISetting.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Manager;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISetting :UIWindow
|
||||
{
|
||||
public Image musicOff;
|
||||
public Image soundOff;
|
||||
|
||||
public Toggle toggleMusic;
|
||||
public Toggle toggleSound;
|
||||
|
||||
public Slider sliderMusic;
|
||||
public Slider sliderSound;
|
||||
void Start()
|
||||
{
|
||||
this.toggleMusic.isOn = SystemConfig.MusicOn;
|
||||
this.toggleSound.isOn = SystemConfig.SoundOn;
|
||||
this.sliderMusic.value = SystemConfig.MusicVolume;
|
||||
this.sliderSound.value = SystemConfig.SoundVolume;
|
||||
}
|
||||
|
||||
public override void OnYesClick()
|
||||
{
|
||||
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
|
||||
PlayerPrefs.Save();
|
||||
base.OnYesClick();
|
||||
}
|
||||
public void MusicVolume(float vol)
|
||||
{
|
||||
SystemConfig.MusicVolume = (int)vol;
|
||||
PlaySound();
|
||||
}
|
||||
public void SoundVolume(float vol)
|
||||
{
|
||||
SystemConfig.SoundVolume = (int)vol;
|
||||
PlaySound();
|
||||
}
|
||||
public void MusicToogle(bool on)
|
||||
{
|
||||
musicOff.enabled = !on;
|
||||
SystemConfig.MusicOn = on;
|
||||
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
|
||||
}
|
||||
public void SoundToogle(bool on)
|
||||
{
|
||||
soundOff.enabled = !on;
|
||||
SystemConfig.SoundOn = on;
|
||||
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
|
||||
}
|
||||
|
||||
float lastPlay = 0;
|
||||
private void PlaySound()
|
||||
{
|
||||
if (Time.realtimeSinceStartup - lastPlay > 0.1)
|
||||
{
|
||||
lastPlay = Time.realtimeSinceStartup;
|
||||
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/UI/UISetting.cs.meta
Normal file
11
unity/Assets/Script/UI/UISetting.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4453cde885615e4ca79bbcce390a270
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user