实现 50层魔塔原版的贪婪商店功能 | 实现28层原版钥匙回收商人 | 去掉随机属性商店 | 解决40层镜像传送bug

This commit is contained in:
sin365 2024-05-06 01:47:25 +08:00
parent d12c7a2c2e
commit 181e62d81a
14 changed files with 316 additions and 297 deletions

View File

@ -169,6 +169,7 @@
<Compile Include="Assets\Scripts\Event\Level\EventLevel6Actor1.cs" />
<Compile Include="Assets\Scripts\Event\Level\EventLevel6Actor2.cs" />
<Compile Include="Assets\Scripts\Event\Level\EventLevel7Actor1.cs" />
<Compile Include="Assets\Scripts\Event\Level\ShopComm.cs" />
<Compile Include="Assets\Scripts\Framework\MonoSingleton.cs" />
<Compile Include="Assets\Scripts\Framework\Singleton.cs" />
<Compile Include="Assets\Scripts\Framework\Tools.cs" />

View File

@ -15,8 +15,10 @@ public class InfoImageController : MonoBehaviour
}
public void SetText(string text)
{
_infoText.text = text;
{
_animator = GetComponent<Animator>();
_infoText = GetComponentInChildren<Text>();
_infoText.text = text;
}
public void DestroySelf()

View File

@ -8,6 +8,14 @@ public class EventItemOther3 : MonoBehaviour, IInteraction
// 对称飞行
public bool Interaction()
{
//暂时禁用
switch (GameManager.Instance.LevelManager.Level)
{
case 40:
GameManager.Instance.UIManager.ShowInfo("BOSS层无法使用");
break;
}
// 获取对称坐标
Vector2 point = GameManager.Instance.PlayerManager.PlayerController.transform.position * -1;
// 判断坐标是否可以传送

View File

@ -1,65 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EventLevel12Actor3 : ActorController
{
public override bool Interaction()
{
// 打开商店界面
GameManager.Instance.EventManager.OnShopShow?.Invoke(GetComponent<ActorController>().Name, 50, ShopShowCallback);
return false;
}
/// <summary>
/// 打开商店回调
/// </summary>
private void ShopShowCallback()
{
// 判断金币是否足够
if (GameManager.Instance.PlayerManager.PlayerInfo.Gold < 50)
{
GameManager.Instance.UIManager.ShowInfo($"不会有人连 50 金币都没有吧!");
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "No");
return;
}
GameManager.Instance.PlayerManager.PlayerInfo.Gold -= 50;
// 随机一个属性
ERandomShopType type = ERandomShopType.Health;
int randomNumber = Random.Range(0, 100);
if (randomNumber <= 30) type = ERandomShopType.Health;
else if (randomNumber > 30 && randomNumber <= 60) type = ERandomShopType.Attack;
else if (randomNumber > 60 && randomNumber <= 90) type = ERandomShopType.Defence;
else type = ERandomShopType.Gold;
// 随机数值
switch (type)
{
case ERandomShopType.Health:
randomNumber = Random.Range(100, 400);
GameManager.Instance.PlayerManager.PlayerInfo.Health += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点生命值提升!");
break;
case ERandomShopType.Attack:
randomNumber = Random.Range(4, 20);
GameManager.Instance.PlayerManager.PlayerInfo.Attack += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点攻击力提升!");
break;
case ERandomShopType.Defence:
randomNumber = Random.Range(4, 20);
GameManager.Instance.PlayerManager.PlayerInfo.Defence += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点防御力提升!");
break;
case ERandomShopType.Gold:
randomNumber = Random.Range(40, 200);
GameManager.Instance.PlayerManager.PlayerInfo.Gold += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"运气爆棚!获得 {randomNumber} 金币!");
break;
default:
print("商店随机了个什么玩意儿?");
break;
}
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Yes");
}
ShopComm.E_ShopFloor floor = ShopComm.E_ShopFloor.F12;
public override bool Interaction()
{
// 打开商店界面
GameManager.Instance.EventManager.OnShopShow?.Invoke(GetComponent<ActorController>().Name, floor,
this,
() => ShopComm.BuyHP(floor),
() => ShopComm.BuyAtk(floor),
() => ShopComm.BuyDef(floor));
return false;
}
}

View File

