Ejemplo n.º 1
0
    private void OnSceneGUI()
    {
        PathAI path = (PathAI)target;

        foreach (PathAI.Waypoint waypoint in path.waypoints)
        {
            if (!waypoint.visible)
            {
                continue;
            }

            float   size = HandleUtility.GetHandleSize(waypoint.location) * 0.1f;
            Vector3 snap = Vector3.one * 0.5f;

            EditorGUI.BeginChangeCheck();
            Vector3 newLocation = Handles.FreeMoveHandle(waypoint.location, Quaternion.identity, size, snap, Handles.DotHandleCap);
            Handles.color = Color.clear;
            Vector3 lookAt      = new Vector3(waypoint.location.x + Mathf.Cos(waypoint.rotation * Mathf.Deg2Rad) * size * 10, waypoint.location.y + Mathf.Sin(waypoint.rotation * Mathf.Deg2Rad) * size * 10, 0);
            Vector3 newRotation = Handles.FreeMoveHandle(lookAt, Quaternion.identity, size, snap, Handles.CircleHandleCap);
            Handles.color = Color.white;
            Handles.ArrowHandleCap(0, waypoint.location, Quaternion.Euler(90, 0, 0) * Quaternion.Euler(0, waypoint.rotation + 90, 0), size * 10, EventType.Repaint);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(path, "Change Waypoint");
                waypoint.location = newLocation;
                waypoint.rotation = (int)(Mathf.Atan2(newRotation.y - newLocation.y, newRotation.x - newLocation.x) * Mathf.Rad2Deg);
                path.Update();
            }
        }
    }
Ejemplo n.º 2
0
 public override void setNextNode(PathAI pathAi)
 {
     print(state);
     if (state == TrafficLight.RED)
     {
         listeners.Add(pathAi);
         pathAi.node = null;
         pathAi.setTarget();
     }
     else
     {
         base.setNextNode(pathAi);
     }
 }
Ejemplo n.º 3
0
    public virtual void setNextNode(PathAI pathAi)
    {
        var c = connections;

        if (pathAi.prevNode != null && c.Count > 1)
        {
            print(pathAi.prevNode);
            c = connections.FindAll(node => node.transform.position != pathAi.prevNode.transform.position);
        }

        pathAi.prevNode = pathAi.node;
        print(c.Count);
        pathAi.node = c[Random.Range(0, c.Count)];
        pathAi.setTarget();
    }
Ejemplo n.º 4
0
 void Awake()
 {
     instance    = this;
     pathfinding = GetComponent <PathAI>();
 }
Ejemplo n.º 5
0
 void Start()
 {
     rb      = GetComponent <Rigidbody>();
     _pathAi = GetComponent <PathAI>();
     anim    = GetComponent <Animator>();
 }
Ejemplo n.º 6
0
 void Start()
 {
     rb      = GetComponent <Rigidbody>();
     _pathAi = GetComponent <PathAI>();
 }