67 lines
1.7 KiB
Plaintext
67 lines
1.7 KiB
Plaintext
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(SpriteRenderer))]
|
|
public class PHomeRouteNode : MonoBehaviour
|
|
{
|
|
[System.Serializable]
|
|
public struct PHomeChildNodeList
|
|
{
|
|
public List<PHomeChildNode> m_childNodes;
|
|
}
|
|
private PHomeRouteNode m_parentNode;
|
|
|
|
public List<PHomeRouteNode> NextNodes;
|
|
|
|
public List<PHomeChildNodeList> m_pathChildNodes;
|
|
|
|
public PHomeRouteNode ParentNode
|
|
{
|
|
get
|
|
{
|
|
return m_parentNode;
|
|
}
|
|
}
|
|
|
|
|
|
private NodeType m_nodeType;
|
|
private SpriteRenderer m_sprite;
|
|
|
|
public void Init(PHomeRouteNode parentNode)
|
|
{
|
|
m_sprite = GetComponent<SpriteRenderer>();
|
|
m_parentNode = parentNode;
|
|
}
|
|
|
|
public void SetNodeType(NodeType nodeType)
|
|
{
|
|
m_nodeType = nodeType;
|
|
m_sprite.sprite = PHomeGameMode.main.GameConfig.NodeTypeSprites[(int)nodeType];
|
|
}
|
|
|
|
private void OnDrawGizmosSelected()
|
|
{
|
|
if (NextNodes != null)
|
|
{
|
|
foreach (var item in NextNodes)
|
|
{
|
|
Gizmos.color = Color.red;
|
|
Gizmos.DrawLine(transform.position, item.transform.position);
|
|
}
|
|
}
|
|
if (m_pathChildNodes != null)
|
|
{
|
|
for (int i = 0; i < m_pathChildNodes.Count; i++)
|
|
{
|
|
for (int j = 0; j < m_pathChildNodes[i].m_childNodes.Count; j++)
|
|
{
|
|
Vector3 pos = NextNodes[i].transform.position - transform.position;
|
|
m_pathChildNodes[i].m_childNodes[j].transform.position = transform.position + pos.normalized * m_pathChildNodes[i].m_childNodes[j].Distance;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|