Exemple #1
0
        void OnDrawGizmos()
        {
            if (m_DrawDebuglines)
            {
                if (m_Units == null)
                {
                    m_Units = FindObjectsOfType <Selectable.Units.Unit>();
                }

                Pathing.Goal g = null;

                foreach (Selectable.Units.Unit u in m_Units)
                {
                    if (u.CurrentGoal != null)
                    {
                        g = u.CurrentGoal;
                        break;
                    }
                }

                if (g != null)
                {
                    RaycastHit hit;
                    Camera     cam = Camera.main;
                    Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(ray, out hit, 1024f, TerrainData.Layers.m_s_Default))
                    {
                        Vector3 mouseCenter = hit.point + Vector3.up;
                        Debug.Log("Angle: " + g.GetDirFromPosition(mouseCenter));

                        for (float x = -m_DebugBoxSize * m_NodeRadius; x < m_DebugBoxSize * m_NodeRadius; x += (m_NodeRadius))
                        {
                            for (float y = -m_DebugBoxSize * m_NodeRadius; y < m_DebugBoxSize * m_NodeRadius; y += (m_NodeRadius))
                            {
                                Vector3 at       = mouseCenter + new Vector3(x, 0, y);
                                float   angleDir = g.GetDirFromPosition(at) * Mathf.Deg2Rad;
                                Gizmos.color = Color.red;
                                Gizmos.DrawLine(at, at + m_NodeRadius * new Vector3(Mathf.Sin(angleDir), 0, Mathf.Cos(angleDir)));
                                Gizmos.color = Color.blue;
                                Gizmos.DrawWireSphere(at, m_NodeRadius / 4);
                            }
                        }
                    }
                }
            }
        }
 public void RemoveGoal(Pathing.Goal _goal)
 {
     m_Goals.Remove(_goal);
 }
 public void AddGoal(Pathing.Goal _goal)
 {
     m_Goals.Add(_goal);
 }