1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e76be0085d0afa4b95b37555ae015a2
|
||||
guid: e350f02da82dedd459ba3280f586d116
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 附加 - 数据
|
||||
/// </summary>
|
||||
public class DataAddition {
|
||||
/// <summary> 护甲等级 </summary>
|
||||
public int armorClass = 0;
|
||||
|
||||
/// <summary> 添加属性 </summary>
|
||||
public void Add(DataAddition value) {
|
||||
armorClass += value.armorClass;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 451b46f5359088a46bc1efc7fcf7ff7b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -22,7 +22,7 @@ public class DataCharacter : DataAttribute {
|
||||
/// <summary> 种族 </summary>
|
||||
public DataRace race = DataRace.None();
|
||||
/// <summary> 职业 </summary>
|
||||
public DataProfession profession = DataProfession.None();
|
||||
public DataProfession profession;
|
||||
/// <summary> 装备栏 </summary>
|
||||
public DataEquipmentSlot equipmentSlot = new DataEquipmentSlot();
|
||||
|
||||
@@ -39,35 +39,35 @@ public class DataCharacter : DataAttribute {
|
||||
/// <summary> 魅力调整值(charisma) </summary>
|
||||
public int ChaModifier => Modifier(Cha);
|
||||
|
||||
public DataCharacter() {
|
||||
profession = DataProfession.None(this);
|
||||
}
|
||||
/// <summary> 更新角色状态 </summary>
|
||||
public void Update() {
|
||||
// 更新属性
|
||||
Cover(basic);
|
||||
// 添加种族属性
|
||||
Add(race);
|
||||
// 添加职业属性
|
||||
Add(profession);
|
||||
UpdateAttribute();
|
||||
// 战斗等级
|
||||
level = profession.level;
|
||||
// 护甲等级
|
||||
armorClass = 10 + DexModifier;
|
||||
armorClass = GetArmorClass();
|
||||
// 升级经验 = 100 * 3^level
|
||||
expPoint.y = 100 * (int)Mathf.Pow(3, level);
|
||||
// 最大生命值
|
||||
hitPoint.y = race.HitPoint() + profession.HitPoint();
|
||||
hitPoint.y = profession.HitPoint();
|
||||
}
|
||||
/// <summary> 更新角色属性 </summary>
|
||||
public void UpdateAttribute() {
|
||||
// 更新属性
|
||||
Cover(basic);
|
||||
// 添加种族属性
|
||||
if (race != null) { Add(race); }
|
||||
// 添加职业属性
|
||||
if (profession != null) { Add(profession); }
|
||||
}
|
||||
/// <summary> 计算护甲等级(AC) </summary>
|
||||
public int GetArmorClass() {
|
||||
// TODO:需要补充专长,技能,熟练之类的加值
|
||||
return equipmentSlot.GetArmorClass(DexModifier);
|
||||
}
|
||||
// 计算护甲等级(AC)
|
||||
|
||||
// 无甲基础AC = 10
|
||||
|
||||
// 护甲
|
||||
// 重甲 敏捷加值无效
|
||||
// 中甲 敏捷加值上限+2
|
||||
// 轻甲 敏捷加值全额生效
|
||||
|
||||
// 盾牌 直接增加
|
||||
|
||||
// 法术 直接增加
|
||||
|
||||
// 打印角色卡
|
||||
public void PrintCharacterSheet() {
|
||||
|
||||
@@ -7,15 +7,28 @@ using UnityEngine;
|
||||
/// 职业 - 数据
|
||||
/// </summary>
|
||||
public class DataProfession : DataAttribute {
|
||||
/// <summary> 绑定角色 </summary>
|
||||
public readonly DataCharacter character;
|
||||
/// <summary> 职业名称 </summary>
|
||||
public string name;
|
||||
public readonly string name;
|
||||
/// <summary> 生命骰子 </summary>
|
||||
public readonly int hitDice = 0;
|
||||
/// <summary> 职业等级 </summary>
|
||||
public int level = 0;
|
||||
/// <summary> 生命骰子 </summary>
|
||||
public int hitDice = 0;
|
||||
/// <summary> 累计生命点 </summary>
|
||||
public List<int> hitPoints = new List<int>();
|
||||
|
||||
public DataProfession(DataCharacter character, string name, int hitDice) {
|
||||
this.character = character;
|
||||
this.name = name;
|
||||
this.hitDice = hitDice;
|
||||
|
||||
character.UpdateAttribute();
|
||||
level = 1;
|
||||
hitPoints = new List<int>();
|
||||
// 初始生命 = 满生命骰子 + 体质调整值
|
||||
hitPoints.Add(hitDice + character.ConModifier);
|
||||
}
|
||||
/// <summary> 升级:骰生命骰子+体质调整值 </summary>
|
||||
public void Upgrade(int modifier) {
|
||||
level++;
|
||||
@@ -27,47 +40,38 @@ public class DataProfession : DataAttribute {
|
||||
return hitPoints.Sum();
|
||||
}
|
||||
|
||||
/// <summary> 无职业 </summary>
|
||||
public static DataProfession None() {
|
||||
return new DataProfession() { name = "无" };
|
||||
/// <summary> 无职业 1d4 </summary>
|
||||
public static DataProfession None(DataCharacter character) {
|
||||
return new DataProfession(character, "无", 4);
|
||||
}
|
||||
/// <summary> 战士职业 </summary>
|
||||
public static DataProfession Warrior(int modifier) {
|
||||
DataProfession profession = new DataProfession();
|
||||
// 战士,初始1级,1d10生命骰子,初始生命=满生命骰子+体质调整值
|
||||
profession.name = "战士";
|
||||
profession.level = 1;
|
||||
profession.hitDice = 10;
|
||||
profession.hitPoints.Add(profession.hitDice + modifier);
|
||||
// 职业属性加成
|
||||
profession.Str = 2;
|
||||
profession.Con = 1;
|
||||
return profession;
|
||||
/// <summary> 随机职业 </summary>
|
||||
public static DataProfession Random(DataCharacter character) {
|
||||
int index = Dice.Roll(5);
|
||||
if (index == 1) { return Warrior(character); }
|
||||
if (index == 2) { return Wizard(character); }
|
||||
if (index == 3) { return Cleric(character); }
|
||||
if (index == 4) { return Ranger(character); }
|
||||
if (index == 5) { return Chanter(character); }
|
||||
return None(character);
|
||||
}
|
||||
/// <summary> 法师职业 </summary>
|
||||
public static DataProfession Wizard(int modifier) {
|
||||
DataProfession profession = new DataProfession();
|
||||
// 法师,初始1级,1d6生命骰子,初始生命=满生命骰子+体质调整值
|
||||
profession.name = "法师";
|
||||
profession.level = 1;
|
||||
profession.hitDice = 6;
|
||||
profession.hitPoints.Add(profession.hitDice + modifier);
|
||||
// 职业属性加成
|
||||
profession.Int = 2;
|
||||
profession.Dex = 1;
|
||||
return profession;
|
||||
/// <summary> 战士 1d10 </summary>
|
||||
public static DataProfession Warrior(DataCharacter character) {
|
||||
return new DataProfession(character, "战士", 10);
|
||||
}
|
||||
/// <summary> 牧师职业 </summary>
|
||||
public static DataProfession Cleric(int modifier) {
|
||||
DataProfession profession = new DataProfession();
|
||||
// 牧师,初始1级,1d8生命骰子,初始生命=满生命骰子+体质调整值
|
||||
profession.name = "牧师";
|
||||
profession.level = 1;
|
||||
profession.hitDice = 8;
|
||||
profession.hitPoints.Add(profession.hitDice + modifier);
|
||||
// 职业属性加成
|
||||
profession.Wis = 2;
|
||||
profession.Con = 1;
|
||||
return profession;
|
||||
/// <summary> 法师 1d6 </summary>
|
||||
public static DataProfession Wizard(DataCharacter character) {
|
||||
return new DataProfession(character, "法师", 6);
|
||||
}
|
||||
/// <summary> 牧师 1d8 </summary>
|
||||
public static DataProfession Cleric(DataCharacter character) {
|
||||
return new DataProfession(character, "牧师", 8);
|
||||
}
|
||||
/// <summary> 游侠 1d8 </summary>
|
||||
public static DataProfession Ranger(DataCharacter character) {
|
||||
return new DataProfession(character, "游侠", 8);
|
||||
}
|
||||
/// <summary> 歌者 1d6 </summary>
|
||||
public static DataProfession Chanter(DataCharacter character) {
|
||||
return new DataProfession(character, "歌者", 6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,18 +7,61 @@ using UnityEngine;
|
||||
/// </summary>
|
||||
public class DataRace : DataAttribute {
|
||||
/// <summary> 种族名称 </summary>
|
||||
public string name;
|
||||
/// <summary> 基础生命点 </summary>
|
||||
public int hitPoint = 10;
|
||||
public readonly string name;
|
||||
|
||||
/// <summary> 生命点:每级生命点总和 </summary>
|
||||
public int HitPoint() {
|
||||
return hitPoint;
|
||||
public DataRace(string name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// 混血人类,木精灵,丘陵矮人(Hill Dwarf),龙裔,半精灵
|
||||
/// <summary> 无种族 </summary>
|
||||
public static DataRace None() {
|
||||
// 初始生命值10点
|
||||
return new DataRace() { name = "无" };
|
||||
return new DataRace("未知");
|
||||
}
|
||||
/// <summary> 随机职业 </summary>
|
||||
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();
|
||||
}
|
||||
/// <summary> 人类(Human) </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 精灵(Elven) </summary>
|
||||
public static DataRace Elven() {
|
||||
DataRace race = new DataRace("精灵");
|
||||
// 种族属性加成 敏捷+2 智力+2 感知+1
|
||||
race.Dex = 2; race.Int = 2; race.Int = 1;
|
||||
return race;
|
||||
}
|
||||
/// <summary> 矮人(Dwarf) </summary>
|
||||
public static DataRace Dwarf() {
|
||||
DataRace race = new DataRace("矮人");
|
||||
// 种族属性加成 力量+2 体质+2 感知+1
|
||||
race.Str = 2; race.Con = 2; race.Wis = 1;
|
||||
return race;
|
||||
}
|
||||
/// <summary> 半兽人(Orc) </summary>
|
||||
public static DataRace Orc() {
|
||||
DataRace race = new DataRace("半兽人");
|
||||
// 种族属性加成 力量+3 体质+2
|
||||
race.Str = 3; race.Con = 2;
|
||||
return race;
|
||||
}
|
||||
/// <summary> 半身人(Halfling) </summary>
|
||||
public static DataRace Halfling() {
|
||||
DataRace race = new DataRace("半身人");
|
||||
// 种族属性加成 敏捷+2 魅力+2 体质+1
|
||||
race.Dex = 2; race.Cha = 2; race.Con = 1;
|
||||
return race;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,17 +7,17 @@ using UnityEngine;
|
||||
/// </summary>
|
||||
public class DataEquipmentSlot : DataInventory {
|
||||
/// <summary> 武器1 </summary>
|
||||
public DataWeapon Weapon1;
|
||||
public DataWeapon weapon1;
|
||||
/// <summary> 武器2 </summary>
|
||||
public DataWeapon Weapon2;
|
||||
public DataWeapon weapon2;
|
||||
/// <summary> 护甲 </summary>
|
||||
public DataArmor Armor;
|
||||
public DataArmor armor;
|
||||
/// <summary> 头盔 </summary>
|
||||
public DataEquipment Helmets;
|
||||
public DataEquipment helmets;
|
||||
/// <summary> 手套 </summary>
|
||||
public DataEquipment Gloves;
|
||||
public DataEquipment gloves;
|
||||
/// <summary> 鞋子 </summary>
|
||||
public DataEquipment Shoes;
|
||||
public DataEquipment shoes;
|
||||
|
||||
public override bool Add(DataItem item) {
|
||||
// 如果是武器,则尝试装备
|
||||
@@ -32,18 +32,56 @@ public class DataEquipmentSlot : DataInventory {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary> 获取护甲等级 </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 获取护甲等级 </summary>
|
||||
public int GetArmorClass(DataEquipment equipment) {
|
||||
return equipment.Addition().armorClass;
|
||||
}
|
||||
/// <summary> 获取护甲加值 </summary>
|
||||
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;
|
||||
weapon1 = weapon;
|
||||
return true;
|
||||
}
|
||||
private bool Wear(DataArmor armor) {
|
||||
Armor = 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; }
|
||||
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
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 护甲类型。
|
||||
/// </summary>
|
||||
public enum ArmorType {
|
||||
/// <summary> 布甲 </summary>
|
||||
ClothArmor,
|
||||
/// <summary> 轻甲 </summary>
|
||||
LightArmor,
|
||||
/// <summary> 中甲 </summary>
|
||||
MediumArmor,
|
||||
/// <summary> 重甲 </summary>
|
||||
HeavyArmor,
|
||||
}
|
||||
/// <summary>
|
||||
/// 护甲 - 数据
|
||||
/// </summary>
|
||||
public class DataArmor : DataEquipment {
|
||||
/// <summary> 护甲类型 </summary>
|
||||
public ArmorType armorType;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 062eefbb65fcc2e44aa8f4fe25fe7ab8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,24 +2,34 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 装备类型。
|
||||
/// </summary>
|
||||
public enum EquipmentType {
|
||||
/// <summary> 武器 </summary>
|
||||
Weapon,
|
||||
/// <summary> 护甲 </summary>
|
||||
Armor,
|
||||
/// <summary> 头盔 </summary>
|
||||
Helmets,
|
||||
/// <summary> 手套 </summary>
|
||||
Gloves,
|
||||
/// <summary> 鞋子 </summary>
|
||||
Shoes,
|
||||
}
|
||||
/// <summary>
|
||||
/// 装备 - 数据
|
||||
/// </summary>
|
||||
public class DataEquipment : DataItem {
|
||||
/// <summary> 装备类型 </summary>
|
||||
public EquipmentType equipmentType;
|
||||
}
|
||||
/// <summary>
|
||||
/// 武器 - 数据
|
||||
/// </summary>
|
||||
public class DataWeapon : DataEquipment {
|
||||
/// <summary> 武器类型 </summary>
|
||||
public WeaponType weaponType;
|
||||
}
|
||||
/// <summary>
|
||||
/// 护甲 - 数据
|
||||
/// </summary>
|
||||
public class DataArmor : DataEquipment {
|
||||
/// <summary> 护甲类型 </summary>
|
||||
public ArmorType armorType;
|
||||
/// <summary> 附加效果 </summary>
|
||||
public List<DataAddition> additions;
|
||||
|
||||
/// <summary> 附加效果 </summary>
|
||||
public DataAddition Addition() {
|
||||
DataAddition addition = new DataAddition();
|
||||
additions.ForEach(obj => addition.Add(obj));
|
||||
return addition;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,15 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 物品类型。
|
||||
/// </summary>
|
||||
public enum ItemType {
|
||||
/// <summary> 材料 </summary>
|
||||
Material,
|
||||
/// <summary> 装备 </summary>
|
||||
Equipment
|
||||
}
|
||||
/// <summary>
|
||||
/// 物品 - 数据
|
||||
/// </summary>
|
||||
@@ -11,38 +20,4 @@ public class DataItem {
|
||||
/// <summary> 物品类型 </summary>
|
||||
public ItemType itemType;
|
||||
}
|
||||
/// <summary>
|
||||
/// 物品类型。
|
||||
/// </summary>
|
||||
public enum ItemType {
|
||||
Material, // 材料
|
||||
Equipment // 装备
|
||||
}
|
||||
/// <summary>
|
||||
/// 装备类型。
|
||||
/// </summary>
|
||||
public enum EquipmentType {
|
||||
Weapon, // 武器
|
||||
Armor, // 护甲
|
||||
Helmets, //头盔
|
||||
Gloves, // 手套
|
||||
Shoes, // 鞋子
|
||||
}
|
||||
/// <summary>
|
||||
/// 武器类型。
|
||||
/// </summary>
|
||||
public enum WeaponType {
|
||||
LightWeapon, // 轻型武器
|
||||
MediumWeapon, // 中型武器
|
||||
HeavyWeapon, //重型武器
|
||||
Shield, // 盾牌
|
||||
}
|
||||
/// <summary>
|
||||
/// 护甲类型。
|
||||
/// </summary>
|
||||
public enum ArmorType {
|
||||
ClothArmor, // 布甲
|
||||
LightArmor, // 轻甲
|
||||
MediumArmor, // 中甲
|
||||
HeavyArmor, // 重甲
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 武器类型。
|
||||
/// </summary>
|
||||
public enum WeaponType {
|
||||
/// <summary> 轻型武器 </summary>
|
||||
LightWeapon,
|
||||
/// <summary> 中型武器 </summary>
|
||||
MediumWeapon,
|
||||
/// <summary> 重型武器 </summary>
|
||||
HeavyWeapon,
|
||||
/// <summary> 盾牌 </summary>
|
||||
Shield,
|
||||
}
|
||||
/// <summary>
|
||||
/// 武器 - 数据
|
||||
/// </summary>
|
||||
public class DataWeapon : DataEquipment {
|
||||
/// <summary> 武器类型 </summary>
|
||||
public WeaponType weaponType;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0be9cb0c2accc804eb824de0e8ca3fa5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72a044516298bc0459d7dd5caace3862
|
||||
guid: f7cb6057f1015c34e83bfc292a519030
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗 - 模拟器
|
||||
/// </summary>
|
||||
public class BattleSimulator {
|
||||
|
||||
// 先攻判断
|
||||
// 艾薇拉(18) → 哥布林射手(15) → 托尔吉(7) → 哥布林战士(5)
|
||||
|
||||
// 突袭轮
|
||||
// 哥布林射手 使用短弓射击(23)对艾薇拉(AC12)造成了 5穿刺伤害
|
||||
|
||||
// 正式回合1
|
||||
// 艾薇拉 施放纠缠术(法术豁免DC14),哥布林射手(敏捷豁免6)被束缚
|
||||
// 艾薇拉 躲至矿石掩体后(AC提升至14)
|
||||
|
||||
// 哥布林射手 试图挣脱藤蔓(力量豁免3)失败了
|
||||
// 哥布林射手 使用多重射击,第一箭(劣势2)对托尔吉(AC14)未命中,第二箭(劣势9)对托尔吉(AC14)未命中
|
||||
|
||||
// 托尔吉 使用狂暴(附赠动作开启)→ 获得力量加成与抗性
|
||||
// 托尔吉 移动至哥布林战士前面
|
||||
// 托尔吉 使用巨斧猛击(19)对哥布林战士(AC12) 造成了 14钝击伤害
|
||||
|
||||
// 哥布林战士死亡
|
||||
|
||||
// 正式回合2
|
||||
// 艾薇拉 施放奥术飞弹(法术豁免DC14),哥布林射手(敏捷豁免6)受到了 10奥术伤害
|
||||
|
||||
// 哥布林射手死亡
|
||||
|
||||
public BattleSimulator() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ade6b45b3d808449b5ed0cf0810fffd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -14,7 +14,13 @@ public class ManagerSimulator : ModuleSingle<ManagerSimulator> {
|
||||
|
||||
private void Start() {
|
||||
character = new DataCharacter();
|
||||
// 种族
|
||||
character.race = DataRace.Orc();
|
||||
// 职业
|
||||
character.profession = DataProfession.Warrior(character);
|
||||
// 更新属性
|
||||
character.Update();
|
||||
// 打印角色卡
|
||||
character.PrintCharacterSheet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class Test : ModuleUIPage {
|
||||
|
||||
private string skill;
|
||||
|
||||
public override VisualElement Element => root;
|
||||
public Label label => Q<Label>();
|
||||
|
||||
private void Awake() {
|
||||
string goblin = Settings("哥布林射手", Color.red);
|
||||
string skill = Settings("短弓射击(23)", Color.yellow);
|
||||
string elvira = Settings("艾薇拉(12)", Color.green);
|
||||
string damage = Settings("5穿刺伤害", Color.red);
|
||||
label.text = $"{goblin}使用{skill}对{elvira}造成了{damage}";
|
||||
label.RegisterCallback<MouseMoveEvent>(OnMouseMove);
|
||||
|
||||
this.skill = Regex.Replace(goblin, "<.*?>", "");
|
||||
}
|
||||
|
||||
private void OnMouseMove(MouseMoveEvent evt) {
|
||||
Vector2 localPosition = evt.localMousePosition;
|
||||
if (label.EnterString(skill, localPosition)) { Debug.Log($"鼠标位 {skill} 上"); }
|
||||
}
|
||||
|
||||
private string Settings(string value, Color color) {
|
||||
value = UITool.RichTextUnderline(value);
|
||||
return UITool.RichTextColor(value, color);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13b55fb0978ba0740b207fa9fc1c91bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -590,9 +590,72 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
document: {fileID: 670296963}
|
||||
SlideButtonTemplate: {fileID: 9197481963319205126, guid: 9452bd34d4b5bff4084d975753638b86, type: 3}
|
||||
--- !u!1 &1769112986
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1769112988}
|
||||
- component: {fileID: 1769112987}
|
||||
- component: {fileID: 1769112989}
|
||||
m_Layer: 5
|
||||
m_Name: UIDocument
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1769112987
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1769112986}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_PanelSettings: {fileID: 11400000, guid: 782028a3ae72af7429ad2ecdce684390, type: 2}
|
||||
m_ParentUI: {fileID: 0}
|
||||
sourceAsset: {fileID: 9197481963319205126, guid: 5b53b711220b25a4e9a9896bd5dfad93, type: 3}
|
||||
m_SortingOrder: 0
|
||||
--- !u!4 &1769112988
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1769112986}
|
||||
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: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1769112989
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1769112986}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 13b55fb0978ba0740b207fa9fc1c91bf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
document: {fileID: 1769112987}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 1439912283}
|
||||
- {fileID: 670296964}
|
||||
- {fileID: 1769112988}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Label tabindex="-1" text="<color=red><u>哥布林射手</u></color> 使用短弓射击(23)对艾薇拉(AC12)造成了 5穿刺伤害" parse-escape-sequences="true" display-tooltip-when-elided="true" style="color: rgb(255, 255, 255); margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;" />
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b53b711220b25a4e9a9896bd5dfad93
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -1,26 +1,66 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM && UNITY_INPUT_SYSTEM_PACKAGE
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace MuHua
|
||||
{
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// UI工具
|
||||
/// </summary>
|
||||
public static class UITool
|
||||
{
|
||||
public static class UITool {
|
||||
/// <summary> 获取鼠标位置 </summary>
|
||||
public static Vector3 GetMousePosition()
|
||||
{
|
||||
public static Vector3 GetMousePosition() {
|
||||
#if ENABLE_INPUT_SYSTEM && UNITY_INPUT_SYSTEM_PACKAGE
|
||||
return Mouse.current.position.ReadValue();
|
||||
#else
|
||||
return Input.mousePosition;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary> 富文本: 颜色 </summary>
|
||||
public static string RichTextColor(string value, Color color) {
|
||||
string hexRGBA = ColorUtility.ToHtmlStringRGBA(color);
|
||||
return $"<color=#{hexRGBA}>{value}</color>";
|
||||
}
|
||||
/// <summary> 富文本: 下划线 </summary>
|
||||
public static string RichTextUnderline(string value) {
|
||||
return $"<u>{value}</u>";
|
||||
}
|
||||
/// <summary> 排除富文本 </summary>
|
||||
public static string RemoveRichText(string str) {
|
||||
return Regex.Replace(str, "<.*?>", "");
|
||||
}
|
||||
/// <summary> 判断 localPosition 是否在 string 上 </summary>
|
||||
public static bool EnterString(this Label label, string str, Vector2 localPosition) {
|
||||
string rawText = RemoveRichText(label.text);
|
||||
int startIndex = rawText.IndexOf(str);
|
||||
if (startIndex == -1) return false;
|
||||
|
||||
// 计算起始位置宽度
|
||||
float startWidth = label.MeasureTextSize(
|
||||
rawText.Substring(0, startIndex),
|
||||
label.resolvedStyle.width,
|
||||
VisualElement.MeasureMode.Undefined,
|
||||
label.resolvedStyle.height,
|
||||
VisualElement.MeasureMode.Undefined
|
||||
).x;
|
||||
|
||||
// 计算目标字符串总宽度
|
||||
float targetWidth = label.MeasureTextSize(
|
||||
str,
|
||||
label.resolvedStyle.width,
|
||||
VisualElement.MeasureMode.Undefined,
|
||||
label.resolvedStyle.height,
|
||||
VisualElement.MeasureMode.Undefined
|
||||
).x;
|
||||
|
||||
Rect rect = new Rect(startWidth, 0, targetWidth, label.resolvedStyle.height);
|
||||
return rect.Contains(localPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user