G1-Karte in Unity (Assets/Luneraria/Scenes/G1_Map.unity), reproduzierbar gebaut aus dem Godot-Weltgenerator (gebacken), den FBX-Modellen aus U2A und der Karte des C#-Kerns. - tools/godot-golden/world_export.gd: backt Gelände (Raster, Farben, Lauf- und Standhöhen), Lanebeläge, Plattform, Brücke, Randsteine, Basen, Landmarken, Vegetation, Adern, Grottentreppen, Aufstellungsbereiche und Licht. Braucht einen echten Renderer (HEADLESS=0); prüft auf Headless-Einheitstransformationen. - LuneWorldBuilder: Meshes (GUID-stabil), Szene, Licht, Himmel, Post-Processing, 16 Türme, 2 Ancients und die Grotte aus LuneMap mit Teammaterialien. - Materialsystem: Luneraria/Surface (Gelände, Kluft-Oberflächen, Fluss, Adern, Kristall, G2-Werte mit Teamvarianten und Vertex-AO) und Luneraria/Pad; LuneMaterialSet.Dress wie Godots dress. - View-Assembly: LuneSpace (Unity = (-x, h, y)), LuneGround, LuneCameraMath, LuneBuildingView (Zustände intakt bis Ruine). - Vergleichsbilder mit den Kameraeinstellungen der Godot-G2-Aufnahmen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
3.8 KiB
C#
98 lines
3.8 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Luneraria.View
|
|
{
|
|
/// <summary>
|
|
/// A tower (Grenzwacht, Bastion, Kernwacht) or an Ancient (Mondherz) of the G2 set. Shows the
|
|
/// authoritative building HP as one of five looks, like scripts/luneraria/view/lune_tower_view.gd
|
|
/// and lune_ancient_view.gd: intact, lightly and heavily damaged, collapsing, ruin. The view never
|
|
/// decides anything; HP comes from the core (U2C binds it).
|
|
/// </summary>
|
|
public sealed class LuneBuildingView : MonoBehaviour
|
|
{
|
|
public enum Look { Intact, Light, Heavy, Destroying, Ruin }
|
|
|
|
/// <summary>HP fractions where the look changes (the same bands for towers and Ancients).</summary>
|
|
public const float LightBelow = .605f;
|
|
public const float HeavyBelow = .305f;
|
|
|
|
public string BuildingId = "";
|
|
public int Team;
|
|
/// <summary>outer, inner, base or core.</summary>
|
|
public string Tier = "";
|
|
public Look Current = Look.Intact;
|
|
|
|
readonly Dictionary<string, Transform> _parts = new Dictionary<string, Transform>();
|
|
|
|
public bool IsAncient { get { return Tier == "core"; } }
|
|
|
|
void Collect()
|
|
{
|
|
if (_parts.Count > 0)
|
|
return;
|
|
Transform model = transform.childCount > 0 ? transform.GetChild(0) : transform;
|
|
foreach (Transform part in model)
|
|
_parts[part.name] = part;
|
|
}
|
|
|
|
/// <summary>Look for an HP fraction; a destroyed building shows its ruin.</summary>
|
|
public static Look LookFor(float hp, float maxHp)
|
|
{
|
|
float fraction = Mathf.Clamp01(hp / Mathf.Max(1f, maxHp));
|
|
if (hp <= 0f)
|
|
return Look.Ruin;
|
|
if (fraction < HeavyBelow)
|
|
return Look.Heavy;
|
|
if (fraction < LightBelow)
|
|
return Look.Light;
|
|
return Look.Intact;
|
|
}
|
|
|
|
/// <summary>Part visibility of a look (Godot _enter of the tower and Ancient views).</summary>
|
|
public void Show(Look look)
|
|
{
|
|
Collect();
|
|
Current = look;
|
|
bool standing = look != Look.Ruin;
|
|
if (IsAncient)
|
|
{
|
|
foreach (KeyValuePair<string, Transform> part in _parts)
|
|
{
|
|
string key = part.Key;
|
|
bool visible;
|
|
if (key.StartsWith("Ruin"))
|
|
visible = !standing;
|
|
else if (key == "Crest_A")
|
|
visible = standing && Team == 0;
|
|
else if (key == "Crest_B")
|
|
visible = standing && Team != 0;
|
|
else if (key == "Dais" || key == "Pedestal")
|
|
visible = true;
|
|
else
|
|
visible = standing;
|
|
part.Value.gameObject.SetActive(visible);
|
|
}
|
|
return;
|
|
}
|
|
bool damagedTop = look == Look.Heavy || look == Look.Destroying;
|
|
Set("Upper", standing && !damagedTop);
|
|
Set("Upper_Damaged", standing && damagedTop);
|
|
Set("Debris", look == Look.Heavy || look == Look.Destroying);
|
|
Set("Lower", standing);
|
|
Set("Ruin", !standing);
|
|
foreach (KeyValuePair<string, Transform> part in _parts)
|
|
{
|
|
string key = part.Key;
|
|
if (key == "Crystal" || key == "Ring" || key.StartsWith("Shard") || key.StartsWith("Banner") || key.StartsWith("Pennant"))
|
|
part.Value.gameObject.SetActive(standing);
|
|
}
|
|
}
|
|
|
|
void Set(string key, bool visible)
|
|
{
|
|
if (_parts.TryGetValue(key, out Transform part))
|
|
part.gameObject.SetActive(visible);
|
|
}
|
|
}
|
|
}
|