From 5ca97fb0b1665f17aeb38047efcdea80dc439ac1 Mon Sep 17 00:00:00 2001 From: MuHua-123 <136542559+MuHua-123@users.noreply.github.com> Date: Wed, 23 Jul 2025 18:01:18 +0800 Subject: [PATCH] 1 --- .../Module/Addition/DataAddition.cs | 16 --- Assets/ModuleCore/Module/Character.meta | 8 -- .../Module/Character/DataAttribute.cs | 77 ------------- .../Module/Character/DataCharacter.cs | 99 ---------------- .../ModuleCore/Module/Character/DataRace.cs | 67 ----------- Assets/ModuleCore/Module/DataCharacter.cs | 93 +++++++++++++++ .../{Character => }/DataCharacter.cs.meta | 0 Assets/ModuleCore/Module/DataEquipment.cs | 51 +++++++++ .../Module/{Item => }/DataEquipment.cs.meta | 2 +- .../Module/{Inventory => }/DataInventory.cs | 21 ++-- .../{Inventory => }/DataInventory.cs.meta | 0 Assets/ModuleCore/Module/DataItem.cs | 64 +++++++++++ .../Module/{Item => }/DataItem.cs.meta | 0 .../Module/Inventory/DataBackpack.cs | 18 --- .../Module/Inventory/DataBackpack.cs.meta | 11 -- .../Module/Inventory/DataEquipmentSlot.cs | 87 -------------- .../Inventory/DataEquipmentSlot.cs.meta | 11 -- .../Module/Inventory/DataStorage.cs | 18 --- .../Module/Inventory/DataStorage.cs.meta | 11 -- Assets/ModuleCore/Module/Item.meta | 8 -- Assets/ModuleCore/Module/Item/DataArmor.cs | 24 ---- .../ModuleCore/Module/Item/DataArmor.cs.meta | 11 -- .../ModuleCore/Module/Item/DataEquipment.cs | 35 ------ Assets/ModuleCore/Module/Item/DataItem.cs | 23 ---- Assets/ModuleCore/Module/Item/DataMaterial.cs | 13 --- .../Module/Item/DataMaterial.cs.meta | 11 -- Assets/ModuleCore/Module/Item/DataWeapon.cs | 24 ---- .../ModuleCore/Module/Item/DataWeapon.cs.meta | 11 -- .../ModuleBattle/BattleCharacter.cs | 10 +- .../ModuleBattle/BattlePhase/PhaseAction.cs | 48 ++++++-- .../ModuleBattle/BattlePhase/PhaseAssault.cs | 6 +- .../ModuleBattle/BattlePhase/PhaseFinish.cs | 10 +- .../ModuleBattle/BattlePhase/PhaseFormal.cs | 3 + .../BattlePhase/PhaseInitiative.cs | 4 +- .../ModuleBattle/BattleSimulator.cs | 8 +- .../Addition.meta => ModuleCharacter.meta} | 2 +- .../ModuleCharacter/AttributeTool.cs | 48 ++++++++ .../AttributeTool.cs.meta} | 2 +- .../ModuleCharacter/CharacterTool.cs | 81 +++++++++++++ .../CharacterTool.cs.meta} | 2 +- .../ProfessionTool.cs} | 65 +++++------ .../ProfessionTool.cs.meta} | 2 +- Assets/ModuleCore/ModuleCharacter/RaceTool.cs | 47 ++++++++ .../RaceTool.cs.meta} | 2 +- .../Inventory.meta => ModuleInventory.meta} | 2 +- .../ModuleInventory/ArmorDictionary.cs | 42 +++++++ .../ModuleInventory/ArmorDictionary.cs.meta | 11 ++ .../ModuleInventory/EquipmentTool.cs | 106 ++++++++++++++++++ .../ModuleInventory/EquipmentTool.cs.meta | 11 ++ .../ModuleInventory/WeaponDictionary.cs | 49 ++++++++ .../ModuleInventory/WeaponDictionary.cs.meta | 11 ++ .../ModuleSingle/ManagerSimulator.cs | 2 +- Assets/ModuleCore/ModuleTools/Dice.cs | 14 +++ .../SampleScene/SampleScene.unity | 51 +-------- 54 files changed, 749 insertions(+), 704 deletions(-) delete mode 100644 Assets/ModuleCore/Module/Addition/DataAddition.cs delete mode 100644 Assets/ModuleCore/Module/Character.meta delete mode 100644 Assets/ModuleCore/Module/Character/DataAttribute.cs delete mode 100644 Assets/ModuleCore/Module/Character/DataCharacter.cs delete mode 100644 Assets/ModuleCore/Module/Character/DataRace.cs create mode 100644 Assets/ModuleCore/Module/DataCharacter.cs rename Assets/ModuleCore/Module/{Character => }/DataCharacter.cs.meta (100%) create mode 100644 Assets/ModuleCore/Module/DataEquipment.cs rename Assets/ModuleCore/Module/{Item => }/DataEquipment.cs.meta (83%) rename Assets/ModuleCore/Module/{Inventory => }/DataInventory.cs (57%) rename Assets/ModuleCore/Module/{Inventory => }/DataInventory.cs.meta (100%) create mode 100644 Assets/ModuleCore/Module/DataItem.cs rename Assets/ModuleCore/Module/{Item => }/DataItem.cs.meta (100%) delete mode 100644 Assets/ModuleCore/Module/Inventory/DataBackpack.cs delete mode 100644 Assets/ModuleCore/Module/Inventory/DataBackpack.cs.meta delete mode 100644 Assets/ModuleCore/Module/Inventory/DataEquipmentSlot.cs delete mode 100644 Assets/ModuleCore/Module/Inventory/DataEquipmentSlot.cs.meta delete mode 100644 Assets/ModuleCore/Module/Inventory/DataStorage.cs delete mode 100644 Assets/ModuleCore/Module/Inventory/DataStorage.cs.meta delete mode 100644 Assets/ModuleCore/Module/Item.meta delete mode 100644 Assets/ModuleCore/Module/Item/DataArmor.cs delete mode 100644 Assets/ModuleCore/Module/Item/DataArmor.cs.meta delete mode 100644 Assets/ModuleCore/Module/Item/DataEquipment.cs delete mode 100644 Assets/ModuleCore/Module/Item/DataItem.cs delete mode 100644 Assets/ModuleCore/Module/Item/DataMaterial.cs delete mode 100644 Assets/ModuleCore/Module/Item/DataMaterial.cs.meta delete mode 100644 Assets/ModuleCore/Module/Item/DataWeapon.cs delete mode 100644 Assets/ModuleCore/Module/Item/DataWeapon.cs.meta rename Assets/ModuleCore/{Module/Addition.meta => ModuleCharacter.meta} (77%) create mode 100644 Assets/ModuleCore/ModuleCharacter/AttributeTool.cs rename Assets/ModuleCore/{Module/Character/DataProfession.cs.meta => ModuleCharacter/AttributeTool.cs.meta} (83%) create mode 100644 Assets/ModuleCore/ModuleCharacter/CharacterTool.cs rename Assets/ModuleCore/{Module/Character/DataAttribute.cs.meta => ModuleCharacter/CharacterTool.cs.meta} (83%) rename Assets/ModuleCore/{Module/Character/DataProfession.cs => ModuleCharacter/ProfessionTool.cs} (50%) rename Assets/ModuleCore/{Module/Addition/DataAddition.cs.meta => ModuleCharacter/ProfessionTool.cs.meta} (83%) create mode 100644 Assets/ModuleCore/ModuleCharacter/RaceTool.cs rename Assets/ModuleCore/{Module/Character/DataRace.cs.meta => ModuleCharacter/RaceTool.cs.meta} (83%) rename Assets/ModuleCore/{Module/Inventory.meta => ModuleInventory.meta} (77%) create mode 100644 Assets/ModuleCore/ModuleInventory/ArmorDictionary.cs create mode 100644 Assets/ModuleCore/ModuleInventory/ArmorDictionary.cs.meta create mode 100644 Assets/ModuleCore/ModuleInventory/EquipmentTool.cs create mode 100644 Assets/ModuleCore/ModuleInventory/EquipmentTool.cs.meta create mode 100644 Assets/ModuleCore/ModuleInventory/WeaponDictionary.cs create mode 100644 Assets/ModuleCore/ModuleInventory/WeaponDictionary.cs.meta diff --git a/Assets/ModuleCore/Module/Addition/DataAddition.cs b/Assets/ModuleCore/Module/Addition/DataAddition.cs deleted file mode 100644 index dc8ee59..0000000 --- a/Assets/ModuleCore/Module/Addition/DataAddition.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 附加 - 数据 -/// -public class DataAddition { - /// 护甲等级 - public int armorClass = 0; - - /// 添加属性 - public void Add(DataAddition value) { - armorClass += value.armorClass; - } -} diff --git a/Assets/ModuleCore/Module/Character.meta b/Assets/ModuleCore/Module/Character.meta deleted file mode 100644 index b372ebb..0000000 --- a/Assets/ModuleCore/Module/Character.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f600b7e509b166244a37c240ffee12ba -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/Module/Character/DataAttribute.cs b/Assets/ModuleCore/Module/Character/DataAttribute.cs deleted file mode 100644 index 40dc3f9..0000000 --- a/Assets/ModuleCore/Module/Character/DataAttribute.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 属性 - 数据 -/// -public class DataAttribute { - /// 力量(strength) - public virtual int Str { get; set; } - /// 敏捷(dexterity) - public virtual int Dex { get; set; } - /// 体质(constitution) - public virtual int Con { get; set; } - /// 智力(intelligence) - public virtual int Int { get; set; } - /// 感知(wisdom) - public virtual int Wis { get; set; } - /// 魅力(charisma) - public virtual int Cha { get; set; } - - /// 力量调整值(strength) - public int StrModifier => Modifier(Str); - /// 敏捷调整值(dexterity) - public int DexModifier => Modifier(Dex); - /// 体质调整值(constitution) - public int ConModifier => Modifier(Con); - /// 智力调整值(intelligence) - public int IntModifier => Modifier(Int); - /// 感知调整值(wisdom) - public int WisModifier => Modifier(Wis); - /// 魅力调整值(charisma) - public int ChaModifier => Modifier(Cha); - - /// 创建初始属性 - public static DataAttribute Initial() { - DataAttribute attribute = new DataAttribute(); - attribute.Str = Dice.RollAttribute(); - attribute.Dex = Dice.RollAttribute(); - attribute.Con = Dice.RollAttribute(); - attribute.Int = Dice.RollAttribute(); - attribute.Wis = Dice.RollAttribute(); - attribute.Cha = Dice.RollAttribute(); - return attribute; - } - // 计算属性调整值(属性值-10)/2 向下取整 - public int Modifier(int value) { - return (int)System.Math.Floor((value - 10) / 2.0); - } - /// 添加属性 - public void Add(DataAttribute value) { - Str += value.Str; - Dex += value.Dex; - Con += value.Con; - Int += value.Int; - Wis += value.Wis; - Cha += value.Cha; - } - /// 减少属性 - public void Sub(DataAttribute value) { - Str -= value.Str; - Dex -= value.Dex; - Con -= value.Con; - Int -= value.Int; - Wis -= value.Wis; - Cha -= value.Cha; - } - /// 覆盖属性 - public void Cover(DataAttribute value) { - Str = value.Str; - Dex = value.Dex; - Con = value.Con; - Int = value.Int; - Wis = value.Wis; - Cha = value.Cha; - } -} diff --git a/Assets/ModuleCore/Module/Character/DataCharacter.cs b/Assets/ModuleCore/Module/Character/DataCharacter.cs deleted file mode 100644 index 384d7f6..0000000 --- a/Assets/ModuleCore/Module/Character/DataCharacter.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 角色 - 数据 -/// -public class DataCharacter : DataAttribute { - /// 角色名字 - public string name; - /// 经验点 - public int expPoint; - /// 种族 - public DataRace race; - /// 属性 - public DataAttribute basis; - /// 职业 - public DataProfession profession; - /// 装备栏 - public DataEquipmentSlot equipmentSlot; - - /// 战斗等级 - public int Level => GetLevel(); - /// 生命点 - public int HitPoint => GetHitPoint(); - /// 护甲等级 - public int ArmorClass => GetArmorClass(); - - public override int Str { get => basis.Str + race.Str; } - public override int Dex { get => basis.Dex + race.Dex; } - public override int Con { get => basis.Con + race.Con; } - public override int Int { get => basis.Int + race.Int; } - public override int Wis { get => basis.Wis + race.Wis; } - public override int Cha { get => basis.Cha + race.Cha; } - - /// 设置职业 - public void Settings(DataRace race) { - this.race = race; - } - /// 设置职业 - public void Settings(DataProfession profession) { - this.profession = profession; - profession.character = this; - } - /// 战斗等级 - public int GetLevel() { - // TODO:需要补充多职业的等级总和 - return profession.level; - } - /// 生命点 - public int GetHitPoint() { - // TODO:需要补充多职业的生命值加成 - return profession.HitPoint(); - } - /// 计算护甲等级(AC) - public int GetArmorClass() { - // TODO:需要补充专长,技能,熟练之类的加值 - return equipmentSlot.GetArmorClass(DexModifier); - } - - /// 创建默认角色 - public static DataCharacter Create(string name) { - DataCharacter character = new DataCharacter(); - character.name = name; - character.race = DataRace.None(); - character.basis = Initial(); - character.profession = DataProfession.None(); - character.profession.Initial(character); - character.equipmentSlot = new DataEquipmentSlot(); - return character; - } - /// 创建默认角色 - public static DataCharacter Create(string name, DataRace race, DataProfession profession) { - DataCharacter character = new DataCharacter(); - character.name = name; - character.race = race; - character.basis = Initial(); - character.profession = profession; - character.profession.Initial(character); - character.equipmentSlot = new DataEquipmentSlot(); - return character; - } - - // 打印角色卡 - public void PrintCharacterSheet() { - Debug.Log($"=== {name} LV{Level} ==="); - Debug.Log($"种族: {race.name}"); - Debug.Log($"职业: {profession.name}"); - Debug.Log($"力量: {Str} ({StrModifier.ToString("+#;-#;+0")})"); - Debug.Log($"敏捷: {Dex} ({DexModifier.ToString("+#;-#;+0")})"); - Debug.Log($"体质: {Con} ({ConModifier.ToString("+#;-#;+0")})"); - Debug.Log($"智力: {Int} ({IntModifier.ToString("+#;-#;+0")})"); - Debug.Log($"感知: {Wis} ({WisModifier.ToString("+#;-#;+0")})"); - Debug.Log($"魅力: {Cha} ({ChaModifier.ToString("+#;-#;+0")})"); - Debug.Log($"经验值: {expPoint}"); - Debug.Log($"生命值: {HitPoint}"); - Debug.Log($"护甲等级: {ArmorClass})"); - } -} diff --git a/Assets/ModuleCore/Module/Character/DataRace.cs b/Assets/ModuleCore/Module/Character/DataRace.cs deleted file mode 100644 index 69dbdb3..0000000 --- a/Assets/ModuleCore/Module/Character/DataRace.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 种族 - 数据 -/// -public class DataRace : DataAttribute { - /// 种族名称 - public readonly string name; - - public DataRace(string name) { - this.name = name; - } - - // 混血人类,木精灵,丘陵矮人(Hill Dwarf),龙裔,半精灵 - /// 无种族 - public static DataRace None() { - return new DataRace("未知"); - } - /// 随机职业 - public static DataRace Random() { - int index = Dice.Roll(5); - if (index == 1) { return Human(); } - if (index == 2) { return Elven(); } - if (index == 3) { return Dwarf(); } - if (index == 4) { return Orc(); } - if (index == 5) { return Halfling(); } - return None(); - } - /// 人类(Human) - public static DataRace Human() { - DataRace race = new DataRace("人类"); - // 种族属性加成 全属性+1 - race.Str = 1; race.Dex = 1; race.Con = 1; - race.Int = 1; race.Wis = 1; race.Cha = 1; - return race; - } - /// 精灵(Elven) - public static DataRace Elven() { - DataRace race = new DataRace("精灵"); - // 种族属性加成 敏捷+2 智力+2 感知+1 - race.Dex = 2; race.Int = 2; race.Int = 1; - return race; - } - /// 矮人(Dwarf) - public static DataRace Dwarf() { - DataRace race = new DataRace("矮人"); - // 种族属性加成 力量+2 体质+2 感知+1 - race.Str = 2; race.Con = 2; race.Wis = 1; - return race; - } - /// 半兽人(Orc) - public static DataRace Orc() { - DataRace race = new DataRace("半兽人"); - // 种族属性加成 力量+3 体质+2 - race.Str = 3; race.Con = 2; - return race; - } - /// 半身人(Halfling) - public static DataRace Halfling() { - DataRace race = new DataRace("半身人"); - // 种族属性加成 敏捷+2 魅力+2 体质+1 - race.Dex = 2; race.Cha = 2; race.Con = 1; - return race; - } -} diff --git a/Assets/ModuleCore/Module/DataCharacter.cs b/Assets/ModuleCore/Module/DataCharacter.cs new file mode 100644 index 0000000..514143f --- /dev/null +++ b/Assets/ModuleCore/Module/DataCharacter.cs @@ -0,0 +1,93 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 属性 - 数据 +/// +public class DataAttribute { + /// 力量(strength) + public virtual int Str { get; set; } + /// 敏捷(dexterity) + public virtual int Dex { get; set; } + /// 体质(constitution) + public virtual int Con { get; set; } + /// 智力(intelligence) + public virtual int Int { get; set; } + /// 感知(wisdom) + public virtual int Wis { get; set; } + /// 魅力(charisma) + public virtual int Cha { get; set; } + + /// 力量调整值(strength) + public int StrModifier => AttributeTool.Modifier(Str); + /// 敏捷调整值(dexterity) + public int DexModifier => AttributeTool.Modifier(Dex); + /// 体质调整值(constitution) + public int ConModifier => AttributeTool.Modifier(Con); + /// 智力调整值(intelligence) + public int IntModifier => AttributeTool.Modifier(Int); + /// 感知调整值(wisdom) + public int WisModifier => AttributeTool.Modifier(Wis); + /// 魅力调整值(charisma) + public int ChaModifier => AttributeTool.Modifier(Cha); +} +/// +/// 角色 - 数据 +/// +public class DataCharacter : DataAttribute { + /// 名字 + public string name; + /// 经验 + public int expPoint; + /// 种族 + public DataRace race; + /// 属性 + public DataAttribute basis; + /// 职业 + public DataProfession profession; + /// 装备 + public DataEquipment equipment; + + /// 战斗等级 + public int Level => CharacterTool.GetLevel(this); + /// 生命点 + public int HitPoint => CharacterTool.GetHitPoint(this); + /// 护甲等级 + public int ArmorClass => CharacterTool.GetArmorClass(this); + + /// 力量(strength) 基础值 + 种族加值 + public override int Str { get => basis.Str + race.Str; } + /// 敏捷(dexterity) 基础值 + 种族加值 + public override int Dex { get => basis.Dex + race.Dex; } + /// 体质(constitution) 基础值 + 种族加值 + public override int Con { get => basis.Con + race.Con; } + /// 智力(intelligence) 基础值 + 种族加值 + public override int Int { get => basis.Int + race.Int; } + /// 感知(wisdom) 基础值 + 种族加值 + public override int Wis { get => basis.Wis + race.Wis; } + /// 魅力(charisma) 基础值 + 种族加值 + public override int Cha { get => basis.Cha + race.Cha; } +} +/// +/// 种族 - 数据 +/// +public class DataRace : DataAttribute { + /// 种族名称 + public string name; +} +/// +/// 职业 - 数据 +/// +public class DataProfession { + /// 职业名称 + public string name; + /// 生命骰子 + public int hitDice = 0; + /// 角色 + public DataCharacter character; + /// 职业等级 + public int level = 0; + /// 累计生命点 + public List hitPoints = new List(); +} \ No newline at end of file diff --git a/Assets/ModuleCore/Module/Character/DataCharacter.cs.meta b/Assets/ModuleCore/Module/DataCharacter.cs.meta similarity index 100% rename from Assets/ModuleCore/Module/Character/DataCharacter.cs.meta rename to Assets/ModuleCore/Module/DataCharacter.cs.meta diff --git a/Assets/ModuleCore/Module/DataEquipment.cs b/Assets/ModuleCore/Module/DataEquipment.cs new file mode 100644 index 0000000..6a2d203 --- /dev/null +++ b/Assets/ModuleCore/Module/DataEquipment.cs @@ -0,0 +1,51 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 装备栏 - 库存 +/// +public class DataEquipment { + /// 武器1 + public DataWeapon weapon1; + /// 武器2 + public DataWeapon weapon2; + /// 护甲 + public DataArmor armor; + /// 头盔 + public DataWear helmets; + /// 手套 + public DataWear gloves; + /// 鞋子 + public DataWear shoes; + + /// 附加效果 + public DataAddition addition = new DataAddition(); +} +/// +/// 附加 - 数据 +/// +public class DataAddition { + /// 护甲等级 + public int armorClass = 0; + /// 伤害骰子 + public List damageDices = new List(); +} +/// +/// 伤害类型 +/// +public enum DamageType { 穿刺, 挥砍, 钝击 } +/// +/// 伤害 - 数据 +/// +public class DataDamageDice { + /// 伤害骰子 + public readonly int dice; + /// 伤害类型 + public readonly DamageType damageType; + + public DataDamageDice(int dice, DamageType damageType) { + this.dice = dice; + this.damageType = damageType; + } +} \ No newline at end of file diff --git a/Assets/ModuleCore/Module/Item/DataEquipment.cs.meta b/Assets/ModuleCore/Module/DataEquipment.cs.meta similarity index 83% rename from Assets/ModuleCore/Module/Item/DataEquipment.cs.meta rename to Assets/ModuleCore/Module/DataEquipment.cs.meta index a19fe8c..2fc9a95 100644 --- a/Assets/ModuleCore/Module/Item/DataEquipment.cs.meta +++ b/Assets/ModuleCore/Module/DataEquipment.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c500c73626d889c4c8cac76a53f95b2d +guid: 62fae57d4dbef374ba92424caa7b6885 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/Module/Inventory/DataInventory.cs b/Assets/ModuleCore/Module/DataInventory.cs similarity index 57% rename from Assets/ModuleCore/Module/Inventory/DataInventory.cs rename to Assets/ModuleCore/Module/DataInventory.cs index e18aa7d..39067fb 100644 --- a/Assets/ModuleCore/Module/Inventory/DataInventory.cs +++ b/Assets/ModuleCore/Module/DataInventory.cs @@ -2,19 +2,26 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +/// +/// 库存类型枚举,区分背包、仓库等不同库存。 +/// +public enum InventoryType { EquipmentSlot, Backpack, Storage } /// /// 物品库存 - 数据 /// public abstract class DataInventory { /// 库存类型 public InventoryType inventoryType; - - /// 添加物品 - public abstract bool Add(DataItem item); - /// 移除物品 - public abstract bool Remove(DataItem item); } /// -/// 库存类型枚举,区分背包、仓库等不同库存。 +/// 仓库 - 库存 /// -public enum InventoryType { EquipmentSlot, Backpack, Storage } \ No newline at end of file +public class DataStorage : DataInventory { + +} +/// +/// 背包 - 库存 +/// +public class DataBackpack : DataInventory { + +} \ No newline at end of file diff --git a/Assets/ModuleCore/Module/Inventory/DataInventory.cs.meta b/Assets/ModuleCore/Module/DataInventory.cs.meta similarity index 100% rename from Assets/ModuleCore/Module/Inventory/DataInventory.cs.meta rename to Assets/ModuleCore/Module/DataInventory.cs.meta diff --git a/Assets/ModuleCore/Module/DataItem.cs b/Assets/ModuleCore/Module/DataItem.cs new file mode 100644 index 0000000..34e98c7 --- /dev/null +++ b/Assets/ModuleCore/Module/DataItem.cs @@ -0,0 +1,64 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEditor.EditorTools; +using UnityEngine; + +/// +/// 物品类型 +/// +public enum ItemType { 材料, 装备 } +/// +/// 物品 - 数据 +/// +public class DataItem { + /// 物品名称 + public string name; + /// 物品类型 + public ItemType itemType; +} +/// +/// 材料 - 数据 +/// +public class DataMaterial : DataItem { + /// 物品数量 + public int quantity; + /// 堆叠上限 + public int maxStack; +} +/// +/// 穿戴类型 +/// +public enum WearType { 武器, 护甲, 头盔, 手套, 鞋子, } +/// +/// 穿戴 - 数据 +/// +public class DataWear : DataItem { + /// 装备类型 + public WearType wearType; + /// 附加列表 + public List additions = new List(); + /// 附加效果 + public virtual DataAddition Addition => EquipmentTool.Merge(additions); +} +/// +/// 武器类型。 +/// +public enum WeaponType { 轻型武器, 中型武器, 重型武器, 盾牌, } +/// +/// 武器 - 数据 +/// +public class DataWeapon : DataWear { + /// 武器类型 + public WeaponType weaponType; +} +/// +/// 护甲类型。 +/// +public enum ArmorType { 布甲, 轻甲, 中甲, 重甲, } +/// +/// 护甲 - 数据 +/// +public class DataArmor : DataWear { + /// 护甲类型 + public ArmorType armorType; +} \ No newline at end of file diff --git a/Assets/ModuleCore/Module/Item/DataItem.cs.meta b/Assets/ModuleCore/Module/DataItem.cs.meta similarity index 100% rename from Assets/ModuleCore/Module/Item/DataItem.cs.meta rename to Assets/ModuleCore/Module/DataItem.cs.meta diff --git a/Assets/ModuleCore/Module/Inventory/DataBackpack.cs b/Assets/ModuleCore/Module/Inventory/DataBackpack.cs deleted file mode 100644 index 3d337e9..0000000 --- a/Assets/ModuleCore/Module/Inventory/DataBackpack.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataBackpack : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } -} diff --git a/Assets/ModuleCore/Module/Inventory/DataBackpack.cs.meta b/Assets/ModuleCore/Module/Inventory/DataBackpack.cs.meta deleted file mode 100644 index a836268..0000000 --- a/Assets/ModuleCore/Module/Inventory/DataBackpack.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6f54ab1b3cd1a8f4d9ec1fb975e05ef6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/Module/Inventory/DataEquipmentSlot.cs b/Assets/ModuleCore/Module/Inventory/DataEquipmentSlot.cs deleted file mode 100644 index 8273f0c..0000000 --- a/Assets/ModuleCore/Module/Inventory/DataEquipmentSlot.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 装备栏 - 数据 -/// -public class DataEquipmentSlot : DataInventory { - /// 武器1 - public DataWeapon weapon1; - /// 武器2 - public DataWeapon weapon2; - /// 护甲 - public DataArmor armor; - /// 头盔 - public DataEquipment helmets; - /// 手套 - public DataEquipment gloves; - /// 鞋子 - public DataEquipment shoes; - - public override bool Add(DataItem item) { - // 如果是武器,则尝试装备 - if (item is DataWeapon weapon) { return Wear(weapon); } - // 如果是护甲,则尝试装备 - if (item is DataArmor armor) { return Wear(armor); } - // 如果是其他,则尝试装备 - if (item is DataEquipment equipment) { return Wear(equipment); } - return false; - } - public override bool Remove(DataItem item) { - throw new System.NotImplementedException(); - } - - /// 获取护甲等级 - public int GetArmorClass(int modifier) { - int addValue = GetAddValue(); - // 无甲 基础AC = 10,调整值全额生效 - if (armor == null) { return 10 + modifier + addValue; } - // 布甲 调整值全额生效 - if (armor.armorType == ArmorType.ClothArmor) { } - // 轻甲 调整值全额生效 - if (armor.armorType == ArmorType.LightArmor) { } - // 中甲 调整值上限=2 - if (armor.armorType == ArmorType.MediumArmor) { modifier = Mathf.Min(modifier, 2); } - // 重甲 调整值无效‌ - if (armor.armorType == ArmorType.HeavyArmor) { modifier = 0; } - // 基础AC + 调整值 + 附加值 - return GetArmorClass(armor) + modifier + addValue; - } - /// 获取护甲等级 - public int GetArmorClass(DataEquipment equipment) { - return equipment.Addition().armorClass; - } - /// 获取护甲加值 - public int GetAddValue() { - int addValue = 0; - // 武器1 加值 - if (weapon1 != null) { addValue += GetArmorClass(weapon1); } - // 武器2 加值 - if (weapon2 != null) { addValue += GetArmorClass(weapon2); } - // 头盔 加值 - if (helmets != null) { addValue += GetArmorClass(helmets); } - // 手套 加值 - if (gloves != null) { addValue += GetArmorClass(gloves); } - // 鞋子 加值 - if (shoes != null) { addValue += GetArmorClass(shoes); } - return addValue; - } - - #region 穿戴 - private bool Wear(DataWeapon weapon) { - weapon1 = weapon; - return true; - } - private bool Wear(DataArmor armor) { - this.armor = armor; - return true; - } - private bool Wear(DataEquipment equipment) { - if (equipment.equipmentType == EquipmentType.Helmets) { helmets = equipment; return true; } - if (equipment.equipmentType == EquipmentType.Gloves) { gloves = equipment; return true; } - if (equipment.equipmentType == EquipmentType.Shoes) { shoes = equipment; return true; } - return false; - } - #endregion -} diff --git a/Assets/ModuleCore/Module/Inventory/DataEquipmentSlot.cs.meta b/Assets/ModuleCore/Module/Inventory/DataEquipmentSlot.cs.meta deleted file mode 100644 index 1ef4b34..0000000 --- a/Assets/ModuleCore/Module/Inventory/DataEquipmentSlot.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 83edeb48630d62a44a8d7c7551e9f0fb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/Module/Inventory/DataStorage.cs b/Assets/ModuleCore/Module/Inventory/DataStorage.cs deleted file mode 100644 index 7008903..0000000 --- a/Assets/ModuleCore/Module/Inventory/DataStorage.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DataStorage : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } -} diff --git a/Assets/ModuleCore/Module/Inventory/DataStorage.cs.meta b/Assets/ModuleCore/Module/Inventory/DataStorage.cs.meta deleted file mode 100644 index dba3136..0000000 --- a/Assets/ModuleCore/Module/Inventory/DataStorage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 943f05d3866fd8e4cb463a4f0597d0c5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/Module/Item.meta b/Assets/ModuleCore/Module/Item.meta deleted file mode 100644 index 6535c7e..0000000 --- a/Assets/ModuleCore/Module/Item.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: da6831802283b3643bf03d784ccc5813 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/Module/Item/DataArmor.cs b/Assets/ModuleCore/Module/Item/DataArmor.cs deleted file mode 100644 index 80c2cbe..0000000 --- a/Assets/ModuleCore/Module/Item/DataArmor.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 护甲类型。 -/// -public enum ArmorType { - /// 布甲 - ClothArmor, - /// 轻甲 - LightArmor, - /// 中甲 - MediumArmor, - /// 重甲 - HeavyArmor, -} -/// -/// 护甲 - 数据 -/// -public class DataArmor : DataEquipment { - /// 护甲类型 - public ArmorType armorType; -} diff --git a/Assets/ModuleCore/Module/Item/DataArmor.cs.meta b/Assets/ModuleCore/Module/Item/DataArmor.cs.meta deleted file mode 100644 index 2c57168..0000000 --- a/Assets/ModuleCore/Module/Item/DataArmor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 062eefbb65fcc2e44aa8f4fe25fe7ab8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/Module/Item/DataEquipment.cs b/Assets/ModuleCore/Module/Item/DataEquipment.cs deleted file mode 100644 index 33ae963..0000000 --- a/Assets/ModuleCore/Module/Item/DataEquipment.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 装备类型。 -/// -public enum EquipmentType { - /// 武器 - Weapon, - /// 护甲 - Armor, - /// 头盔 - Helmets, - /// 手套 - Gloves, - /// 鞋子 - Shoes, -} -/// -/// 装备 - 数据 -/// -public class DataEquipment : DataItem { - /// 装备类型 - public EquipmentType equipmentType; - /// 附加效果 - public List additions; - - /// 附加效果 - public DataAddition Addition() { - DataAddition addition = new DataAddition(); - additions.ForEach(obj => addition.Add(obj)); - return addition; - } -} diff --git a/Assets/ModuleCore/Module/Item/DataItem.cs b/Assets/ModuleCore/Module/Item/DataItem.cs deleted file mode 100644 index d7f2324..0000000 --- a/Assets/ModuleCore/Module/Item/DataItem.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 物品类型。 -/// -public enum ItemType { - /// 材料 - Material, - /// 装备 - Equipment -} -/// -/// 物品 - 数据 -/// -public class DataItem { - /// 物品名称 - public string name; - /// 物品类型 - public ItemType itemType; -} - diff --git a/Assets/ModuleCore/Module/Item/DataMaterial.cs b/Assets/ModuleCore/Module/Item/DataMaterial.cs deleted file mode 100644 index 0562828..0000000 --- a/Assets/ModuleCore/Module/Item/DataMaterial.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 材料 - 数据 -/// -public class DataMaterial : DataItem { - /// 物品数量 - public int quantity; - /// 堆叠上限 - public int maxStack; -} diff --git a/Assets/ModuleCore/Module/Item/DataMaterial.cs.meta b/Assets/ModuleCore/Module/Item/DataMaterial.cs.meta deleted file mode 100644 index 698351d..0000000 --- a/Assets/ModuleCore/Module/Item/DataMaterial.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d8fb2ebbb537271478ec399677a1b08a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/Module/Item/DataWeapon.cs b/Assets/ModuleCore/Module/Item/DataWeapon.cs deleted file mode 100644 index 698b95f..0000000 --- a/Assets/ModuleCore/Module/Item/DataWeapon.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -/// -/// 武器类型。 -/// -public enum WeaponType { - /// 轻型武器 - LightWeapon, - /// 中型武器 - MediumWeapon, - /// 重型武器 - HeavyWeapon, - /// 盾牌 - Shield, -} -/// -/// 武器 - 数据 -/// -public class DataWeapon : DataEquipment { - /// 武器类型 - public WeaponType weaponType; -} diff --git a/Assets/ModuleCore/Module/Item/DataWeapon.cs.meta b/Assets/ModuleCore/Module/Item/DataWeapon.cs.meta deleted file mode 100644 index 6e5df08..0000000 --- a/Assets/ModuleCore/Module/Item/DataWeapon.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0be9cb0c2accc804eb824de0e8ca3fa5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleBattle/BattleCharacter.cs b/Assets/ModuleCore/ModuleBattle/BattleCharacter.cs index eb11ee7..b96dd2e 100644 --- a/Assets/ModuleCore/ModuleBattle/BattleCharacter.cs +++ b/Assets/ModuleCore/ModuleBattle/BattleCharacter.cs @@ -26,7 +26,7 @@ public class BattleCharacter : DataAttribute { public BattleCharacter(DataCharacter character, int team) { this.character = character; - Cover(character); + AttributeTool.Cover(this, character); this.team = team; name = character.name; level = character.Level; @@ -35,8 +35,12 @@ public class BattleCharacter : DataAttribute { armorClass = character.ArmorClass; } - /// 攻击目标 - public bool AttackTarget(BattleCharacter target) { + /// 是否允许行动 + public bool IsAction() { + return hitPoint.x > 0; + } + /// 是否敌对目标 + public bool IsHostility(BattleCharacter target) { return team != target.team && target.hitPoint.x > 0; } } diff --git a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseAction.cs b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseAction.cs index b1dc613..ccaca18 100644 --- a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseAction.cs +++ b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseAction.cs @@ -6,6 +6,10 @@ using UnityEngine; /// 行动阶段 /// public class PhaseAction : BattlePhase { + /// 当前行动 + private BattleCharacter currentAction; + /// 当前目标 + private BattleCharacter currentTarget; public PhaseAction(BattleSimulator simulator) : base(simulator) { } @@ -13,14 +17,23 @@ public class PhaseAction : BattlePhase { // throw new System.NotImplementedException(); } public override void UpdatePhase() { - // 选择行动目标,没有行动目标则进入结算阶段 - if (!BattleQueue.Dequeue(out BattleCharacter character)) { simulator.Transition(PhaseType.结算阶段); return; } - // 判断是否可以行动 - if (ActionPredicate(character)) { return; } - // 选择一个可以攻击的目标 - BattleCharacter target = BattleQueue.FirstOrDefault(obj => character.AttackTarget(obj)); - // 对目标进行攻击 - + // 选择行动的角色,如果没有则进入下一轮 + if (!SelectAction()) { return; } + // 选择攻击的目标,如果没有目标则结算战斗 + if (!SelectTarget()) { return; } + // 命中检定 + int hit = Dice.Roll20(currentAction.DexModifier); + int ac = currentTarget.armorClass; + bool isHit = hit > ac; + // 伤害计算 + if (isHit) { + int damage = Dice.Roll8(currentAction.StrModifier); + currentTarget.hitPoint.x -= damage; + Debug.Log($"{currentAction.name}使用 普通攻击({hit}) 对 {currentTarget.name}({ac}) 造成 {damage} 点伤害!"); + } + else { + Debug.Log($"{currentAction.name}使用 普通攻击({hit}) 对 {currentTarget.name}({ac}) 未命中!"); + } // TODO:记录器 // Debug.Log($"正式回合:{roundCount}"); } @@ -28,9 +41,20 @@ public class PhaseAction : BattlePhase { // throw new System.NotImplementedException(); } - /// 行动判断 - private bool ActionPredicate(BattleCharacter character) { - return character.hitPoint.x > 0; + /// 选择当前行动角色 + private bool SelectAction() { + // 选择行动的角色,如果没有则进入下一回合 + if (!BattleQueue.Dequeue(out currentAction)) { simulator.Transition(PhaseType.回合阶段); return false; } + // 判断是否可以行动 + if (!currentAction.IsAction()) { return false; } + return true; + } + /// 选择当前目标角色 + private bool SelectTarget() { + // 选择一个可以攻击的目标 + currentTarget = BattleQueue.FirstOrDefault(obj => currentAction.IsHostility(obj)); + // 如果没有可以攻击的目标则结算战斗 + if (currentTarget == null) { simulator.Transition(PhaseType.结算阶段); } + return currentTarget != null; } - } diff --git a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseAssault.cs b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseAssault.cs index 017eddc..bd2b051 100644 --- a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseAssault.cs +++ b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseAssault.cs @@ -10,12 +10,12 @@ public class PhaseAssault : BattlePhase { public PhaseAssault(BattleSimulator simulator) : base(simulator) { } public override void StartPhase() { - throw new System.NotImplementedException(); + // throw new System.NotImplementedException(); } public override void UpdatePhase() { - throw new System.NotImplementedException(); + // throw new System.NotImplementedException(); } public override void QuitPhase() { - throw new System.NotImplementedException(); + // throw new System.NotImplementedException(); } } diff --git a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseFinish.cs b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseFinish.cs index e9edc73..1c5c1a5 100644 --- a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseFinish.cs +++ b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseFinish.cs @@ -10,12 +10,16 @@ public class PhaseFinish : BattlePhase { public PhaseFinish(BattleSimulator simulator) : base(simulator) { } public override void StartPhase() { - throw new System.NotImplementedException(); + // TODO:记录器 + Debug.Log("结束战斗!"); } public override void UpdatePhase() { - throw new System.NotImplementedException(); + // TODO:需要添加结算判断 + // simulator.Transition(PhaseType.回合阶段); + // TODO:记录器 + } public override void QuitPhase() { - throw new System.NotImplementedException(); + // throw new System.NotImplementedException(); } } diff --git a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseFormal.cs b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseFormal.cs index c6dd6a5..a971522 100644 --- a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseFormal.cs +++ b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseFormal.cs @@ -20,6 +20,9 @@ public class PhaseFormal : BattlePhase { simulator.Transition(PhaseType.行动阶段); // TODO:记录器 Debug.Log($"正式回合:{roundCount}"); + string message = "存活"; + BattleQueue.ForEach(obj => message += $" {obj.name}({obj.hitPoint.x})"); + Debug.Log(message); } public override void QuitPhase() { // throw new System.NotImplementedException(); diff --git a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseInitiative.cs b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseInitiative.cs index a0202af..c35dee4 100644 --- a/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseInitiative.cs +++ b/Assets/ModuleCore/ModuleBattle/BattlePhase/PhaseInitiative.cs @@ -18,7 +18,9 @@ public class PhaseInitiative : BattlePhase { // TODO:需要添加突袭阶段 simulator.Transition(PhaseType.回合阶段); // TODO:记录器 - Debug.Log("先攻"); + string message = "先攻"; + BattleQueue.ForEach(obj => message += $" {obj.name}({obj.sequence})"); + Debug.Log(message); } public override void QuitPhase() { // throw new System.NotImplementedException(); diff --git a/Assets/ModuleCore/ModuleBattle/BattleSimulator.cs b/Assets/ModuleCore/ModuleBattle/BattleSimulator.cs index aea05fc..5af8cdf 100644 --- a/Assets/ModuleCore/ModuleBattle/BattleSimulator.cs +++ b/Assets/ModuleCore/ModuleBattle/BattleSimulator.cs @@ -9,7 +9,6 @@ using UnityEngine; /// 战斗 - 模拟器 /// public class BattleSimulator { - /// 战斗队列 public BattleQueue battleQueue = new BattleQueue(); @@ -19,6 +18,9 @@ public class BattleSimulator { public Dictionary dictionary = new Dictionary(); public BattleSimulator(BattleTeam team1, BattleTeam team2) { + team1.Initial(1); + team2.Initial(2); + battleQueue.Add(team1.battles); battleQueue.Add(team2.battles); @@ -27,6 +29,8 @@ public class BattleSimulator { dictionary.Add(PhaseType.回合阶段, new PhaseFormal(this)); dictionary.Add(PhaseType.行动阶段, new PhaseAction(this)); dictionary.Add(PhaseType.结算阶段, new PhaseFinish(this)); + + Transition(PhaseType.先攻阶段); } public void Update() { currentPhase?.UpdatePhase(); @@ -40,7 +44,7 @@ public class BattleSimulator { currentPhase?.QuitPhase(); currentPhase = newPhase; currentPhase?.StartPhase(); - Debug.Log($"战斗阶段已转换为: {phaseType}"); + // Debug.Log($"战斗阶段已转换为: {phaseType}"); } else { // 不存在时输出警告信息 diff --git a/Assets/ModuleCore/Module/Addition.meta b/Assets/ModuleCore/ModuleCharacter.meta similarity index 77% rename from Assets/ModuleCore/Module/Addition.meta rename to Assets/ModuleCore/ModuleCharacter.meta index d6aae2b..0b3aa13 100644 --- a/Assets/ModuleCore/Module/Addition.meta +++ b/Assets/ModuleCore/ModuleCharacter.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e350f02da82dedd459ba3280f586d116 +guid: 1f85c0d8dce903b4eb5fb0aca37d2040 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleCore/ModuleCharacter/AttributeTool.cs b/Assets/ModuleCore/ModuleCharacter/AttributeTool.cs new file mode 100644 index 0000000..cae1fdd --- /dev/null +++ b/Assets/ModuleCore/ModuleCharacter/AttributeTool.cs @@ -0,0 +1,48 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 属性 - 工具 +/// +public static class AttributeTool { + + #region 创建 + /// 随机初始属性 + public static DataAttribute Random() { + DataAttribute attribute = new DataAttribute(); + attribute.Str = Dice.RollAttribute(); + attribute.Dex = Dice.RollAttribute(); + attribute.Con = Dice.RollAttribute(); + attribute.Int = Dice.RollAttribute(); + attribute.Wis = Dice.RollAttribute(); + attribute.Cha = Dice.RollAttribute(); + return attribute; + } + #endregion + + #region 扩展 + // 计算属性调整值(属性值-10)/2 向下取整 + public static int Modifier(int value) { + return (int)System.Math.Floor((value - 10) / 2.0); + } + /// 添加属性 + public static void Add(this DataAttribute a, DataAttribute b) { + a.Str += b.Str; a.Dex += b.Dex; + a.Con += b.Con; a.Int += b.Int; + a.Wis += b.Wis; a.Cha += b.Cha; + } + /// 减少属性 + public static void Sub(this DataAttribute a, DataAttribute b) { + a.Str -= b.Str; a.Dex -= b.Dex; + a.Con -= b.Con; a.Int -= b.Int; + a.Wis -= b.Wis; a.Cha -= b.Cha; + } + /// 覆盖属性 + public static void Cover(this DataAttribute a, DataAttribute b) { + a.Str = b.Str; a.Dex = b.Dex; + a.Con = b.Con; a.Int = b.Int; + a.Wis = b.Wis; a.Cha = b.Cha; + } + #endregion +} diff --git a/Assets/ModuleCore/Module/Character/DataProfession.cs.meta b/Assets/ModuleCore/ModuleCharacter/AttributeTool.cs.meta similarity index 83% rename from Assets/ModuleCore/Module/Character/DataProfession.cs.meta rename to Assets/ModuleCore/ModuleCharacter/AttributeTool.cs.meta index f5ad694..94146d0 100644 --- a/Assets/ModuleCore/Module/Character/DataProfession.cs.meta +++ b/Assets/ModuleCore/ModuleCharacter/AttributeTool.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9fd9942ce333fa94aa2297f3569a4939 +guid: f6a814b3a3b754241ae35753e6d7c7f8 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/ModuleCharacter/CharacterTool.cs b/Assets/ModuleCore/ModuleCharacter/CharacterTool.cs new file mode 100644 index 0000000..d8c9298 --- /dev/null +++ b/Assets/ModuleCore/ModuleCharacter/CharacterTool.cs @@ -0,0 +1,81 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 角色工具 +/// +public static class CharacterTool { + + #region 设置参数 + /// 设置职业 + public static void Settings(this DataCharacter character, DataRace race) { + character.race = race; + } + /// 设置职业 + public static void Settings(this DataCharacter character, DataProfession profession) { + character.profession = profession; + profession.character = character; + } + #endregion + + #region 属性扩展 + /// 战斗等级 + public static int GetLevel(this DataCharacter character) { + // TODO:需要补充多职业的等级总和 + return character.profession.level; + } + /// 生命点 + public static int GetHitPoint(this DataCharacter character) { + // TODO:需要补充多职业的生命值加成 + return character.profession.HitPoint(); + } + /// 计算护甲等级(AC) + public static int GetArmorClass(this DataCharacter character) { + // TODO:需要补充专长,技能,熟练之类的加值 + int modifier = character.DexModifier; + return character.equipment.ArmorClass(modifier); + } + #endregion + + #region 创建角色 + /// 创建默认角色 + public static DataCharacter Create(string name) { + DataCharacter character = new DataCharacter(); + character.name = name; + character.race = RaceTool.None(); + character.basis = AttributeTool.Random(); + character.profession = ProfessionTool.None(); + character.profession.Initial(character); + character.equipment = new DataEquipment(); + return character; + } + /// 创建默认角色 + public static DataCharacter Create(string name, DataRace race, DataProfession profession) { + DataCharacter character = new DataCharacter(); + character.name = name; + character.race = race; + character.basis = AttributeTool.Random(); + character.profession = profession; + character.profession.Initial(character); + character.equipment = new DataEquipment(); + return character; + } + #endregion + + // 打印角色卡 + public static void PrintCharacterSheet(this DataCharacter character) { + Debug.Log($"=== {character.name} LV{character.Level} ==="); + Debug.Log($"种族: {character.race.name}"); + Debug.Log($"职业: {character.profession.name}"); + Debug.Log($"力量: {character.Str} ({character.StrModifier.ToString("+#;-#;+0")})"); + Debug.Log($"敏捷: {character.Dex} ({character.DexModifier.ToString("+#;-#;+0")})"); + Debug.Log($"体质: {character.Con} ({character.ConModifier.ToString("+#;-#;+0")})"); + Debug.Log($"智力: {character.Int} ({character.IntModifier.ToString("+#;-#;+0")})"); + Debug.Log($"感知: {character.Wis} ({character.WisModifier.ToString("+#;-#;+0")})"); + Debug.Log($"魅力: {character.Cha} ({character.ChaModifier.ToString("+#;-#;+0")})"); + Debug.Log($"经验值: {character.expPoint}"); + Debug.Log($"生命值: {character.HitPoint}"); + Debug.Log($"护甲等级: {character.ArmorClass})"); + } +} diff --git a/Assets/ModuleCore/Module/Character/DataAttribute.cs.meta b/Assets/ModuleCore/ModuleCharacter/CharacterTool.cs.meta similarity index 83% rename from Assets/ModuleCore/Module/Character/DataAttribute.cs.meta rename to Assets/ModuleCore/ModuleCharacter/CharacterTool.cs.meta index b2adddf..8f34937 100644 --- a/Assets/ModuleCore/Module/Character/DataAttribute.cs.meta +++ b/Assets/ModuleCore/ModuleCharacter/CharacterTool.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: fb070bc540efae048ae79c8319c0c0e2 +guid: a6bdd4c70e0068d4dbe460c7a6961901 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/Module/Character/DataProfession.cs b/Assets/ModuleCore/ModuleCharacter/ProfessionTool.cs similarity index 50% rename from Assets/ModuleCore/Module/Character/DataProfession.cs rename to Assets/ModuleCore/ModuleCharacter/ProfessionTool.cs index 5f1c4d9..0e54bfb 100644 --- a/Assets/ModuleCore/Module/Character/DataProfession.cs +++ b/Assets/ModuleCore/ModuleCharacter/ProfessionTool.cs @@ -4,46 +4,42 @@ using System.Linq; using UnityEngine; /// -/// 职业 - 数据 +/// 种族 - 工具 /// -public class DataProfession { - /// 职业名称 - public readonly string name; - /// 生命骰子 - public readonly int hitDice = 0; - /// 角色 - public DataCharacter character; - /// 职业等级 - public int level = 0; - /// 累计生命点 - public List hitPoints = new List(); +public static class ProfessionTool { - public DataProfession(string name, int hitDice) { - this.name = name; - this.hitDice = hitDice; - } + #region 扩展 /// 初始:满生命骰子 + 体质调整值 - public void Initial(DataCharacter character) { - this.character = character; - level = 1; - // 初始生命 = - hitPoints = new List(); - hitPoints.Add(hitDice + character.ConModifier); + public static void Initial(this DataProfession profession, DataCharacter character) { + profession.character = character; + int hitPoint = profession.hitDice + character.ConModifier; + profession.level = 1; + profession.hitPoints = new List { hitPoint }; } /// 升级:骰生命骰子 + 体质调整值 - public void Upgrade() { - level++; - int hitPoint = Dice.Roll(hitDice) + character.ConModifier; - hitPoints.Add(hitPoint); + public static void Upgrade(this DataProfession profession) { + profession.level++; + int hitPoint = Dice.Roll(profession.hitDice); + int modifier = profession.character.ConModifier; + profession.hitPoints.Add(hitPoint + modifier); } /// 生命点:每级生命点总和 - public int HitPoint() { - return hitPoints.Sum(); + public static int HitPoint(this DataProfession profession) { + return profession.hitPoints.Sum(); } + #endregion + #region 创建 + /// 创建 + public static DataProfession Create(string name, int hitDice) { + DataProfession profession = new DataProfession { name = name, hitDice = hitDice }; + profession.name = name; + profession.hitDice = hitDice; + return profession; + } /// 无职业 1d4 public static DataProfession None() { - return new DataProfession("无", 4); + return Create("无", 4); } /// 随机职业 public static DataProfession Random() { @@ -57,22 +53,23 @@ public class DataProfession { } /// 战士 1d10 public static DataProfession Warrior() { - return new DataProfession("战士", 10); + return Create("战士", 10); } /// 法师 1d6 public static DataProfession Wizard() { - return new DataProfession("法师", 6); + return Create("法师", 6); } /// 牧师 1d8 public static DataProfession Cleric() { - return new DataProfession("牧师", 8); + return Create("牧师", 8); } /// 游侠 1d8 public static DataProfession Ranger() { - return new DataProfession("游侠", 8); + return Create("游侠", 8); } /// 歌者 1d6 public static DataProfession Chanter() { - return new DataProfession("歌者", 6); + return Create("歌者", 6); } + #endregion } diff --git a/Assets/ModuleCore/Module/Addition/DataAddition.cs.meta b/Assets/ModuleCore/ModuleCharacter/ProfessionTool.cs.meta similarity index 83% rename from Assets/ModuleCore/Module/Addition/DataAddition.cs.meta rename to Assets/ModuleCore/ModuleCharacter/ProfessionTool.cs.meta index 901af4b..3fb23d7 100644 --- a/Assets/ModuleCore/Module/Addition/DataAddition.cs.meta +++ b/Assets/ModuleCore/ModuleCharacter/ProfessionTool.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 451b46f5359088a46bc1efc7fcf7ff7b +guid: bd48318dcbe216449a81d70622f8ba35 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/ModuleCharacter/RaceTool.cs b/Assets/ModuleCore/ModuleCharacter/RaceTool.cs new file mode 100644 index 0000000..936cc72 --- /dev/null +++ b/Assets/ModuleCore/ModuleCharacter/RaceTool.cs @@ -0,0 +1,47 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 种族 - 工具 +/// +public static class RaceTool { + + #region 创建 + // 混血人类,木精灵,丘陵矮人(Hill Dwarf),龙裔,半精灵 + /// 无种族 + public static DataRace None() { + return new DataRace { name = "未知" }; + } + /// 随机职业 + public static DataRace Random() { + int index = Dice.Roll(5); + if (index == 1) { return Human(); } + if (index == 2) { return Elven(); } + if (index == 3) { return Dwarf(); } + if (index == 4) { return Orc(); } + if (index == 5) { return Halfling(); } + return None(); + } + /// 人类(Human) 全属性+1 + public static DataRace Human() { + return new DataRace { name = "人类", Str = 1, Dex = 1, Con = 1, Int = 1, Wis = 1, Cha = 1 }; + } + /// 精灵(Elven) 敏捷+2 智力+2 感知+1 + public static DataRace Elven() { + return new DataRace { name = "精灵", Dex = 2, Int = 2, Wis = 1 }; + } + /// 矮人(Dwarf) 力量+2 体质+2 感知+1 + public static DataRace Dwarf() { + return new DataRace { name = "矮人", Str = 2, Con = 2, Wis = 1 }; + } + /// 半兽人(Orc) 力量+3 体质+2 + public static DataRace Orc() { + return new DataRace { name = "半兽人", Str = 3, Con = 2 }; + } + /// 半身人(Halfling) 敏捷+2 魅力+2 体质+1 + public static DataRace Halfling() { + return new DataRace { name = "半身人", Dex = 2, Cha = 2, Con = 1 }; + } + #endregion +} diff --git a/Assets/ModuleCore/Module/Character/DataRace.cs.meta b/Assets/ModuleCore/ModuleCharacter/RaceTool.cs.meta similarity index 83% rename from Assets/ModuleCore/Module/Character/DataRace.cs.meta rename to Assets/ModuleCore/ModuleCharacter/RaceTool.cs.meta index 226d76e..4f587b7 100644 --- a/Assets/ModuleCore/Module/Character/DataRace.cs.meta +++ b/Assets/ModuleCore/ModuleCharacter/RaceTool.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e444293bdefc67346a3d80901305e4c7 +guid: 9694db834fdbe8744882901e02003034 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ModuleCore/Module/Inventory.meta b/Assets/ModuleCore/ModuleInventory.meta similarity index 77% rename from Assets/ModuleCore/Module/Inventory.meta rename to Assets/ModuleCore/ModuleInventory.meta index 3f161fe..b1cff23 100644 --- a/Assets/ModuleCore/Module/Inventory.meta +++ b/Assets/ModuleCore/ModuleInventory.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 31e213ee804e43848b56cd336a8025d4 +guid: c29e0b5bff9f654439aa3e867ac20484 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/ModuleCore/ModuleInventory/ArmorDictionary.cs b/Assets/ModuleCore/ModuleInventory/ArmorDictionary.cs new file mode 100644 index 0000000..aae7721 --- /dev/null +++ b/Assets/ModuleCore/ModuleInventory/ArmorDictionary.cs @@ -0,0 +1,42 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 装备 - 字典 +/// +public static class ArmorDictionary { + /// 武器 + public static DataArmor Armor(string name, ArmorType armorType) { + DataArmor armor = new DataArmor(); + armor.name = name; + armor.itemType = ItemType.装备; + armor.wearType = WearType.护甲; + armor.armorType = armorType; + return armor; + } + /// 法师袍 ac10 + public static DataArmor Armor101() { + DataArmor armor = Armor("法师袍", ArmorType.布甲); + armor.additions.Add(new DataAddition { armorClass = 10 }); + return armor; + } + /// 皮甲 ac11 + public static DataArmor Armor201() { + DataArmor armor = Armor("皮甲", ArmorType.轻甲); + armor.additions.Add(new DataAddition { armorClass = 11 }); + return armor; + } + /// 链甲 ac15 + public static DataArmor Armor301() { + DataArmor armor = Armor("链甲", ArmorType.中甲); + armor.additions.Add(new DataAddition { armorClass = 15 }); + return armor; + } + /// 板甲 ac18 + public static DataArmor Armor401() { + DataArmor armor = Armor("板甲", ArmorType.重甲); + armor.additions.Add(new DataAddition { armorClass = 18 }); + return armor; + } +} diff --git a/Assets/ModuleCore/ModuleInventory/ArmorDictionary.cs.meta b/Assets/ModuleCore/ModuleInventory/ArmorDictionary.cs.meta new file mode 100644 index 0000000..7c9e28e --- /dev/null +++ b/Assets/ModuleCore/ModuleInventory/ArmorDictionary.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f13627182bd77434991f32751b8c15f7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleInventory/EquipmentTool.cs b/Assets/ModuleCore/ModuleInventory/EquipmentTool.cs new file mode 100644 index 0000000..c7aa0dd --- /dev/null +++ b/Assets/ModuleCore/ModuleInventory/EquipmentTool.cs @@ -0,0 +1,106 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 装备栏 - 工具 +/// +public static class EquipmentTool { + + #region 附加 + /// 添加属性 + public static void Add(this DataAddition a, DataAddition b) { + a.armorClass += b.armorClass; + a.damageDices.AddRange(b.damageDices); + } + /// 合并属性 + public static DataAddition Merge(List additions) { + DataAddition addition = new DataAddition(); + additions.ForEach(obj => addition.Add(obj)); + return addition; + } + /// 更新附加值 + public static void UpdateAddition(this DataEquipment equipment) { + DataAddition addition = new DataAddition(); + if (equipment.weapon1 != null) { addition.Add(equipment.weapon1.Addition); } + if (equipment.weapon2 != null) { addition.Add(equipment.weapon2.Addition); } + if (equipment.armor != null) { addition.Add(equipment.armor.Addition); } + if (equipment.helmets != null) { addition.Add(equipment.helmets.Addition); } + if (equipment.gloves != null) { addition.Add(equipment.gloves.Addition); } + if (equipment.shoes != null) { addition.Add(equipment.shoes.Addition); } + equipment.addition = addition; + } + /// 获取护甲等级 + public static int ArmorClass(this DataEquipment equipment, int modifier) { + int addValue = equipment.addition.armorClass; + // 无甲 基础AC = 10 + 调整值 + 附加值 + if (equipment.armor == null) { return 10 + modifier + addValue; } + // 布甲/轻甲 调整值全额生效 + if (equipment.armor.armorType == ArmorType.布甲) { } + // 调整值全额生效 + if (equipment.armor.armorType == ArmorType.轻甲) { } + // 中甲 调整值上限=2 + if (equipment.armor.armorType == ArmorType.中甲) { modifier = Mathf.Min(modifier, 2); } + // 重甲 调整值无效‌ + if (equipment.armor.armorType == ArmorType.重甲) { modifier = 0; } + // 调整值 + 附加值 + return modifier + addValue; + } + #endregion + + #region 穿戴 + /// 穿戴装备 + public static bool Wear(this DataEquipment equipment, DataWear wear, out DataWear old) { + old = wear; bool isWear = false; + if (wear.wearType == WearType.武器) { isWear = WearWeapon(equipment, wear, out old); } + if (wear.wearType == WearType.护甲) { isWear = WearArmor(equipment, wear, out old); } + if (wear.wearType == WearType.头盔) { isWear = WearHelmets(equipment, wear, out old); } + if (wear.wearType == WearType.手套) { isWear = WearGloves(equipment, wear, out old); } + if (wear.wearType == WearType.鞋子) { isWear = WearShoes(equipment, wear, out old); } + equipment.UpdateAddition(); + return isWear; + } + /// 穿戴武器 + public static bool WearWeapon(this DataEquipment equipment, DataWear wear, out DataWear old) { + old = null; + // 校验是否为武器类型 + if (!(wear is DataWeapon newWeapon)) { return false; } + // 情况1:主手为空,直接装备主手 + if (equipment.weapon1 == null) { equipment.weapon1 = newWeapon; return true; } + // 情况2:副手为空,直接装备副手 + if (equipment.weapon2 == null) { equipment.weapon2 = newWeapon; return true; } + // 情况3:主手副手都不为空,默认替换主手 + old = equipment.weapon1; + equipment.weapon1 = newWeapon; + equipment.UpdateAddition(); + return true; + } + /// 穿戴护甲 + public static bool WearArmor(this DataEquipment equipment, DataWear wear, out DataWear old) { + old = null; + // 校验是否为护甲类型 + if (!(wear is DataArmor newArmor)) { return false; } + old = equipment.armor; + equipment.armor = newArmor; + return true; + } + /// 穿戴头盔 + public static bool WearHelmets(this DataEquipment equipment, DataWear wear, out DataWear old) { + old = equipment.helmets; + equipment.helmets = wear; + return true; + } + /// 穿戴手套 + public static bool WearGloves(this DataEquipment equipment, DataWear wear, out DataWear old) { + old = equipment.gloves; + equipment.gloves = wear; + return true; + } + /// 穿戴鞋子 + public static bool WearShoes(this DataEquipment equipment, DataWear wear, out DataWear old) { + old = equipment.shoes; + equipment.shoes = wear; + return true; + } + #endregion +} diff --git a/Assets/ModuleCore/ModuleInventory/EquipmentTool.cs.meta b/Assets/ModuleCore/ModuleInventory/EquipmentTool.cs.meta new file mode 100644 index 0000000..3e56f89 --- /dev/null +++ b/Assets/ModuleCore/ModuleInventory/EquipmentTool.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1fd627b70f23dd44493bf8fb1e577370 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleInventory/WeaponDictionary.cs b/Assets/ModuleCore/ModuleInventory/WeaponDictionary.cs new file mode 100644 index 0000000..6e58ffc --- /dev/null +++ b/Assets/ModuleCore/ModuleInventory/WeaponDictionary.cs @@ -0,0 +1,49 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// 武器 - 字典 +/// +public static class WeaponDictionary { + /// 武器 + public static DataWeapon Weapon(string name, WeaponType weaponType) { + DataWeapon weapon = new DataWeapon(); + weapon.name = name; + weapon.itemType = ItemType.装备; + weapon.wearType = WearType.武器; + weapon.weaponType = weaponType; + return weapon; + } + /// 伤害骰子 + public static DataAddition DamageDice(int value, DamageType type) { + DataDamageDice dice = new DataDamageDice(value, type); + DataAddition addition = new DataAddition(); + addition.damageDices.Add(dice); + return addition; + } + /// 匕首 1d4 + public static DataWeapon Weapon101() { + DataWeapon weapon = Weapon("匕首", WeaponType.轻型武器); + weapon.additions.Add(DamageDice(4, DamageType.穿刺)); + return weapon; + } + /// 木棒 1d6 + public static DataWeapon Weapon201() { + DataWeapon weapon = Weapon("木棒", WeaponType.中型武器); + weapon.additions.Add(DamageDice(6, DamageType.挥砍)); + return weapon; + } + /// 巨棒 1d8 + public static DataWeapon Weapon301() { + DataWeapon weapon = Weapon("巨棒", WeaponType.重型武器); + weapon.additions.Add(DamageDice(8, DamageType.钝击)); + return weapon; + } + /// 木盾 ac1 + public static DataWeapon Weapon401() { + DataWeapon weapon = Weapon("木盾", WeaponType.盾牌); + weapon.additions.Add(new DataAddition { armorClass = 1 }); + return weapon; + } +} diff --git a/Assets/ModuleCore/ModuleInventory/WeaponDictionary.cs.meta b/Assets/ModuleCore/ModuleInventory/WeaponDictionary.cs.meta new file mode 100644 index 0000000..d5ffe84 --- /dev/null +++ b/Assets/ModuleCore/ModuleInventory/WeaponDictionary.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 32522aef438403f4d9ed01fe6650243b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ModuleCore/ModuleSingle/ManagerSimulator.cs b/Assets/ModuleCore/ModuleSingle/ManagerSimulator.cs index 67c7dbe..c914148 100644 --- a/Assets/ModuleCore/ModuleSingle/ManagerSimulator.cs +++ b/Assets/ModuleCore/ModuleSingle/ManagerSimulator.cs @@ -33,6 +33,6 @@ public class ManagerSimulator : ModuleSingle { } private DataCharacter RandomCharacter(string name) { - return DataCharacter.Create(name, DataRace.Random(), DataProfession.Random()); + return CharacterTool.Create(name, RaceTool.Random(), ProfessionTool.Random()); } } diff --git a/Assets/ModuleCore/ModuleTools/Dice.cs b/Assets/ModuleCore/ModuleTools/Dice.cs index 182adfb..40e3f78 100644 --- a/Assets/ModuleCore/ModuleTools/Dice.cs +++ b/Assets/ModuleCore/ModuleTools/Dice.cs @@ -12,6 +12,20 @@ public static class Dice { public static int Roll(int value) { return Random.Range(1, value + 1); } + /// d6 + 调整值 + 加值 + public static int Roll6(int modifier = 0, int addValue = 0, DiceGrade grade = DiceGrade.平势) { + int d1 = Roll(6); int d2 = Roll(6); + if (grade == DiceGrade.优势) { d1 = d1 >= d2 ? d1 : d2; } + if (grade == DiceGrade.平势) { d1 = d1 <= d2 ? d1 : d2; } + return d1 + modifier + addValue; + } + /// d8 + 调整值 + 加值 + public static int Roll8(int modifier = 0, int addValue = 0, DiceGrade grade = DiceGrade.平势) { + int d1 = Roll(8); int d2 = Roll(8); + if (grade == DiceGrade.优势) { d1 = d1 >= d2 ? d1 : d2; } + if (grade == DiceGrade.平势) { d1 = d1 <= d2 ? d1 : d2; } + return d1 + modifier + addValue; + } /// d20 + 调整值 + 加值 public static int Roll20(int modifier = 0, int addValue = 0, DiceGrade grade = DiceGrade.平势) { int d1 = Roll(20); int d2 = Roll(20); diff --git a/Assets/SceneManager/SampleScene/SampleScene.unity b/Assets/SceneManager/SampleScene/SampleScene.unity index 1ceed1a..1f073e5 100644 --- a/Assets/SceneManager/SampleScene/SampleScene.unity +++ b/Assets/SceneManager/SampleScene/SampleScene.unity @@ -122,50 +122,6 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &169597751 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 169597752} - - component: {fileID: 169597753} - m_Layer: 0 - m_Name: ManagerSimulator - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &169597752 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 169597751} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1439912283} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &169597753 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 169597751} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3ce4cafcd40fff3428928289fa060de4, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &670296962 GameObject: m_ObjectHideFlags: 0 @@ -437,7 +393,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1439912283} - - component: {fileID: 1439912284} + - component: {fileID: 1439912285} m_Layer: 0 m_Name: "----\u5168\u5C40\u7BA1\u7406----" m_TagString: Untagged @@ -461,10 +417,9 @@ Transform: - {fileID: 963194228} - {fileID: 705507995} - {fileID: 1586181182} - - {fileID: 169597752} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1439912284 +--- !u!114 &1439912285 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -473,7 +428,7 @@ MonoBehaviour: m_GameObject: {fileID: 1439912282} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 50f6b4ec374a86846b626668e0b5627e, type: 3} + m_Script: {fileID: 11500000, guid: 3ce4cafcd40fff3428928289fa060de4, type: 3} m_Name: m_EditorClassIdentifier: --- !u!1 &1586181179