Cute_demon_attacks/meng_yao/Assets/script/Player/PlayerManager.cs
2024-11-04 06:56:09 +08:00

98 lines
2.4 KiB
C#

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;
}
}
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;
}
}