@ -6,6 +6,31 @@ public class EventLevel28Actor1 : ActorController
{
public override bool Interaction()
{
GameManager.Instance.UIManager.ShowInteractionDialog(GetComponent<ResourceController>().Name, "我按100个金币一把的价格回收黄钥匙你出售吗", "成交!", "算了吧", () =>
{
if (GameManager.Instance.BackpackManager.ConsumeItem(1))
{
GameManager.Instance.PlayerManager.PlayerInfo.Gold += 100;
GameManager.Instance.UIManager.ShowInfo("失去黄色钥匙x1");
GameManager.Instance.UIManager.ShowInfo("获得100金币");
// 打开人物控制器
GameManager.Instance.PlayerManager.Enable = true;
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Yes");
}
else
{
GameManager.Instance.UIManager.ShowInfo("你没有黄钥匙");
// 打开人物控制器
GameManager.Instance.PlayerManager.Enable = true;
}
});
return false;
/*
GameManager.Instance.UIManager.ShowInteractionDialog(GetComponent<ResourceController>().Name, "我会随机赋予你属性,但同样我也会收取你一部分属性,你确定要试试吗?", "谁怕谁", "我走了", () =>
{
// 随机两个属性
@ -63,5 +88,6 @@ public class EventLevel28Actor1 : ActorController
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Yes");
});
return false;
}
*/
}
}

View File

@ -1,65 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EventLevel32Actor1 : ActorController
{
public override bool Interaction()
{
// 打开商店界面
GameManager.Instance.EventManager.OnShopShow?.Invoke(GetComponent<ActorController>().Name, 100, ShopShowCallback);
return false;
}
/// <summary>
/// 打开商店回调
/// </summary>
private void ShopShowCallback()
{
// 判断金币是否足够
if (GameManager.Instance.PlayerManager.PlayerInfo.Gold < 100)
{
GameManager.Instance.UIManager.ShowInfo($"不会有人连 100 金币都没有吧!");
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "No");
return;
}
GameManager.Instance.PlayerManager.PlayerInfo.Gold -= 100;
// 随机一个属性
ERandomShopType type = ERandomShopType.Health;
int randomNumber = Random.Range(0, 100);
if (randomNumber <= 30) type = ERandomShopType.Health;
else if (randomNumber > 30 && randomNumber <= 60) type = ERandomShopType.Attack;
else if (randomNumber > 60 && randomNumber <= 90) type = ERandomShopType.Defence;
else type = ERandomShopType.Gold;
// 随机数值
switch (type)
{
case ERandomShopType.Health:
randomNumber = Random.Range(200, 800);
GameManager.Instance.PlayerManager.PlayerInfo.Health += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点生命值提升!");
break;
case ERandomShopType.Attack:
randomNumber = Random.Range(8, 40);
GameManager.Instance.PlayerManager.PlayerInfo.Attack += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点攻击力提升!");
break;
case ERandomShopType.Defence:
randomNumber = Random.Range(8, 40);
GameManager.Instance.PlayerManager.PlayerInfo.Defence += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点防御力提升!");
break;
case ERandomShopType.Gold:
randomNumber = Random.Range(80, 400);
GameManager.Instance.PlayerManager.PlayerInfo.Gold += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"运气爆棚!获得 {randomNumber} 金币!");
break;
default:
print("商店随机了个什么玩意儿?");
break;
}
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Yes");
}
ShopComm.E_ShopFloor floor = ShopComm.E_ShopFloor.F32;
public override bool Interaction()
{
// 打开商店界面
GameManager.Instance.EventManager.OnShopShow?.Invoke(GetComponent<ActorController>().Name, floor,
this,
() => ShopComm.BuyHP(floor),
() => ShopComm.BuyAtk(floor),
() => ShopComm.BuyDef(floor));
return false;
}
}

View File

