Compare commits
8 Commits
DND
...
c17af4d74b
| Author | SHA1 | Date | |
|---|---|---|---|
| c17af4d74b | |||
| 714f29fc26 | |||
| 63b30ebd03 | |||
| 91a40e097b | |||
| 6bc06bcd8c | |||
| f7fab248d4 | |||
| 9a20ee8ac5 | |||
| 04b65e6945 |
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7cb6057f1015c34e83bfc292a519030
|
||||
guid: dbbcf80f718a4894aaba28723063b222
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59e1aa3dad18b83438571f22a94d78af
|
||||
guid: 4d30cb813fec1a948ad6201956953a63
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,122 @@
|
||||
{
|
||||
"name": "StandardInput",
|
||||
"maps": [
|
||||
{
|
||||
"name": "InputBasic",
|
||||
"id": "dcaef661-3fef-4b8a-8ee2-c830742705af",
|
||||
"actions": [
|
||||
{
|
||||
"name": "MousePosition",
|
||||
"type": "Value",
|
||||
"id": "58dbfc1a-ce22-4cb9-9b72-cc97107c0c6c",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "b1095b66-293e-44f5-9967-074c009ee196",
|
||||
"path": "<Pointer>/position",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MousePosition",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "InputMenu",
|
||||
"id": "980e951d-9299-4b1a-8308-0fde7904e580",
|
||||
"actions": [
|
||||
{
|
||||
"name": "MouseLeft",
|
||||
"type": "PassThrough",
|
||||
"id": "1eaab500-f97a-4e25-8e55-bd9ba394a9fa",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "MouseMiddle",
|
||||
"type": "Button",
|
||||
"id": "0e915abf-a0b6-4905-801d-8a3444ddd397",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "MouseRight",
|
||||
"type": "Button",
|
||||
"id": "b25fa7f4-605b-451b-a54b-9de5de512a93",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "SwitchMode",
|
||||
"type": "Button",
|
||||
"id": "6bc96010-9a95-4528-853c-d7e65e3718e7",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "30c1725b-c74a-44f4-825f-c562431c31d0",
|
||||
"path": "<Mouse>/leftButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MouseLeft",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "346fe765-3269-495b-8581-cf1740dda41d",
|
||||
"path": "<Mouse>/middleButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MouseMiddle",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "4acb9a53-be6c-4cf2-99d1-7856adcea129",
|
||||
"path": "<Mouse>/rightButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MouseRight",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "b3242681-adbb-4f3d-9ffe-8127338161a1",
|
||||
"path": "<Keyboard>/tab",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "SwitchMode",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"controlSchemes": []
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12612ec510e450c4281d930f360a1f88
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 0
|
||||
wrapperCodePath:
|
||||
wrapperClassName:
|
||||
wrapperCodeNamespace:
|
||||
@@ -1,108 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = System.Random;
|
||||
|
||||
public class DNDWarrior : MonoBehaviour {
|
||||
// 战士基础属性
|
||||
public int Strength { get; private set; }
|
||||
public int Dexterity { get; private set; }
|
||||
public int Constitution { get; private set; }
|
||||
public int Intelligence { get; private set; }
|
||||
public int Wisdom { get; private set; }
|
||||
public int Charisma { get; private set; }
|
||||
|
||||
public int Level { get; private set; } = 1;
|
||||
public int HitPoints { get; private set; }
|
||||
public int ArmorClass { get; private set; }
|
||||
public string ArmorType { get; private set; } = "Chain Mail"; // 默认中甲
|
||||
|
||||
private Random _random = new Random();
|
||||
|
||||
private void Awake() {
|
||||
Strength = Roll4d6();
|
||||
Dexterity = Roll4d6();
|
||||
Constitution = Roll4d6();
|
||||
Intelligence = Roll4d6();
|
||||
Wisdom = Roll4d6();
|
||||
Charisma = Roll4d6();
|
||||
|
||||
// 计算初始生命值(1d10+体质修正)
|
||||
HitPoints = 10 + GetAbilityModifier(Constitution);
|
||||
CalculateAC();
|
||||
PrintCharacterSheet();
|
||||
|
||||
Console.WriteLine("\n=== 升级到12级 ===");
|
||||
LevelUpTo(12);
|
||||
PrintCharacterSheet();
|
||||
}
|
||||
|
||||
// 4d6规则:投4次d6,去掉最低值
|
||||
private int Roll4d6() {
|
||||
List<int> rolls = new List<int>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
rolls.Add(_random.Next(1, 7));
|
||||
}
|
||||
rolls.Sort();
|
||||
return rolls[1] + rolls[2] + rolls[3]; // 取最高3个值
|
||||
}
|
||||
|
||||
// 计算属性调整值(属性值-10)/2 向下取整
|
||||
private int GetAbilityModifier(int abilityScore) {
|
||||
return (int)Math.Floor((abilityScore - 10) / 2.0);
|
||||
}
|
||||
|
||||
// 计算护甲等级(AC)
|
||||
private void CalculateAC() {
|
||||
int dexModifier = GetAbilityModifier(Dexterity);
|
||||
|
||||
switch (ArmorType) {
|
||||
case "Plate Armor": // 重甲(敏捷修正上限+1)
|
||||
ArmorClass = 18 + Math.Min(dexModifier, 1);
|
||||
break;
|
||||
case "Chain Mail": // 中甲(敏捷修正上限+2)
|
||||
ArmorClass = 16 + Math.Min(dexModifier, 2);
|
||||
break;
|
||||
default: // 无甲(全敏捷修正)
|
||||
ArmorClass = 10 + dexModifier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 升级到指定等级(模拟到12级)
|
||||
public void LevelUpTo(int targetLevel) {
|
||||
while (Level < targetLevel) {
|
||||
Level++;
|
||||
|
||||
// 每级生命值增加:1d10+体质修正
|
||||
HitPoints += _random.Next(1, 11) + GetAbilityModifier(Constitution);
|
||||
|
||||
// 每4级获得属性点(4/8/12级)
|
||||
if (Level % 4 == 0) {
|
||||
// 战士优先提升力量或体质
|
||||
if (Strength < 20) Strength += 2;
|
||||
else if (Constitution < 20) Constitution += 2;
|
||||
}
|
||||
|
||||
// 6级更换板甲
|
||||
if (Level == 6) ArmorType = "Plate Armor";
|
||||
|
||||
CalculateAC(); // 更新AC
|
||||
}
|
||||
}
|
||||
|
||||
// 打印角色卡
|
||||
public void PrintCharacterSheet() {
|
||||
Debug.Log($"=== 战士 LV{Level} ===");
|
||||
Debug.Log($"力量: {Strength} (+{GetAbilityModifier(Strength)})");
|
||||
Debug.Log($"敏捷: {Dexterity} (+{GetAbilityModifier(Dexterity)})");
|
||||
Debug.Log($"体质: {Constitution} (+{GetAbilityModifier(Constitution)})");
|
||||
Debug.Log($"智力: {Intelligence} (+{GetAbilityModifier(Intelligence)})");
|
||||
Debug.Log($"感知: {Wisdom} (+{GetAbilityModifier(Wisdom)})");
|
||||
Debug.Log($"魅力: {Charisma} (+{GetAbilityModifier(Charisma)})");
|
||||
Debug.Log($"生命值: {HitPoints}");
|
||||
Debug.Log($"护甲: {ArmorType} (AC: {ArmorClass})");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 属性 - 数据
|
||||
/// </summary>
|
||||
public class DataAttribute {
|
||||
/// <summary> 力量(strength) </summary>
|
||||
public virtual int Str { get; set; }
|
||||
/// <summary> 敏捷(dexterity) </summary>
|
||||
public virtual int Dex { get; set; }
|
||||
/// <summary> 体质(constitution) </summary>
|
||||
public virtual int Con { get; set; }
|
||||
/// <summary> 智力(intelligence) </summary>
|
||||
public virtual int Int { get; set; }
|
||||
/// <summary> 感知(wisdom) </summary>
|
||||
public virtual int Wis { get; set; }
|
||||
/// <summary> 魅力(charisma) </summary>
|
||||
public virtual int Cha { get; set; }
|
||||
|
||||
/// <summary> 力量调整值(strength) </summary>
|
||||
public int StrModifier => AttributeTool.Modifier(Str);
|
||||
/// <summary> 敏捷调整值(dexterity) </summary>
|
||||
public int DexModifier => AttributeTool.Modifier(Dex);
|
||||
/// <summary> 体质调整值(constitution) </summary>
|
||||
public int ConModifier => AttributeTool.Modifier(Con);
|
||||
/// <summary> 智力调整值(intelligence) </summary>
|
||||
public int IntModifier => AttributeTool.Modifier(Int);
|
||||
/// <summary> 感知调整值(wisdom) </summary>
|
||||
public int WisModifier => AttributeTool.Modifier(Wis);
|
||||
/// <summary> 魅力调整值(charisma) </summary>
|
||||
public int ChaModifier => AttributeTool.Modifier(Cha);
|
||||
}
|
||||
/// <summary>
|
||||
/// 角色 - 数据
|
||||
/// TODO: 补充角色的专长(Feats)、技能(Skills)、法术(Spells)等
|
||||
/// </summary>
|
||||
public class DataCharacter : DataAttribute {
|
||||
/// <summary> 名字 </summary>
|
||||
public string name;
|
||||
/// <summary> 经验 </summary>
|
||||
public int expPoint;
|
||||
/// <summary> 种族 </summary>
|
||||
public DataRace race;
|
||||
/// <summary> 属性 </summary>
|
||||
public DataAttribute basis;
|
||||
/// <summary> 职业 </summary>
|
||||
public DataProfession profession;
|
||||
/// <summary> 装备 </summary>
|
||||
public DataEquipment equipment;
|
||||
|
||||
/// <summary> 战斗等级 </summary>
|
||||
public int Level => CharacterTool.GetLevel(this);
|
||||
/// <summary> 生命点 </summary>
|
||||
public int HitPoint => CharacterTool.GetHitPoint(this);
|
||||
/// <summary> 护甲等级 </summary>
|
||||
public int ArmorClass => CharacterTool.GetArmorClass(this);
|
||||
|
||||
/// <summary> 力量(strength) 基础值 + 种族加值 </summary>
|
||||
public override int Str { get => basis.Str + race.Str; }
|
||||
/// <summary> 敏捷(dexterity) 基础值 + 种族加值 </summary>
|
||||
public override int Dex { get => basis.Dex + race.Dex; }
|
||||
/// <summary> 体质(constitution) 基础值 + 种族加值 </summary>
|
||||
public override int Con { get => basis.Con + race.Con; }
|
||||
/// <summary> 智力(intelligence) 基础值 + 种族加值 </summary>
|
||||
public override int Int { get => basis.Int + race.Int; }
|
||||
/// <summary> 感知(wisdom) 基础值 + 种族加值 </summary>
|
||||
public override int Wis { get => basis.Wis + race.Wis; }
|
||||
/// <summary> 魅力(charisma) 基础值 + 种族加值 </summary>
|
||||
public override int Cha { get => basis.Cha + race.Cha; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 种族 - 数据
|
||||
/// TODO: 补充种族特殊能力
|
||||
/// </summary>
|
||||
public class DataRace : DataAttribute {
|
||||
/// <summary> 种族名称 </summary>
|
||||
public string name;
|
||||
}
|
||||
/// <summary>
|
||||
/// 职业 - 数据
|
||||
/// </summary>
|
||||
public class DataProfession {
|
||||
/// <summary> 职业名称 </summary>
|
||||
public string name;
|
||||
/// <summary> 生命骰子 </summary>
|
||||
public int hitDice = 0;
|
||||
/// <summary> 角色 </summary>
|
||||
public DataCharacter character;
|
||||
/// <summary> 职业等级 </summary>
|
||||
public int level = 0;
|
||||
/// <summary> 累计生命点 </summary>
|
||||
public List<int> hitPoints = new List<int>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 战斗角色 - 数据
|
||||
/// </summary>
|
||||
public class DataCombatRole : DataAttribute {
|
||||
/// <summary> 角色数据 </summary>
|
||||
public readonly DataCharacter character;
|
||||
/// <summary> 战斗角色 </summary>
|
||||
public DataCombatRole(DataCharacter character) => this.character = character;
|
||||
|
||||
/// <summary> 归属队伍 </summary>
|
||||
public int team;
|
||||
/// <summary> 角色名字 </summary>
|
||||
public string name;
|
||||
/// <summary> 战斗等级 </summary>
|
||||
public int level;
|
||||
/// <summary> 战场位置 </summary>
|
||||
public int position;
|
||||
/// <summary> 先攻顺序 </summary>
|
||||
public int sequence;
|
||||
/// <summary> 护甲等级 </summary>
|
||||
public int armorClass;
|
||||
/// <summary> 生命点 </summary>
|
||||
public Vector2Int hitPoint;
|
||||
/// <summary> 武器1 </summary>
|
||||
public DataWeapon weapon1;
|
||||
/// <summary> 武器2 </summary>
|
||||
public DataWeapon weapon2;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 装备栏 - 库存
|
||||
/// </summary>
|
||||
public class DataEquipment {
|
||||
/// <summary> 武器1 </summary>
|
||||
public DataWeapon weapon1;
|
||||
/// <summary> 武器2 </summary>
|
||||
public DataWeapon weapon2;
|
||||
/// <summary> 护甲 </summary>
|
||||
public DataArmor armor;
|
||||
/// <summary> 头盔 </summary>
|
||||
public DataWear helmets;
|
||||
/// <summary> 手套 </summary>
|
||||
public DataWear gloves;
|
||||
/// <summary> 鞋子 </summary>
|
||||
public DataWear shoes;
|
||||
|
||||
/// <summary> 附加效果 </summary>
|
||||
public DataAddition addition = new DataAddition();
|
||||
}
|
||||
/// <summary>
|
||||
/// 附加 - 数据
|
||||
/// </summary>
|
||||
public class DataAddition {
|
||||
/// <summary> 护甲等级 </summary>
|
||||
public int armorClass = 0;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 库存类型枚举,区分背包、仓库等不同库存。
|
||||
/// </summary>
|
||||
public enum InventoryType { EquipmentSlot, Backpack, Storage }
|
||||
/// <summary>
|
||||
/// 物品库存 - 数据
|
||||
/// </summary>
|
||||
public abstract class DataInventory {
|
||||
/// <summary> 库存类型 </summary>
|
||||
public InventoryType inventoryType;
|
||||
}
|
||||
/// <summary>
|
||||
/// 仓库 - 库存
|
||||
/// </summary>
|
||||
public class DataStorage : DataInventory {
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 背包 - 库存
|
||||
/// </summary>
|
||||
public class DataBackpack : DataInventory {
|
||||
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 物品类型
|
||||
/// </summary>
|
||||
public enum ItemType { 材料, 装备 }
|
||||
/// <summary>
|
||||
/// 物品 - 数据
|
||||
/// </summary>
|
||||
public class DataItem {
|
||||
/// <summary> 物品名称 </summary>
|
||||
public string name;
|
||||
/// <summary> 物品类型 </summary>
|
||||
public ItemType itemType;
|
||||
}
|
||||
/// <summary>
|
||||
/// 材料 - 数据
|
||||
/// </summary>
|
||||
public class DataMaterial : DataItem {
|
||||
/// <summary> 物品数量 </summary>
|
||||
public int quantity;
|
||||
/// <summary> 堆叠上限 </summary>
|
||||
public int maxStack;
|
||||
}
|
||||
/// <summary>
|
||||
/// 穿戴类型
|
||||
/// </summary>
|
||||
public enum WearType { 武器, 护甲, 头盔, 手套, 鞋子, }
|
||||
/// <summary>
|
||||
/// 穿戴 - 数据
|
||||
/// </summary>
|
||||
public class DataWear : DataItem {
|
||||
/// <summary> 装备类型 </summary>
|
||||
public WearType wearType;
|
||||
/// <summary> 附加列表 </summary>
|
||||
public List<DataAddition> additions = new List<DataAddition>();
|
||||
/// <summary> 附加效果 </summary>
|
||||
public virtual DataAddition Addition => EquipmentTool.Merge(additions);
|
||||
}
|
||||
/// <summary>
|
||||
/// 武器类型。
|
||||
/// </summary>
|
||||
public enum WeaponType { 无, 轻型武器, 中型武器, 重型武器, 盾牌, }
|
||||
/// <summary>
|
||||
/// 武器 - 数据
|
||||
/// </summary>
|
||||
public class DataWeapon : DataWear {
|
||||
/// <summary> 武器类型 </summary>
|
||||
public WeaponType weaponType;
|
||||
/// <summary> 伤害骰子 </summary>
|
||||
public DataDamageDice damageDice;
|
||||
}
|
||||
/// <summary>
|
||||
/// 伤害类型
|
||||
/// </summary>
|
||||
public enum DamageType { 无, 穿刺, 挥砍, 钝击 }
|
||||
/// <summary>
|
||||
/// 伤害骰子 - 数据
|
||||
/// </summary>
|
||||
public class DataDamageDice {
|
||||
/// <summary> 伤害骰子 </summary>
|
||||
public readonly int value;
|
||||
/// <summary> 伤害类型 </summary>
|
||||
public readonly DamageType type;
|
||||
|
||||
public DataDamageDice(int value, DamageType type) {
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 护甲类型。
|
||||
/// </summary>
|
||||
public enum ArmorType { 布甲, 轻甲, 中甲, 重甲, }
|
||||
/// <summary>
|
||||
/// 护甲 - 数据
|
||||
/// </summary>
|
||||
public class DataArmor : DataWear {
|
||||
/// <summary> 护甲类型 </summary>
|
||||
public ArmorType armorType;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 557ad290ccf27454baad3a04e41aec95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 用户
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DataUser {
|
||||
public string id;
|
||||
public string username;
|
||||
public string passwordhash;
|
||||
}
|
||||
/// <summary>
|
||||
/// 注册请求
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DataRegisterRequest {
|
||||
public string username;
|
||||
public string password;
|
||||
}
|
||||
/// <summary>
|
||||
/// 登录请求
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DataLoginRequest {
|
||||
public string username;
|
||||
public string password;
|
||||
}
|
||||
/// <summary>
|
||||
/// 登录响应,返回JWT。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DataLoginResponse {
|
||||
public string token;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改密码请求。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DataChangePasswordRequest {
|
||||
public string username;
|
||||
public string oldpassword;
|
||||
public string newpassword;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: febe432c83103fd4fbbc833bc7dd08cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 阶段类型
|
||||
/// </summary>
|
||||
public enum PhaseType {
|
||||
先攻阶段, 突袭阶段, 回合阶段, 行动阶段, 结算阶段,
|
||||
选择角色, 角色攻击
|
||||
}
|
||||
/// <summary>
|
||||
/// 阶段
|
||||
/// </summary>
|
||||
public interface IPhase {
|
||||
/// <summary> 执行阶段 </summary>
|
||||
public void Execute();
|
||||
}
|
||||
/// <summary>
|
||||
/// 战斗阶段
|
||||
/// </summary>
|
||||
public abstract class BattlePhase : IPhase {
|
||||
/// <summary> 模拟器 </summary>
|
||||
public readonly BattleSimulator simulator;
|
||||
|
||||
/// <summary> 行动角色 </summary>
|
||||
public DataCombatRole ActionRole => simulator.actionRole;
|
||||
/// <summary> 战斗队列 </summary>
|
||||
public BattleQueue BattleQueue => simulator.battleQueue;
|
||||
|
||||
public BattlePhase(BattleSimulator simulator) => this.simulator = simulator;
|
||||
|
||||
public abstract void Execute();
|
||||
/// <summary> 阶段过渡 </summary>
|
||||
public void Transition(PhaseType phaseType) => simulator.Transition(phaseType);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee046dc0d64f6184c966baba17876ec9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,89 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 行动阶段
|
||||
/// </summary>
|
||||
public class PhaseAction : BattlePhase {
|
||||
|
||||
public PhaseAction(BattleSimulator simulator) : base(simulator) { }
|
||||
|
||||
public override void Execute() {
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 行动角色选择
|
||||
/// </summary>
|
||||
public class PhaseActionRoleSelect : BattlePhase {
|
||||
|
||||
public PhaseActionRoleSelect(BattleSimulator simulator) : base(simulator) { }
|
||||
|
||||
public override void Execute() {
|
||||
// 选择行动的角色,如果没有则进入下一回合
|
||||
if (!BattleQueue.Dequeue(out simulator.actionRole)) { Transition(PhaseType.回合阶段); return; }
|
||||
// 判断是否可以行动
|
||||
if (ActionRole.hitPoint.x <= 0) { Transition(PhaseType.选择角色); return; }
|
||||
// 进行ai判断
|
||||
// TODO: 进行武器攻击,使用技能,使用法术,使用物品的判断
|
||||
Transition(PhaseType.角色攻击);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 武器攻击
|
||||
/// </summary>
|
||||
public class PhaseActionRoleAttack : BattlePhase {
|
||||
|
||||
public PhaseActionRoleAttack(BattleSimulator simulator) : base(simulator) { }
|
||||
|
||||
public override void Execute() {
|
||||
// 如果没有可以攻击的目标则结算战斗
|
||||
if (!AttackTarget(out DataCombatRole target)) { Transition(PhaseType.结算阶段); return; }
|
||||
// 武器判断:轻型武器使用敏捷,其他都使用力量
|
||||
string weaponName = ActionRole.weapon1.name;
|
||||
WeaponType weaponType = ActionRole.weapon1.weaponType;
|
||||
int modifier = weaponType == WeaponType.轻型武器 ? ActionRole.DexModifier : ActionRole.StrModifier;
|
||||
// 命中检定: d20 + 属性修正
|
||||
int hit = Dice.Roll20(modifier);
|
||||
int armorClass = target.armorClass;
|
||||
// 如果命中小于等于目标护甲等级,则不造成伤害
|
||||
if (hit > armorClass) {
|
||||
// 获取所有武器伤害骰
|
||||
DataDamageDice damageDice = ActionRole.weapon1.damageDice;
|
||||
// 伤害计算: 武器伤害骰 + 属性修正
|
||||
int damage = Dice.Roll(damageDice.value) + modifier;
|
||||
target.hitPoint.x -= damage;
|
||||
// 生成战斗消息
|
||||
MessageHit(hit, weaponName, target.name, armorClass, damage, damageDice.type);
|
||||
}
|
||||
else {
|
||||
// 生成战斗消息
|
||||
MessageMiss(hit, weaponName, target.name, armorClass);
|
||||
}
|
||||
// 结束行动
|
||||
Transition(PhaseType.选择角色);
|
||||
}
|
||||
/// <summary> 攻击目标 </summary>
|
||||
private bool AttackTarget(out DataCombatRole target) {
|
||||
List<DataCombatRole> roles = BattleQueue.Where(Hostility);
|
||||
if (roles.Count == 0) { target = null; return false; }
|
||||
int randomIndex = Random.Range(0, roles.Count);
|
||||
target = roles[randomIndex];
|
||||
return true;
|
||||
}
|
||||
/// <summary> 敌对目标 </summary>
|
||||
private bool Hostility(DataCombatRole role) {
|
||||
return role.team != ActionRole.team && role.hitPoint.x > 0;
|
||||
}
|
||||
/// <summary> 战斗消息:没有命中 </summary>
|
||||
private void MessageMiss(int hit, string weapon, string attacked, int armorClass) {
|
||||
MissAttack message = new MissAttack(ActionRole.name, hit, weapon, attacked, armorClass);
|
||||
Debug.Log(message);
|
||||
}
|
||||
/// <summary> 战斗消息:命中 </summary>
|
||||
private void MessageHit(int hit, string weapon, string attacked, int armorClass, int damage, DamageType damageType) {
|
||||
HitAttack message = new HitAttack(ActionRole.name, hit, weapon, attacked, armorClass, damage, damageType);
|
||||
Debug.Log(message);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad6c0033db83a3c4fa9d92f3f1912d5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 突袭阶段
|
||||
/// </summary>
|
||||
public class PhaseAssault : BattlePhase {
|
||||
|
||||
public PhaseAssault(BattleSimulator simulator) : base(simulator) { }
|
||||
|
||||
public override void Execute() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 620e71ced51f8e94997a198ac8b1e6c6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 结束阶段
|
||||
/// </summary>
|
||||
public class PhaseFinish : BattlePhase {
|
||||
|
||||
public PhaseFinish(BattleSimulator simulator) : base(simulator) { }
|
||||
|
||||
public override void Execute() {
|
||||
// TODO:需要添加结算判断
|
||||
// simulator.Transition(PhaseType.回合阶段);
|
||||
// TODO:记录器
|
||||
Debug.Log("结束战斗!");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 357207f5d09ca394e84210d51916507b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 正式阶段
|
||||
/// </summary>
|
||||
public class PhaseFormal : BattlePhase {
|
||||
/// <summary> 回合计数 </summary>
|
||||
public int roundCount;
|
||||
|
||||
public PhaseFormal(BattleSimulator simulator) : base(simulator) { }
|
||||
|
||||
public override void Execute() {
|
||||
roundCount++;
|
||||
BattleQueue.UpdateQueue();
|
||||
// TODO:记录器
|
||||
Debug.Log($"正式回合:{roundCount}");
|
||||
string message = "存活";
|
||||
BattleQueue.ForEach(obj => message += $" {obj.name}({obj.hitPoint.x})");
|
||||
Debug.Log(message);
|
||||
simulator.Transition(PhaseType.选择角色);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 066680fafb7f9cf4dbac4f7291e682cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,22 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 先攻阶段
|
||||
/// </summary>
|
||||
public class PhaseInitiative : BattlePhase {
|
||||
|
||||
public PhaseInitiative(BattleSimulator simulator) : base(simulator) { }
|
||||
|
||||
public override void Execute() {
|
||||
BattleQueue.ForEach(obj => obj.sequence = Dice.Roll20(obj.DexModifier));
|
||||
BattleQueue.OrderByDescending(c => c.sequence);
|
||||
// TODO:需要添加突袭阶段
|
||||
// TODO:记录器
|
||||
string message = "先攻";
|
||||
BattleQueue.ForEach(obj => message += $" {obj.name}({obj.sequence})");
|
||||
Debug.Log(message);
|
||||
simulator.Transition(PhaseType.回合阶段);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fc0f8aced9d5f04f879b8300fd02e47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗队列
|
||||
/// </summary>
|
||||
public class BattleQueue {
|
||||
/// <summary> 执行队列 </summary>
|
||||
public Queue<DataCombatRole> queue = new Queue<DataCombatRole>();
|
||||
/// <summary> 战斗合集 </summary>
|
||||
public List<DataCombatRole> characters = new List<DataCombatRole>();
|
||||
|
||||
/// <summary> 添加角色 </summary>
|
||||
public void Add(List<DataCombatRole> list) {
|
||||
characters.AddRange(list);
|
||||
}
|
||||
/// <summary> 添加角色 </summary>
|
||||
public void Add(DataCombatRole character) {
|
||||
characters.Add(character);
|
||||
}
|
||||
/// <summary> 遍历角色 </summary>
|
||||
public void ForEach(Action<DataCombatRole> action) {
|
||||
characters.ForEach(action);
|
||||
}
|
||||
// /// <summary> 排序:大到小 </summary>
|
||||
public void OrderByDescending(Func<DataCombatRole, int> func) {
|
||||
characters = characters.OrderByDescending(func).ToList();
|
||||
}
|
||||
/// <summary> 根据条件查询元素 </summary>
|
||||
public List<DataCombatRole> Where(Func<DataCombatRole, bool> predicate) {
|
||||
return characters.Where(predicate).ToList();
|
||||
}
|
||||
/// <summary> 根据条件查询第一个匹配的元素 </summary>
|
||||
public DataCombatRole FirstOrDefault(Func<DataCombatRole, bool> predicate) {
|
||||
return characters.FirstOrDefault(predicate);
|
||||
}
|
||||
/// <summary> 更新队列 </summary>
|
||||
public void UpdateQueue() {
|
||||
queue = new Queue<DataCombatRole>(characters);
|
||||
}
|
||||
/// <summary> 取出一个 </summary>
|
||||
public bool Dequeue(out DataCombatRole battle) {
|
||||
battle = queue.Count > 0 ? queue.Dequeue() : null;
|
||||
return battle != null;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed7fc5b50e619ea4a8eaf9d71dc0ec9d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,105 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗报告
|
||||
/// </summary>
|
||||
public class BattleReport {
|
||||
/// <summary> 战斗消息 </summary>
|
||||
public List<BattleMessage> messages;
|
||||
}
|
||||
/// <summary>
|
||||
/// 战斗消息
|
||||
/// </summary>
|
||||
public class BattleMessage {
|
||||
/// <summary> 战斗消息内容 </summary>
|
||||
public string content;
|
||||
/// <summary> 战斗消息内容 </summary>
|
||||
public override string ToString() {
|
||||
return content;
|
||||
}
|
||||
// 辅助方法:随机选择一个字符串,增加多样性
|
||||
public string RandomChoice(params string[] options) {
|
||||
if (options.Length == 0) return "";
|
||||
return options[Random.Range(0, options.Length)];
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 未命中攻击 - 战斗消息
|
||||
/// </summary>
|
||||
public class MissAttack : BattleMessage {
|
||||
public MissAttack(string attacker, int hit, string weapon, string attacked, int armorClass) {
|
||||
// 托尔吉使用巨斧猛击(19)没有命中哥布林战士(AC12)
|
||||
content = $"{attacker}使用{weapon}({hit})没有命中{attacked}({armorClass})";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 命中攻击 - 战斗消息
|
||||
/// </summary>
|
||||
public class HitAttack : BattleMessage {
|
||||
public HitAttack(string attacker, int hit, string weapon, string attacked, int armorClass, int damage, DamageType damageType) {
|
||||
string damageTypeString = damageType == DamageType.无 ? "" : damageType.ToString();
|
||||
// 托尔吉使用巨斧猛击(19)对哥布林战士(AC12)造成了 14钝击伤害
|
||||
content = $"{attacker}使用{weapon}({hit})对{attacked}({armorClass})造成了{damage}{damageTypeString}伤害";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 普通攻击 - 战斗消息
|
||||
/// </summary>
|
||||
public class MessageNormalAttack : BattleMessage {
|
||||
/// <summary> 攻击者 </summary>
|
||||
public DataCombatRole attacker;
|
||||
/// <summary> 命中值 </summary>
|
||||
public int hit;
|
||||
/// <summary> 伤害值 </summary>
|
||||
public int damage;
|
||||
|
||||
/// <summary> 被攻击者 </summary>
|
||||
public DataCombatRole attacked;
|
||||
/// <summary> 护甲等级 </summary>
|
||||
public int armorClass;
|
||||
|
||||
/// <summary> 设置攻击者 </summary>
|
||||
public void Settings(DataCombatRole attacker, int hit, int damage) {
|
||||
this.attacker = attacker;
|
||||
this.hit = hit;
|
||||
this.damage = damage;
|
||||
}
|
||||
/// <summary> 设置被攻击者 </summary>
|
||||
public void Settings(DataCombatRole attacked, int armorClass) {
|
||||
this.attacked = attacked;
|
||||
this.armorClass = armorClass;
|
||||
}
|
||||
public override string ToString() {
|
||||
return $"{attacker.name}{Dynamics()}{attacked.name}({armorClass}),{attacked.name}{Result()}";
|
||||
}
|
||||
|
||||
/// <summary> 动态修饰词 </summary>
|
||||
private string Dynamics() {
|
||||
return $"使用长剑劈向({hit})";
|
||||
}
|
||||
/// <summary> 结果修饰词 </summary>
|
||||
private string Result() {
|
||||
return hit <= armorClass ? Miss() : Hit();
|
||||
}
|
||||
// 未命中的多种情况
|
||||
private string Miss() {
|
||||
string[] missText = new string[] {
|
||||
"轻松避开了这一击!",
|
||||
"巧妙地闪开了!",
|
||||
"险之又险地躲过了!",
|
||||
"成功格挡住了!"
|
||||
};
|
||||
return RandomChoice(missText);
|
||||
}
|
||||
// 命中的情况,可根据伤害量或是否暴击细分
|
||||
private string Hit() {
|
||||
string[] hitText = new string[] {
|
||||
$"躲避不及遭受到了{damage}点伤害!",
|
||||
$"被狠狠击中,承受了{damage}点伤害!",
|
||||
$"格挡失败受到了{damage}点伤害!",
|
||||
};
|
||||
return RandomChoice(hitText);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26a3fb20ae1a54143ab478049f4acd8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗 - 模拟器
|
||||
/// </summary>
|
||||
public class BattleSimulator {
|
||||
/// <summary> 当前行动 </summary>
|
||||
public DataCombatRole actionRole;
|
||||
/// <summary> 战斗队列 </summary>
|
||||
public BattleQueue battleQueue = new BattleQueue();
|
||||
|
||||
/// <summary> 当前阶段 </summary>
|
||||
public IPhase currentPhase;
|
||||
/// <summary> 阶段字典 </summary>
|
||||
public Dictionary<PhaseType, IPhase> dictionary = new Dictionary<PhaseType, IPhase>();
|
||||
|
||||
public BattleSimulator(BattleTeam team1, BattleTeam team2) {
|
||||
team1.Initial();
|
||||
team2.Initial();
|
||||
|
||||
team1.Settings(1, 1);
|
||||
team2.Settings(2, 1);
|
||||
|
||||
battleQueue.Add(team1.battles);
|
||||
battleQueue.Add(team2.battles);
|
||||
|
||||
dictionary.Add(PhaseType.先攻阶段, new PhaseInitiative(this));
|
||||
dictionary.Add(PhaseType.突袭阶段, new PhaseAssault(this));
|
||||
dictionary.Add(PhaseType.回合阶段, new PhaseFormal(this));
|
||||
dictionary.Add(PhaseType.行动阶段, new PhaseAction(this));
|
||||
dictionary.Add(PhaseType.选择角色, new PhaseActionRoleSelect(this));
|
||||
dictionary.Add(PhaseType.角色攻击, new PhaseActionRoleAttack(this));
|
||||
dictionary.Add(PhaseType.结算阶段, new PhaseFinish(this));
|
||||
}
|
||||
|
||||
/// <summary> 阶段过渡 </summary>
|
||||
public void Transition(PhaseType phaseType) {
|
||||
// 检查阶段字典中是否存在指定的阶段类型
|
||||
if (!dictionary.TryGetValue(phaseType, out IPhase newPhase)) { return; }
|
||||
currentPhase = newPhase;
|
||||
currentPhase?.Execute();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ade6b45b3d808449b5ed0cf0810fffd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗技能
|
||||
/// </summary>
|
||||
public class BattleSkill {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4f5e0db8e96cfd4d8d9243f4057f99a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,43 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗队伍
|
||||
/// </summary>
|
||||
public class BattleTeam {
|
||||
/// <summary> 队伍名字 </summary>
|
||||
public string name;
|
||||
/// <summary> 原始数据 </summary>
|
||||
public List<DataCharacter> characters = new List<DataCharacter>();
|
||||
/// <summary> 战斗数据 </summary>
|
||||
public List<DataCombatRole> battles = new List<DataCombatRole>();
|
||||
|
||||
/// <summary> 添加角色 </summary>
|
||||
public void Add(List<DataCharacter> list) {
|
||||
characters.AddRange(list);
|
||||
}
|
||||
/// <summary> 添加角色 </summary>
|
||||
public void Add(DataCharacter obj) {
|
||||
characters.Add(obj);
|
||||
}
|
||||
/// <summary> 删除角色 </summary>
|
||||
public void Remove(DataCharacter character) {
|
||||
characters.Remove(character);
|
||||
}
|
||||
|
||||
/// <summary> 初始化 </summary>
|
||||
public void Initial() {
|
||||
characters.ForEach(Initial);
|
||||
}
|
||||
/// <summary> 初始化 </summary>
|
||||
public void Initial(DataCharacter character) {
|
||||
DataCombatRole role = new DataCombatRole(character);
|
||||
role.Initial();
|
||||
battles.Add(role);
|
||||
}
|
||||
/// <summary> 战斗编队 </summary>
|
||||
public void Settings(int team, int position) {
|
||||
battles.ForEach(obj => obj.Settings(team, position));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60ddd9f20d0d1bd49a6b68d86ccc904a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,26 +0,0 @@
|
||||
### 战斗流程示例
|
||||
|
||||
#### 先攻判断
|
||||
- 艾薇拉(18) → 哥布林射手(15) → 托尔吉(7) → 哥布林战士(5)
|
||||
|
||||
#### 突袭轮
|
||||
- 哥布林射手 使用短弓射击(23)对艾薇拉(AC12)造成了 5穿刺伤害
|
||||
|
||||
#### 正式回合1
|
||||
- 艾薇拉 施放纠缠术(法术豁免DC14),哥布林射手(敏捷豁免6)被束缚
|
||||
- 艾薇拉 躲至矿石掩体后(AC提升至14)
|
||||
|
||||
- 哥布林射手 试图挣脱藤蔓(力量豁免3)失败了
|
||||
- 哥布林射手 使用多重射击,第一箭(劣势2)对托尔吉(AC14)未命中,第二箭(劣势9)对托尔吉(AC14)未命中
|
||||
|
||||
- 托尔吉 使用狂暴(附赠动作开启)→ 获得力量加成与抗性
|
||||
- 托尔吉 移动至哥布林战士前面
|
||||
- 托尔吉 使用巨斧猛击(19)对哥布林战士(AC12) 造成了 14钝击伤害
|
||||
- 托尔吉 使用巨斧猛击(19)没有命中哥布林战士(AC12)
|
||||
|
||||
- 哥布林战士死亡
|
||||
|
||||
#### 正式回合2
|
||||
- 艾薇拉 施放奥术飞弹(法术豁免DC14),哥布林射手(敏捷豁免6)受到了 10奥术伤害
|
||||
|
||||
- 哥布林射手死亡
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c29e0b5bff9f654439aa3e867ac20484
|
||||
guid: 498e3f400477d1040a16f935cc815387
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 相机控制器
|
||||
/// </summary>
|
||||
public abstract class CameraController : MonoBehaviour {
|
||||
/// <summary> 位置 </summary>
|
||||
public abstract Vector3 Position { get; set; }
|
||||
/// <summary> 正向 </summary>
|
||||
public abstract Vector3 Forward { get; set; }
|
||||
/// <summary> 右向 </summary>
|
||||
public abstract Vector3 Right { get; set; }
|
||||
/// <summary> 旋转 </summary>
|
||||
public abstract Vector3 EulerAngles { get; set; }
|
||||
/// <summary> 视野 </summary>
|
||||
public abstract float VisualField { get; set; }
|
||||
|
||||
/// <summary> 初始化 </summary>
|
||||
public virtual void Initial() {
|
||||
ModuleCamera.OnCameraMode += ModuleCamera_OnCameraMode;
|
||||
}
|
||||
/// <summary> 释放 </summary>
|
||||
public virtual void Release() {
|
||||
ModuleCamera.OnCameraMode -= ModuleCamera_OnCameraMode;
|
||||
}
|
||||
|
||||
/// <summary> 相机模式 </summary>
|
||||
public abstract void ModuleCamera_OnCameraMode(EnumCameraMode mode);
|
||||
/// <summary> 重置相机 </summary>
|
||||
public abstract void ResetCamera();
|
||||
|
||||
/// <summary> 屏幕坐标转换世界坐标 </summary>
|
||||
public virtual Vector3 ScreenToWorldPosition(Vector3 screenPosition) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62fae57d4dbef374ba92424caa7b6885
|
||||
guid: 4e120a7c12f40d74cac5e48d41461d2c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f85c0d8dce903b4eb5fb0aca37d2040
|
||||
guid: d00e77fe0a528d74b9779c92c146dcf8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 移轴 - 相机
|
||||
/// </summary>
|
||||
public class CameraAxis : CameraController {
|
||||
|
||||
public Camera mainCamera;
|
||||
public Camera Screenshot;
|
||||
|
||||
[HideInInspector]
|
||||
public RenderTexture renderTexture;
|
||||
|
||||
private float originalVisualField;
|
||||
private Vector3 originalPosition;
|
||||
private Vector3 originalEulerAngles;
|
||||
|
||||
public override Vector3 Position {
|
||||
get => transform.position;
|
||||
set => transform.position = value;
|
||||
}
|
||||
public override Vector3 Forward {
|
||||
get => mainCamera.transform.forward;
|
||||
set => mainCamera.transform.forward = value;
|
||||
}
|
||||
public override Vector3 Right {
|
||||
get => mainCamera.transform.right;
|
||||
set => mainCamera.transform.right = value;
|
||||
}
|
||||
public override Vector3 EulerAngles {
|
||||
get => transform.eulerAngles;
|
||||
set => transform.eulerAngles = value;
|
||||
}
|
||||
public override float VisualField {
|
||||
get => mainCamera.transform.localPosition.z;
|
||||
set => mainCamera.transform.localPosition = new Vector3(0, 0, value);
|
||||
}
|
||||
|
||||
public override void Initial() {
|
||||
base.Initial();
|
||||
originalPosition = Position;
|
||||
originalEulerAngles = EulerAngles;
|
||||
originalVisualField = VisualField;
|
||||
|
||||
renderTexture = new RenderTexture(1920, 1080, 16, RenderTextureFormat.ARGB32);
|
||||
Screenshot.targetTexture = renderTexture;
|
||||
}
|
||||
public override void ModuleCamera_OnCameraMode(EnumCameraMode mode) {
|
||||
gameObject.SetActive(mode == EnumCameraMode.Axis);
|
||||
if (mode == EnumCameraMode.Axis) { ModuleCamera.CurrentCamera = this; }
|
||||
}
|
||||
|
||||
public override void ResetCamera() {
|
||||
// if (!Utilities.FindObject(out MonoSceneSettings settings)) { return; }
|
||||
// Position = settings.initialPosition.position;
|
||||
// EulerAngles = settings.initialPosition.eulerAngles;
|
||||
// VisualField = settings.visualField.localPosition.z;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d99eda4d1308724c8374c9e305743bc
|
||||
guid: a57fb20032bb3e5488a7b363d12f19fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 默认 - 相机
|
||||
/// </summary>
|
||||
public class CameraDefault : CameraController {
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
public override Vector3 Position {
|
||||
get => transform.position;
|
||||
set => transform.position = value;
|
||||
}
|
||||
public override Vector3 Forward {
|
||||
get => mainCamera.transform.forward;
|
||||
set => mainCamera.transform.forward = value;
|
||||
}
|
||||
public override Vector3 Right {
|
||||
get => mainCamera.transform.right;
|
||||
set => mainCamera.transform.right = value;
|
||||
}
|
||||
public override Vector3 EulerAngles {
|
||||
get => transform.eulerAngles;
|
||||
set => transform.eulerAngles = value;
|
||||
}
|
||||
public override float VisualField {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override void ModuleCamera_OnCameraMode(EnumCameraMode mode) {
|
||||
gameObject.SetActive(mode == EnumCameraMode.None);
|
||||
if (mode == EnumCameraMode.None) { ModuleCamera.CurrentCamera = this; }
|
||||
}
|
||||
|
||||
public override void ResetCamera() {
|
||||
// if (!Utilities.FindObject(out SettingsScene settings)) { return; }
|
||||
// transform.position = settings.InitialPosition.position;
|
||||
// transform.eulerAngles = settings.InitialPosition.eulerAngles;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 278351779c3c1514bbcce18723dd500c
|
||||
guid: 317ca1fd043483b42b67b042380a2f54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 相机模块
|
||||
/// </summary>
|
||||
public class ModuleCamera : ModuleSingle<ModuleCamera> {
|
||||
|
||||
/// <summary> 当前相机 </summary>
|
||||
public static CameraController CurrentCamera;
|
||||
/// <summary> 相机模式事件 </summary>
|
||||
public static event Action<EnumCameraMode> OnCameraMode;
|
||||
|
||||
/// <summary> 设置相机模式 </summary>
|
||||
public static void Settings(EnumCameraMode mode, bool isReset = true) {
|
||||
OnCameraMode?.Invoke(mode);
|
||||
if (isReset) { I.ResetCamera(); }
|
||||
}
|
||||
|
||||
public List<CameraController> cameras;
|
||||
|
||||
protected override void Awake() {
|
||||
NoReplace();
|
||||
cameras.ForEach(obj => obj.Initial());
|
||||
}
|
||||
|
||||
private void OnDestroy() => cameras.ForEach(obj => obj.Release());
|
||||
|
||||
/// <summary> 重置相机 </summary>
|
||||
public void ResetCamera() => cameras.ForEach(obj => obj.ResetCamera());
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 相机模式
|
||||
/// </summary>
|
||||
public enum EnumCameraMode {
|
||||
None,// 无
|
||||
|
||||
Axis,// 移轴相机
|
||||
|
||||
// FreeEdit,// 自由编辑
|
||||
|
||||
// ThirdPerson,// 第三人称
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ae234ab6cd19bf46983ee5f38afd957
|
||||
guid: 745a630404a79d243a8041c505ec469c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,48 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 属性 - 工具
|
||||
/// </summary>
|
||||
public static class AttributeTool {
|
||||
|
||||
#region 创建
|
||||
/// <summary> 随机初始属性 </summary>
|
||||
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);
|
||||
}
|
||||
/// <summary> 添加属性 </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 减少属性 </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 覆盖属性 </summary>
|
||||
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
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6a814b3a3b754241ae35753e6d7c7f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,56 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 角色 - 字典
|
||||
/// </summary>
|
||||
public static class CharacterDictionary {
|
||||
/// <summary> 艾薇拉 精灵 法师 </summary>
|
||||
public static DataCharacter Character001() {
|
||||
DataCharacter character = new DataCharacter();
|
||||
character.name = "艾薇拉";
|
||||
character.race = RaceTool.Elven();
|
||||
character.basis = new DataAttribute { Str = 8, Dex = 12, Con = 10, Int = 16, Wis = 14, Cha = 11 };
|
||||
character.profession = ProfessionTool.Wizard();
|
||||
character.profession.Initial(character);
|
||||
character.equipment = new DataEquipment();
|
||||
// 装备法杖
|
||||
character.equipment.Wear(WeaponDictionary.Weapon302(), out DataWear old1);
|
||||
// 装备法袍
|
||||
character.equipment.Wear(ArmorDictionary.Armor101(), out DataWear old2);
|
||||
return character;
|
||||
}
|
||||
/// <summary> 托尔吉 兽人 战士 </summary>
|
||||
public static DataCharacter Character002() {
|
||||
DataCharacter character = new DataCharacter();
|
||||
character.name = "托尔吉";
|
||||
character.race = RaceTool.Orc();
|
||||
character.basis = new DataAttribute { Str = 16, Dex = 10, Con = 14, Int = 8, Wis = 10, Cha = 9 };
|
||||
character.profession = ProfessionTool.Warrior();
|
||||
character.profession.Initial(character);
|
||||
character.equipment = new DataEquipment();
|
||||
// 装备木棒和木盾
|
||||
character.equipment.Wear(WeaponDictionary.Weapon201(), out DataWear old1);
|
||||
character.equipment.Wear(WeaponDictionary.Weapon401(), out DataWear old2);
|
||||
// 装备板甲
|
||||
character.equipment.Wear(ArmorDictionary.Armor401(), out DataWear old3);
|
||||
return character;
|
||||
}
|
||||
/// <summary> 格伦布林 矮人 牧师 </summary>
|
||||
public static DataCharacter Character003() {
|
||||
DataCharacter character = new DataCharacter();
|
||||
character.name = "格伦布林";
|
||||
character.race = RaceTool.Dwarf();
|
||||
character.basis = new DataAttribute { Str = 14, Dex = 10, Con = 16, Int = 9, Wis = 15, Cha = 12 };
|
||||
character.profession = ProfessionTool.Cleric();
|
||||
character.profession.Initial(character);
|
||||
character.equipment = new DataEquipment();
|
||||
// 装备木棒和木盾
|
||||
character.equipment.Wear(WeaponDictionary.Weapon201(), out DataWear old1);
|
||||
character.equipment.Wear(WeaponDictionary.Weapon401(), out DataWear old2);
|
||||
// 装备链甲
|
||||
character.equipment.Wear(ArmorDictionary.Armor301(), out DataWear old3);
|
||||
return character;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c6813cdd5afeb949843c657358613db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,81 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 角色工具
|
||||
/// </summary>
|
||||
public static class CharacterTool {
|
||||
|
||||
#region 设置参数
|
||||
/// <summary> 设置职业 </summary>
|
||||
public static void Settings(this DataCharacter character, DataRace race) {
|
||||
character.race = race;
|
||||
}
|
||||
/// <summary> 设置职业 </summary>
|
||||
public static void Settings(this DataCharacter character, DataProfession profession) {
|
||||
character.profession = profession;
|
||||
profession.character = character;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 属性扩展
|
||||
/// <summary> 战斗等级 </summary>
|
||||
public static int GetLevel(this DataCharacter character) {
|
||||
// TODO:需要补充多职业的等级总和
|
||||
return character.profession.level;
|
||||
}
|
||||
/// <summary> 生命点 </summary>
|
||||
public static int GetHitPoint(this DataCharacter character) {
|
||||
// TODO:需要补充多职业的生命值加成
|
||||
return character.profession.HitPoint();
|
||||
}
|
||||
/// <summary> 计算护甲等级(AC) </summary>
|
||||
public static int GetArmorClass(this DataCharacter character) {
|
||||
// TODO:需要补充专长,技能,熟练之类的加值
|
||||
int modifier = character.DexModifier;
|
||||
return character.equipment.ArmorClass(modifier);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建角色
|
||||
/// <summary> 创建默认角色 </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 创建默认角色 </summary>
|
||||
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})");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6bdd4c70e0068d4dbe460c7a6961901
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,30 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗角色 - 工具
|
||||
/// </summary>
|
||||
public static class CombatRoleTool {
|
||||
|
||||
#region 设置参数
|
||||
/// <summary> 初始角色 </summary>
|
||||
public static void Initial(this DataCombatRole role) {
|
||||
AttributeTool.Cover(role, role.character);
|
||||
role.name = role.character.name;
|
||||
role.level = role.character.Level;
|
||||
role.hitPoint = new Vector2Int(role.character.HitPoint, role.character.HitPoint);
|
||||
role.armorClass = role.character.ArmorClass;
|
||||
role.weapon1 = role.character.equipment.weapon1;
|
||||
role.weapon2 = role.character.equipment.weapon2;
|
||||
if (role.weapon1 == null) { role.weapon1 = WeaponDictionary.Weapon000(); }
|
||||
if (role.weapon2 == null) { role.weapon2 = WeaponDictionary.Weapon000(); }
|
||||
}
|
||||
/// <summary> 设置队伍 </summary>
|
||||
public static void Settings(this DataCombatRole role, int team, int position) {
|
||||
role.team = team;
|
||||
role.position = position;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2eb2cecc8838b1445a24dce7aa669bd3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 怪物 - 字典
|
||||
/// </summary>
|
||||
public static class MonsterDictionary {
|
||||
/// <summary> 哥布林战士 怪物 </summary>
|
||||
public static DataCharacter Monster001() {
|
||||
DataCharacter character = new DataCharacter();
|
||||
character.name = "哥布林战士";
|
||||
character.race = RaceTool.None();
|
||||
character.basis = AttributeTool.Random();
|
||||
character.profession = ProfessionTool.None();
|
||||
character.profession.Initial(character);
|
||||
character.equipment = new DataEquipment();
|
||||
return character;
|
||||
}
|
||||
/// <summary> 哥布林射手 怪物 </summary>
|
||||
public static DataCharacter Monster002() {
|
||||
DataCharacter character = new DataCharacter();
|
||||
character.name = "哥布林射手";
|
||||
character.race = RaceTool.None();
|
||||
character.basis = AttributeTool.Random();
|
||||
character.profession = ProfessionTool.None();
|
||||
character.profession.Initial(character);
|
||||
character.equipment = new DataEquipment();
|
||||
return character;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b03641f0b64dd44894d3b5f3cb10d5d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,75 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 种族 - 工具
|
||||
/// </summary>
|
||||
public static class ProfessionTool {
|
||||
|
||||
#region 扩展
|
||||
/// <summary> 初始:满生命骰子 + 体质调整值 </summary>
|
||||
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<int> { hitPoint };
|
||||
}
|
||||
/// <summary> 升级:骰生命骰子 + 体质调整值 </summary>
|
||||
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);
|
||||
}
|
||||
/// <summary> 生命点:每级生命点总和 </summary>
|
||||
public static int HitPoint(this DataProfession profession) {
|
||||
return profession.hitPoints.Sum();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建
|
||||
/// <summary> 创建 </summary>
|
||||
public static DataProfession Create(string name, int hitDice) {
|
||||
DataProfession profession = new DataProfession { name = name, hitDice = hitDice };
|
||||
profession.name = name;
|
||||
profession.hitDice = hitDice;
|
||||
return profession;
|
||||
}
|
||||
/// <summary> 无职业 1d4 </summary>
|
||||
public static DataProfession None() {
|
||||
return Create("无", 4);
|
||||
}
|
||||
/// <summary> 随机职业 </summary>
|
||||
public static DataProfession Random() {
|
||||
int index = Dice.Roll(5);
|
||||
if (index == 1) { return Warrior(); }
|
||||
if (index == 2) { return Wizard(); }
|
||||
if (index == 3) { return Cleric(); }
|
||||
if (index == 4) { return Ranger(); }
|
||||
if (index == 5) { return Chanter(); }
|
||||
return None();
|
||||
}
|
||||
/// <summary> 战士 1d10 </summary>
|
||||
public static DataProfession Warrior() {
|
||||
return Create("战士", 10);
|
||||
}
|
||||
/// <summary> 法师 1d6 </summary>
|
||||
public static DataProfession Wizard() {
|
||||
return Create("法师", 6);
|
||||
}
|
||||
/// <summary> 牧师 1d8 </summary>
|
||||
public static DataProfession Cleric() {
|
||||
return Create("牧师", 8);
|
||||
}
|
||||
/// <summary> 游侠 1d8 </summary>
|
||||
public static DataProfession Ranger() {
|
||||
return Create("游侠", 8);
|
||||
}
|
||||
/// <summary> 歌者 1d6 </summary>
|
||||
public static DataProfession Chanter() {
|
||||
return Create("歌者", 6);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd48318dcbe216449a81d70622f8ba35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,47 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 种族 - 工具
|
||||
/// </summary>
|
||||
public static class RaceTool {
|
||||
|
||||
#region 创建
|
||||
// 混血人类,木精灵,丘陵矮人(Hill Dwarf),龙裔,半精灵
|
||||
/// <summary> 无种族 </summary>
|
||||
public static DataRace None() {
|
||||
return new DataRace { name = "未知" };
|
||||
}
|
||||
/// <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) 全属性+1 </summary>
|
||||
public static DataRace Human() {
|
||||
return new DataRace { name = "人类", Str = 1, Dex = 1, Con = 1, Int = 1, Wis = 1, Cha = 1 };
|
||||
}
|
||||
/// <summary> 精灵(Elven) 敏捷+2 智力+2 感知+1 </summary>
|
||||
public static DataRace Elven() {
|
||||
return new DataRace { name = "精灵", Dex = 2, Int = 2, Wis = 1 };
|
||||
}
|
||||
/// <summary> 矮人(Dwarf) 力量+2 体质+2 感知+1 </summary>
|
||||
public static DataRace Dwarf() {
|
||||
return new DataRace { name = "矮人", Str = 2, Con = 2, Wis = 1 };
|
||||
}
|
||||
/// <summary> 半兽人(Orc) 力量+3 体质+2 </summary>
|
||||
public static DataRace Orc() {
|
||||
return new DataRace { name = "半兽人", Str = 3, Con = 2 };
|
||||
}
|
||||
/// <summary> 半身人(Halfling) 敏捷+2 魅力+2 体质+1 </summary>
|
||||
public static DataRace Halfling() {
|
||||
return new DataRace { name = "半身人", Dex = 2, Cha = 2, Con = 1 };
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9694db834fdbe8744882901e02003034
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c72786dd03e5934cb9edc370f3127ab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
/// <summary>
|
||||
/// 基础输入
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(PlayerInput))]
|
||||
public class InputBasic : MonoBehaviour {
|
||||
public Vector3 mousePosition;
|
||||
|
||||
#region 输入系统
|
||||
/// <summary> 鼠标位置 </summary>
|
||||
public void OnMousePosition(InputValue inputValue) {
|
||||
mousePosition = inputValue.Get<Vector2>();
|
||||
ModuleInput.mousePosition = mousePosition;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dee866dfe25bee147af6c082a02e6088
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
/// <summary>
|
||||
/// 输入 - 控制
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(PlayerInput))]
|
||||
public abstract class InputControl : MonoBehaviour {
|
||||
|
||||
protected virtual void Awake() {
|
||||
ModuleInput.OnInputMode += ModuleInput_OnInputMode;
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy() {
|
||||
ModuleInput.OnInputMode -= ModuleInput_OnInputMode;
|
||||
}
|
||||
|
||||
/// <summary> 输入模式 </summary>
|
||||
protected abstract void ModuleInput_OnInputMode(InputMode mode);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fccf5d06f2bfe274ca0c36cb9f830a89
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea1d3ff12fa75374db81a3fa96568dbf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 菜单 - 输入
|
||||
/// </summary>
|
||||
public class InputMenu : InputControl {
|
||||
|
||||
private UIMenuPanel menu;
|
||||
|
||||
protected override void ModuleInput_OnInputMode(InputMode mode) {
|
||||
// throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
#region 输入系统
|
||||
/// <summary> 鼠标左键 </summary>
|
||||
public void OnMouseLeft(InputValue inputValue) {
|
||||
if (inputValue.isPressed) return;
|
||||
UIShortcutMenu.I.Close();
|
||||
}
|
||||
/// <summary> 鼠标右键 </summary>
|
||||
public void OnMouseRight(InputValue inputValue) {
|
||||
UIShortcutMenu.I.Add("测试1/测试11", () => { Debug.Log("测试1/测试11"); });
|
||||
UIShortcutMenu.I.Add("测试1/测试12", () => { Debug.Log("测试1/测试12"); });
|
||||
|
||||
UIShortcutMenu.I.Add("测试2", () => { Debug.Log("测试2"); });
|
||||
|
||||
UIShortcutMenu.I.Open();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c410af27a0301a42af9f1934da770a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 输入模块
|
||||
/// </summary>
|
||||
public class ModuleInput : ModuleSingle<ModuleInput> {
|
||||
|
||||
/// <summary> 当前输入模式 </summary>
|
||||
public static InputMode Current;
|
||||
/// <summary> 回退输入模式 </summary>
|
||||
public static InputMode BackMode;
|
||||
/// <summary> 鼠标指针位置 </summary>
|
||||
public static Vector2 mousePosition;
|
||||
/// <summary> 转换模式事件 </summary>
|
||||
public static event Action<InputMode> OnInputMode;
|
||||
|
||||
/// <summary> 指针是否在UI上 </summary>
|
||||
private static bool isPointerOverUIObject;
|
||||
/// <summary> 指针是否在UI上 </summary>
|
||||
public static bool IsPointerOverUIObject => isPointerOverUIObject;
|
||||
|
||||
/// <summary> 设置输入模式 </summary>
|
||||
public static void Settings(InputMode mode) {
|
||||
BackMode = Current;
|
||||
Current = mode;
|
||||
OnInputMode?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 设置输入模式 </summary>
|
||||
public static void Back() {
|
||||
Current = BackMode;
|
||||
OnInputMode?.Invoke(Current);
|
||||
}
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
private void Update() {
|
||||
#if UNITY_STANDALONE
|
||||
//电脑平台
|
||||
isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject();
|
||||
#elif UNITY_WEBGL
|
||||
//WebGL平台
|
||||
isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject();
|
||||
#elif UNITY_ANDROID
|
||||
//安卓平台
|
||||
isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId);
|
||||
#elif UNITY_IOS
|
||||
//苹果平台
|
||||
isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 输入模式
|
||||
/// </summary>
|
||||
public enum InputMode {
|
||||
None,// 无
|
||||
|
||||
FashionDesign,// 服装设计
|
||||
|
||||
OrnamentDesign,// 配饰设计
|
||||
|
||||
FashionDisplay,// 服装展示
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 660f596e493d2b547b176b764baa4a7c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,42 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 装备 - 字典
|
||||
/// </summary>
|
||||
public static class ArmorDictionary {
|
||||
/// <summary> 护甲 </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 法师袍 ac10 </summary>
|
||||
public static DataArmor Armor101() {
|
||||
DataArmor armor = Armor("法师袍", ArmorType.布甲);
|
||||
armor.additions.Add(new DataAddition { armorClass = 10 });
|
||||
return armor;
|
||||
}
|
||||
/// <summary> 皮甲 ac11 </summary>
|
||||
public static DataArmor Armor201() {
|
||||
DataArmor armor = Armor("皮甲", ArmorType.轻甲);
|
||||
armor.additions.Add(new DataAddition { armorClass = 11 });
|
||||
return armor;
|
||||
}
|
||||
/// <summary> 链甲 ac15 </summary>
|
||||
public static DataArmor Armor301() {
|
||||
DataArmor armor = Armor("链甲", ArmorType.中甲);
|
||||
armor.additions.Add(new DataAddition { armorClass = 15 });
|
||||
return armor;
|
||||
}
|
||||
/// <summary> 板甲 ac18 </summary>
|
||||
public static DataArmor Armor401() {
|
||||
DataArmor armor = Armor("板甲", ArmorType.重甲);
|
||||
armor.additions.Add(new DataAddition { armorClass = 18 });
|
||||
return armor;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f13627182bd77434991f32751b8c15f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,105 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 装备栏 - 工具
|
||||
/// </summary>
|
||||
public static class EquipmentTool {
|
||||
|
||||
#region 附加
|
||||
/// <summary> 添加属性 </summary>
|
||||
public static void Add(this DataAddition a, DataAddition b) {
|
||||
a.armorClass += b.armorClass;
|
||||
}
|
||||
/// <summary> 合并属性 </summary>
|
||||
public static DataAddition Merge(List<DataAddition> additions) {
|
||||
DataAddition addition = new DataAddition();
|
||||
additions.ForEach(obj => addition.Add(obj));
|
||||
return addition;
|
||||
}
|
||||
/// <summary> 更新附加值 </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 获取护甲等级 </summary>
|
||||
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 穿戴
|
||||
/// <summary> 穿戴装备 </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 穿戴武器 </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 穿戴护甲 </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary> 穿戴头盔 </summary>
|
||||
public static bool WearHelmets(this DataEquipment equipment, DataWear wear, out DataWear old) {
|
||||
old = equipment.helmets;
|
||||
equipment.helmets = wear;
|
||||
return true;
|
||||
}
|
||||
/// <summary> 穿戴手套 </summary>
|
||||
public static bool WearGloves(this DataEquipment equipment, DataWear wear, out DataWear old) {
|
||||
old = equipment.gloves;
|
||||
equipment.gloves = wear;
|
||||
return true;
|
||||
}
|
||||
/// <summary> 穿戴鞋子 </summary>
|
||||
public static bool WearShoes(this DataEquipment equipment, DataWear wear, out DataWear old) {
|
||||
old = equipment.shoes;
|
||||
equipment.shoes = wear;
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fd627b70f23dd44493bf8fb1e577370
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,71 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 武器 - 字典
|
||||
/// </summary>
|
||||
public static class WeaponDictionary {
|
||||
/// <summary> 武器 </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary> 空手 1d2 </summary>
|
||||
public static DataWeapon Weapon000() {
|
||||
DataWeapon weapon = Weapon("空手", WeaponType.无);
|
||||
weapon.damageDice = new DataDamageDice(2, DamageType.无);
|
||||
return weapon;
|
||||
}
|
||||
|
||||
/// <summary> 匕首 1d4 </summary>
|
||||
public static DataWeapon Weapon101() {
|
||||
DataWeapon weapon = Weapon("匕首", WeaponType.轻型武器);
|
||||
weapon.damageDice = new DataDamageDice(4, DamageType.穿刺);
|
||||
return weapon;
|
||||
}
|
||||
/// <summary> 短弓 1d6 </summary>
|
||||
public static DataWeapon Weapon102() {
|
||||
DataWeapon weapon = Weapon("短弓", WeaponType.轻型武器);
|
||||
weapon.damageDice = new DataDamageDice(6, DamageType.穿刺);
|
||||
return weapon;
|
||||
}
|
||||
|
||||
/// <summary> 木棒 1d6 </summary>
|
||||
public static DataWeapon Weapon201() {
|
||||
DataWeapon weapon = Weapon("木棒", WeaponType.中型武器);
|
||||
weapon.damageDice = new DataDamageDice(6, DamageType.钝击);
|
||||
return weapon;
|
||||
}
|
||||
|
||||
/// <summary> 巨棒 1d8 </summary>
|
||||
public static DataWeapon Weapon301() {
|
||||
DataWeapon weapon = Weapon("巨棒", WeaponType.重型武器);
|
||||
weapon.damageDice = new DataDamageDice(8, DamageType.钝击);
|
||||
return weapon;
|
||||
}
|
||||
/// <summary> 法杖 1d6 </summary>
|
||||
public static DataWeapon Weapon302() {
|
||||
DataWeapon weapon = Weapon("法杖", WeaponType.重型武器);
|
||||
weapon.damageDice = new DataDamageDice(6, DamageType.钝击);
|
||||
return weapon;
|
||||
}
|
||||
|
||||
/// <summary> 木盾 ac1 </summary>
|
||||
public static DataWeapon Weapon401() {
|
||||
DataWeapon weapon = Weapon("木盾", WeaponType.盾牌);
|
||||
weapon.additions.Add(new DataAddition { armorClass = 1 });
|
||||
return weapon;
|
||||
}
|
||||
/// <summary> 箭袋 +20 </summary>
|
||||
public static DataWeapon Weapon402() {
|
||||
DataWeapon weapon = Weapon("箭袋", WeaponType.盾牌);
|
||||
weapon.additions.Add(new DataAddition { armorClass = 1 });
|
||||
return weapon;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32522aef438403f4d9ed01fe6650243b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,43 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 请求 - 管理器
|
||||
/// </summary>
|
||||
public class ManagerRequest : ModuleSingle<ManagerRequest> {
|
||||
|
||||
/// <summary> 域名 </summary>
|
||||
public static string Address => "http://localhost:5086";
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
|
||||
#region 用户
|
||||
/// <summary> 登录 </summary>
|
||||
public void Login(string username, string password, Action<string> callback) {
|
||||
string url = Address + "/api/user/login";
|
||||
DataLoginRequest login = new DataLoginRequest { username = username, password = password };
|
||||
PostForm(url, login, callback);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 请求类型
|
||||
public void PostForm<T>(string url, T data, Action<string> callback) {
|
||||
string json = JsonTool.ToJson(data);
|
||||
Debug.Log(json);
|
||||
DataRequestPost request = new DataRequestPost(url, json);
|
||||
request.OnError = (json) => { ErrorHandle(url, json); };
|
||||
request.OnCallback = callback;
|
||||
NetworkRequestAsync.Execute(request);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 结果处理
|
||||
/// <summary> 错误处理 </summary>
|
||||
private void ErrorHandle(string url, string json) {
|
||||
Debug.LogError($"{url} \n {json}");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b4112fa4a2bfe84984b0472be3af46c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,34 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟器 - 管理
|
||||
/// </summary>
|
||||
public class ManagerSimulator : ModuleSingle<ManagerSimulator> {
|
||||
|
||||
/// <summary> 队伍1 </summary>
|
||||
public BattleTeam team1;
|
||||
/// <summary> 队伍2 </summary>
|
||||
public BattleTeam team2;
|
||||
|
||||
public BattleSimulator battleSimulator;
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
|
||||
private void Start() {
|
||||
team1 = new BattleTeam();
|
||||
team1.Add(CharacterDictionary.Character001());
|
||||
team1.Add(CharacterDictionary.Character002());
|
||||
team1.Add(CharacterDictionary.Character003());
|
||||
|
||||
team2 = new BattleTeam();
|
||||
team2.Add(MonsterDictionary.Monster001());
|
||||
team2.Add(MonsterDictionary.Monster002());
|
||||
team2.Add(MonsterDictionary.Monster002());
|
||||
|
||||
battleSimulator = new BattleSimulator(team1, team2);
|
||||
battleSimulator.Transition(PhaseType.先攻阶段);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ce4cafcd40fff3428928289fa060de4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,24 +8,50 @@ using MuHua;
|
||||
/// <summary>
|
||||
/// UI模块
|
||||
/// </summary>
|
||||
public class ModuleUI : ModuleSingle<ModuleUI> {
|
||||
public static EnumPage page;
|
||||
public static event Action<EnumPage> OnJumpPage;
|
||||
public class ModuleUI : ModuleUISingle<ModuleUI> {
|
||||
/// <summary> 当前页面 </summary>
|
||||
public static Page Current;
|
||||
/// <summary> 回退页面 </summary>
|
||||
public static Page BackPage;
|
||||
/// <summary> 控件列表 </summary>
|
||||
public static List<UIControl> controls = new List<UIControl>();
|
||||
/// <summary> 页面跳转事件 </summary>
|
||||
public static event Action<Page> OnJumpPage;
|
||||
|
||||
public UIDocument document;// 绑定文档
|
||||
/// <summary> 跳转页面 </summary>
|
||||
public static void Settings(Page pageType) {
|
||||
BackPage = Current;
|
||||
Current = pageType;
|
||||
OnJumpPage?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 回退页面 </summary>
|
||||
public static void Back() {
|
||||
Current = BackPage;
|
||||
OnJumpPage?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 添加控件 </summary>
|
||||
public static void AddControl(UIControl control) {
|
||||
controls.Add(control);
|
||||
}
|
||||
/// <summary> 移除控件 </summary>
|
||||
public static void RemoveControl(UIControl control) {
|
||||
controls.Remove(control);
|
||||
}
|
||||
|
||||
/// <summary> 根目录文档 </summary>
|
||||
public VisualElement root => document.rootVisualElement;
|
||||
public override VisualElement Element => document.rootVisualElement;
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
/// <summary> 跳转页面 </summary>
|
||||
public static void Settings(EnumPage pageType) => OnJumpPage?.Invoke(pageType);
|
||||
private void Update() => controls.ForEach(control => control.Update());
|
||||
|
||||
private void OnDestroy() => controls.ForEach(control => control.Dispose());
|
||||
}
|
||||
/// <summary>
|
||||
/// 页面
|
||||
/// </summary>
|
||||
public enum EnumPage {
|
||||
public enum Page {
|
||||
/// <summary> 无 </summary>
|
||||
None,
|
||||
/// <summary> 登录 </summary>
|
||||
Login,
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 登录页面
|
||||
/// </summary>
|
||||
public class UILoginPage : ModuleUIPage {
|
||||
|
||||
private UILoginPanel loginPanel;
|
||||
private UIRegisterPanel registerPanel;
|
||||
|
||||
public override VisualElement Element => root.Q<VisualElement>("LoginPage");
|
||||
|
||||
public VisualElement LoginPanel => Q<VisualElement>("LoginPanel");
|
||||
public VisualElement RegisterPanel => Q<VisualElement>("RegisterPanel");
|
||||
|
||||
private void Awake() {
|
||||
loginPanel = new UILoginPanel(LoginPanel, this);
|
||||
registerPanel = new UIRegisterPanel(RegisterPanel, this);
|
||||
|
||||
ModuleUI.OnJumpPage += ModuleUI_OnJumpPage;
|
||||
}
|
||||
|
||||
private void ModuleUI_OnJumpPage(EnumPage page) {
|
||||
Element.EnableInClassList("document-page-hide", page != EnumPage.Login);
|
||||
if (page != EnumPage.Login) { return; }
|
||||
OpenLoginPanel();
|
||||
}
|
||||
public void OpenLoginPanel() {
|
||||
loginPanel.Resetting(false);
|
||||
registerPanel.Resetting(true);
|
||||
}
|
||||
public void OpenRegisterPanel() {
|
||||
loginPanel.Resetting(true);
|
||||
registerPanel.Resetting(false);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 登录面板
|
||||
/// </summary>
|
||||
public class UILoginPanel : ModuleUIPanel {
|
||||
|
||||
private string username;
|
||||
private string password;
|
||||
|
||||
public Label Title => Q<Label>("Title");
|
||||
public UITextField InputField1 => Q<UITextField>("InputField1");
|
||||
public UITextField InputField2 => Q<UITextField>("InputField2");
|
||||
public Button Button1 => Q<Button>("Button1");
|
||||
public Button Button2 => Q<Button>("Button2");
|
||||
|
||||
public UILoginPanel(VisualElement element, UILoginPage parent) : base(element) {
|
||||
InputField1.RegisterCallback<ChangeEvent<string>>(evt => { username = evt.newValue; });
|
||||
InputField2.RegisterCallback<ChangeEvent<string>>(evt => { password = evt.newValue; });
|
||||
Button1.clicked += () => parent.OpenRegisterPanel();
|
||||
Button2.clicked += () => ManagerRequest.I.Login(username, password, (s) => {
|
||||
ModuleUI.Settings(EnumPage.None);
|
||||
Debug.Log(s);
|
||||
});
|
||||
}
|
||||
public void Resetting(bool isHide) {
|
||||
InputField1.value = username = "";
|
||||
InputField2.value = password = "";
|
||||
element.EnableInClassList("login-hide", isHide);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 注册面板
|
||||
/// </summary>
|
||||
public class UIRegisterPanel : ModuleUIPanel {
|
||||
|
||||
private string username;
|
||||
private string password;
|
||||
|
||||
public Label Title => Q<Label>("Title");
|
||||
public UITextField InputField1 => Q<UITextField>("InputField1");
|
||||
public UITextField InputField2 => Q<UITextField>("InputField2");
|
||||
public Button Button1 => Q<Button>("Button1");
|
||||
public Button Button2 => Q<Button>("Button2");
|
||||
|
||||
public UIRegisterPanel(VisualElement element, UILoginPage parent) : base(element) {
|
||||
InputField1.RegisterCallback<ChangeEvent<string>>(evt => { username = evt.newValue; });
|
||||
InputField2.RegisterCallback<ChangeEvent<string>>(evt => { password = evt.newValue; });
|
||||
Button1.clicked += () => parent.OpenLoginPanel();
|
||||
Button2.clicked += () => { };
|
||||
}
|
||||
public void Resetting(bool isHide) {
|
||||
InputField1.value = "";
|
||||
InputField2.value = "";
|
||||
element.EnableInClassList("login-hide", isHide);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71f4d873d8595a04b9f0e23ece70c12f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 测试页面
|
||||
/// </summary>
|
||||
public class UITestPage : ModuleUIPage {
|
||||
|
||||
public VisualTreeAsset SlideButtonTemplate;
|
||||
|
||||
public UISlideButton<UIOption, Option> slideButton;
|
||||
|
||||
public override VisualElement Element => root;
|
||||
public VisualElement SlideButton => Q<VisualElement>("SlideButton");
|
||||
|
||||
public void Awake() {
|
||||
slideButton = new UISlideButton<UIOption, Option>(SlideButton, root, SlideButtonTemplate, (data, element) => new UIOption(data, element));
|
||||
|
||||
List<Option> options = new List<Option>();
|
||||
options.Add(new Option());
|
||||
options.Add(new Option());
|
||||
options.Add(new Option());
|
||||
options.Add(new Option());
|
||||
slideButton.Create(options);
|
||||
|
||||
slideButton.Items[1].Select();
|
||||
}
|
||||
public void Update() {
|
||||
slideButton.Update();
|
||||
}
|
||||
|
||||
public class Option : DataSlideButton {
|
||||
|
||||
}
|
||||
|
||||
public class UIOption : ModuleUIItem<Option> {
|
||||
|
||||
public Button Button => Q<Button>("Button");
|
||||
|
||||
public UIOption(Option value, VisualElement element) : base(value, element) {
|
||||
value.element = element;
|
||||
Button.clicked += Select;
|
||||
}
|
||||
public override void SelectState() {
|
||||
Button.EnableInClassList("slidebutton-button-s", true);
|
||||
}
|
||||
public override void DefaultState() {
|
||||
Button.EnableInClassList("slidebutton-button-s", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be9d3ba84a127e14abd0d56796e7d7e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIBannerTip : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7279e9c7234eb6645b7b1e172b70919d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 指针提示
|
||||
/// </summary>
|
||||
public class UIGuidance : ModuleUIPanel {
|
||||
|
||||
private bool isDown;
|
||||
private Action callback;
|
||||
private Action<bool> ValueChanged;
|
||||
private Vector2 offset;
|
||||
private Vector3 originalPosition;
|
||||
private Vector3 pointerPosition;
|
||||
private VisualElement target;
|
||||
private UIToggle toggle;
|
||||
|
||||
public Label Prompt => Q<Label>("Prompt");
|
||||
public VisualElement Toggle => Q<VisualElement>("Toggle");
|
||||
public VisualElement Button => Q<VisualElement>("Button");
|
||||
public VisualElement Pointer => Q<VisualElement>("Pointer");
|
||||
|
||||
public UIGuidance(VisualElement element) : base(element) {
|
||||
toggle = new UIToggle(Toggle);
|
||||
toggle.ValueChanged += (value) => { ValueChanged?.Invoke(value); };
|
||||
|
||||
Button.RegisterCallback<ClickEvent>(ClickEvent);
|
||||
|
||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
||||
element.RegisterCallback<MouseUpEvent>(MouseUpEvent);
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
#if UNITY_EDITOR
|
||||
if (target == null) { return; }
|
||||
if (isDown) {
|
||||
Vector3 mousePosition = UITool.GetMousePosition();
|
||||
Vector3 differ = new Vector3(mousePosition.x, Screen.height - mousePosition.y) - pointerPosition;
|
||||
|
||||
Pointer.transform.position = originalPosition + differ;
|
||||
}
|
||||
else {
|
||||
Pointer.transform.position = target.worldBound.position + offset;
|
||||
}
|
||||
#else
|
||||
if (target == null) { return; }
|
||||
Pointer.transform.position = target.worldBound.position + offset;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void ClickEvent(ClickEvent evt) {
|
||||
element.EnableInClassList("document-page-hide", true);
|
||||
callback?.Invoke();
|
||||
}
|
||||
private void MouseDownEvent(MouseDownEvent evt) {
|
||||
#if UNITY_EDITOR
|
||||
isDown = true;
|
||||
originalPosition = Pointer.transform.position;
|
||||
Vector3 mousePosition = UITool.GetMousePosition();
|
||||
pointerPosition = new Vector3(mousePosition.x, Screen.height - mousePosition.y);
|
||||
#endif
|
||||
}
|
||||
private void MouseUpEvent(MouseUpEvent evt) {
|
||||
isDown = false;
|
||||
float x = Pointer.transform.position.x - target.worldBound.position.x;
|
||||
float y = Pointer.transform.position.y - target.worldBound.position.y;
|
||||
Vector3 offset = new Vector3(x, y);
|
||||
Debug.Log(offset);
|
||||
}
|
||||
|
||||
/// <summary> 打开提示 </summary>
|
||||
public void Settings(string content, VisualElement target, Vector2 offset, Action callback) {
|
||||
this.target = target;
|
||||
this.offset = offset;
|
||||
this.callback = callback;
|
||||
Prompt.text = content;
|
||||
element.EnableInClassList("document-page-hide", false);
|
||||
}
|
||||
/// <summary> 设置提示 </summary>
|
||||
public void Settings(bool value, Action<bool> ValueChanged) {
|
||||
this.ValueChanged = ValueChanged;
|
||||
toggle.UpdateValue(value, false);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 图案页指引
|
||||
/// </summary>
|
||||
public class UIPatternPageGuidance : ModuleUIPanel {
|
||||
|
||||
private bool isNot;
|
||||
|
||||
public VisualElement Top => Q<VisualElement>("Top");
|
||||
public Button Button1 => Top.Q<Button>("Button1");// 创建图案
|
||||
public Button Button4 => Top.Q<Button>("Button4");// 创建元素
|
||||
|
||||
public VisualElement Dashboard => Q<VisualElement>("Dashboard");
|
||||
public VisualElement PatternLibrary => Q<VisualElement>("PatternLibrary");
|
||||
public VisualElement TemplateLibrary => Q<VisualElement>("TemplateLibrary");
|
||||
|
||||
public UIPatternPageGuidance(VisualElement element) : base(element) { }
|
||||
|
||||
public void Guidance1() {
|
||||
if (isNot) { return; }
|
||||
string content = "第一步 点击【创建图案】按钮,即可新建一个空白画板,开始您的设计。";
|
||||
Guidance(content, Button1, new Vector2(140, -55), Guidance2);
|
||||
}
|
||||
public void Guidance2() {
|
||||
string content = "第二步 提供两种创作方式 \n1,选用模板:点击【图案模板】,选择模板后参考其结构与配色,进行纹样重构与创新设计。";
|
||||
Guidance(content, TemplateLibrary, new Vector2(310, 0), Guidance3);
|
||||
}
|
||||
public void Guidance3() {
|
||||
string content = "2,全新创作:点击【创建元素】创建空白图案框,自行选择【图案元素库】内的图案素材进行创新设计。";
|
||||
Guidance(content, Button4, new Vector2(-530, -65), Guidance4);
|
||||
}
|
||||
public void Guidance4() {
|
||||
string content = "导入个人素材:点击【自定义】-【导入素材】,导入后请点击【自定义】刷新以更新显示。";
|
||||
Guidance(content, PatternLibrary, new Vector2(310, 0), Guidance5);
|
||||
}
|
||||
public void Guidance5() {
|
||||
string content = "图案编辑功能:选中图案元素,可调整其颜色、位置、大小、镜像、连续排列等操作。\n画布设置:如设计透明背景的图案,可根据图案色彩风格自定义画板颜色,便于更直观地进行设计。";
|
||||
Guidance(content, Dashboard, new Vector2(-530, 0), null);
|
||||
}
|
||||
public void Guidance(string content, VisualElement visual, Vector3 offset, Action action) {
|
||||
// UIGuidance guidance = ModuleUI.I.popupManager.guidance;
|
||||
// guidance.Settings(content, visual, offset, action);
|
||||
// guidance.Settings(isNot, (value) => { isNot = value; });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8df138b434ab51f40b134f831376120e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcb666edf8774b643830fdbb6a3973bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI弹出管理器
|
||||
/// </summary>
|
||||
public class UIPopupManager : ModuleUISingle<UIPopupManager> {
|
||||
|
||||
public override VisualElement Element => root.Q<VisualElement>("Popup");
|
||||
|
||||
public VisualElement PopupDialog => Q<VisualElement>("PopupDialog");
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI快捷菜单
|
||||
/// </summary>
|
||||
public class UIShortcutMenu : ModuleUISingle<UIShortcutMenu> {
|
||||
/// <summary> 菜单模板 </summary>
|
||||
public VisualTreeAsset menuTreeAsset;
|
||||
/// <summary> 项目模板 </summary>
|
||||
public VisualTreeAsset itemTreeAsset;
|
||||
|
||||
/// <summary> 数据列表 </summary>
|
||||
public List<DataMenuItem> datas = new List<DataMenuItem>();
|
||||
/// <summary> 控件列表 </summary>
|
||||
public static List<UIControl> controls = new List<UIControl>();
|
||||
|
||||
public override VisualElement Element => root.Q<VisualElement>("ShortcutMenu");
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
|
||||
private void Update() => controls.ForEach(control => control.Update());
|
||||
|
||||
private void OnDestroy() => controls.ForEach(control => control.Dispose());
|
||||
|
||||
/// <summary> 打开菜单 </summary>
|
||||
public void Open() {
|
||||
Close();
|
||||
Vector3 position = UITool.GetMousePosition(Element);
|
||||
UIMenuPanel menuPanel = Create();
|
||||
menuPanel.Settings(position, datas);
|
||||
}
|
||||
/// <summary> 关闭菜单 </summary>
|
||||
public void Close() {
|
||||
controls.ForEach(control => control.Dispose());
|
||||
controls.Clear();
|
||||
Element.Clear();
|
||||
}
|
||||
/// <summary> 创建子菜单 </summary>
|
||||
public UIMenuPanel Create() {
|
||||
// 创建菜单元素
|
||||
VisualElement element = menuTreeAsset.Instantiate();
|
||||
element.EnableInClassList("menu", true);
|
||||
Element.Add(element);
|
||||
UIMenuPanel menuPanel = new UIMenuPanel(element, itemTreeAsset);
|
||||
controls.Add(menuPanel);
|
||||
return menuPanel;
|
||||
}
|
||||
|
||||
/// <summary> 添加菜单项(方法) </summary>
|
||||
public void Add(string name, Action callback) {
|
||||
string[] names = name.Split('/');
|
||||
|
||||
List<DataMenuItem> datas = this.datas;
|
||||
for (int i = 0; i < names.Length; i++) {
|
||||
string menu = names[i];
|
||||
DataMenuItem item = datas.Find(obj => obj.name == menu);
|
||||
if (item == null) {
|
||||
item = new DataMenuItem { name = menu };
|
||||
if (i == names.Length - 1) { item.callback = callback; }
|
||||
datas.Add(item);
|
||||
}
|
||||
datas = item.items;
|
||||
}
|
||||
}
|
||||
/// <summary> 移除菜单项 </summary>
|
||||
public void Remove(string name) {
|
||||
string[] names = name.Split('/');
|
||||
List<DataMenuItem> datas = this.datas;
|
||||
DataMenuItem parent = null;
|
||||
DataMenuItem target = null;
|
||||
|
||||
for (int i = 0; i < names.Length; i++) {
|
||||
string menu = names[i];
|
||||
target = datas.Find(obj => obj.name == menu);
|
||||
if (target == null) return; // 未找到,直接返回
|
||||
if (i == names.Length - 1) {
|
||||
// 找到要移除的项
|
||||
datas.Remove(target);
|
||||
return;
|
||||
}
|
||||
parent = target;
|
||||
datas = target.items;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// UI快捷菜单面板
|
||||
/// </summary>
|
||||
public class UIMenuPanel : ModuleUIPanel, UIControl {
|
||||
|
||||
public UIMenuPanel menuPanel;
|
||||
public VisualElement submenu;
|
||||
public ModuleUIItems<UIItem, DataMenuItem> items;
|
||||
|
||||
public VisualElement Container => Q<VisualElement>("Container");
|
||||
|
||||
public UIMenuPanel(VisualElement element, VisualTreeAsset templateAsset) : base(element) {
|
||||
items = new ModuleUIItems<UIItem, DataMenuItem>(Container, templateAsset,
|
||||
(data, element) => new UIItem(data, element, this));
|
||||
}
|
||||
public void Update() {
|
||||
// throw new NotImplementedException();
|
||||
}
|
||||
public void Dispose() {
|
||||
items.Release();
|
||||
}
|
||||
|
||||
public void Settings(Vector3 position, List<DataMenuItem> datas) {
|
||||
items.Create(datas);
|
||||
element.transform.position = position;
|
||||
}
|
||||
|
||||
/// <summary> 打开子菜单 </summary>
|
||||
public void Open(VisualElement submenu, List<DataMenuItem> datas) {
|
||||
if (this.submenu == submenu) { return; }
|
||||
// 更新子菜单
|
||||
this.submenu = submenu;
|
||||
if (menuPanel == null) { menuPanel = UIShortcutMenu.I.Create(); }
|
||||
float x = submenu.worldBound.position.x + submenu.resolvedStyle.width;
|
||||
float y = submenu.worldBound.position.y - 5;
|
||||
Vector3 position = new Vector3(x, y, 0);
|
||||
menuPanel.Settings(position, datas);
|
||||
bool isEnable = datas != null && datas.Count > 0;
|
||||
menuPanel.OpenSubmenu(isEnable);
|
||||
}
|
||||
public void OpenSubmenu(bool open) {
|
||||
element.EnableInClassList("menu-hide", !open);
|
||||
menuPanel?.OpenSubmenu(false);
|
||||
}
|
||||
|
||||
/// <summary> UI项目 </summary>
|
||||
public class UIItem : ModuleUIItem<DataMenuItem> {
|
||||
public readonly UIMenuPanel parent;
|
||||
|
||||
public Label Name => element.Q<Label>("Name");
|
||||
public VisualElement Arrow => element.Q<VisualElement>("Arrow");
|
||||
|
||||
public UIItem(DataMenuItem value, VisualElement element, UIMenuPanel parent) : base(value, element) {
|
||||
this.parent = parent;
|
||||
Name.text = value.name;
|
||||
Arrow.EnableInClassList("menu-arrow-hide", value.items == null || value.items.Count == 0);
|
||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
||||
element.RegisterCallback<MouseMoveEvent>(MouseMoveEvent);
|
||||
}
|
||||
private void MouseDownEvent(MouseDownEvent evt) {
|
||||
value.callback?.Invoke();
|
||||
UIShortcutMenu.I.Close();
|
||||
}
|
||||
private void MouseMoveEvent(MouseMoveEvent evt) {
|
||||
parent.Open(element, value.items);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 菜单项目
|
||||
/// </summary>
|
||||
public class DataMenuItem {
|
||||
/// <summary> 名称 </summary>
|
||||
public string name;
|
||||
/// <summary> 回调 </summary>
|
||||
public Action callback;
|
||||
/// <summary> 子菜单项 </summary>
|
||||
public List<DataMenuItem> items = new List<DataMenuItem>();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 422a458e7229d6b4a8fff66af1840238
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI弹出管理器
|
||||
/// </summary>
|
||||
public class UIPopupManager : ModuleUIPage {
|
||||
|
||||
// public UIPopup dialog;
|
||||
|
||||
public override VisualElement Element => root.Q<VisualElement>("Popup");
|
||||
|
||||
public VisualElement PopupDialog => Q<VisualElement>("PopupDialog");
|
||||
|
||||
private void Awake() {
|
||||
// dialog = new UIPopup(PopupDialog);
|
||||
}
|
||||
private void OnDestroy() {
|
||||
// config.Release();
|
||||
// configMaterial.Release();
|
||||
// equipmentSelection.Release();
|
||||
// paramrInput.Release();
|
||||
}
|
||||
private void Update() {
|
||||
// config.Update();
|
||||
// configMaterial.Update();
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13b55fb0978ba0740b207fa9fc1c91bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c10f564a26ea3e47bdf3a1955a57237
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,114 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
|
||||
m_Name: Universal Render Pipeline Asset
|
||||
m_EditorClassIdentifier:
|
||||
k_AssetVersion: 11
|
||||
k_AssetPreviousVersion: 11
|
||||
m_RendererType: 1
|
||||
m_RendererData: {fileID: 0}
|
||||
m_RendererDataList:
|
||||
- {fileID: 11400000, guid: 70bc0ab60d42b71418f8b765dc387cda, type: 2}
|
||||
m_DefaultRendererIndex: 0
|
||||
m_RequireDepthTexture: 0
|
||||
m_RequireOpaqueTexture: 0
|
||||
m_OpaqueDownsampling: 1
|
||||
m_SupportsTerrainHoles: 1
|
||||
m_SupportsHDR: 1
|
||||
m_HDRColorBufferPrecision: 0
|
||||
m_MSAA: 1
|
||||
m_RenderScale: 1
|
||||
m_UpscalingFilter: 0
|
||||
m_FsrOverrideSharpness: 0
|
||||
m_FsrSharpness: 0.92
|
||||
m_EnableLODCrossFade: 1
|
||||
m_LODCrossFadeDitheringType: 1
|
||||
m_ShEvalMode: 0
|
||||
m_MainLightRenderingMode: 1
|
||||
m_MainLightShadowsSupported: 1
|
||||
m_MainLightShadowmapResolution: 2048
|
||||
m_AdditionalLightsRenderingMode: 1
|
||||
m_AdditionalLightsPerObjectLimit: 4
|
||||
m_AdditionalLightShadowsSupported: 0
|
||||
m_AdditionalLightsShadowmapResolution: 2048
|
||||
m_AdditionalLightsShadowResolutionTierLow: 256
|
||||
m_AdditionalLightsShadowResolutionTierMedium: 512
|
||||
m_AdditionalLightsShadowResolutionTierHigh: 1024
|
||||
m_ReflectionProbeBlending: 0
|
||||
m_ReflectionProbeBoxProjection: 0
|
||||
m_ShadowDistance: 50
|
||||
m_ShadowCascadeCount: 1
|
||||
m_Cascade2Split: 0.25
|
||||
m_Cascade3Split: {x: 0.1, y: 0.3}
|
||||
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
|
||||
m_CascadeBorder: 0.2
|
||||
m_ShadowDepthBias: 1
|
||||
m_ShadowNormalBias: 1
|
||||
m_AnyShadowsSupported: 1
|
||||
m_SoftShadowsSupported: 0
|
||||
m_ConservativeEnclosingSphere: 1
|
||||
m_NumIterationsEnclosingSphere: 64
|
||||
m_SoftShadowQuality: 2
|
||||
m_AdditionalLightsCookieResolution: 2048
|
||||
m_AdditionalLightsCookieFormat: 3
|
||||
m_UseSRPBatcher: 1
|
||||
m_SupportsDynamicBatching: 0
|
||||
m_MixedLightingSupported: 1
|
||||
m_SupportsLightCookies: 1
|
||||
m_SupportsLightLayers: 0
|
||||
m_DebugLevel: 0
|
||||
m_StoreActionsOptimization: 0
|
||||
m_EnableRenderGraph: 0
|
||||
m_UseAdaptivePerformance: 1
|
||||
m_ColorGradingMode: 0
|
||||
m_ColorGradingLutSize: 32
|
||||
m_UseFastSRGBLinearConversion: 0
|
||||
m_SupportDataDrivenLensFlare: 1
|
||||
m_ShadowType: 1
|
||||
m_LocalShadowsSupported: 0
|
||||
m_LocalShadowsAtlasResolution: 256
|
||||
m_MaxPixelLights: 0
|
||||
m_ShadowAtlasResolution: 256
|
||||
m_VolumeFrameworkUpdateMode: 0
|
||||
m_Textures:
|
||||
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
|
||||
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
|
||||
m_PrefilteringModeMainLightShadows: 1
|
||||
m_PrefilteringModeAdditionalLight: 4
|
||||
m_PrefilteringModeAdditionalLightShadows: 1
|
||||
m_PrefilterXRKeywords: 0
|
||||
m_PrefilteringModeForwardPlus: 1
|
||||
m_PrefilteringModeDeferredRendering: 1
|
||||
m_PrefilteringModeScreenSpaceOcclusion: 1
|
||||
m_PrefilterDebugKeywords: 0
|
||||
m_PrefilterWriteRenderingLayers: 0
|
||||
m_PrefilterHDROutput: 0
|
||||
m_PrefilterSSAODepthNormals: 0
|
||||
m_PrefilterSSAOSourceDepthLow: 0
|
||||
m_PrefilterSSAOSourceDepthMedium: 0
|
||||
m_PrefilterSSAOSourceDepthHigh: 0
|
||||
m_PrefilterSSAOInterleaved: 0
|
||||
m_PrefilterSSAOBlueNoise: 0
|
||||
m_PrefilterSSAOSampleCountLow: 0
|
||||
m_PrefilterSSAOSampleCountMedium: 0
|
||||
m_PrefilterSSAOSampleCountHigh: 0
|
||||
m_PrefilterDBufferMRT1: 0
|
||||
m_PrefilterDBufferMRT2: 0
|
||||
m_PrefilterDBufferMRT3: 0
|
||||
m_PrefilterSoftShadowsQualityLow: 0
|
||||
m_PrefilterSoftShadowsQualityMedium: 0
|
||||
m_PrefilterSoftShadowsQualityHigh: 0
|
||||
m_PrefilterSoftShadows: 0
|
||||
m_PrefilterScreenCoord: 0
|
||||
m_PrefilterNativeRenderPass: 0
|
||||
m_ShaderVariantLogLevel: 0
|
||||
m_ShadowCascades: 0
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user