Ejemplo n.º 1
0
    private GameObject _gameObject; // generic for prefabs that have data dispersed

    public void SetInfo(GameObject currentGameObject)
    {
        _destroyInfoInstances();

        if (!currentGameObject)
        {
            return;
        }

        _gameObject = currentGameObject;

        var shooter           = currentGameObject.GetComponent <Shooter>();
        var defender          = currentGameObject.GetComponent <Defender>();
        var attacker          = currentGameObject.GetComponent <Attacker>();
        var currencyButton    = currentGameObject.GetComponent <CurrencyButton>();
        var _currencyProducer = currentGameObject.GetComponent <CurrencyProducer>();

        _defenderButton = currentGameObject.GetComponent <DefenderButton>();
        _controlTower   = currentGameObject.GetComponent <ControlTower>();

        if (shooter)
        {
            _currentInfoShooter = Instantiate(infoShooter, transform.position, Quaternion.identity);
            _currentInfoShooter.transform.SetParent(transform);
        }
        else if (_controlTower || currencyButton)
        {
            _currentInfoResources = Instantiate(infoResources, transform.position, Quaternion.identity);
            _currentInfoResources.transform.SetParent(transform);
        }
        else if (_defenderButton)
        {
            _currentInfoDefenderButton = Instantiate(infoDefenderButton, transform.position, Quaternion.identity);
            _currentInfoDefenderButton.transform.SetParent(transform);
        }
        else if (attacker || _currencyProducer)
        {
            _currentInfoDamageHealthBar = Instantiate(infoDamageHealthBar, transform.position, Quaternion.identity);
            _currentInfoDamageHealthBar.transform.SetParent(transform);
        }
        else if (defender)     // Box
        {
            _currentInfoBox = Instantiate(infoBox, transform.position, Quaternion.identity);
            _currentInfoBox.transform.SetParent(transform);
        }
    }
 private void Start() {
     _infoShooter = FindObjectOfType<InfoShooter>();
 }