@ -1,65 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EventLevel46Actor2 : ActorController
{
public override bool Interaction()
{
// 打开商店界面
GameManager.Instance.EventManager.OnShopShow?.Invoke(GetComponent<ActorController>().Name, 200, ShopShowCallback);
return false;
}
/// <summary>
/// 打开商店回调
/// </summary>
private void ShopShowCallback()
{
// 判断金币是否足够
if (GameManager.Instance.PlayerManager.PlayerInfo.Gold < 200)
{
GameManager.Instance.UIManager.ShowInfo($"不会有人连 200 金币都没有吧!");
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "No");
return;
}
GameManager.Instance.PlayerManager.PlayerInfo.Gold -= 200;
// 随机一个属性
ERandomShopType type = ERandomShopType.Health;
int randomNumber = Random.Range(0, 100);
if (randomNumber <= 30) type = ERandomShopType.Health;
else if (randomNumber > 30 && randomNumber <= 60) type = ERandomShopType.Attack;
else if (randomNumber > 60 && randomNumber <= 90) type = ERandomShopType.Defence;
else type = ERandomShopType.Gold;
// 随机数值
switch (type)
{
case ERandomShopType.Health:
randomNumber = Random.Range(400, 1600);
GameManager.Instance.PlayerManager.PlayerInfo.Health += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点生命值提升!");
break;
case ERandomShopType.Attack:
randomNumber = Random.Range(16, 80);
GameManager.Instance.PlayerManager.PlayerInfo.Attack += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点攻击力提升!");
break;
case ERandomShopType.Defence:
randomNumber = Random.Range(16, 80);
GameManager.Instance.PlayerManager.PlayerInfo.Defence += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点防御力提升!");
break;
case ERandomShopType.Gold:
randomNumber = Random.Range(160, 800);
GameManager.Instance.PlayerManager.PlayerInfo.Gold += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"运气爆棚!获得 {randomNumber} 金币!");
break;
default:
print("商店随机了个什么玩意儿?");
break;
}
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Yes");
}
ShopComm.E_ShopFloor floor = ShopComm.E_ShopFloor.F46;
public override bool Interaction()
{
// 打开商店界面
GameManager.Instance.EventManager.OnShopShow?.Invoke(GetComponent<ActorController>().Name, floor,
this,
() => ShopComm.BuyHP(floor),
() => ShopComm.BuyAtk(floor),
() => ShopComm.BuyDef(floor));
return false;
}
}

View File

@ -1,7 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum ERandomShopType
{
Health,
@ -12,62 +8,15 @@ public enum ERandomShopType
public class EventLevel4Actor1 : ActorController
{
public override bool Interaction()
ShopComm.E_ShopFloor floor = ShopComm.E_ShopFloor.F4;
public override bool Interaction()
{
// 打开商店界面
GameManager.Instance.EventManager.OnShopShow?.Invoke(GetComponent<ActorController>().Name, 25, ShopShowCallback);
return false;
}
/// <summary>
/// 打开商店回调
/// </summary>
private void ShopShowCallback()
{
// 判断金币是否足够
if (GameManager.Instance.PlayerManager.PlayerInfo.Gold < 25)
{
GameManager.Instance.UIManager.ShowInfo($"不会有人连 25 金币都没有吧!");
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "No");
return;
}
GameManager.Instance.PlayerManager.PlayerInfo.Gold -= 25;
// 随机一个属性
ERandomShopType type = ERandomShopType.Health;
int randomNumber = Random.Range(0, 100);
if (randomNumber <= 30) type = ERandomShopType.Health;
else if (randomNumber > 30 && randomNumber <= 60) type = ERandomShopType.Attack;
else if (randomNumber > 60 && randomNumber <= 90) type = ERandomShopType.Defence;
else type = ERandomShopType.Gold;
// 随机数值
switch (type)
{
case ERandomShopType.Health:
randomNumber = Random.Range(50, 200);
GameManager.Instance.PlayerManager.PlayerInfo.Health += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点生命值提升!");
break;
case ERandomShopType.Attack:
randomNumber = Random.Range(2, 10);
GameManager.Instance.PlayerManager.PlayerInfo.Attack += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点攻击力提升!");
break;
case ERandomShopType.Defence:
randomNumber = Random.Range(2, 10);
GameManager.Instance.PlayerManager.PlayerInfo.Defence += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"获得 {randomNumber} 点防御力提升!");
break;
case ERandomShopType.Gold:
randomNumber = Random.Range(20, 100);
GameManager.Instance.PlayerManager.PlayerInfo.Gold += randomNumber;
GameManager.Instance.UIManager.ShowInfo($"运气爆棚!获得 {randomNumber} 金币!");
break;
default:
print("商店随机了个什么玩意儿?");
break;
}
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Yes");
// 打开商店界面
GameManager.Instance.EventManager.OnShopShow?.Invoke(GetComponent<ActorController>().Name, floor,
this,
() => ShopComm.BuyHP(floor),
() => ShopComm.BuyAtk(floor),
() => ShopComm.BuyDef(floor));
return false;
}
}

