コード例 #1
0
    void OnSceneGUI()
    {
        WaypointsHolder wp = target as WaypointsHolder;

        //retrieve all children objects in WaypointsHolder game object
        if (wp.GetComponent <Waypoint>())
        {
            //if selected object is child, than save all children of its parrent in array
            if (wp.transform.parent)
            {
                childs = wp.transform.parent.GetComponentsInChildren <Transform>();
            }
        }
        else
        {
            //save all children in array
            if (wp.transform.childCount > 1)
            {
                childs = wp.GetComponentsInChildren <Transform>();
            }
        }

        Handles.color = Color.red;


        //draw lines between child game objects
        if (wp.drawLines && childs != null && childs.Length > 1)
        {
            for (var i = 1; i < childs.Length - 1; i++)
            {
                //Handles.DrawLine(childs[i].position, childs[i+1].position);
                Handles.DrawAAPolyLine(childs[i].position, childs[i + 1].position);
            }
        }
    }
コード例 #2
0
    //----------------------------------------------------------------------------------
    public override void OnInspectorGUI()
    {
        _target = (WaypointsHolder)target;

        DrawDefaultInspector();

        if (Application.isPlaying)
        {
            return;
        }


        if (GUILayout.Button(new GUIContent("Clean", "Remove all missing waypoints")))
        {
            _target.Clean();
        }

        if (GUILayout.Button(new GUIContent("Gather child Waypoints", "Reset waypoints list, by gathering only waypoints in children objects")))
        {
            _target.waypoints.Clear();
            foreach (Waypoint waypoint in _target.gameObject.GetComponentsInChildren <Waypoint>())
            {
                _target.waypoints.Add(waypoint);
            }
        }


        GUI.color = creationEnabled ? Color.yellow : Color.white;
        if (GUILayout.Button(new GUIContent("Right mouse to create: " + (creationEnabled ? "ENABLED" : "DISABLED"), "Enable/Disable dynamic waypoints creation by RMB right in Editor Scene View")))
        {
            creationEnabled = !creationEnabled;
        }
    }
コード例 #3
0
        public EBTStatus SelectNearestRoute()
        {
            if (Singleton <BattleLogic> .GetInstance() == null || BattleLogic.instance.mapLogic == null)
            {
                return(EBTStatus.BT_FAILURE);
            }
            CUtilList <WaypointsHolder> waypointsList = BattleLogic.instance.mapLogic.GetWaypointsList(m_wrapper.actor.pCharMeta.ActorCamp);

            if (waypointsList == null || waypointsList.Count == 0)
            {
                return(EBTStatus.BT_FAILURE);
            }
            long            num             = long.MaxValue;
            WaypointsHolder waypointsHolder = null;

            for (int i = 0; i < waypointsList.Count; i++)
            {
                VecInt3 vInt = new VecInt3(waypointsList[i].startPoint.transform.position);
                long    sqrMagnitudeLong2D = (m_wrapper.actorLocation - vInt).sqrMagnitudeLong2D;
                if (sqrMagnitudeLong2D < num)
                {
                    waypointsHolder = waypointsList[i];
                    num             = sqrMagnitudeLong2D;
                }
            }
            if (waypointsHolder == null)
            {
                return(EBTStatus.BT_FAILURE);
            }
            m_wrapper.m_curWaypointsHolder        = waypointsHolder;
            m_wrapper.m_curWaypointTarget         = m_wrapper.m_curWaypointsHolder.startPoint;
            m_wrapper.m_curWaypointTargetPosition = new VecInt3(m_wrapper.m_curWaypointTarget.transform.position);
            return(EBTStatus.BT_SUCCESS);
        }