private new void DrawSelectedPointInspector()
    {
        GUILayout.Label("Selected Point");
        EditorGUI.BeginChangeCheck();
        Vector3 point = EditorGUILayout.Vector3Field("Position", splinePP.GetControlPoint(selectedIndex));

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(splinePP, "Move Point");
            EditorUtility.SetDirty(splinePP);
            splinePP.SetControlPoint(selectedIndex, point);
        }
        EditorGUI.BeginChangeCheck();
        BezierControlPointMode mode = (BezierControlPointMode)
                                      EditorGUILayout.EnumPopup("Mode", splinePP.GetControlPointMode(selectedIndex));

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(splinePP, "Change Point Mode");
            splinePP.SetControlPointMode(selectedIndex, mode);
            EditorUtility.SetDirty(splinePP);
        }
    }
示例#2
0
 /// <summary>
 /// Changes police path statements (PolicePathMovingEnum)
 /// </summary>
 /// <param name="policePath"></param>
 private void PolicePathMovingStatements(PolicePath policePath)
 {
     if (!Stopped)
     {
         if (transform.position.z >= policePath.GetControlPoint(policePath.ChangePointIndex - 2).z)
         {
             if (transform.position.z >= policePath.GetControlPoint(policePath.ChangePointIndex).z)
             {
                 if (policePathMoving == PolicePathMovingEnum.Stop)
                 {
                     return;
                 }
                 else
                 {
                     policePathMoving = PolicePathMovingEnum.ExitFromTheRoad;
                 }
             }
             else
             {
                 policePathMoving = PolicePathMovingEnum.SpeedReduction;
             }
         }
     }
     else
     {
         if (transform.position.z > policePath.GetControlPoint(policePath.StopPointIndex + 3).z)
         {
             if (didNotLeavePolicemanBefore)
             {
                 policePath.Occupied        = false;
                 policePathMoving           = PolicePathMovingEnum.ReturnToTheRoad;
                 didNotLeavePolicemanBefore = false;
             }
         }
     }
 }
示例#3
0
    /// <summary>
    /// Actions while cars are in sight
    /// </summary>
    /// <param name="detectedCars"></param>
    private void DetectedCarsChecking(Dictionary <GameObject, CarMovement> detectedCars)
    {
        foreach (var car in detectedCars)
        {
            if (car.Key.Equals(null))
            {
                //Debug.Log(gameObject.name + "=> машины уже нет на карте!");
                detectedCars.Remove(car.Key);
                if (detectedCars.Count == 0)
                {
                    switch (policePathMoving)
                    {
                    case PolicePathMovingEnum.None:
                    case PolicePathMovingEnum.Starting:
                    case PolicePathMovingEnum.ReturnToTheRoad:
                        speedAdjustment = SpeedAdjustmentEnum.Increase;
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    int fwdCarsCount = 0;
                    foreach (var remCar in detectedCars)
                    {
                        if (car.Key.transform.position.z > transform.position.z)
                        {
                            fwdCarsCount++;
                        }
                    }
                    if (fwdCarsCount == 0)
                    {
                        speedAdjustment = SpeedAdjustmentEnum.Increase;
                    }
                }
                return;
            }
            switch (policePathMoving)
            {
            case PolicePathMovingEnum.Starting:
                //если машина, которая в поле зрения сзади
                if (car.Key.transform.position.z < transform.position.z)
                {
                    switch (car.Value.policePathMoving)
                    {
                    case PolicePathMovingEnum.None:
                        speedAdjustment = SpeedAdjustmentEnum.Stop;
                        break;

                    case PolicePathMovingEnum.ReturnToTheRoad:
                        speedAdjustment = SpeedAdjustmentEnum.Stop;
                        break;

                    default:
                        break;
                    }
                }
                else    //если машина, которая осталась в поле зрения спереди
                {
                    switch (car.Value.policePathMoving)
                    {
                    case PolicePathMovingEnum.None:
                        speedAdjustment = SpeedAdjustmentEnum.Stop;
                        break;

                    case PolicePathMovingEnum.SpeedReduction:
                        speedAdjustment = SpeedAdjustmentEnum.Decrease;
                        break;

                    case PolicePathMovingEnum.ReturnToTheRoad:
                        speedAdjustment = SpeedAdjustmentEnum.Stop;
                        break;

                    default:
                        break;
                    }
                }
                break;

            case PolicePathMovingEnum.None:
            {
                if (car.Key.transform.position.z > transform.position.z)        //если машина, которая осталась в поле зрения спереди
                {
                    if (car.Value.policePathMoving == PolicePathMovingEnum.ExitFromTheRoad)
                    {
                        PolicePath detectedCarPolicePath = car.Value.CurrentPath as PolicePath;
                        if (car.Key.transform.position.z > detectedCarPolicePath.GetControlPoint(detectedCarPolicePath.ChangePointIndex + 3).z)
                        {
                            speedAdjustment = SpeedAdjustmentEnum.Increase;
                        }
                    }
                }
                break;
            }
            }
            //Debug.Log(gameObject.name + "=>" + car.Key.name + " нахожусь в личном пространстве машины: " + car.Key.name +
            //    "\nМоё состояние на полицейском пути: " + policePathMoving +
            //    "\nМоя настройка скорости: " + speedAdjustment);
        }
    }