View File

@ -0,0 +1,111 @@
using System.Collections.Generic;
using UnityEngine;
public class ShopComm
{
/*
20n次购买所需金币10n*(n-1)+20
424
1248
32816
461020
*/
public enum E_ShopFloor
{
F4,
F12,
F32,
F46
}
public class FloorShopInfo
{
public E_ShopFloor Floor;
public int AddHP;
public int AddAtk;
public int AddDef;
}
static Dictionary<E_ShopFloor, FloorShopInfo> dictShopFloor = new Dictionary<E_ShopFloor, FloorShopInfo>()
{
{ E_ShopFloor.F4,new FloorShopInfo(){Floor = E_ShopFloor.F4,AddAtk = 2,AddDef = 4 ,AddHP = 100}},
{ E_ShopFloor.F12,new FloorShopInfo(){Floor = E_ShopFloor.F4,AddAtk = 4,AddDef = 8,AddHP = 100 }},
{ E_ShopFloor.F32,new FloorShopInfo(){Floor = E_ShopFloor.F4,AddAtk = 8,AddDef = 16,AddHP = 100 }},
{ E_ShopFloor.F46,new FloorShopInfo(){Floor = E_ShopFloor.F4,AddAtk = 10,AddDef = 20,AddHP = 100 }},
};
public static FloorShopInfo GetFloorShopInfo(E_ShopFloor floor)
{
return dictShopFloor[floor];
}
public static int GetShopNeedMoney(E_ShopFloor floor)
{
int BuyNum = 0;
switch (floor)
{
case E_ShopFloor.F4: BuyNum = GameManager.Instance.PlayerManager.PlayerInfo.StoreBuyNum_F4; break;
case E_ShopFloor.F12: BuyNum = GameManager.Instance.PlayerManager.PlayerInfo.StoreBuyNum_F12; break;
case E_ShopFloor.F32: BuyNum = GameManager.Instance.PlayerManager.PlayerInfo.StoreBuyNum_F32; break;
case E_ShopFloor.F46: BuyNum = GameManager.Instance.PlayerManager.PlayerInfo.StoreBuyNum_F46; break;
}
return (10 * BuyNum * (BuyNum - 1) + 20);
}
public static bool CheckMoney(E_ShopFloor floor)
{
int needMoney = GetShopNeedMoney(floor);
// 判断金币是否足够
if (GameManager.Instance.PlayerManager.PlayerInfo.Gold < needMoney)
{
GameManager.Instance.UIManager.ShowInfo($"不会有人连 {needMoney} 金币都没有吧!");
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "No");
return false;
}
return true;
}
public static void SetShopUseMoney(E_ShopFloor floor)
{
int needMoney = GetShopNeedMoney(floor);
GameManager.Instance.PlayerManager.PlayerInfo.Gold -= needMoney;
//追加购买次数
switch (floor)
{
case E_ShopFloor.F4: GameManager.Instance.PlayerManager.PlayerInfo.StoreBuyNum_F4++; break;
case E_ShopFloor.F12: GameManager.Instance.PlayerManager.PlayerInfo.StoreBuyNum_F12++; break;
case E_ShopFloor.F32: GameManager.Instance.PlayerManager.PlayerInfo.StoreBuyNum_F32++; break;
case E_ShopFloor.F46: GameManager.Instance.PlayerManager.PlayerInfo.StoreBuyNum_F46++; break;
}
}
public static void BuyHP(E_ShopFloor floor)
{
if (!CheckMoney(floor))
return;
SetShopUseMoney(floor);
int hp = dictShopFloor[floor].AddHP;
GameManager.Instance.PlayerManager.PlayerInfo.Health += hp;
GameManager.Instance.UIManager.ShowInfo($"获得 {hp} 点生命值提升!");
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Yes");
}
public static void BuyAtk(E_ShopFloor floor)
{
if (!CheckMoney(floor))
return;
SetShopUseMoney(floor);
int atk = dictShopFloor[floor].AddAtk;
GameManager.Instance.PlayerManager.PlayerInfo.Attack += atk;
GameManager.Instance.UIManager.ShowInfo($"获得 {atk} 点攻击力提升!");
}
public static void BuyDef(E_ShopFloor floor)
{
if (!CheckMoney(floor))
return;
SetShopUseMoney(floor);
int def = dictShopFloor[floor].AddDef;
GameManager.Instance.PlayerManager.PlayerInfo.Defence += def;
GameManager.Instance.UIManager.ShowInfo($"获得 {def} 点防御力提升!");
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 289293a7d8170934dbba5f74dc889cc6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static ShopComm;
public class EventManager : Singleton<EventManager>
{
@ -74,15 +75,16 @@ public class EventManager : Singleton<EventManager>
/// </summary>
public Action OnResourceLoaded;
/// <summary>
/// 打开商店事件
/// </summary>
public Action<string, int, Action> OnShopShow;
/// <summary>
/// 打开商店事件
/// </summary>
public Action<string, E_ShopFloor, ActorController,Action, Action,Action> OnShopShow;
//public Action<string, int, Action> OnShopShow;
/// <summary>
/// 法老权杖上楼事件
/// </summary>
public Action OnArtifactUp;
/// <summary>
/// 法老权杖上楼事件
/// </summary>
public Action OnArtifactUp;
/// <summary>
/// 法老权杖下楼事件
/// </summary>

View File

@ -35,7 +35,16 @@ public class PlayerInfo
[SerializeField]
private string _notepadInfo;
public int Health
[SerializeField]
public int StoreBuyNum_F4 = 1;
[SerializeField]
public int StoreBuyNum_F12 = 1;
[SerializeField]
public int StoreBuyNum_F32 = 1;
[SerializeField]
public int StoreBuyNum_F46 = 1;
public int Health
{
get => _health;
set

View File

@ -51,6 +51,11 @@ public class GameInfo
public int MaxLevelInfo;
public string BackpackInfo;
public string PlotInfo;
//每个层商店购买次数
public int StoreBuyNum_F4 = 0;
public int StoreBuyNum_F12 = 0;
public int StoreBuyNum_F32 = 0;
public int StoreBuyNum_F46 = 0;
}
public class ResourceManager : Singleton<ResourceManager>
@ -357,7 +362,8 @@ public class ResourceManager : Singleton<ResourceManager>
MaxLevelInfo = GameManager.Instance.LevelManager.MaxLevel,
BackpackInfo = JsonUtility.ToJson(new Serialization<int, ItemInfo>(GameManager.Instance.BackpackManager.BackpackDictionary)),
PlotInfo = JsonUtility.ToJson(new Serialization<int, int>(GameManager.Instance.PlotManager.PlotDictionary)),
};
};
// 保存资源信息
PlayerPrefs.SetString("GameInfo", JsonUtility.ToJson(gameInfo));
// UI 提示

