convert game playing..
This commit is contained in:
@@ -2,11 +2,13 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using BumpCombat.Combat;
|
||||
using BumpCombat.Constants;
|
||||
using BumpCombat.Core;
|
||||
using BumpCombat.Enemies;
|
||||
using BumpCombat.Player;
|
||||
using BumpCombat.Progression;
|
||||
using BumpCombat.Spawning;
|
||||
using BumpCombat.Stage;
|
||||
using BumpCombat.UI;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
@@ -676,8 +678,7 @@ namespace BumpCombat.PlayModeTests
|
||||
AssertRect(eventText.rectTransform, new Vector2(0.5f, 1f),
|
||||
new Vector2(0.5f, 1f), new Vector2(0f, -100f),
|
||||
new Vector2(420f, 28f));
|
||||
Assert.That(eventText.gameObject.activeSelf, Is.True);
|
||||
Assert.That(eventText.text, Does.Contain("다음"));
|
||||
Assert.That(eventText.gameObject.activeSelf, Is.False);
|
||||
Assert.That(debug.gameObject.activeSelf, Is.True);
|
||||
AssertRect(gauge, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0f, -24f), new Vector2(352f, 18f));
|
||||
@@ -780,25 +781,13 @@ namespace BumpCombat.PlayModeTests
|
||||
gridSnapping.GetValue(pixelPerfect).ToString(),
|
||||
Is.EqualTo("PixelSnapping"));
|
||||
|
||||
RenderTexture target = new(1399, 799, 24, RenderTextureFormat.ARGB32);
|
||||
target.Create();
|
||||
RenderTexture previousTarget = camera.targetTexture;
|
||||
camera.targetTexture = target;
|
||||
RunConstants stageConstants = GameplayConstants.Current.Run;
|
||||
try
|
||||
{
|
||||
camera.Render();
|
||||
yield return null;
|
||||
|
||||
Rect pixelRect = camera.pixelRect;
|
||||
Assert.That(pixelRect.width, Is.EqualTo(1398f).Within(0.01f));
|
||||
Assert.That(pixelRect.height, Is.EqualTo(798f).Within(0.01f));
|
||||
Assert.That(pixelRect.x, Is.EqualTo(0f).Within(0.01f));
|
||||
Assert.That(pixelRect.y, Is.EqualTo(0f).Within(0.01f));
|
||||
Assert.That(pixelRect.width % 2f, Is.EqualTo(0f).Within(0.01f));
|
||||
Assert.That(pixelRect.height % 2f, Is.EqualTo(0f).Within(0.01f));
|
||||
Assert.That(camera.aspect, Is.EqualTo(1398f / 798f).Within(0.001f));
|
||||
Assert.That(camera.orthographicSize, Is.EqualTo(6.234375f).Within(0.01f));
|
||||
|
||||
PropertyInfo assetsPpu = pixelPerfect.GetType().GetProperty("assetsPPU");
|
||||
PropertyInfo referenceWidth = pixelPerfect.GetType().GetProperty("refResolutionX");
|
||||
PropertyInfo referenceHeight = pixelPerfect.GetType().GetProperty("refResolutionY");
|
||||
FieldInfo internalField = pixelPerfect.GetType().GetField(
|
||||
"m_Internal",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
@@ -812,31 +801,66 @@ namespace BumpCombat.PlayModeTests
|
||||
FieldInfo useOffscreenField = internalCamera.GetType().GetField(
|
||||
"useOffscreenRT",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
Assert.That(widthField.GetValue(internalCamera), Is.EqualTo(0));
|
||||
Assert.That(heightField.GetValue(internalCamera), Is.EqualTo(0));
|
||||
Assert.That(useOffscreenField.GetValue(internalCamera), Is.False);
|
||||
int[,] targetSizes = { { 1920, 1080 }, { 1280, 720 }, { 1399, 799 } };
|
||||
for (int i = 0; i < targetSizes.GetLength(0); i++)
|
||||
{
|
||||
RenderTexture target = new(
|
||||
targetSizes[i, 0],
|
||||
targetSizes[i, 1],
|
||||
24,
|
||||
RenderTextureFormat.ARGB32);
|
||||
target.Create();
|
||||
camera.targetTexture = target;
|
||||
try
|
||||
{
|
||||
camera.Render();
|
||||
yield return null;
|
||||
|
||||
float correctedOrthoSize = camera.orthographicSize;
|
||||
camera.Render();
|
||||
Assert.That(camera.pixelRect.width, Is.EqualTo(1398f).Within(0.01f));
|
||||
Assert.That(camera.pixelRect.height, Is.EqualTo(798f).Within(0.01f));
|
||||
Assert.That(camera.orthographicSize,
|
||||
Is.EqualTo(correctedOrthoSize).Within(0.01f));
|
||||
int targetWidth = targetSizes[i, 0];
|
||||
int targetHeight = targetSizes[i, 1];
|
||||
int expectedWidth = targetWidth & ~1;
|
||||
int expectedHeight = targetHeight & ~1;
|
||||
Rect pixelRect = camera.pixelRect;
|
||||
Assert.That(pixelRect.width, Is.EqualTo(expectedWidth).Within(0.01f));
|
||||
Assert.That(pixelRect.height, Is.EqualTo(expectedHeight).Within(0.01f));
|
||||
Assert.That(pixelRect.x, Is.EqualTo(0f).Within(0.01f));
|
||||
Assert.That(pixelRect.y, Is.EqualTo(0f).Within(0.01f));
|
||||
Assert.That(camera.aspect,
|
||||
Is.EqualTo(expectedWidth / (float)expectedHeight).Within(0.001f));
|
||||
Assert.That(camera.orthographicSize,
|
||||
Is.EqualTo(stageConstants.StageCameraViewHalfExtents.y
|
||||
* expectedHeight / targetHeight).Within(0.01f));
|
||||
Assert.That(assetsPpu.GetValue(pixelPerfect), Is.EqualTo(32));
|
||||
Assert.That(
|
||||
referenceWidth.GetValue(pixelPerfect),
|
||||
Is.EqualTo(Mathf.RoundToInt(
|
||||
stageConstants.StageCameraViewHalfExtents.x * 2f * 32f)));
|
||||
Assert.That(
|
||||
referenceHeight.GetValue(pixelPerfect),
|
||||
Is.EqualTo(Mathf.RoundToInt(
|
||||
stageConstants.StageCameraViewHalfExtents.y * 2f * 32f)));
|
||||
Assert.That(widthField.GetValue(internalCamera), Is.EqualTo(0));
|
||||
Assert.That(heightField.GetValue(internalCamera), Is.EqualTo(0));
|
||||
Assert.That(useOffscreenField.GetValue(internalCamera), Is.False);
|
||||
|
||||
ArenaCameraFollow follow = camera.GetComponent<ArenaCameraFollow>();
|
||||
bool previousFollowEnabled = follow.enabled;
|
||||
follow.enabled = false;
|
||||
camera.Render();
|
||||
follow.enabled = previousFollowEnabled;
|
||||
camera.Render();
|
||||
Assert.That(camera.pixelRect.width, Is.EqualTo(1398f).Within(0.01f));
|
||||
Assert.That(camera.pixelRect.height, Is.EqualTo(798f).Within(0.01f));
|
||||
camera.Render();
|
||||
Assert.That(camera.pixelRect.width, Is.EqualTo(expectedWidth).Within(0.01f));
|
||||
Assert.That(camera.pixelRect.height, Is.EqualTo(expectedHeight).Within(0.01f));
|
||||
Assert.That(camera.orthographicSize,
|
||||
Is.EqualTo(stageConstants.StageCameraViewHalfExtents.y
|
||||
* expectedHeight / targetHeight).Within(0.01f));
|
||||
}
|
||||
finally
|
||||
{
|
||||
camera.targetTexture = previousTarget;
|
||||
target.Release();
|
||||
Object.Destroy(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
camera.targetTexture = previousTarget;
|
||||
target.Release();
|
||||
Object.Destroy(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -846,10 +870,14 @@ namespace BumpCombat.PlayModeTests
|
||||
yield return LoadCombatPrototype();
|
||||
|
||||
RunHUD hud = Object.FindAnyObjectByType<RunHUD>();
|
||||
StageManager stageManager = StageManager.Instance;
|
||||
SpawnDirector director = Object.FindAnyObjectByType<SpawnDirector>();
|
||||
PlayerController player = Object.FindAnyObjectByType<PlayerController>();
|
||||
ArenaBounds arena = ArenaBounds.Resolve();
|
||||
Assert.That(hud, Is.Not.Null);
|
||||
Assert.That(stageManager, Is.Not.Null);
|
||||
Assert.That(stageManager.CurrentZone, Is.Not.Null);
|
||||
Assert.That(stageManager.CurrentZone.Preset, Is.Not.Null);
|
||||
Assert.That(arena, Is.Not.Null);
|
||||
|
||||
director.enabled = false;
|
||||
@@ -867,6 +895,28 @@ namespace BumpCombat.PlayModeTests
|
||||
Time.timeScale = 0f;
|
||||
yield return new WaitForSecondsRealtime(0.2f);
|
||||
|
||||
Camera worldCamera = Camera.main;
|
||||
EnemyController eventEnemy = null;
|
||||
EnemyController[] activeEnemies = Object.FindObjectsByType<EnemyController>(
|
||||
FindObjectsInactive.Exclude,
|
||||
FindObjectsSortMode.None);
|
||||
for (int i = 0; i < activeEnemies.Length; i++)
|
||||
{
|
||||
if (activeEnemies[i].IsEventEnemy)
|
||||
{
|
||||
eventEnemy = activeEnemies[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.That(eventEnemy, Is.Not.Null);
|
||||
ZoneInstance visibilityZone = stageManager.CurrentZone;
|
||||
Vector2 onScreenPosition = player.transform.position;
|
||||
visibilityZone.UpdateVisibility(onScreenPosition);
|
||||
eventEnemy.GetComponent<Rigidbody2D>().position = onScreenPosition;
|
||||
eventEnemy.transform.position = onScreenPosition;
|
||||
Physics2D.SyncTransforms();
|
||||
yield return new WaitForSecondsRealtime(0.12f);
|
||||
|
||||
GameObject minimap = GameObject.Find("Minimap");
|
||||
Image playerMarker = GameObject.Find("Minimap Player")
|
||||
.GetComponent<Image>();
|
||||
@@ -884,7 +934,73 @@ namespace BumpCombat.PlayModeTests
|
||||
}
|
||||
RectTransform viewport = GameObject.Find("Minimap Camera Viewport")
|
||||
.GetComponent<RectTransform>();
|
||||
Transform terrain = GameObject.Find("Minimap Terrain")?.transform;
|
||||
Assert.That(minimap.activeSelf, Is.True);
|
||||
Assert.That(terrain, Is.Not.Null);
|
||||
int expectedTerrainCells = 0;
|
||||
RoomPreset currentPreset = stageManager.CurrentZone.Preset;
|
||||
for (int y = 0; y < currentPreset.GridHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < currentPreset.GridWidth; x++)
|
||||
{
|
||||
PresetCellType cellType = stageManager.CurrentZone.GetRuntimeCell(x, y);
|
||||
if (cellType != PresetCellType.Empty)
|
||||
{
|
||||
expectedTerrainCells++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.That(terrain.childCount, Is.EqualTo(expectedTerrainCells));
|
||||
for (int i = 0; i < currentPreset.Sockets.Count; i++)
|
||||
{
|
||||
RoomPresetSocket socket = currentPreset.Sockets[i];
|
||||
for (int offset = 0; offset < socket.Width; offset++)
|
||||
{
|
||||
Vector2Int socketCell = socket.CellPosition;
|
||||
if (socket.Direction == StageDirection.North ||
|
||||
socket.Direction == StageDirection.South)
|
||||
{
|
||||
socketCell.x += offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
socketCell.y += offset;
|
||||
}
|
||||
|
||||
bool isActive = stageManager.CurrentZone.GetRuntimeCell(socketCell.x, socketCell.y)
|
||||
== PresetCellType.Socket;
|
||||
|
||||
Image terrainCell = terrain.Find($"Terrain {socketCell.x},{socketCell.y}")
|
||||
?.GetComponent<Image>();
|
||||
if (isActive)
|
||||
{
|
||||
Assert.That(terrainCell, Is.Not.Null, socket.Id);
|
||||
Color32 terrainColor = terrainCell.color;
|
||||
if (visibilityZone.IsCellVisible(socketCell.x, socketCell.y))
|
||||
{
|
||||
Assert.That(
|
||||
terrainColor.Equals(new Color32(54, 103, 112, 230)),
|
||||
Is.True,
|
||||
socket.Id);
|
||||
}
|
||||
else if (visibilityZone.IsCellExplored(socketCell.x, socketCell.y))
|
||||
{
|
||||
Assert.That(terrainColor, Is.Not.EqualTo(
|
||||
new Color32(54, 103, 112, 230)), socket.Id);
|
||||
Assert.That(terrainColor.a, Is.EqualTo(255), socket.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.That(terrainColor, Is.EqualTo(new Color32(2, 4, 5, 255)),
|
||||
socket.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.That(terrainCell, Is.Null, socket.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.That(
|
||||
((Color32)playerMarker.color).Equals(
|
||||
new Color32(106, 236, 255, 255)),
|
||||
@@ -898,6 +1014,68 @@ namespace BumpCombat.PlayModeTests
|
||||
Assert.That(viewport.rect.width, Is.GreaterThan(0f));
|
||||
Assert.That(viewport.rect.height, Is.GreaterThan(0f));
|
||||
|
||||
Vector2 nearEdgePosition = onScreenPosition;
|
||||
bool foundVisiblePosition = false;
|
||||
for (int y = 0; y < currentPreset.GridHeight && !foundVisiblePosition; y++)
|
||||
{
|
||||
for (int x = 0; x < currentPreset.GridWidth; x++)
|
||||
{
|
||||
if (!visibilityZone.IsCellVisible(x, y))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector2 candidate = currentPreset.CellToWorldPosition(
|
||||
visibilityZone.ZoneCenter,
|
||||
new Vector2Int(x, y));
|
||||
if (Vector2.Distance(candidate, onScreenPosition) > 0.5f
|
||||
&& arena.IsInsideCameraVisible(worldCamera, candidate))
|
||||
{
|
||||
nearEdgePosition = candidate;
|
||||
foundVisiblePosition = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.That(foundVisiblePosition, Is.True);
|
||||
eventEnemy.GetComponent<Rigidbody2D>().position = nearEdgePosition;
|
||||
eventEnemy.transform.position = nearEdgePosition;
|
||||
Physics2D.SyncTransforms();
|
||||
yield return new WaitForSecondsRealtime(0.12f);
|
||||
Assert.That(visibilityZone.IsWorldPositionVisible(nearEdgePosition), Is.True);
|
||||
Assert.That(eventMarker.gameObject.activeSelf, Is.True, "An enemy inside the current camera view should have a marker");
|
||||
|
||||
Vector2 outsidePosition = onScreenPosition + Vector2.right * 6.5f;
|
||||
bool foundHiddenPosition = false;
|
||||
for (int y = 0; y < currentPreset.GridHeight && !foundHiddenPosition; y++)
|
||||
{
|
||||
for (int x = 0; x < currentPreset.GridWidth; x++)
|
||||
{
|
||||
if (visibilityZone.IsCellVisible(x, y))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector2 candidate = currentPreset.CellToWorldPosition(
|
||||
visibilityZone.ZoneCenter,
|
||||
new Vector2Int(x, y));
|
||||
if (arena.IsInsideCameraVisible(worldCamera, candidate))
|
||||
{
|
||||
outsidePosition = candidate;
|
||||
foundHiddenPosition = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eventEnemy.GetComponent<Rigidbody2D>().position = outsidePosition;
|
||||
eventEnemy.transform.position = outsidePosition;
|
||||
Physics2D.SyncTransforms();
|
||||
yield return new WaitForSecondsRealtime(0.12f);
|
||||
Assert.That(visibilityZone.IsWorldPositionVisible(outsidePosition), Is.False);
|
||||
Assert.That(eventMarker.gameObject.activeSelf, Is.False, "An enemy outside the current camera view should not have a marker");
|
||||
|
||||
Vector2 oldMarkerPosition = playerMarker.rectTransform.anchoredPosition;
|
||||
Vector2 movedPosition = arena.ClampPlayerPosition(new Vector2(6f, 2f));
|
||||
player.GetComponent<Rigidbody2D>().position = movedPosition;
|
||||
|
||||
Reference in New Issue
Block a user