Cute_demon_attacks/meng_yao/Assets/script/Player/PlayerManager.cs
wulongxiao e552d26617 接口
2024-12-17 15:31:37 +08:00

103 lines
2.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public enum MoneyType {
Stones,//钻石
Forging,//锻造
Coins,//金币
Ore//矿石
}
public class PlayerManager
{
private static PlayerManager _instance;
public Main_jiekou main_Jiekou;
public static PlayerManager Instance
{
get
{
if (_instance == null)
{
_instance = new PlayerManager();
}
return _instance;
}
}
public float Stones = 10000;
public float Forging = 10000;
public float Coins = 10000;
public float Ore = 10000;
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;
// Promptmgr.assestPanel.SetStoneText(Stones);
break;
case MoneyType.Forging:
if((Forging + num) < 0)
{
Promptmgr.Instance.PromptBubble("锻造币不足!!!", Color.black, Color.red);
return;
}
Forging += num;
// Promptmgr.assestPanel.SetForgingText(Forging);
break;
case MoneyType.Coins:
if ((Coins + num) < 0)
{
Promptmgr.Instance.PromptBubble("锻造币不足!!!", Color.black, Color.red);
return;
}
Coins += num;
// Promptmgr.assestPanel.SetCoinText(Coins);
break;
case MoneyType.Ore:
if ((Ore + num) < 0)
{
Promptmgr.Instance.PromptBubble("矿石不足!!!", Color.black, Color.red);
return;
}
Ore += num;
// Promptmgr.assestPanel.SetOreText(Ore);
break;
}
}
public float GetNumer(MoneyType type)
{
switch (type)
{
case MoneyType.Stones:
return Stones;
case MoneyType.Forging:
return Forging;
case MoneyType.Coins:
return Coins;
case MoneyType.Ore:
return Ore;
}
return 0;
}
}