コード例 #1
0
    private void Build()
    {
        if (!_actionStarted)
        {
            return;
        }
        (bool, string)response;
        var position = _mapController.GetMousePosition(_mousePosition);

        switch (_state)
        {
        case State.Inactive:
            return;

        case State.BuildTerrain:
            _mapController.BuildTerrain(position, "Concrete");
            break;

        case State.BuildWall:
            response = _mapController.BuildWall(position);
            if (!response.Item1 && !_recentErrors.ContainsKey(position))
            {
                _recentErrors[position] = Time.time + 5f;
                FloatingTextManager.I().DisplayText(response.Item2, position, Color.red);
            }
            else
            {
                _recentErrors[position] = Time.time + 2f;
            }

            break;

        case State.DestroyWall:
            _mapController.DestroyWall(position);
            break;

        case State.BuildFurniture:
            response = _mapController.BuildFurniture(position, CurrentObjectName, rotations[_rotation]);
            if (!response.Item1 && !_recentErrors.ContainsKey(position))
            {
                _recentErrors[position] = Time.time + 5f;
                FloatingTextManager.I().DisplayText(response.Item2, position, Color.red);
            }
            else
            {
                _recentErrors[position] = Time.time + 2f;
            }

            if (response.Item1)
            {
                _uiController.UpdateSelectionName(CurrentObjectName);
            }
            _actionStarted = false;
            break;

        case State.DestroyFurniture:
            var values = _mapController.DestroyFurniture(position);
            _actionStarted = false;
            break;
        }
    }