Example #1
0
 public void Init(VehicleDirection vehicleDirection, RelativePositionCars relativePositionCars, SignPriorityWay signValue)
 {
     _movementAtCrossroad  = GetComponent <PointMovement>();
     _signValue            = signValue;
     _relativePositionCars = relativePositionCars;
     _vehicleDirection     = vehicleDirection;
     EnableTurnSignalCar(vehicleDirection);
 }
    // Start is called before the first frame update

    public void OnClickDeletePoint()
    {
        PointMovement pointMovement = moveImg.GetComponent <PointMovement>();

        pointMovement.target.Clear();
        foreach (var a in pointMovement.points)
        {
            Destroy(a);
        }
        pointMovement.points.Clear();
    }
Example #3
0
    //Inspector Draw
    private void Awake()
    {
        //Class
        t = target as AI_Patrol;

        if (EditorPrefs.HasKey("PatrolSettingsPath"))
        {
            settings = (AI_PatrolSettings)AssetDatabase.LoadAssetAtPath(EditorPrefs.GetString("PatrolSettingsPath"), typeof(AI_PatrolSettings));
            SetData();
        }

        //Variables
        patrolOptions    = Enum.GetNames(typeof(PatrolMode)); //Get all the enum types
        pointMoveOptions = Enum.GetNames(typeof(PointMovement));

        patrolMode         = t.patrolMode; //Get enum type for ref later on
        patrolOptionsIndex = (int)patrolMode;

        pointMovement     = PointMovement.XZ; //Get enum type for ref later on
        pointOptionsIndex = (int)pointMovement;
    }
Example #4
0
    //Setting Buttons/UI
    private void PatrolSettings()
    {
        //Patrol Mode Selection
        GUILayout.BeginArea(new Rect(10, 10, 250, 160));

        //Show Patrol modes
        GUILayout.Label("Patrol Modes", EditorStyles.boldLabel);
        int patrolIndex = GUILayout.SelectionGrid(patrolOptionsIndex, patrolOptions, 2);

        GUILayout.Label("Point Movement Mode", EditorStyles.boldLabel);
        int pointIndex = GUILayout.SelectionGrid(pointOptionsIndex, pointMoveOptions, 2);

        //Make sure that the GUI has been pressed and update it from there
        if (GUI.changed)
        {
            //Add to undo list
            Undo.RecordObject(t, "Changed point position");

            //Set data to changed
            patrolMode         = (PatrolMode)patrolIndex;
            t.patrolMode       = patrolMode;
            patrolOptionsIndex = patrolIndex;

            pointMovement     = (PointMovement)pointIndex;
            pointOptionsIndex = pointIndex;
        }

        GUILayout.EndArea();

        //State that the settings cannot be changed whilst playing
        if (EditorApplication.isPlaying)
        {
            GUILayout.BeginArea(new Rect(10, 180, 250, 30));
            GUILayout.Label("Settings are disabled when game is active");
            GUILayout.EndArea();

            return;
        }

        //Patrol Mode Settings
        GUILayout.BeginArea(new Rect(10, 150, 250, 80));
        GUILayout.Label("Patrol Quick Settings", EditorStyles.boldLabel);

        //Focus on the current object selected
        //HandleExt.CreateButton ("Change to a Top-view of path", GUILayout.Width (250), SceneView.lastActiveSceneView.FrameSelected ());

        //Move to origin point ready for patrol
        switch (patrolMode)
        {
        case PatrolMode.FollowPoints:
            if (GUILayout.Button("Move to Origin Point", GUILayout.Width(250)))
            {
                t.gameObject.transform.position = points[0].point;
                currentPoint = 0;
            }

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Next Point"))
            {
                currentPoint = (currentPoint == points.Length - 1 ? 0 : currentPoint + 1);
                t.gameObject.transform.position = points[currentPoint].point;
            }

            if (GUILayout.Button("Previous Point"))
            {
                currentPoint = (currentPoint == 0 ? points.Length - 1 : currentPoint - 1);
                t.gameObject.transform.position = points[currentPoint].point;
            }

            GUILayout.EndHorizontal();
            break;

        case PatrolMode.RandomPoint:
            if (GUILayout.Button("Move to Random Point", GUILayout.Width(250)))
            {
                t.gameObject.transform.position = t.GetNextPoint();
            }
            break;
        }

        GUILayout.EndArea();

        //NavMesh Generation
        GUILayout.BeginArea(new Rect(300, 10, 350, 100));
        GUILayout.Label("NavMesh Path Generation", EditorStyles.boldLabel);

        GUILayout.BeginHorizontal();
        bool calculatePath = GUILayout.Button("Generate Path", GUILayout.Width(124));
        bool clearPath     = GUILayout.Button("Clear Path", GUILayout.Width(124));

        GUILayout.EndHorizontal();

        GUILayout.Label("Will clear path on deselect", EditorStyles.miniBoldLabel);
        GUILayout.Label("Not accurate to agents - Points are equal to NavMesh corners", EditorStyles.miniBoldLabel);


        //Generate the path
        if (calculatePath)
        {
            pathPoints = CalculateNavMeshPath();
        }

        //Clear it since it's not needed anymore
        if (clearPath)
        {
            pathPoints = null;
        }


        GUILayout.EndArea();
    }