View File

@ -44,8 +44,14 @@ public class UIManager : MonoSingleton<UIManager>
private GameObject _shopPanel;
private Text _shopNameValueText;
private Text _shopInfoValueText;
private Button _shopYesButton;
private Button _shopNoButton;
private Button _shopAddHPButton;
private Text _shopAddHPButtonText;
private Button _shopAddAtkButton;
private Text _shopAddAtkButtonText;
private Button _shopAddDefButton;
private Text _shopAddDefButtonText;
private Button _shopNoButton;
private GameObject _infoPanel;
@ -117,8 +123,13 @@ public class UIManager : MonoSingleton<UIManager>
_shopPanel = MainCanvas.transform.Find("ShopPanel").gameObject;
_shopNameValueText = _shopPanel.transform.Find("ShopNameValueText").GetComponent<Text>();
_shopInfoValueText = _shopPanel.transform.Find("ShopValueText").GetComponent<Text>();
_shopYesButton = _shopPanel.transform.Find("YesButton").GetComponent<Button>();
_shopNoButton = _shopPanel.transform.Find("NoButton").GetComponent<Button>();
_shopAddHPButton = _shopPanel.transform.Find("shopAddHPButton").GetComponent<Button>();
_shopAddHPButtonText = _shopPanel.transform.Find("shopAddHPButton/shopAddHPButtonText").GetComponent<Text>();
_shopAddAtkButton = _shopPanel.transform.Find("shopAddAtkButton").GetComponent<Button>();
_shopAddAtkButtonText = _shopPanel.transform.Find("shopAddAtkButton/shopAddAtkButtonText").GetComponent<Text>();
_shopAddDefButton = _shopPanel.transform.Find("shopAddDefButton").GetComponent<Button>();
_shopAddDefButtonText = _shopPanel.transform.Find("shopAddDefButton/shopAddDefButtonText").GetComponent<Text>();
_shopNoButton = _shopPanel.transform.Find("NoButton").GetComponent<Button>();
_shopPanel.SetActive(false);
_infoPanel = MainCanvas.transform.Find("InfoPanel").gameObject;
@ -225,43 +236,79 @@ public class UIManager : MonoSingleton<UIManager>
}
/// <summary>
/// 商店打开事件
/// </summary>
/// <param name="name">商店名称</param>
/// <param name="gold">每次所花金币</param>
private void ShopShowEvent(string name, int gold, Action callback)
{
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Shop");
// 禁用人物控制器
GameManager.Instance.PlayerManager.Enable = false;
_shopPanel.SetActive(true);
_shopNameValueText.text = name;
_shopInfoValueText.text = gold.ToString();
_shopYesButton.onClick.RemoveAllListeners();
_shopYesButton.onClick.AddListener(() =>
{
callback?.Invoke();
// 启用人物控制器
GameManager.Instance.PlayerManager.Enable = true;
});
_shopNoButton.onClick.RemoveAllListeners();
_shopNoButton.onClick.AddListener(() =>
{
// 启用人物控制器
GameManager.Instance.PlayerManager.Enable = true;
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "No");
//关闭
/// <summary>
/// 商店打开事件
/// </summary>
/// <param name="name">商店名称</param>
/// <param name="gold">每次所花金币</param>
private void ShopShowEvent(string name, ShopComm.E_ShopFloor floor, ActorController refreshActor, Action BuyHPcallback, Action BuyAtkcallback, Action BuyDefcallback)
{
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Shop");
// 禁用人物控制器
GameManager.Instance.PlayerManager.Enable = false;
_shopPanel.SetActive(true);
_shopNameValueText.text = name;
//_shopInfoValueText.text = gold.ToString();
_shopInfoValueText.text = $"给我<color=yellow>{ShopComm.GetShopNeedMoney(floor)}</color>金币就可以提升以下,一种能力"; ;
ShopComm.FloorShopInfo shopinfo = ShopComm.GetFloorShopInfo(floor);
_shopAddHPButtonText.text = $"生命+{shopinfo.AddHP}";
_shopAddAtkButtonText.text = $"攻击+{shopinfo.AddAtk}";
_shopAddDefButtonText.text = $"防御+{shopinfo.AddDef}";
_shopAddHPButton.onClick.RemoveAllListeners();
_shopAddHPButton.onClick.AddListener(() =>
{
BuyHPcallback?.Invoke();
//关闭
_shopPanel.SetActive(false);
//刷新页面
refreshActor.Interaction();
//// 启用人物控制器
//GameManager.Instance.PlayerManager.Enable = true;
});
_shopAddAtkButton.onClick.RemoveAllListeners();
_shopAddAtkButton.onClick.AddListener(() =>
{
BuyAtkcallback?.Invoke();
//关闭
_shopPanel.SetActive(false);
//刷新页面
refreshActor.Interaction();
});
_shopAddDefButton.onClick.RemoveAllListeners();
_shopAddDefButton.onClick.AddListener(() =>
{
BuyDefcallback?.Invoke();
//关闭
_shopPanel.SetActive(false);
//刷新页面
refreshActor.Interaction();
});
_shopNoButton.onClick.RemoveAllListeners();
_shopNoButton.onClick.AddListener(() =>
{
// 启用人物控制器
GameManager.Instance.PlayerManager.Enable = true;
// 音频播放
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "No");
//关闭
_shopPanel.SetActive(false);
});
}
}
/// <summary>
/// 初始化背包 UI
/// </summary>
public void InitBackpackUI()
/// <summary>
/// 初始化背包 UI
/// </summary>
public void InitBackpackUI()
{
// 清空背包 UI
LayoutElement[] layoutElements = _backpackInfoPanel.GetComponentsInChildren<LayoutElement>();