(client) chore:修复子弹属性错误,人物属性错误,侧边消息堆叠错误
This commit is contained in:
@ -242,6 +242,51 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 613797070}
|
m_Father: {fileID: 613797070}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &178349935
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 178349937}
|
||||||
|
- component: {fileID: 178349936}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: UIMessage
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &178349936
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 178349935}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 067858a7493442389cc3f7624b83e1f3, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
isGlobal: 1
|
||||||
|
--- !u!4 &178349937
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 178349935}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -120.0895, y: 121.65131, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &613797067
|
--- !u!1 &613797067
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -519,6 +564,9 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 7a743a0b262a45d8bb1203e776cbbe00, type: 3}
|
m_Script: {fileID: 11500000, guid: 7a743a0b262a45d8bb1203e776cbbe00, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
testMessage: "\u6D4B\u8BD5\u6D88\u606F"
|
||||||
|
displayCategory: 4
|
||||||
|
messsageColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
--- !u!4 &1223523588
|
--- !u!4 &1223523588
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -939,3 +987,4 @@ SceneRoots:
|
|||||||
- {fileID: 1089547762}
|
- {fileID: 1089547762}
|
||||||
- {fileID: 1245790017}
|
- {fileID: 1245790017}
|
||||||
- {fileID: 593350052837672451}
|
- {fileID: 593350052837672451}
|
||||||
|
- {fileID: 178349937}
|
||||||
|
@ -6,9 +6,17 @@ namespace Entity
|
|||||||
{
|
{
|
||||||
public class Bullet : Entity
|
public class Bullet : Entity
|
||||||
{
|
{
|
||||||
public Entity bulletSource;
|
public Entity bulletSource { get; private set; }
|
||||||
public float lifeTime = 10;
|
public float lifeTime = 10;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void SetBulletSource(Entity source)
|
||||||
|
{
|
||||||
|
bulletSource = source;
|
||||||
|
attributes.attack = source.attributes.attack;
|
||||||
|
}
|
||||||
|
|
||||||
public override void SetTarget(Vector3 pos)
|
public override void SetTarget(Vector3 pos)
|
||||||
{
|
{
|
||||||
base.SetTarget(pos);
|
base.SetTarget(pos);
|
||||||
|
@ -7,6 +7,24 @@ namespace Entity
|
|||||||
{
|
{
|
||||||
public class Character : LivingEntity
|
public class Character : LivingEntity
|
||||||
{
|
{
|
||||||
|
public override Attributes defAttributes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var def = base.defAttributes;
|
||||||
|
var weaponDef = GetCurrentWeapon()?.Attributes;
|
||||||
|
if (weaponDef != null)
|
||||||
|
{
|
||||||
|
weaponDef.health = def.health;
|
||||||
|
weaponDef.moveSpeed = def.moveSpeed;
|
||||||
|
return weaponDef;
|
||||||
|
}
|
||||||
|
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private int _currentSelected; // 私有字段用于存储实际值
|
private int _currentSelected; // 私有字段用于存储实际值
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -62,12 +62,14 @@ namespace Entity
|
|||||||
protected set => _attribute = value;
|
protected set => _attribute = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Attributes _baseAttributes;
|
|
||||||
public virtual Attributes baseAttributes
|
public virtual Attributes baseAttributes => defAttributes;
|
||||||
|
private Attributes _defAttributes;
|
||||||
|
public virtual Attributes defAttributes
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _baseAttributes ??= entityDef == null ? new Attributes() : new Attributes(entityDef.attributes);
|
return _defAttributes ??= entityDef == null ? new Attributes() : new Attributes(entityDef.attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,6 +394,8 @@ namespace Entity
|
|||||||
{
|
{
|
||||||
_attackTimer = weaponResource.AttackCooldown;
|
_attackTimer = weaponResource.AttackCooldown;
|
||||||
_attackDetectionTime = weaponResource.AttackDetectionTime;
|
_attackDetectionTime = weaponResource.AttackDetectionTime;
|
||||||
|
currentAttackWeapon = weaponResource;
|
||||||
|
|
||||||
if (weaponResource.AttackAnimationTime > 0)
|
if (weaponResource.AttackAnimationTime > 0)
|
||||||
{
|
{
|
||||||
TemporaryAnimationManager.Instance.GenerateTemporaryAnimation(
|
TemporaryAnimationManager.Instance.GenerateTemporaryAnimation(
|
||||||
@ -409,14 +413,13 @@ namespace Entity
|
|||||||
HideCurrentBodyTexture();
|
HideCurrentBodyTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentAttackWeapon = weaponResource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetBodyTexture(EntityState state, Orientation orientation)
|
public void SetBodyTexture(EntityState state, Orientation orientation)
|
||||||
{
|
{
|
||||||
HideCurrentBodyTexture();
|
HideCurrentBodyTexture();
|
||||||
if (IsAttacking && !currentAttackWeapon.UseEntityAttackAnimation)
|
if (IsAttacking && currentAttackWeapon is { UseEntityAttackAnimation: false })
|
||||||
return;
|
return;
|
||||||
if (bodyNodes.TryGetValue(state, out var showStateNode))
|
if (bodyNodes.TryGetValue(state, out var showStateNode))
|
||||||
{
|
{
|
||||||
@ -462,7 +465,6 @@ namespace Entity
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hit = from.attributes.attack - attributes.defense;
|
var hit = from.attributes.attack - attributes.defense;
|
||||||
if (hit < 0)
|
if (hit < 0)
|
||||||
hit = from.attributes.attack / 100;
|
hit = from.attributes.attack / 100;
|
||||||
|
@ -482,7 +482,8 @@ namespace Managers
|
|||||||
|
|
||||||
if (result && result.entity is Bullet bullet)
|
if (result && result.entity is Bullet bullet)
|
||||||
{
|
{
|
||||||
bullet.bulletSource = source;
|
bullet.SetBulletSource(source);
|
||||||
|
|
||||||
if (source) bullet.affiliation = source.affiliation;
|
if (source) bullet.affiliation = source.affiliation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Base;
|
|
||||||
using Data;
|
using Data;
|
||||||
using Prefab;
|
using Prefab;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -26,7 +25,7 @@ namespace Managers
|
|||||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisplayMessage(string message, Data.PromptDisplayCategory type,Color? color=null)
|
public void DisplayMessage(string message, PromptDisplayCategory type,Color? color=null)
|
||||||
{
|
{
|
||||||
if (!_canvas)
|
if (!_canvas)
|
||||||
{
|
{
|
||||||
@ -43,7 +42,8 @@ namespace Managers
|
|||||||
TemporaryAnimationManager.Instance.GenerateTemporaryAnimation(message,
|
TemporaryAnimationManager.Instance.GenerateTemporaryAnimation(message,
|
||||||
Program.Instance.FocusedEntity.Position, 5); // 5秒显示时间
|
Program.Instance.FocusedEntity.Position, 5); // 5秒显示时间
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PromptDisplayCategory.Default:
|
||||||
case PromptDisplayCategory.PassiveHint:
|
case PromptDisplayCategory.PassiveHint:
|
||||||
if (_passiveHintContainer == null)
|
if (_passiveHintContainer == null)
|
||||||
{
|
{
|
||||||
@ -55,22 +55,21 @@ namespace Managers
|
|||||||
var hintTextInstance = Instantiate(_temporaryAnimatorTextPrefab, _passiveHintContainer.transform);
|
var hintTextInstance = Instantiate(_temporaryAnimatorTextPrefab, _passiveHintContainer.transform);
|
||||||
|
|
||||||
// 确保它在Layout Group中正确显示
|
// 确保它在Layout Group中正确显示
|
||||||
var hintTextRect = hintTextInstance.GetComponent<RectTransform>();
|
// var hintTextRect = hintTextInstance.GetComponent<RectTransform>();
|
||||||
|
|
||||||
// 如果temporaryAnimatorText有ContentSizeFitter,这里可能不需要设置sizeDelta,但为了LayoutGroup能识别,可以添加LayoutElement
|
// 如果temporaryAnimatorText有ContentSizeFitter,这里可能不需要设置sizeDelta,但为了LayoutGroup能识别,可以添加LayoutElement
|
||||||
var layoutElement = hintTextInstance.GetComponent<LayoutElement>();
|
// var layoutElement = hintTextInstance.GetComponent<LayoutElement>();
|
||||||
if (layoutElement == null) layoutElement = hintTextInstance.gameObject.AddComponent<LayoutElement>();
|
// if (layoutElement == null) layoutElement = hintTextInstance.gameObject.AddComponent<LayoutElement>();
|
||||||
layoutElement.minHeight = 30; // 最小高度
|
// layoutElement.minHeight = 30; // 最小高度
|
||||||
layoutElement.preferredWidth = _passiveHintContainer.sizeDelta.x; // 适应容器的宽度
|
// layoutElement.preferredWidth = _passiveHintContainer.sizeDelta.x; // 适应容器的宽度
|
||||||
|
|
||||||
// 设置字体样式
|
// 设置字体样式
|
||||||
var hintTmpText = hintTextInstance.GetComponent<TMP_Text>();
|
var hintTmpText = hintTextInstance.text;
|
||||||
if (hintTmpText != null)
|
if (hintTmpText)
|
||||||
{
|
{
|
||||||
hintTmpText.fontSize = 24; // 较小的字体
|
hintTmpText.fontSize = 24; // 较小的字体
|
||||||
hintTmpText.alignment = TextAlignmentOptions.TopLeft; // 左上对齐
|
hintTmpText.alignment = TextAlignmentOptions.TopLeft; // 左上对齐
|
||||||
hintTmpText.enableAutoSizing = false; // 关闭自动调整字体,保持统一
|
hintTmpText.enableAutoSizing = false; // 关闭自动调整字体,保持统一
|
||||||
hintTmpText.SetText(message); // 先设置文本,确保布局计算正确
|
|
||||||
if(color.HasValue)
|
if(color.HasValue)
|
||||||
hintTmpText.color = color.Value;
|
hintTmpText.color = color.Value;
|
||||||
}
|
}
|
||||||
@ -106,7 +105,7 @@ namespace Managers
|
|||||||
// textInstance.lifeTime 可以在 Init 方法内部设置,如果 Init 没有提供参数,这里就无法直接设置。
|
// textInstance.lifeTime 可以在 Init 方法内部设置,如果 Init 没有提供参数,这里就无法直接设置。
|
||||||
// 假设 Init 已经处理好生命周期。
|
// 假设 Init 已经处理好生命周期。
|
||||||
break;
|
break;
|
||||||
case PromptDisplayCategory.Default:
|
|
||||||
break;
|
break;
|
||||||
case PromptDisplayCategory.FocusedEntityChatBubble:
|
case PromptDisplayCategory.FocusedEntityChatBubble:
|
||||||
break;
|
break;
|
||||||
@ -186,7 +185,7 @@ namespace Managers
|
|||||||
_passiveHintContainer.anchorMin = new Vector2(0, 0.5f);
|
_passiveHintContainer.anchorMin = new Vector2(0, 0.5f);
|
||||||
_passiveHintContainer.anchorMax = new Vector2(0, 0.5f);
|
_passiveHintContainer.anchorMax = new Vector2(0, 0.5f);
|
||||||
_passiveHintContainer.pivot = new Vector2(0, 0.5f); // 锚点和枢轴都在左中
|
_passiveHintContainer.pivot = new Vector2(0, 0.5f); // 锚点和枢轴都在左中
|
||||||
_passiveHintContainer.anchoredPosition = new Vector2(100, 0); // 从左边距100(示例值),Y轴中心
|
_passiveHintContainer.anchoredPosition = new Vector2(0, 0); // 从左边距100(示例值),Y轴中心
|
||||||
_passiveHintContainer.sizeDelta = new Vector2(400, 600); // 示例宽度和高度
|
_passiveHintContainer.sizeDelta = new Vector2(400, 600); // 示例宽度和高度
|
||||||
|
|
||||||
// 添加VerticalLayoutGroup
|
// 添加VerticalLayoutGroup
|
||||||
@ -194,13 +193,8 @@ namespace Managers
|
|||||||
layoutGroup.childAlignment = TextAnchor.UpperLeft; // 子元素靠左上排布
|
layoutGroup.childAlignment = TextAnchor.UpperLeft; // 子元素靠左上排布
|
||||||
layoutGroup.spacing = 10; // 消息之间的间距
|
layoutGroup.spacing = 10; // 消息之间的间距
|
||||||
layoutGroup.padding = new RectOffset(10, 10, 10, 10); // 容器内边距
|
layoutGroup.padding = new RectOffset(10, 10, 10, 10); // 容器内边距
|
||||||
|
layoutGroup.childControlHeight = true;
|
||||||
// 添加ContentSizeFitter,以便容器根据内容调整大小 (可选,根据实际需求)
|
layoutGroup.childForceExpandHeight = false;
|
||||||
// fitter 会自动调整自身大小以适应子内容
|
|
||||||
var fitter = containerGO.AddComponent<ContentSizeFitter>();
|
|
||||||
fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
|
|
||||||
fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,12 +46,13 @@ namespace Prefab
|
|||||||
var currentAnimationTime = Mathf.Min(_timer, lifeTime);
|
var currentAnimationTime = Mathf.Min(_timer, lifeTime);
|
||||||
var shouldDestroy = _timer >= lifeTime; // 判断是否达到销毁条件
|
var shouldDestroy = _timer >= lifeTime; // 判断是否达到销毁条件
|
||||||
|
|
||||||
// 调用委托获取X和Y轴的偏移量,如果委托未设置则默认为0
|
// 调用委托获取X和Y轴的偏移量,如果委托未设置则使用当前位置的对应轴值
|
||||||
var xOffset = GetXPosition?.Invoke(currentAnimationTime) ?? 0f;
|
// 有委托时:原始位置 + 偏移量;无委托时:当前位置的对应轴值
|
||||||
var yOffset = GetYPosition?.Invoke(currentAnimationTime) ?? 0f;
|
var xPos = GetXPosition != null ? _originalPosition.x + GetXPosition.Invoke(currentAnimationTime) : transform.localPosition.x;
|
||||||
|
var yPos = GetYPosition != null ? _originalPosition.y + GetYPosition.Invoke(currentAnimationTime) : transform.localPosition.y;
|
||||||
// 应用偏移量到物体位置,保持原始Z轴不变
|
|
||||||
transform.localPosition = _originalPosition + new Vector3(xOffset, yOffset, 0);
|
// 应用计算后的值到物体位置,保持原始Z轴不变
|
||||||
|
transform.localPosition = new Vector3(xPos, yPos, _originalPosition.z);
|
||||||
|
|
||||||
// 如果达到销毁条件,在完成最后一帧动画更新后销毁物体
|
// 如果达到销毁条件,在完成最后一帧动画更新后销毁物体
|
||||||
if (shouldDestroy)
|
if (shouldDestroy)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Data;
|
||||||
using Managers;
|
using Managers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -6,6 +7,10 @@ namespace Test
|
|||||||
{
|
{
|
||||||
public class TempAnimationTest:MonoBehaviour
|
public class TempAnimationTest:MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public string testMessage="测试消息";
|
||||||
|
public PromptDisplayCategory displayCategory;
|
||||||
|
public Color messsageColor = Color.white;
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -21,7 +26,7 @@ namespace Test
|
|||||||
|
|
||||||
if (Input.GetMouseButtonDown(1))
|
if (Input.GetMouseButtonDown(1))
|
||||||
{
|
{
|
||||||
TemporaryAnimationManager.Instance.GenerateTemporaryAnimationUI("1,2,3,4,5,1,2,3,4,5",Input.mousePosition);
|
MessageManager.Instance.DisplayMessage(testMessage,displayCategory,messsageColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user