Пример #1
0
    // State changed
    public void OnPlayerInteractionChanged(GameManager.InteractionMode newState)
    {
        switch (newState)
        {
        case GameManager.InteractionMode.NoSelection:
            SetToggleButton(false, _wallButtonReference);
            SetToggleButton(false, _towerButtonReference);
            break;

        case GameManager.InteractionMode.TowerSelection:
            SetToggleButton(false, _wallButtonReference);
            SetToggleButton(true, _towerButtonReference);
            break;

        case GameManager.InteractionMode.WallSelection:
            SetToggleButton(true, _wallButtonReference);
            SetToggleButton(false, _towerButtonReference);
            break;

        case GameManager.InteractionMode.ConstructionConfirmation:
        case GameManager.InteractionMode.DestructionConfirmation:
            SetToggleButton(false, _wallButtonReference);
            SetToggleButton(false, _towerButtonReference);
            break;
        }
    }
Пример #2
0
    //// Public API
    public ConstructionSystem(Transform constructionsParent)
    {
        GameObject towerPrefab = Resources.Load("Prefabs/Tower") as GameObject;
        GameObject wallPrefab  = Resources.Load("Prefabs/Wall") as GameObject;

        this._gameManager = GameManager.Instance;
        this._towerPool   = new PrefabPoolingSystem(towerPrefab, _gameManager.TowerPoolSize, constructionsParent);
        this._wallPool    = new PrefabPoolingSystem(wallPrefab, _gameManager.WallPoolSize, constructionsParent);

        _mode = _gameManager.Interaction;
    }
Пример #3
0
    void UpdateCurrentStructure(GameManager.InteractionMode currentState, GameManager.InteractionMode nextState)
    {
        if (nextState == GameManager.InteractionMode.NoSelection)
        {
            if (_currentStructurePlacement != null)
            {
                switch (currentState)
                {
                case GameManager.InteractionMode.TowerSelection:
                    _towerPool.ReturnInstance(_currentStructurePlacement);
                    _currentStructurePlacement = null;
                    _currentStructureBehaviour = null;
                    break;

                case GameManager.InteractionMode.WallSelection:
                    _wallPool.ReturnInstance(_currentStructurePlacement);
                    _currentStructurePlacement = null;
                    _currentStructureBehaviour = null;
                    break;
                }
            }
        }
        else
        {
            // Return old
            switch (currentState) // Important - there is a validation in GameManager Interaction setter that checks if the current and next are the same
            {
            case GameManager.InteractionMode.TowerSelection:
                if (nextState != GameManager.InteractionMode.ConstructionConfirmation)
                {
                    _towerPool.ReturnInstance(_currentStructurePlacement);
                }
                break;

            case GameManager.InteractionMode.WallSelection:
                if (nextState != GameManager.InteractionMode.ConstructionConfirmation)
                {
                    _wallPool.ReturnInstance(_currentStructurePlacement);
                }
                break;

            case GameManager.InteractionMode.ConstructionConfirmation:
                ReturnConstructionToPool(_currentStructureBehaviour.gameObject);
                _gameManager.Input.SetInGameLayout();
                break;

            case GameManager.InteractionMode.DestructionConfirmation:
                _gameManager.Input.SetInGameLayout();
                break;
            }

            // Get new
            switch (nextState)
            {
            case GameManager.InteractionMode.TowerSelection:
                SetBlueprintedCurrentConstrution(_towerPool.GetInstance());
                break;

            case GameManager.InteractionMode.WallSelection:
                SetBlueprintedCurrentConstrution(_wallPool.GetInstance());
                break;
            }
        }
        _mode = nextState;
    }
Пример #4
0
 public void OnPlayerInteractionChanged(GameManager.InteractionMode nextState)
 {
     UpdateCurrentStructure(_mode, nextState);
 }