Compare commits
16 Commits
DND
..
7007bfaf19
| Author | SHA1 | Date | |
|---|---|---|---|
| 7007bfaf19 | |||
| 539b592959 | |||
| 31fc996021 | |||
| 44b160d069 | |||
| ccad83226f | |||
| 165339172a | |||
| 9be153994f | |||
| f4a07224aa | |||
| c17af4d74b | |||
| 714f29fc26 | |||
| 63b30ebd03 | |||
| 91a40e097b | |||
| 6bc06bcd8c | |||
| f7fab248d4 | |||
| 9a20ee8ac5 | |||
| 04b65e6945 |
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: f7cb6057f1015c34e83bfc292a519030
|
guid: dbbcf80f718a4894aaba28723063b222
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 59e1aa3dad18b83438571f22a94d78af
|
guid: 4d30cb813fec1a948ad6201956953a63
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
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
|
fileFormatVersion: 2
|
||||||
guid: 253123fa56cb88f4e969b587327d3f7f
|
guid: 498e3f400477d1040a16f935cc815387
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
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
|
fileFormatVersion: 2
|
||||||
guid: 3ae234ab6cd19bf46983ee5f38afd957
|
guid: 4e120a7c12f40d74cac5e48d41461d2c
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 1f85c0d8dce903b4eb5fb0aca37d2040
|
guid: d00e77fe0a528d74b9779c92c146dcf8
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
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
|
fileFormatVersion: 2
|
||||||
guid: 3d99eda4d1308724c8374c9e305743bc
|
guid: a57fb20032bb3e5488a7b363d12f19fd
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
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
|
fileFormatVersion: 2
|
||||||
guid: 278351779c3c1514bbcce18723dd500c
|
guid: 317ca1fd043483b42b67b042380a2f54
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
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
|
fileFormatVersion: 2
|
||||||
guid: 62fae57d4dbef374ba92424caa7b6885
|
guid: 745a630404a79d243a8041c505ec469c
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
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,47 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
using MuHua;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 菜单 - 输入
|
||||||
|
/// </summary>
|
||||||
|
public class InputMenu : InputControl {
|
||||||
|
|
||||||
|
private UIMenuPanel menu;
|
||||||
|
|
||||||
|
private void Start() {
|
||||||
|
ShortcutMenu.I.Add("测试1/测试11", () => { Debug.Log("测试1/测试11"); });
|
||||||
|
ShortcutMenu.I.Add("测试1/测试12", () => { Debug.Log("测试1/测试12"); });
|
||||||
|
|
||||||
|
ShortcutMenu.I.Add("删除测试5", () => {
|
||||||
|
ShortcutMenu.I.Remove("测试5");
|
||||||
|
});
|
||||||
|
ShortcutMenu.I.Add("删除测试51", () => {
|
||||||
|
ShortcutMenu.I.Remove("测试5/测试51");
|
||||||
|
});
|
||||||
|
ShortcutMenu.I.Add("删除测试52", () => {
|
||||||
|
ShortcutMenu.I.Remove("测试5/测试52");
|
||||||
|
});
|
||||||
|
|
||||||
|
ShortcutMenu.I.Add("测试5/测试51", () => { Debug.Log("测试51"); });
|
||||||
|
ShortcutMenu.I.Add("测试5/测试52", () => { Debug.Log("测试52"); });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ModuleInput_OnInputMode(InputMode mode) {
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 输入系统
|
||||||
|
/// <summary> 鼠标左键 </summary>
|
||||||
|
public void OnMouseLeft(InputValue inputValue) {
|
||||||
|
if (inputValue.isPressed) return;
|
||||||
|
ShortcutMenu.I.Close();
|
||||||
|
}
|
||||||
|
/// <summary> 鼠标右键 </summary>
|
||||||
|
public void OnMouseRight(InputValue inputValue) {
|
||||||
|
ShortcutMenu.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,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c29e0b5bff9f654439aa3e867ac20484
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
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:
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// UI模块
|
|
||||||
/// </summary>
|
|
||||||
public class ModuleUI : ModuleSingle<ModuleUI> {
|
|
||||||
public static EnumPage page;
|
|
||||||
public static event Action<EnumPage> OnJumpPage;
|
|
||||||
|
|
||||||
public UIDocument document;// 绑定文档
|
|
||||||
|
|
||||||
/// <summary> 根目录文档 </summary>
|
|
||||||
public VisualElement root => document.rootVisualElement;
|
|
||||||
|
|
||||||
protected override void Awake() => NoReplace();
|
|
||||||
|
|
||||||
/// <summary> 跳转页面 </summary>
|
|
||||||
public static void Settings(EnumPage pageType) => OnJumpPage?.Invoke(pageType);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 页面
|
|
||||||
/// </summary>
|
|
||||||
public enum EnumPage {
|
|
||||||
None,
|
|
||||||
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:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 06f31db1c09e8a0409a8b3b960a13216
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// SliderInputH - Panel
|
|
||||||
/// </summary>
|
|
||||||
public class UISliderInputH : ModuleUIPanel {
|
|
||||||
|
|
||||||
public float value;
|
|
||||||
public Vector2 range = new Vector2(1, 1);
|
|
||||||
public UISliderH slider;
|
|
||||||
public event Action<float> ValueChanged;
|
|
||||||
|
|
||||||
public VisualElement Slider => Q<VisualElement>("Slider");
|
|
||||||
public UIFloatField FloatField => Q<UIFloatField>("UIFloatField");
|
|
||||||
|
|
||||||
public UISliderInputH(VisualElement element, VisualElement canvas) : base(element) {
|
|
||||||
slider = new UISliderH(element, canvas);
|
|
||||||
|
|
||||||
slider.ValueChanged += Slider_ValueChanged;
|
|
||||||
FloatField.RegisterCallback<ChangeEvent<float>>(FloatField_ValueChanged);
|
|
||||||
}
|
|
||||||
private void Slider_ValueChanged(float obj) {
|
|
||||||
value = Mathf.Lerp(range.x, range.y, obj);
|
|
||||||
FloatField.SetValueWithoutNotify(value);
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
private void FloatField_ValueChanged(ChangeEvent<float> obj) {
|
|
||||||
value = Mathf.Clamp(obj.newValue, range.x, range.y);
|
|
||||||
float scale = Mathf.InverseLerp(range.x, range.y, value);
|
|
||||||
slider.UpdateValue(scale, false);
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
public void Update() {
|
|
||||||
slider.Update();
|
|
||||||
}
|
|
||||||
/// <summary> 更新值 </summary>
|
|
||||||
public void UpdateValue(float value) {
|
|
||||||
this.value = Mathf.Clamp(range.x, range.y, value);
|
|
||||||
float scale = Mathf.InverseLerp(range.x, range.y, value);
|
|
||||||
slider.UpdateValue(scale, false);
|
|
||||||
FloatField.SetValueWithoutNotify(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d5f8ad3cc3aff1940bdf68f3d911a263
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Vector2 - Panel
|
|
||||||
/// </summary>
|
|
||||||
public class UIVector2 : ModuleUIPanel {
|
|
||||||
|
|
||||||
public bool isLock;
|
|
||||||
public Vector2 value;
|
|
||||||
public UISliderInputH sliderX;
|
|
||||||
public UISliderInputH sliderY;
|
|
||||||
public event Action<Vector2, bool> ValueChanged;
|
|
||||||
|
|
||||||
public Button Lock => Q<Button>("Lock");
|
|
||||||
public VisualElement SliderX => Q<VisualElement>("SliderInputX");
|
|
||||||
public VisualElement SliderY => Q<VisualElement>("SliderInputY");
|
|
||||||
|
|
||||||
public UIVector2(VisualElement element, VisualElement canvas) : base(element) {
|
|
||||||
sliderX = new UISliderInputH(SliderX, canvas);
|
|
||||||
sliderY = new UISliderInputH(SliderY, canvas);
|
|
||||||
|
|
||||||
Lock.clicked += Lock_clicked;
|
|
||||||
sliderX.ValueChanged += SliderX_ValueChanged;
|
|
||||||
sliderY.ValueChanged += SliderY_ValueChanged;
|
|
||||||
}
|
|
||||||
private void Lock_clicked() {
|
|
||||||
isLock = !isLock;
|
|
||||||
Lock.EnableInClassList("dashboard-button-s", isLock);
|
|
||||||
if (isLock) { value.y = value.x; sliderY.UpdateValue(value.x); }
|
|
||||||
ValueChanged?.Invoke(value, isLock);
|
|
||||||
}
|
|
||||||
private void SliderX_ValueChanged(float obj) {
|
|
||||||
value.x = obj;
|
|
||||||
if (isLock) { value.y = obj; sliderY.UpdateValue(obj); }
|
|
||||||
ValueChanged?.Invoke(value, isLock);
|
|
||||||
}
|
|
||||||
private void SliderY_ValueChanged(float obj) {
|
|
||||||
value.y = obj;
|
|
||||||
if (isLock) { value.x = obj; sliderX.UpdateValue(obj); }
|
|
||||||
ValueChanged?.Invoke(value, isLock);
|
|
||||||
}
|
|
||||||
public void Update() {
|
|
||||||
sliderX.Update();
|
|
||||||
sliderY.Update();
|
|
||||||
}
|
|
||||||
/// <summary> 更新值 </summary>
|
|
||||||
public void UpdateValue(Vector2 value, bool isLock) {
|
|
||||||
this.value = value;
|
|
||||||
this.isLock = isLock;
|
|
||||||
sliderX.UpdateValue(value.x);
|
|
||||||
sliderY.UpdateValue(value.y);
|
|
||||||
Lock.EnableInClassList("dashboard-button-s", isLock);
|
|
||||||
}
|
|
||||||
/// <summary> 设置范围 </summary>
|
|
||||||
public void Settings(Vector2 range) {
|
|
||||||
sliderX.range = range;
|
|
||||||
sliderY.range = range;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c0898288ac15d9a4e9a82e0d6d36ff17
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Vector3 - Panel
|
|
||||||
/// </summary>
|
|
||||||
public class UIVector3 : ModuleUIPanel {
|
|
||||||
|
|
||||||
public Vector3 value;
|
|
||||||
public UISliderInputH sliderX;
|
|
||||||
public UISliderInputH sliderY;
|
|
||||||
public UISliderInputH sliderZ;
|
|
||||||
public event Action<Vector3> ValueChanged;
|
|
||||||
|
|
||||||
public VisualElement SliderInputX => Q<VisualElement>("SliderInputX");
|
|
||||||
public VisualElement SliderInputY => Q<VisualElement>("SliderInputY");
|
|
||||||
public VisualElement SliderInputZ => Q<VisualElement>("SliderInputZ");
|
|
||||||
|
|
||||||
public UIVector3(VisualElement element, VisualElement canvas) : base(element) {
|
|
||||||
sliderX = new UISliderInputH(SliderInputX, canvas);
|
|
||||||
sliderY = new UISliderInputH(SliderInputY, canvas);
|
|
||||||
sliderZ = new UISliderInputH(SliderInputZ, canvas);
|
|
||||||
|
|
||||||
sliderX.ValueChanged += SliderX_ValueChanged;
|
|
||||||
sliderY.ValueChanged += SliderY_ValueChanged;
|
|
||||||
sliderZ.ValueChanged += SliderZ_ValueChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SliderX_ValueChanged(float obj) {
|
|
||||||
value.x = obj;
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
private void SliderY_ValueChanged(float obj) {
|
|
||||||
value.y = obj;
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
private void SliderZ_ValueChanged(float obj) {
|
|
||||||
value.z = obj;
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
public void Update() {
|
|
||||||
sliderX.Update();
|
|
||||||
sliderY.Update();
|
|
||||||
sliderZ.Update();
|
|
||||||
}
|
|
||||||
/// <summary> 更新值 </summary>
|
|
||||||
public void UpdateValue(Vector3 value) {
|
|
||||||
this.value = value;
|
|
||||||
sliderX.UpdateValue(value.x);
|
|
||||||
sliderY.UpdateValue(value.y);
|
|
||||||
sliderZ.UpdateValue(value.z);
|
|
||||||
}
|
|
||||||
/// <summary> 设置范围 </summary>
|
|
||||||
public void Settings(Vector2 range) {
|
|
||||||
sliderX.range = range;
|
|
||||||
sliderY.range = range;
|
|
||||||
sliderZ.range = range;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 36d613e41a27e8f40be6e6c05de1aeb1
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using UnityEngine.Video;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 视频播放控件
|
|
||||||
/// </summary>
|
|
||||||
public class UIVideoPlayPanel : ModuleUIPanel {
|
|
||||||
private float showTime;
|
|
||||||
private bool isDownSlider;
|
|
||||||
private Action fullAction;
|
|
||||||
private RenderTexture renderTexture;
|
|
||||||
private VideoPlayer videoPlayer;
|
|
||||||
private UISliderH slider;
|
|
||||||
|
|
||||||
private VisualElement VideoView => element.Q<VisualElement>("VideoView");
|
|
||||||
private VisualElement VideoController => element.Q<VisualElement>("VideoController");
|
|
||||||
private VisualElement Slider => element.Q<VisualElement>("Slider");
|
|
||||||
private Label Time => element.Q<Label>("Time");
|
|
||||||
private Button Play => element.Q<Button>("Play");
|
|
||||||
private Button Pause => element.Q<Button>("Pause");
|
|
||||||
private Button FullScreen => element.Q<Button>("FullScreen");
|
|
||||||
|
|
||||||
public UIVideoPlayPanel(VisualElement element, VisualElement canvas, VideoPlayer videoPlayer, Action fullAction = null) : base(element) {
|
|
||||||
this.videoPlayer = videoPlayer;
|
|
||||||
this.fullAction = fullAction;
|
|
||||||
|
|
||||||
int width = (int)element.parent.resolvedStyle.width;
|
|
||||||
int height = (int)element.parent.resolvedStyle.height;
|
|
||||||
renderTexture = new RenderTexture(width, height, 0);
|
|
||||||
Background background = Background.FromRenderTexture(renderTexture);
|
|
||||||
VideoView.style.backgroundImage = new StyleBackground(background);
|
|
||||||
|
|
||||||
Play.clicked += Play_clicked;
|
|
||||||
Pause.clicked += Pause_clicked;
|
|
||||||
FullScreen.clicked += FullScreen_clicked;
|
|
||||||
|
|
||||||
VideoView.RegisterCallback<PointerDownEvent>((evt) => showTime = 5);
|
|
||||||
VideoController.RegisterCallback<PointerDownEvent>((evt) => showTime = 5);
|
|
||||||
|
|
||||||
Slider.RegisterCallback<PointerDownEvent>((evt) => isDownSlider = true);
|
|
||||||
Slider.RegisterCallback<PointerUpEvent>((evt) => isDownSlider = false);
|
|
||||||
Slider.RegisterCallback<PointerLeaveEvent>((evt) => isDownSlider = false);
|
|
||||||
|
|
||||||
slider = new UISliderH(element, canvas);
|
|
||||||
slider.ValueChanged += Slider_SlidingValueChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 启用 </summary>
|
|
||||||
public void Enable(string url) {
|
|
||||||
videoPlayer.url = url; Enable();
|
|
||||||
}
|
|
||||||
/// <summary> 启用 </summary>
|
|
||||||
public void Enable() {
|
|
||||||
UpdateRenderTexture();
|
|
||||||
videoPlayer.targetTexture = renderTexture;
|
|
||||||
if (videoPlayer.isPlaying) { Play_clicked(); }
|
|
||||||
else { Pause_clicked(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 更新 </summary>
|
|
||||||
public void Update() {
|
|
||||||
if (videoPlayer == null) { return; }
|
|
||||||
showTime -= UnityEngine.Time.deltaTime;
|
|
||||||
Visibility visibility = showTime > 0 ? Visibility.Visible : Visibility.Hidden;
|
|
||||||
VideoController.style.visibility = visibility;
|
|
||||||
//进度条
|
|
||||||
float value = (float)videoPlayer.frame / (float)videoPlayer.frameCount;
|
|
||||||
if (!isDownSlider) { slider.UpdateValue(value, false); }
|
|
||||||
//播放时间
|
|
||||||
string clockTime = TimeSpan.FromSeconds(videoPlayer.clockTime).ToString(@"mm\:ss");
|
|
||||||
string length = TimeSpan.FromSeconds(videoPlayer.length).ToString(@"mm\:ss");
|
|
||||||
Time.text = clockTime + "/" + length;
|
|
||||||
}
|
|
||||||
/// <summary> 播放 </summary>
|
|
||||||
public void Play_clicked() {
|
|
||||||
if (videoPlayer == null) { return; }
|
|
||||||
videoPlayer.Play(); showTime = 5;
|
|
||||||
Play.style.display = DisplayStyle.None;
|
|
||||||
Pause.style.display = DisplayStyle.Flex;
|
|
||||||
}
|
|
||||||
/// <summary> 暂停 </summary>
|
|
||||||
public void Pause_clicked() {
|
|
||||||
if (videoPlayer == null) { return; }
|
|
||||||
videoPlayer.Pause();
|
|
||||||
Play.style.display = DisplayStyle.Flex;
|
|
||||||
Pause.style.display = DisplayStyle.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 更新渲染纹理 </summary>
|
|
||||||
private void UpdateRenderTexture() {
|
|
||||||
int width = (int)element.parent.resolvedStyle.width;
|
|
||||||
int height = (int)element.parent.resolvedStyle.height;
|
|
||||||
if (renderTexture.width == width && renderTexture.height == height) { return; }
|
|
||||||
renderTexture.Release();
|
|
||||||
renderTexture = new RenderTexture(width, height, 0);
|
|
||||||
Background background = Background.FromRenderTexture(renderTexture);
|
|
||||||
VideoView.style.backgroundImage = new StyleBackground(background);
|
|
||||||
}
|
|
||||||
/// <summary> 全屏 </summary>
|
|
||||||
private void FullScreen_clicked() {
|
|
||||||
fullAction?.Invoke();
|
|
||||||
}
|
|
||||||
/// <summary> 进度条更新 </summary>
|
|
||||||
private void Slider_SlidingValueChanged(float obj) {
|
|
||||||
if (videoPlayer == null) { return; }
|
|
||||||
videoPlayer.frame = (long)obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 00c04ca4ef821d0469a77408648f5ff2
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 1a20e449063139b4ea0d19bd0677c7d1
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 5003b2a36519747449a4b6e4d7e5f56e
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 消息页面1
|
|
||||||
/// </summary>
|
|
||||||
public class UIMessage1 : ModuleUIPanel {
|
|
||||||
|
|
||||||
public Label Content => Q<Label>("Content");
|
|
||||||
|
|
||||||
public UIMessage1(VisualElement element) : base(element) { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置消息内容
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="active"></param>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
public void Settings(bool active, string value = "") {
|
|
||||||
element.EnableInClassList("document-page-hide", !active);
|
|
||||||
Content.text = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c0d9cdd61f07fb14a93de29e68c71787
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 消息页面2
|
|
||||||
/// </summary>
|
|
||||||
public class UIMessage2 : ModuleUIPanel {
|
|
||||||
|
|
||||||
private Action callback;
|
|
||||||
|
|
||||||
public Label Content => Q<Label>("Content");
|
|
||||||
public Button Button => Q<Button>("Button");
|
|
||||||
|
|
||||||
public UIMessage2(VisualElement element) : base(element) {
|
|
||||||
Button.clicked += () => { callback?.Invoke(); Settings(false); };
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Settings(bool active) {
|
|
||||||
element.EnableInClassList("document-page-hide", !active);
|
|
||||||
callback = null;
|
|
||||||
}
|
|
||||||
public void Settings(bool active, string value = "", Action callback = null) {
|
|
||||||
element.EnableInClassList("document-page-hide", !active);
|
|
||||||
Content.text = value;
|
|
||||||
this.callback = callback;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d21953f5fb6c41e40b2df711d80a42b3
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user