mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 01:17:12 +08:00
(client) feat:实现技能树界面,实现地图生成器,实现维度指定,实现规则瓦片定义,实现逃跑逻辑,实现消息定义,实现武器动画,实现受击动画 fix: 修复单攻击子弹击中多个目标,修复人物属性计算错误 (#56)
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/56
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
namespace Data
|
||||
{
|
||||
public enum BuildingType
|
||||
{
|
||||
Static,
|
||||
Dynamic,
|
||||
}
|
||||
public class BuildingDef : EntityDef
|
||||
{
|
||||
BuildingType buildingType=BuildingType.Static;
|
||||
public float slowDown = 0f;
|
||||
public TileDef tile;
|
||||
}
|
||||
}
|
||||
8
Client/Assets/Scripts/Data/DimensionDef.cs
Normal file
8
Client/Assets/Scripts/Data/DimensionDef.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Data
|
||||
{
|
||||
public class DimensionDef:Define
|
||||
{
|
||||
public MapGeneratorDef[] mapGenerators;
|
||||
|
||||
}
|
||||
}
|
||||
3
Client/Assets/Scripts/Data/DimensionDef.cs.meta
Normal file
3
Client/Assets/Scripts/Data/DimensionDef.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 922ffbdd4df44760ae4d922dc5616ecd
|
||||
timeCreated: 1758074675
|
||||
@@ -227,11 +227,11 @@ namespace Data
|
||||
|
||||
public class DrawNodeDef : Define
|
||||
{
|
||||
public List<string> textures = new();
|
||||
public List<DrawNodeDef> nodes = new();
|
||||
public string[] textures;
|
||||
public DrawNodeDef[] nodes;
|
||||
public string nodeName;
|
||||
public Vector2 position = new(0, 0);
|
||||
public float FPS = 1f;
|
||||
public float FPS = 5f;
|
||||
|
||||
public override bool Init(XElement xmlDef)
|
||||
{
|
||||
@@ -239,7 +239,7 @@ namespace Data
|
||||
|
||||
nodeName = xmlDef.Attribute("name")?.Value ?? "noName";
|
||||
position = StringToVector(xmlDef.Attribute("position")?.Value ?? "(0 0)");
|
||||
FPS = float.TryParse(xmlDef.Attribute("FPS")?.Value, out var result) ? result : 1.0f;
|
||||
FPS = float.TryParse(xmlDef.Attribute("FPS")?.Value, out var result) ? result : 5.0f;
|
||||
return false;
|
||||
}
|
||||
public Vector2 StringToVector(string vectorDef)
|
||||
@@ -262,35 +262,6 @@ namespace Data
|
||||
|
||||
return Vector2.zero;
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算动画执行一个周期的总时间(包括子对象)。
|
||||
/// 如果自身没有纹理,自身动画时间为0。
|
||||
/// 总周期取自身动画时间和所有子动画周期中的最大值。
|
||||
/// </summary>
|
||||
/// <returns>动画执行一个周期的总时间(秒)。</returns>
|
||||
public float GetAnimationCycleDuration()
|
||||
{
|
||||
if (FPS < 0.01)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
float ownDuration = 0f;
|
||||
// 计算当前节点自身的动画周期时间
|
||||
// 由于 Init 方法已经处理了 FPS 的校验,FPS 保证大于 0
|
||||
if (textures.Count > 0)
|
||||
{
|
||||
ownDuration = textures.Count / FPS;
|
||||
}
|
||||
// 递归计算所有子节点的动画周期,并取其中最长的
|
||||
float maxChildDuration = 0f;
|
||||
foreach (var childNode in nodes)
|
||||
{
|
||||
float childDuration = childNode.GetAnimationCycleDuration();
|
||||
maxChildDuration = Math.Max(maxChildDuration, childDuration);
|
||||
}
|
||||
// 整个 DrawNodeDef 的动画周期是自身动画周期和所有子动画周期中的最大值
|
||||
return Math.Max(ownDuration, maxChildDuration);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,6 @@ namespace Data
|
||||
public class EventDef : Define
|
||||
{
|
||||
public string workClass;
|
||||
public string value;
|
||||
public string parameter;
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,9 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class HediffCompDef:Define
|
||||
public class HediffCompDef : Define
|
||||
{
|
||||
public Type compClass;
|
||||
public override bool Init(XElement xmlDef)
|
||||
{
|
||||
base.Init(xmlDef);
|
||||
var name = xmlDef.Attribute("class")?.Value??"";
|
||||
compClass=Type.GetType(name);
|
||||
return true;
|
||||
}
|
||||
public string compClass;
|
||||
public string properties;
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,7 @@ namespace Data
|
||||
public int wCount;
|
||||
public int hCount;
|
||||
public int pixelsPerUnit = 16;
|
||||
|
||||
public override bool Init(XElement xmlDef)
|
||||
{
|
||||
base.Init(xmlDef);
|
||||
return false;
|
||||
}
|
||||
public bool flipX = false;
|
||||
public bool flipY = false;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace Data
|
||||
}
|
||||
public class ItemDef : Define
|
||||
{
|
||||
public float FPS = 0;
|
||||
public float FPS = 3;
|
||||
public string[] textures;
|
||||
public ItemRarity rarity = ItemRarity.Common;
|
||||
public int maxStack = 10; // 最大堆叠数量,默认为10
|
||||
|
||||
@@ -1,50 +1,52 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Tilemaps;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class TileDef : Define
|
||||
{
|
||||
public ImageDef texture;
|
||||
public string name = "";
|
||||
public Tile.ColliderType collider = Tile.ColliderType.None;
|
||||
|
||||
public override bool Init(XElement xmlDef)
|
||||
{
|
||||
base.Init(xmlDef);
|
||||
name = defName;
|
||||
return false;
|
||||
}
|
||||
public string texture;
|
||||
public RuleTileRuleDef[] rules;
|
||||
}
|
||||
|
||||
public class TileMappingTableDef : Define
|
||||
|
||||
public class RuleTileRuleDef : Define
|
||||
{
|
||||
public Dictionary<string, string> tileDict = new();
|
||||
public override bool Init(XElement xmlDef)
|
||||
public enum NeighborConditionType
|
||||
{
|
||||
base.Init(xmlDef);
|
||||
// 清空字典以确保没有遗留数据
|
||||
tileDict.Clear();
|
||||
// 检查 xmlDef 是否为空
|
||||
if (xmlDef == null)
|
||||
return false;
|
||||
foreach (var element in xmlDef.Elements())
|
||||
Any, // 可以是任何瓦片
|
||||
This, // 必须是当前 Rule Tile 自身 (用于[4]位置)
|
||||
NotThis, // 不能是当前 Rule Tile 自身
|
||||
}
|
||||
|
||||
public NeighborConditionType[] neighborConditions = new NeighborConditionType[8];
|
||||
|
||||
public RuleTile.TilingRuleOutput.OutputSprite outputType = RuleTile.TilingRuleOutput.OutputSprite.Single;
|
||||
public RuleTile.TilingRuleOutput.Transform transform = RuleTile.TilingRuleOutput.Transform.Fixed;
|
||||
|
||||
// --- 输出碰撞器类型 (Output Collider Type) ---
|
||||
// 如果需要为该规则设置特定的碰撞器类型
|
||||
public Tile.ColliderType outputCollider = Tile.ColliderType.None;
|
||||
|
||||
// --- 概率 (Probability) / Perlin Offset ---
|
||||
// 决定此规则被选中的可能性,或者用于Perlin噪声偏移
|
||||
public float chance = 0.5f; // 默认为100%
|
||||
|
||||
// --- 动画精灵 (Animation Sprites) ---
|
||||
// 如果 outputType 是 Animation,这里可以定义一系列动画帧的纹理路径或名称
|
||||
public List<string> animationTextures;
|
||||
public float animationSpeed = 1f;
|
||||
|
||||
// 构造函数或其他辅助方法
|
||||
public RuleTileRuleDef()
|
||||
{
|
||||
for (int i = 0; i < neighborConditions.Length; i++)
|
||||
{
|
||||
// 获取子元素的名称作为键
|
||||
var key = element.Name.LocalName;
|
||||
// 获取子元素的 value 属性作为值
|
||||
var value = element.Attribute("value")?.Value;
|
||||
// 检查 value 是否存在
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
tileDict[key] = value;
|
||||
}
|
||||
neighborConditions[i] = NeighborConditionType.Any;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
9
Client/Assets/Scripts/Data/MapGeneratorDef.cs
Normal file
9
Client/Assets/Scripts/Data/MapGeneratorDef.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Data
|
||||
{
|
||||
public class MapGeneratorDef:Define
|
||||
{
|
||||
public string workClass;
|
||||
public string value;
|
||||
}
|
||||
|
||||
}
|
||||
3
Client/Assets/Scripts/Data/MapGeneratorDef.cs.meta
Normal file
3
Client/Assets/Scripts/Data/MapGeneratorDef.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f00902a97fe47e799ad91e0219c42f7
|
||||
timeCreated: 1758020914
|
||||
@@ -3,6 +3,8 @@ namespace Data
|
||||
public class SkillTreeDef:Define
|
||||
{
|
||||
public string tag="Default";
|
||||
public string position;
|
||||
public int cost = 10;
|
||||
public AffiliationDef faction;
|
||||
public SkillTreeDef[] prerequisites;
|
||||
public WeaponDef[] unlockedWeapons;
|
||||
|
||||
@@ -10,8 +10,9 @@ namespace Data
|
||||
public WeaponType type = WeaponType.Melee;
|
||||
public AttributesDef attributes;
|
||||
public BulletDef bullet;
|
||||
public DrawNodeDef attackAnimation;
|
||||
public string[] attackAnimation;
|
||||
public float attackDetectionTime = 0;
|
||||
public bool useEntityAttackAnimation = true;
|
||||
public WeaponDef() // 构造函数,用于设置武器的默认属性
|
||||
{
|
||||
maxStack = 1; // 武器默认最大堆叠为1
|
||||
|
||||
Reference in New Issue
Block a user