diff --git a/meng_yao/Assets/Resources/Prefabs/AssetsPanel.prefab b/meng_yao/Assets/Resources/Prefabs/AssetsPanel.prefab index ab627839f..4ab80c996 100644 --- a/meng_yao/Assets/Resources/Prefabs/AssetsPanel.prefab +++ b/meng_yao/Assets/Resources/Prefabs/AssetsPanel.prefab @@ -1003,6 +1003,7 @@ GameObject: m_Component: - component: {fileID: 4284489241738703987} - component: {fileID: 4284489241738703984} + - component: {fileID: 44085837872364204} m_Layer: 5 m_Name: AssetsPanel m_TagString: Untagged @@ -1058,6 +1059,22 @@ MonoBehaviour: m_ChildScaleWidth: 0 m_ChildScaleHeight: 0 m_ReverseArrangement: 0 +--- !u!114 &44085837872364204 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4284489241738703986} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 21c091287355b794bba54c08c0a11ab5, type: 3} + m_Name: + m_EditorClassIdentifier: + Stone: {fileID: 4284489241411994666} + Coin: {fileID: 4284489241406162018} + Ore: {fileID: 4284489240705305073} + Forging: {fileID: 4284489241848196371} --- !u!1 &4284489241775518536 GameObject: m_ObjectHideFlags: 0 diff --git a/meng_yao/Assets/script/Panel/AssestPanel.cs b/meng_yao/Assets/script/Panel/AssestPanel.cs new file mode 100644 index 000000000..d246e27d2 --- /dev/null +++ b/meng_yao/Assets/script/Panel/AssestPanel.cs @@ -0,0 +1,52 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +public class AssestPanel : MonoBehaviour +{ + public static AssestPanel instance; + + public Text Stone; + public Text Coin; + public Text Ore; + public Text Forging; + + void Start() + { + instance = this; + Stone.text = PlayerManager.Instance.Stones.ToString(); + Forging.text=PlayerManager.Instance.Forging.ToString(); + Coin.text=PlayerManager.Instance.Coins.ToString(); + Ore.text=PlayerManager.Instance.Ore.ToString(); + } + + public void SetStoneText(float num) + { + if (Stone!=null) + { + Stone.text=num.ToString(); + } + + } + public void SetCoinText(float num) + { + if (Coin != null) + { + Coin.text = num.ToString(); + } + } + public void SetOreText(float num) + { + if (Ore != null) + { + Ore.text = num.ToString(); + } + } + public void SetForgingText(float num) + { + if (Forging != null) + { + Forging.text = num.ToString(); + } + } +} diff --git a/meng_yao/Assets/script/Panel/AssestPanel.cs.meta b/meng_yao/Assets/script/Panel/AssestPanel.cs.meta new file mode 100644 index 000000000..3e9f3f61d --- /dev/null +++ b/meng_yao/Assets/script/Panel/AssestPanel.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 21c091287355b794bba54c08c0a11ab5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/meng_yao/Assets/script/Player.meta b/meng_yao/Assets/script/Player.meta new file mode 100644 index 000000000..1ef361fdb --- /dev/null +++ b/meng_yao/Assets/script/Player.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e1986fcddfc31824ebdd1b29797b201f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/meng_yao/Assets/script/Player/PlayerManager.cs b/meng_yao/Assets/script/Player/PlayerManager.cs new file mode 100644 index 000000000..f1153be42 --- /dev/null +++ b/meng_yao/Assets/script/Player/PlayerManager.cs @@ -0,0 +1,83 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public enum MoneyType { + + Stones,//钻石 + Forging,//锻造 + Coins,//金币 + Ore//矿石 + + +} + + + + +public class PlayerManager +{ + private static PlayerManager _instance; + public static PlayerManager Instance + { + get + { + if (_instance == null) + { + _instance = new PlayerManager(); + + } + return _instance; + } + } + + public float Stones = 100; + public float Forging = 100; + public float Coins = 100; + public float Ore = 100; + + + + public void SetMoney(MoneyType type,float num) + { + switch (type) + { + case MoneyType.Stones: + if ((Stones + num) < 0) + { + Promptmgr.Instance.PromptBubble("砖石不足!!!",Color.black,Color.red); + return; + } + Stones += num; + AssestPanel.instance.SetStoneText(Stones); + break; + case MoneyType.Forging: + if((Forging + num) < 0) + { + Promptmgr.Instance.PromptBubble("锻造币不足!!!", Color.black, Color.red); + return; + } + Forging += num; + AssestPanel.instance.SetForgingText(Forging); + break; + case MoneyType.Coins: + if ((Coins + num) < 0) + { + Promptmgr.Instance.PromptBubble("锻造币不足!!!", Color.black, Color.red); + return; + } + Coins += num; + AssestPanel.instance.SetCoinText(Coins); + break; + case MoneyType.Ore: + if ((Ore + num) < 0) + { + Promptmgr.Instance.PromptBubble("矿石不足!!!", Color.black, Color.red); + return; + } + Ore += num; + AssestPanel.instance.SetOreText(Ore); + break; + } + } +} \ No newline at end of file diff --git a/meng_yao/Assets/script/Player/PlayerManager.cs.meta b/meng_yao/Assets/script/Player/PlayerManager.cs.meta new file mode 100644 index 000000000..6d52ae035 --- /dev/null +++ b/meng_yao/Assets/script/Player/PlayerManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 97ab4196e439a65469b332d791a21c21 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/meng_yao/Assets/script/cultivation_gold_coin_Island/landContorl.cs b/meng_yao/Assets/script/cultivation_gold_coin_Island/landContorl.cs index 06fa6bde0..0daa7708a 100644 --- a/meng_yao/Assets/script/cultivation_gold_coin_Island/landContorl.cs +++ b/meng_yao/Assets/script/cultivation_gold_coin_Island/landContorl.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using UnityEngine; using DG.Tweening; using TMPro; - [System.Serializable] public class Path { @@ -43,12 +42,15 @@ public class landContorl : MonoBehaviour public Transform Btntrans; + public float FishPrice; // Start is called before the first frame update private void Start() { - + FishPrice = 10; + + if (goldshop == null) { Debug.LogError("goldshop==null"); @@ -71,15 +73,16 @@ public class landContorl : MonoBehaviour { ScaleAni(Btntrans); - + if (fishMan!=null) { Promptmgr.Instance.PromptBubble("船已经有了",Color.black,Color.red); return; } - Debug.LogError("检测通过"); - Debug.LogError("扣钱逻辑"); + //Debug.LogError("检测通过"); + //Debug.LogError("扣钱逻辑"); + PlayerManager.Instance.SetMoney(MoneyType.Stones, -FishPrice); fishMan = GameObject.Instantiate(fishManPrefab); //fishMan.transform.SetParent(startPos); fishMan.transform.position = startPos.position;