(client) feat:添加设置类,子弹添加敌我识别; chore:修改了右键菜单的初始化方式为独立创建,加载定义报错提供更多信息,动画加载出错也返回默认序列。
This commit is contained in:
@ -5,21 +5,27 @@ using UnityEngine;
|
||||
|
||||
namespace Base
|
||||
{
|
||||
|
||||
public class Launcher : MonoBehaviour
|
||||
{
|
||||
public GameObject loadingUI;
|
||||
public Gradient progressBar; // 渐变色条
|
||||
public TMP_Text describeText; // 描述文本
|
||||
|
||||
|
||||
public float duration = 0.5f; // 过渡时间
|
||||
public float fadeDuration = 2f; // 不透明度渐隐的时间
|
||||
private float _currentProgress = 0f; // 当前进度
|
||||
private float duration = 0.5f; // 过渡时间
|
||||
|
||||
private Color textColor;
|
||||
|
||||
private string[] _loadingSteps =
|
||||
|
||||
private readonly string[] _loadingSteps =
|
||||
{
|
||||
"初始化日志", "正在载入定义", "正在加载图片资源", "正在切割瓦片", "正在加载区分派系",
|
||||
"正在加载物品"
|
||||
};
|
||||
|
||||
public float progress
|
||||
public float Progress
|
||||
{
|
||||
set
|
||||
{
|
||||
@ -33,12 +39,32 @@ namespace Base
|
||||
progressBar.color2 = Color.white;
|
||||
progressBar.color1 = Color.Lerp(Color.black, Color.white, (value - 0.5f) * 2);
|
||||
}
|
||||
|
||||
progressBar.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public float Opacity
|
||||
{
|
||||
set
|
||||
{
|
||||
var alpha = (byte)(value * 255);
|
||||
progressBar.color1.a = alpha;
|
||||
progressBar.color2.a = alpha;
|
||||
describeText.color = value > 0.5f ? Color.Lerp(new Color(1, 1, 1, 0), textColor, (value - 0.5f) * 2) : new Color(1, 1, 1, 0);
|
||||
progressBar.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Base.Setting.Instance.Init();
|
||||
#if !DEBUG
|
||||
duration = Base.Setting.Instance.progressStepDuration;
|
||||
fadeDuration = Base.Setting.Instance.exitAnimationDuration;
|
||||
#endif
|
||||
loadingUI.SetActive(true);
|
||||
textColor = describeText.color;
|
||||
StartCoroutine(LoadAllManagers());
|
||||
}
|
||||
|
||||
@ -81,7 +107,10 @@ namespace Base
|
||||
|
||||
// 加载完成后的处理
|
||||
describeText.text = "加载完成!";
|
||||
progress = 1f;
|
||||
Progress = 1f;
|
||||
|
||||
// 开始渐隐效果
|
||||
yield return FadeOutProgressBar();
|
||||
}
|
||||
|
||||
private IEnumerator SmoothTransitionTo(float targetProgress)
|
||||
@ -93,12 +122,29 @@ namespace Base
|
||||
{
|
||||
elapsedTime += Time.deltaTime;
|
||||
var t = Mathf.SmoothStep(0f, 1f, elapsedTime / duration); // 使用 SmoothStep 实现平滑过渡
|
||||
progress = Mathf.Lerp(startProgress, targetProgress, t);
|
||||
Progress = Mathf.Lerp(startProgress, targetProgress, t);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// 确保最终进度达到目标值
|
||||
progress = targetProgress;
|
||||
Progress = targetProgress;
|
||||
}
|
||||
|
||||
private IEnumerator FadeOutProgressBar()
|
||||
{
|
||||
var elapsedTime = 0f;
|
||||
|
||||
while (elapsedTime < fadeDuration)
|
||||
{
|
||||
elapsedTime += Time.deltaTime;
|
||||
var t = Mathf.SmoothStep(0f, 1f, elapsedTime / fadeDuration); // 使用 SmoothStep 实现平滑渐隐
|
||||
Opacity = 1f - t; // 不透明度从 1 到 0
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// 确保最终不透明度为 0
|
||||
Opacity = 0f;
|
||||
loadingUI.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Prefab;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Base
|
||||
{
|
||||
public class RightMenu : Utils.MonoSingleton<RightMenu>
|
||||
{
|
||||
public RightMenuPrefab rightMenuPrefab;
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
set
|
||||
{
|
||||
rightMenuPrefab.transform.position = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return rightMenuPrefab.transform.position;
|
||||
}
|
||||
}
|
||||
public void Show()
|
||||
{
|
||||
rightMenuPrefab.Show();
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
rightMenuPrefab.Hide();
|
||||
}
|
||||
public void Init(List<(string name, UnityAction callback)> buttons)
|
||||
{
|
||||
rightMenuPrefab.Init(buttons);
|
||||
}
|
||||
protected override void OnStart()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f6fd5ff82ab4ce4aae8dd41118277f8
|
90
Client/Assets/Scripts/Base/Setting.cs
Normal file
90
Client/Assets/Scripts/Base/Setting.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Base
|
||||
{
|
||||
|
||||
|
||||
public class Setting : Utils.Singleton<Setting>
|
||||
{
|
||||
// 游戏设置数据类(用于序列化)
|
||||
[System.Serializable]
|
||||
public class GameSettings
|
||||
{
|
||||
public float progressStepDuration = 1f;
|
||||
public float exitAnimationDuration = 2f;
|
||||
public bool developerMode = false;
|
||||
public bool friendlyFire = false;
|
||||
public float globalVolume = 1.0f;
|
||||
public WindowMode currentWindowMode = WindowMode.Fullscreen;
|
||||
public Vector2Int windowResolution = new(1920, 1080);
|
||||
}
|
||||
|
||||
// 当前游戏设置
|
||||
public GameSettings CurrentSettings = new();
|
||||
|
||||
// 窗口模式枚举
|
||||
public enum WindowMode { Fullscreen, Windowed, Borderless }
|
||||
|
||||
// 常用分辨率选项
|
||||
public static readonly Vector2Int[] CommonResolutions = new Vector2Int[]
|
||||
{
|
||||
new(800, 600),
|
||||
new(1024, 768),
|
||||
new(1280, 720),
|
||||
new(1366, 768),
|
||||
new(1600, 900),
|
||||
new(1920, 1080),
|
||||
new(2560, 1440),
|
||||
new(3840, 2160)
|
||||
};
|
||||
|
||||
// 初始化加载设置
|
||||
public void Init()
|
||||
{
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(CurrentSettings);
|
||||
PlayerPrefs.SetString("GameSettings", json);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
public void LoadSettings()
|
||||
{
|
||||
if (PlayerPrefs.HasKey("GameSettings"))
|
||||
{
|
||||
string json = PlayerPrefs.GetString("GameSettings");
|
||||
CurrentSettings = JsonConvert.DeserializeObject<GameSettings>(json);
|
||||
}
|
||||
|
||||
// 应用加载的设置
|
||||
ApplyAudioSettings();
|
||||
ApplyWindowSettings();
|
||||
}
|
||||
|
||||
// 应用音频设置
|
||||
private void ApplyAudioSettings()
|
||||
{
|
||||
AudioListener.volume = Mathf.Clamp01(CurrentSettings.globalVolume);
|
||||
}
|
||||
|
||||
// 应用窗口设置
|
||||
private void ApplyWindowSettings()
|
||||
{
|
||||
switch (CurrentSettings.currentWindowMode)
|
||||
{
|
||||
case WindowMode.Fullscreen:
|
||||
Screen.SetResolution(CurrentSettings.windowResolution.x, CurrentSettings.windowResolution.y, FullScreenMode.FullScreenWindow);
|
||||
break;
|
||||
case WindowMode.Windowed:
|
||||
Screen.SetResolution(CurrentSettings.windowResolution.x, CurrentSettings.windowResolution.y, FullScreenMode.Windowed);
|
||||
break;
|
||||
case WindowMode.Borderless:
|
||||
Screen.SetResolution(CurrentSettings.windowResolution.x, CurrentSettings.windowResolution.y, FullScreenMode.MaximizedWindow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
Client/Assets/Scripts/Base/Setting.cs.meta
Normal file
3
Client/Assets/Scripts/Base/Setting.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9eb8b1554550478c85cc87558920ec6b
|
||||
timeCreated: 1755524879
|
@ -1,10 +1,16 @@
|
||||
using System;
|
||||
using Base;
|
||||
using Data;
|
||||
using Prefab;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity
|
||||
{
|
||||
public class Bullet : Entity
|
||||
{
|
||||
public Entity bulletSource;
|
||||
public float lifeTime = 10;
|
||||
|
||||
public override void SetTarget(Vector3 pos)
|
||||
{
|
||||
base.SetTarget(pos);
|
||||
@ -14,24 +20,47 @@ namespace Entity
|
||||
protected override void AutoBehave()
|
||||
{
|
||||
TryMove();
|
||||
lifeTime-=Time.deltaTime;
|
||||
if (lifeTime <= 0)
|
||||
{
|
||||
Kill();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
other.GetComponent<Entity>()?.OnHit(this);
|
||||
var entity = other.GetComponent<Entity>();
|
||||
if (!entity || entity == bulletSource) return;
|
||||
if (Managers.AffiliationManager.Instance.GetRelation(bulletSource.affiliation, entity.affiliation) != Relation.Friendly)
|
||||
{
|
||||
entity.OnHit(this);
|
||||
}
|
||||
else if (Setting.Instance.CurrentSettings.friendlyFire)
|
||||
{
|
||||
entity.OnHit(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
return; // 如果是友好关系且不允许友军伤害,则不处理
|
||||
}
|
||||
attributes.health -= 1;
|
||||
}
|
||||
|
||||
// 旋转对象到指定方向
|
||||
public static void RotateTransformToDirection(Transform transform, Vector3 targetDirection)
|
||||
{
|
||||
// 默认向上方向
|
||||
Vector3 upDirection = Vector3.up;
|
||||
// 确保目标方向不是零向量
|
||||
if (targetDirection == Vector3.zero)
|
||||
return;
|
||||
|
||||
// 计算旋转角度
|
||||
float angle = Mathf.Atan2(targetDirection.x, targetDirection.y) * Mathf.Rad2Deg;
|
||||
// 计算当前向上方向与目标方向之间的角度
|
||||
float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg;
|
||||
|
||||
// 设置旋转
|
||||
transform.rotation = Quaternion.Euler(0, 0, angle);
|
||||
// 调整角度,因为默认贴图向上是0度,而Atan2计算的是相对于x轴的角度
|
||||
angle -= 90f;
|
||||
|
||||
// 应用旋转
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, angle);
|
||||
}
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ namespace Entity
|
||||
var buttonDef = def.Values.First();
|
||||
Vector3 dir = Utils.MousePosition.GetWorldPosition();
|
||||
Managers.EntityManage.Instance.GenerateBulletEntity((BulletDef)buttonDef, Position,
|
||||
dir - Position);
|
||||
dir - Position, this);
|
||||
}
|
||||
}
|
||||
}
|
@ -149,7 +149,7 @@ namespace Entity
|
||||
{
|
||||
attributes = entityDef.attributes.Clone();
|
||||
aiTree = Utils.BehaviorTree.ConvertToAIBase(entityDef.behaviorTree);
|
||||
affiliation = entityDef.affiliation.defName;
|
||||
affiliation = entityDef.affiliation?.defName;
|
||||
InitBody(entityDef.drawingOrder);
|
||||
this.entityDef = entityDef;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Managers;
|
||||
using Prefab;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
@ -7,6 +8,8 @@ namespace Entity
|
||||
{
|
||||
public class Outline : MonoBehaviour
|
||||
{
|
||||
public RightMenuPrefab rightMenuPrefab;
|
||||
|
||||
public GameObject body;
|
||||
public SpriteRenderer outlineRenderer;
|
||||
public CapsuleCollider2D outlineCollider;
|
||||
@ -96,10 +99,7 @@ namespace Entity
|
||||
// 检测是否按下的是鼠标右键
|
||||
if (Input.GetMouseButtonDown(1)) // 鼠标右键对应的是按钮索引 1
|
||||
{
|
||||
var rightMenu = Base.RightMenu.Instance;
|
||||
rightMenu.Init(GetMenu());
|
||||
rightMenu.Position = Input.mousePosition;
|
||||
rightMenu.Show();
|
||||
RightMenuManager.GenerateRightMenu(GetMenu(), Input.mousePosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,14 @@ namespace Managers
|
||||
{
|
||||
return _affiliations[defName].defName;
|
||||
}
|
||||
|
||||
public Relation GetRelation(AffiliationDef affiliation1, AffiliationDef affiliation2)
|
||||
{
|
||||
if (affiliation1 == null || affiliation2 == null)
|
||||
{
|
||||
return Relation.Neutral; // 如果任一阵营不存在,返回中立关系
|
||||
}
|
||||
return GetRelation(affiliation1.defName, affiliation2.defName);
|
||||
}
|
||||
public Relation GetRelation(string factionName1, string factionName2)
|
||||
{
|
||||
// 如果查询的是同一个派系,默认是友好关系
|
||||
|
@ -158,20 +158,20 @@ namespace Managers
|
||||
{
|
||||
if (defRef.Item1 == null)
|
||||
{
|
||||
Debug.LogError("defRef.Item1 为 null!");
|
||||
Debug.LogError("被引用定义为 null!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (defRef.Item2 == null)
|
||||
{
|
||||
Debug.LogError("defRef.Item2 为 null!");
|
||||
Debug.LogError("被引用定义的字段引用为 null!");
|
||||
continue;
|
||||
}
|
||||
|
||||
var value = FindDefine(defRef.Item3.description, defRef.Item3.defName);
|
||||
if (value == null)
|
||||
{
|
||||
Debug.LogError($"FindDefine 返回 null: description={defRef.Item3.description}, defName={defRef.Item3.defName}");
|
||||
Debug.LogError($"未找到引用,出错的定义:定义类型:{defRef.Item1.GetType().Name}, 定义名:{defRef.Item1.defName} ; 类型:{defRef.Item3.description}, 定义名:{defRef.Item3.defName}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2,23 +2,25 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Base;
|
||||
using Entity;
|
||||
using Prefab;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
public class EntityManage : Utils.MonoSingleton<EntityManage>, ITick
|
||||
{
|
||||
public Dictionary<string, LinkedList<EntityPrefab>> factionEntities = new();
|
||||
|
||||
public EntityPrefab entityPrefab;
|
||||
|
||||
public EntityPrefab characterPrefab;
|
||||
public EntityPrefab buildingPrefab;
|
||||
public EntityPrefab bulletPrefab;
|
||||
|
||||
public EntityPrefab defaultEntityPrefab;
|
||||
|
||||
private Dictionary<string, Transform> layerCache = new Dictionary<string, Transform>();
|
||||
private List<Tuple<string, EntityPrefab>> pendingAdditions;
|
||||
private List<Tuple<string, EntityPrefab>> pendingAdditions = new();
|
||||
|
||||
public LinkedList<EntityPrefab> FindEntitiesByFaction(string factionKey)
|
||||
{
|
||||
@ -158,7 +160,7 @@ namespace Managers
|
||||
public void GenerateEntity(Data.EntityDef entityDef, Vector3 pos)
|
||||
{
|
||||
// 验证关键参数
|
||||
if (!entityPrefab)
|
||||
if (!characterPrefab)
|
||||
{
|
||||
Debug.LogError("entityPrefab is null! Assign a valid prefab.");
|
||||
GenerateDefaultEntity(pos);
|
||||
@ -177,7 +179,7 @@ namespace Managers
|
||||
|
||||
// 调用通用生成逻辑
|
||||
var result = GenerateEntityInternal(
|
||||
entityPrefab.gameObject,
|
||||
characterPrefab.gameObject,
|
||||
entityLevelTransform,
|
||||
pos,
|
||||
entityDef
|
||||
@ -224,7 +226,8 @@ namespace Managers
|
||||
/// <summary>
|
||||
/// 生成子弹实体(含方向设置)
|
||||
/// </summary>
|
||||
public void GenerateBulletEntity(Data.BulletDef bulletDef, Vector3 pos, Vector3 dir)
|
||||
public void GenerateBulletEntity(Data.BulletDef bulletDef, Vector3 pos, Vector3 dir,
|
||||
Entity.Entity source = null)
|
||||
{
|
||||
// 修正:检查正确的预制体 (bulletPrefab)
|
||||
if (!bulletPrefab)
|
||||
@ -252,6 +255,11 @@ namespace Managers
|
||||
// 子弹特有的方向设置
|
||||
entityComponent => entityComponent.entity.SetTarget(pos + dir)
|
||||
);
|
||||
if (result.entity is Bullet bullet)
|
||||
{
|
||||
bullet.bulletSource = source;
|
||||
if (source) bullet.affiliation = source.affiliation;
|
||||
}
|
||||
|
||||
if (!result) GenerateDefaultEntity(pos);
|
||||
}
|
||||
|
@ -346,14 +346,14 @@ namespace Managers
|
||||
if (!bodyTexture.TryGetValue(packageName, out var packageDict))
|
||||
{
|
||||
Debug.LogWarning($"Package '{packageName}' not found.");
|
||||
return Array.Empty<Sprite>();
|
||||
return new[] { defaultSprite };
|
||||
}
|
||||
|
||||
// 检查文件路径是否存在
|
||||
if (!packageDict.TryGetValue(filePath, out var pathDict))
|
||||
{
|
||||
Debug.LogWarning($"File path '{filePath}' not found in package '{packageName}'.");
|
||||
return Array.Empty<Sprite>();
|
||||
return new[] { defaultSprite };
|
||||
}
|
||||
|
||||
// 收集所有匹配的Sprite
|
||||
|
63
Client/Assets/Scripts/Managers/RightMenuManager.cs
Normal file
63
Client/Assets/Scripts/Managers/RightMenuManager.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using Prefab;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
public class RightMenuManager:Utils.MonoSingleton<RightMenuManager>
|
||||
{
|
||||
[SerializeField]
|
||||
private GameObject _canvas;
|
||||
|
||||
[SerializeField]
|
||||
private RightMenuPrefab _rightMenuPrefab;
|
||||
|
||||
public GameObject Canvas
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_canvas == null)
|
||||
{
|
||||
_canvas = GameObject.Find("Canvas"); // 根据你的实际场景修改查找条件
|
||||
if (_canvas == null)
|
||||
{
|
||||
Debug.LogError("RightMenu Canvas not found in scene!");
|
||||
}
|
||||
}
|
||||
return _canvas;
|
||||
}
|
||||
}
|
||||
|
||||
public RightMenuPrefab RightMenuPrefab
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_rightMenuPrefab == null)
|
||||
{
|
||||
_rightMenuPrefab = Resources.Load<RightMenuPrefab>("Prefab/RightMenu");
|
||||
if (_rightMenuPrefab == null)
|
||||
{
|
||||
Debug.LogError("RightMenuPrefab not found in Resources!");
|
||||
}
|
||||
}
|
||||
return _rightMenuPrefab;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateRightMenu(List<(string name, UnityAction callback)> buttons,Vector3 position)
|
||||
{
|
||||
var rightMenuObj = Instantiate(RightMenuManager.Instance.RightMenuPrefab.gameObject,
|
||||
RightMenuManager.Instance.Canvas.transform);
|
||||
var rightMenu=rightMenuObj.GetComponent<RightMenuPrefab>();
|
||||
rightMenu.Init(buttons);
|
||||
rightMenu.transform.position = position;
|
||||
rightMenu.Show();
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
3
Client/Assets/Scripts/Managers/RightMenuManager.cs.meta
Normal file
3
Client/Assets/Scripts/Managers/RightMenuManager.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 409b8017bbd6443eb2dde17ea6fd5e29
|
||||
timeCreated: 1755526878
|
@ -20,9 +20,14 @@ namespace Map
|
||||
|
||||
public bool CanPassThrough(int x, int y)
|
||||
{
|
||||
return GetTileCost(x, y) < 1;
|
||||
return GetTilePassCost(x, y) < 1;
|
||||
}
|
||||
public float GetTileCost(int x, int y)
|
||||
public float GetTilePassCost(int x, int y)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float GetTileBulletCover(int x, int y)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace Prefab
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
public void Init(List<(string name, UnityAction callback)> buttons)
|
||||
@ -27,8 +27,6 @@ namespace Prefab
|
||||
Debug.LogError("Menu or ButtonPrefab is not assigned!");
|
||||
return;
|
||||
}
|
||||
|
||||
ClearMenu();
|
||||
foreach (var (label, callback) in buttons)
|
||||
{
|
||||
// 实例化按钮预制体
|
||||
@ -68,14 +66,6 @@ namespace Prefab
|
||||
}
|
||||
}
|
||||
}
|
||||
public void ClearMenu()
|
||||
{
|
||||
// 遍历菜单下的所有子对象并销毁它们
|
||||
foreach (Transform child in menu.transform)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
}
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Hide();
|
||||
|
@ -141,7 +141,7 @@ namespace Utils
|
||||
var distance = (from.x == to.x || from.y == to.y) ? 1f : 1.4142f;
|
||||
|
||||
// 应用目标瓦片的速度削减率
|
||||
var costModifier = Map.MapGenerator.Instance.GetTileCost(to.x, to.y);
|
||||
var costModifier = Map.MapGenerator.Instance.GetTilePassCost(to.x, to.y);
|
||||
|
||||
// 成本 = 距离 × (1 + 速度削减率)
|
||||
return distance * (1 + costModifier);
|
||||
|
Reference in New Issue
Block a user