3D: герой у Терема -- гуляет по свободным клеткам рядом с Теремом, тап -- фраза и окно героя (перенос из 2D)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alexander
2026-11-06 16:42:03 +01:00
co-authored by Claude Opus 5.5
parent 6d36c14313
commit 538dbea222
4 changed files with 226 additions and 0 deletions
+28
View File
@@ -828,6 +828,7 @@ public class City3DController : MonoBehaviour, City3DSave.ILive
if (!stateApplied && map != null) ApplySaved();
if (cam == null) return;
UpdateConstructionViews();
UpdateHero();
bool down, held, up;
Vector3 pos;
if (Input.touchCount > 0)
@@ -898,6 +899,12 @@ public class City3DController : MonoBehaviour, City3DSave.ILive
void Tap(Vector3 pos)
{
// Тап по герою -- фраза и окно героя (как в 2D)
if (mode == Mode.View && City3DHero.Instance != null && !City3DHero.Instance.Hidden)
{
foreach (var hit in Physics.RaycastAll(cam.ScreenPointToRay(pos), 500f))
if (hit.collider.GetComponentInParent<City3DHero>() != null) { City3DHero.Instance.OnTapped(); return; }
}
if (!CellUnder(pos, mode == Mode.Place || mode == Mode.Move, out int cx, out int cy)) return;
if (mode == Mode.Place || mode == Mode.Move)
{
@@ -1015,6 +1022,27 @@ public class City3DController : MonoBehaviour, City3DSave.ILive
float guiScale = 1f;
GUIStyle button, label, box;
// ---------------- Герой у Терема (перенос из 2D) ----------------
// Терем достроен -- у его ворот герой; Терема нет -- героя нет. В режиме стройки и переноса прячется
void UpdateHero()
{
if (!stateApplied) return;
string castleId = null;
foreach (var pair in buildingType)
{
if (Types[pair.Value].Name != "Терем") continue;
if (!buildingViews.TryGetValue(pair.Key, out var view) || view == null || BuildTimer.IsConstructing(view.transform)) continue;
castleId = pair.Key;
break;
}
var hero = City3DHero.Instance;
if (castleId == null) { if (hero != null) Destroy(hero.gameObject); return; }
if (hero == null || hero.CastleId != castleId || hero.CastleView == null)
hero = City3DHero.Spawn(transform, map, castleId, buildingViews[castleId], () => townHallLevel);
hero.Hidden = mode == Mode.Place || mode == Mode.Move;
}
// ---------------- Стройка по времени в 3D ----------------
// BuildTimer затемняет только 2D-спрайты, поэтому в 3D здание, которое ещё строится, выглядело готовым
// (Казармы «построены», а нанимать нельзя). Здесь: здание темнее и над ним -- «Стройка 0:45» (05.11)