예제 #1
0
 public void RemoveTileEventHandler(TileEventHandler teh)
 {
     _tileEventHandlers.Remove(teh);
     _healtileEventHandlers.Remove(teh);
     //Debug.Log("TC: Remove a tileEventHandler, total " + _tileEventHandlers.Count);
     //Debug.Log("TC: Remove a tileEventHandlerForHealTower, total " + _healtileEventHandlers.Count);
 }
예제 #2
0
        public Tile(GameObject gameObject, int x, int y, float blockSize, Transform parentTransform, Vector3 startPosition)
        {
            GridX     = x;
            GridY     = y;
            BlockSize = blockSize;
            Vector3 tilePosition = startPosition;

            tilePosition.x += GridX * blockSize + blockSize / 2;
            tilePosition.y += GridY * blockSize + blockSize / 2;
            tilePosition.z += 0f;

            Position = tilePosition;

            TileObject = Instantiate(gameObject, tilePosition, Quaternion.identity) as GameObject;
            if (TileObject == null)
            {
                Debug.LogAssertion("Unable to create tile at " + x + "," + y);
                return;
            }
            TileObject.transform.SetParent(parentTransform);
            TileEventHandler eventHandler = TileObject.GetComponent <TileEventHandler>();

            if (eventHandler != null)
            {
                eventHandler.GridX = GridX;
                eventHandler.GridY = GridY;
            }
        }
예제 #3
0
 public void setTowerEventHandler(TileEventHandler teh)
 {
     _tileEventHandler = teh;
     //Debug.Log("SB: setTowerEventHandler called, position" + _tileEventHandler.GridX + " " + _tileEventHandler.GridY);
     if (null == _buildCheckPanel)
     {
         _buildCheckPanel   = BuildCheckPanel.Instance;
         _towerInfoPanel    = TowerInfoPanel.Instance;
         _notificationPanel = NotificationPanel.Instance;
     }
 }
 public void setTowerEventHandler(TileEventHandler teh)
 {
     _enoughGold = true;
     _destroy    = false;
     if (null == _tileEventHandler)
     {
         _buildCheckPanel   = BuildCheckPanel.Instance;
         _towerInfoPanel    = TowerInfoPanel.Instance;
         _notificationPanel = NotificationPanel.Instance;
     }
     _tileEventHandler = teh;
 }
    public void setTowerEventHandler(TileEventHandler teh)
    {
        _tileEventHandler = teh;
        if (null == _gameBoard)
        {
            _towerController = TowerController.Instance;                                 // used for check range
            _gameBoard       = GameManager.Instance.CurrentLevelManager.GameBoardSystem; // used for highlight

            _buildCheckPanel   = BuildCheckPanel.Instance;                               // used for set appear
            _towerInfoPanel    = TowerInfoPanel.Instance;                                // used for set appear
            _notificationPanel = NotificationPanel.Instance;                             // used for notification, set appear
        }
    }
예제 #6
0
 // set current selected TileEventHandler
 public void setTileEventHandler(TileEventHandler teh)
 {
     _upgradeCase      = false;
     _tileEventHandler = teh;
     if (null == _gameBoard)
     {
         _levelManager        = GameManager.Instance.CurrentLevelManager;
         _gameBoard           = _levelManager.GameBoardSystem;
         _towerBuildPanel     = TowerBuildPanel.Instance;
         _buildCheckPanel     = BuildCheckPanel.Instance;
         _towerInfoPanel      = TowerInfoPanel.Instance;
         _towerOperationPanel = TowerOperationPanel.Instance;
         _notificationPanel   = NotificationPanel.Instance;
     }
 }
예제 #7
0
    public GameObject BuildTower(TileEventHandler teh, int x, int y, int index)
    {
        Vector3 gamePosition = _gameBoard.BoardTiles[x, y].TileObject.transform.position;

        _towerGameObject = Instantiate(Towers[index], gamePosition, Quaternion.identity) as GameObject;
        switch (index)
        {
        case 0:
            _tankTowerPtr = _towerGameObject.GetComponent <TankTower>();    // get scripts
            if (_tankTowerPtr.BuildCost > _levelManager.GetGold())
            {
                //Debug.Log("TC: Not enough gold to build");
                _notificationPanel.SetNotificationType("NotEnoughMoney");
                _notificationPanel.Appear();
                Destroy(_towerGameObject);
                return(null);
            }
            break;

        case 1:
            _rangeTowerPtr = _towerGameObject.GetComponent <RangeTower>();    // get scripts
            if (_rangeTowerPtr.BuildCost > _levelManager.GetGold())
            {
                //Debug.Log("TC: Not enough gold to build");
                _notificationPanel.SetNotificationType("NotEnoughMoney");
                _notificationPanel.Appear();
                Destroy(_towerGameObject);
                return(null);
            }
            break;

        case 2:
            _slowTowerPtr = _towerGameObject.GetComponent <SlowTower>();    // get scripts
            if (_slowTowerPtr.BuildCost > _levelManager.GetGold())
            {
                //Debug.Log("TC: Not enough gold to build");
                _notificationPanel.SetNotificationType("NotEnoughMoney");
                _notificationPanel.Appear();
                Destroy(_towerGameObject);
                return(null);
            }
            break;

        case 3:
            _healTowerPtr = _towerGameObject.GetComponent <HealTower>();    // get scripts
            if (_healTowerPtr.BuildCost > _levelManager.GetGold())
            {
                //Debug.Log("TC: Not enough gold to build");
                _notificationPanel.SetNotificationType("NotEnoughMoney");
                _notificationPanel.Appear();
                Destroy(_towerGameObject);
                return(null);
            }
            break;

        case 4:
            _goldTowerPtr = _towerGameObject.GetComponent <GoldTower>();    // get scripts
            if (_goldTowerPtr.BuildCost > _levelManager.GetGold())
            {
                //Debug.Log("TC: Not enough gold to build");
                _notificationPanel.SetNotificationType("NotEnoughMoney");
                _notificationPanel.Appear();
                Destroy(_towerGameObject);
                return(null);
            }
            break;
            // TODO~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        }
        //Debug.Log("TC: Tower object created");
        return(_towerGameObject);
    }
예제 #8
0
 public void AddHealTileEventHandler(TileEventHandler teh)
 {
     _healtileEventHandlers.Add(teh);
     //Debug.Log("TC: Add a healTileEventHandler, total " + _healtileEventHandlers.Count);
 }
예제 #9
0
 public void AddTileEventHandler(TileEventHandler teh)
 {
     _tileEventHandlers.Add(teh);
     //Debug.Log("TC: Add a tileEventHandler, total " + _tileEventHandlers.Count);
 }