Exemple #1
0
    private void DestroyPlaceStart()
    {
        if (placeStart != null)
        {
            // Stop any ongoing grid generation
            placeStart.StopGridGeneration();

            Destroy(placeStart.gameObject);
            placeStart = null;
        }
    }
Exemple #2
0
    private void SetAction(Action newAction)
    {
        if (action == newAction || changingAction)
        {
            return;
        }

        if (newAction != Action.None && (networkPatch == null || reachabilityPatch == null))
        {
            if (networkPatch == null)
            {
                Debug.LogWarning("Network data is not available.");
            }
            if (reachabilityPatch == null)
            {
                Debug.LogWarning("Reachability data is not available.");
            }
            return;
        }

        changingAction = true;

        switch (action)
        {
        case Action.None:
            break;

        case Action.PlaceStartSingle:
            startSingleButton.isOn = false;
            placeStart.Deactivate();
            break;

        case Action.PlaceStartMulti:
            startMultiButton.isOn = false;
            placeStart.Deactivate();
            break;

        case Action.CreateRoad:
            createRoadToggle.isOn = false;
            FinishCreateRoad();
            break;

        case Action.RemoveRoad:
            removeRoadToggle.isOn = false;
            AllowRemoveRoads(false);
            break;
        }

        switch (newAction)
        {
        case Action.None:
            break;

        case Action.PlaceStartSingle:
        case Action.PlaceStartMulti:
            if (placeStart == null)
            {
                placeStart      = Instantiate(placeStartPrefab);
                placeStart.name = placeStartPrefab.name;
            }
            float travelTime = traveTimeSlider.value * travelTimeScale;
            placeStart.Init(networkPatch, reachabilityPatch, mobilityModes[mobilityMode].invSpeeds, travelTime);
            placeStart.SetNewRoads(activeRoadLayers);
            placeStart.Activate();
            placeStart.isMultiStart = newAction == Action.PlaceStartMulti;
            break;

        case Action.CreateRoad:
            StartCreateRoad();
            break;

        case Action.RemoveRoad:
            AllowRemoveRoads(true);
            break;
        }

        action         = newAction;
        changingAction = false;
    }