修改框架

This commit is contained in:
MuHua-123
2025-09-25 17:50:28 +08:00
parent d940a18e13
commit 18c6b4387d
79 changed files with 1017 additions and 392 deletions
@@ -8,7 +8,7 @@ using MuHua;
/// </summary>
public class AssetsManager : ModuleSingle<AssetsManager> {
public List<ConstItem> items;
public List<ConstInventoryItem> items;
protected override void Awake() => NoReplace(false);
@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MuHua;
/// <summary>
/// 物品 - 管理器
/// </summary>
public class ManagerItem : ModuleSingle<ManagerItem> {
/// <summary> 材料列表 </summary>
public List<ConstMaterial> materials;
/// <summary> 装备列表 </summary>
public List<ConstEquipment> equipments;
protected override void Awake() => NoReplace(false);
}
/// <summary>
/// 物品奖励
/// </summary>
public class ItemReward {
/// <summary> 物品列表 </summary>
public List<InventoryItem> items;
public void Settings<T>(List<T> list) where T : ConstInventoryItem {
items = new List<InventoryItem>();
list.ForEach(obj => items.Add(obj.To()));
}
public (InventoryItem, int) Get(int max = 1) {
int count = Random.Range(1, max + 1);
int index = Random.Range(0, items.Count);
return (items[index], count);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 287f1e957d7061a42977427a98b178b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -9,7 +9,7 @@ using MuHua;
public class SingleManager : ModuleSingle<SingleManager> {
public Inventory inventory;
public Equipment equipment;
public EquipmentColumn equipment;
public ItemReward materialReward;
public ItemReward equipmentReward;
@@ -18,27 +18,7 @@ public class SingleManager : ModuleSingle<SingleManager> {
private void Start() {
inventory = new Inventory(40);
equipment = new Equipment();
WeaponSlot weaponSlot = new WeaponSlot(SlotType.);
DeputySlot deputySlot = new DeputySlot(SlotType.);
weaponSlot.deputy = deputySlot;
deputySlot.weapon = weaponSlot;
equipment.AddSlot(weaponSlot);
equipment.AddSlot(deputySlot);
equipment.AddSlot(new ArmorSlot(SlotType., ArmorType.));
equipment.AddSlot(new ArmorSlot(SlotType., ArmorType.));
equipment.AddSlot(new ArmorSlot(SlotType., ArmorType.));
equipment.AddSlot(new ArmorSlot(SlotType., ArmorType.));
equipment.AddSlot(new ArmorSlot(SlotType., ArmorType.));
equipment.AddSlot(new AccessorySlot(SlotType., AccessoryType.));
equipment.AddSlot(new AccessorySlot(SlotType.1, AccessoryType.));
equipment.AddSlot(new AccessorySlot(SlotType.2, AccessoryType.));
equipment.AddSlot(new AccessorySlot(SlotType.1, AccessoryType.));
equipment.AddSlot(new AccessorySlot(SlotType.2, AccessoryType.));
equipment = new EquipmentColumn();
materialReward = new ItemReward();
materialReward.Settings(ManagerItem.I.materials);
@@ -53,11 +33,11 @@ public class SingleManager : ModuleSingle<SingleManager> {
private void RewardMaterial() {
(DataItem item, int count) = materialReward.Get(10);
(InventoryItem item, int count) = materialReward.Get(10);
inventory.AddItem(item, count);
}
private void RewardEquipment() {
(DataItem item, int count) = equipmentReward.Get(1);
(InventoryItem item, int count) = equipmentReward.Get(1);
inventory.AddItem(item, count);
}
}