2025-09-15 23:01:07 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
2025-09-16 00:08:50 +02:00
|
|
|
[ExecuteAlways]
|
2025-09-15 23:01:07 +02:00
|
|
|
public class Node : MonoBehaviour
|
|
|
|
|
{
|
2025-09-16 14:20:19 +02:00
|
|
|
[Range(-1, 1)]
|
|
|
|
|
[SerializeField]
|
2025-09-16 18:19:40 +02:00
|
|
|
private int Owner = -1;
|
|
|
|
|
public Material materialOwnerSelf, materialOwnerOther, materialOwnerNone;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
UpdateColor();
|
|
|
|
|
}
|
2025-09-16 14:20:19 +02:00
|
|
|
|
2025-09-15 23:01:07 +02:00
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2025-09-16 16:50:21 +02:00
|
|
|
|
2025-09-15 23:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
2025-09-16 18:19:40 +02:00
|
|
|
{
|
|
|
|
|
UpdateTransform();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnValidate()
|
|
|
|
|
{
|
|
|
|
|
UpdateColor();
|
|
|
|
|
UpdateTransform();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateTransform()
|
|
|
|
|
{
|
2025-09-16 16:50:21 +02:00
|
|
|
transform.localPosition = transform.localPosition.normalized * 20f;
|
|
|
|
|
transform.forward = transform.position;
|
2025-09-16 18:19:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateColor()
|
|
|
|
|
{
|
2025-09-16 14:20:19 +02:00
|
|
|
switch (Owner)
|
|
|
|
|
{
|
2025-09-16 18:19:40 +02:00
|
|
|
case -1: transform.GetChild(0).GetComponent<Renderer>().sharedMaterial = materialOwnerNone; break;
|
|
|
|
|
case 0: transform.GetChild(0).GetComponent<Renderer>().sharedMaterial = materialOwnerSelf; break;
|
|
|
|
|
case 1: transform.GetChild(0).GetComponent<Renderer>().sharedMaterial = materialOwnerOther; break;
|
|
|
|
|
}
|
2025-09-16 16:50:21 +02:00
|
|
|
}
|
2025-09-16 17:40:34 +02:00
|
|
|
|
2025-09-15 23:01:07 +02:00
|
|
|
}
|