Passion & UI
This commit is contained in:
@@ -40,6 +40,28 @@ namespace Cielonos.MainGame.Characters
|
||||
|
||||
public partial class BackpackSubmodule
|
||||
{
|
||||
public bool HaveItem(string itemClass)
|
||||
{
|
||||
Type type = Type.GetType($"Cielonos.MainGame.Inventory.Collections.{itemClass}");
|
||||
if (type == null)
|
||||
{
|
||||
Debug.LogError($"[Backpack] 无法找到道具类类型:'{itemClass}'。确保它在命名空间 Cielonos.MainGame.Inventory.Collections 中。");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof(MainWeaponBase).IsAssignableFrom(type))
|
||||
return mainWeapons.Exists(item => item.GetType() == type);
|
||||
if (typeof(SupportEquipmentBase).IsAssignableFrom(type))
|
||||
return supportEquipments.Exists(item => item.GetType() == type);
|
||||
if (typeof(PassiveEquipmentBase).IsAssignableFrom(type))
|
||||
return passiveEquipments.Exists(item => item.GetType() == type);
|
||||
if (typeof(ConsumableBase).IsAssignableFrom(type))
|
||||
return consumables.Exists(item => item.GetType() == type);
|
||||
|
||||
Debug.LogError($"[Backpack] 类型 '{itemClass}' 不属于任何已知的道具基类。");
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过 Resources 加载 Prefab,实例化到对应的 Container 下,然后加入背包。
|
||||
/// 若为消耗品且背包中已存在同类型实例,则直接堆叠,不再重复生成。
|
||||
|
||||
@@ -27,11 +27,17 @@ namespace Cielonos.MainGame.Characters
|
||||
RegisterOperations();
|
||||
backpackSm ??= new BackpackSubmodule(this);
|
||||
equipmentSm ??= new EquipmentSubmodule(this);
|
||||
|
||||
//backpackSm.ObtainItem<DualHarmony>();
|
||||
/*backpackSm.ObtainItem<Polychrome>();
|
||||
|
||||
backpackSm.ObtainItem<Polychrome>();
|
||||
backpackSm.ObtainItem<FutureWand>();
|
||||
backpackSm.ObtainItem<Ascension>();
|
||||
backpackSm.ObtainItem<Passion>();
|
||||
backpackSm.ObtainItem<ThermalDetonator>();
|
||||
//backpackSm.ObtainItem<PerceptiveMetalPlating>();
|
||||
//backpackSm.ObtainItem<DualHarmony>();
|
||||
/*backpackSm.ObtainItem<Polychrome>();
|
||||
|
||||
|
||||
backpackSm.ObtainItem<BlackHoleDisplacer>();
|
||||
backpackSm.ObtainItem<DecayPropagator>();
|
||||
backpackSm.ObtainItem<DecayAccelerationCoil>();
|
||||
@@ -40,10 +46,10 @@ namespace Cielonos.MainGame.Characters
|
||||
backpackSm.ObtainItem<PhotonPolarizer>();
|
||||
backpackSm.ObtainItem<PhotonDissociator>();*/
|
||||
|
||||
/*foreach (MainWeaponBase mainWeapon in backpackSm.mainWeapons)
|
||||
foreach (MainWeaponBase mainWeapon in backpackSm.mainWeapons)
|
||||
{
|
||||
equipmentSm.PrepareMainWeapon(mainWeapon);
|
||||
}*/
|
||||
}
|
||||
|
||||
//backpackSm.ObtainItem<BlackHoleDisplacer>();
|
||||
}
|
||||
@@ -177,10 +183,13 @@ namespace Cielonos.MainGame.Characters
|
||||
private void SwitchMainWeapon(int direction)
|
||||
{
|
||||
int currentIndex = equipmentSm.preparedMainWeapons.IndexOf(currentMainWeapon);
|
||||
currentMainWeapon?.OnSwitchOut();
|
||||
equipmentSm.RemoveMainWeapon();
|
||||
|
||||
int newIndex = (currentIndex + direction + equipmentSm.preparedMainWeapons.Count) % equipmentSm.preparedMainWeapons.Count;
|
||||
Debug.Log($"Switching main weapon from index {currentIndex} to {newIndex}");
|
||||
equipmentSm.EquipMainWeapon(equipmentSm.preparedMainWeapons[newIndex]);
|
||||
MainWeaponBase newWeapon = equipmentSm.preparedMainWeapons[newIndex];
|
||||
equipmentSm.EquipMainWeapon(newWeapon);
|
||||
newWeapon.OnSwitchIn();
|
||||
}
|
||||
|
||||
private void MainWeaponPrimaryPress()
|
||||
|
||||
Reference in New Issue
Block a user