mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 04:07:13 +08:00
(client) feat:健康给予,路径优化,结算界面,商店界面 (#60)
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/60
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Tilemaps;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Managers;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Tilemaps;
|
||||
using Utils;
|
||||
|
||||
namespace Map
|
||||
@@ -51,7 +51,7 @@ namespace Map
|
||||
private BasicTerrainGeneratorConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化地形生成器,解析JSON配置字符串。
|
||||
/// 初始化地形生成器,解析JSON配置字符串。
|
||||
/// </summary>
|
||||
/// <param name="value">包含地形生成参数的JSON字符串。</param>
|
||||
public override void Init(string value)
|
||||
@@ -110,7 +110,7 @@ namespace Map
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据柏林噪声生成地形。此方法现在是异步的,以避免阻塞主线程。
|
||||
/// 根据柏林噪声生成地形。此方法现在是异步的,以避免阻塞主线程。
|
||||
/// </summary>
|
||||
/// <param name="landform">地图生成器实例,包含要操作的瓦片地图。</param>
|
||||
public override async Task Process(Landform landform)
|
||||
@@ -134,9 +134,7 @@ namespace Map
|
||||
{
|
||||
elseTile = TileManager.Instance.GetTile(_config.ElseTileDefName);
|
||||
if (elseTile == null)
|
||||
{
|
||||
Debug.LogWarning($"基本地形生成器: 无法获取 else-瓦片定义名称: '{_config.ElseTileDefName}'。将不会放置 else-瓦片。");
|
||||
}
|
||||
}
|
||||
|
||||
Tilemap targetTilemap;
|
||||
@@ -173,19 +171,13 @@ namespace Map
|
||||
var sampleY = y / (double)_config.MapCellSizeY * _config.Scale + _config.OffsetY;
|
||||
var noiseValue = PerlinNoise.Instance.Noise(sampleX, sampleY);
|
||||
// 核心修改部分:将 x, y 与 OriginX, OriginY 相加,用于指定瓦片的实际放置位置。
|
||||
Vector3Int tilePosition = new Vector3Int(x + _config.OriginX, y + _config.OriginY, 0);
|
||||
var tilePosition = new Vector3Int(x + _config.OriginX, y + _config.OriginY, 0);
|
||||
if (noiseValue >= _config.MinThreshold && noiseValue <= _config.MaxThreshold)
|
||||
{
|
||||
targetTilemap.SetTile(tilePosition, terrainTile);
|
||||
}
|
||||
else if (elseTile != null)
|
||||
{
|
||||
targetTilemap.SetTile(tilePosition, elseTile);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetTilemap.SetTile(tilePosition, null);
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Yield();
|
||||
@@ -193,7 +185,7 @@ namespace Map
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前配置的地图尺寸。
|
||||
/// 获取当前配置的地图尺寸。
|
||||
/// </summary>
|
||||
/// <returns>表示地图宽度和高度的 Vector2Int。</returns>
|
||||
public override Vector2Int GetSize()
|
||||
@@ -209,4 +201,4 @@ namespace Map
|
||||
return new Vector2Int(_config.MapCellSizeX, _config.MapCellSizeY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user