コード例 #1
0
    public void buttonClick()
    {
        TowerBasic towerScript = tower.GetComponent <TowerBasic>();

        Money.money = Money.money + (towerScript.turretValue) / 2;
        Destroy(tower.transform.gameObject);
        buttonInteractable                   = false;
        buttonUpdated                        = false;
        ButtonTowerInfo.buttonUpdated        = false;
        ButtonTowerInfo.buttonInteractable   = false;
        ButtonDamage.buttonUpdated           = false;
        ButtonDamage.buttonInteractable      = false;
        ButtonAttackSpeed.buttonUpdated      = false;
        ButtonAttackSpeed.buttonInteractable = false;
        ButtonAttackRange.buttonUpdated      = false;
        ButtonAttackRange.buttonInteractable = false;
        ButtonClose.buttonUpdated            = false;
        ButtonClose.buttonInteractable       = false;
        buttonText = "";
        ButtonTowerInfo.buttonText   = "";
        ButtonDamage.buttonText      = "";
        ButtonAttackSpeed.buttonText = "";
        ButtonAttackRange.buttonText = "";
        ButtonClose.buttonText       = "";
    }
コード例 #2
0
ファイル: ButtonDamage.cs プロジェクト: Snifif/TD-Informatik
    public void buttonClick()
    {
        TowerBasic towerScript  = tower.GetComponent <TowerBasic>();
        int        upgradePrice = towerScript.turretPrice / 2 * (int)Mathf.Pow(2, towerScript.damageMultiplier);

        if (Money.money >= upgradePrice)
        {
            towerScript.damageMultiplier++;
            Money.money             = Money.money - upgradePrice;
            towerScript.turretValue = towerScript.turretValue + upgradePrice;
        }
        towerScript.MouseClick();
    }
コード例 #3
0
    private void OnMouseDown()  // Spawnen vom gewünschten Tower, wenn auf ein Node gedrückt wird
    {
        if (ConnectedTurret == null)
        {
            if (GameMenu.LT == true && Money.money >= 160)
            {
                ConnectedTurret = Instantiate(LaserTower, new Vector3(gameObject.transform.position.x, 0.8f, gameObject.transform.position.z), Quaternion.identity);
                Money.money     = Money.money - 160;
                TowerBasic tower = ConnectedTurret.GetComponent <TowerBasic>();
                tower.turretType  = "LaserTower";
                tower.turretPrice = laserTowerPrice;
                tower.turretValue = laserTowerPrice;
                towerPlaced       = true;
            }

            if (GameMenu.TT == true && Money.money >= 20)
            {
                ConnectedTurret = Instantiate(TurretTower, new Vector3(gameObject.transform.position.x, 0.8f, gameObject.transform.position.z), Quaternion.identity);
                Money.money     = Money.money - 20;
                TowerBasic tower = ConnectedTurret.GetComponent <TowerBasic>();
                tower.turretType  = "TurretTower";
                tower.turretPrice = turretTowerPrice;
                tower.turretValue = turretTowerPrice;
                towerPlaced       = true;
            }

            if (GameMenu.YT == true && Money.money >= 200)
            {
                ConnectedTurret = Instantiate(Yeeter, new Vector3(gameObject.transform.position.x, 0.8f, gameObject.transform.position.z), Quaternion.identity);
                Money.money     = Money.money - 200;
                TowerBasic tower = ConnectedTurret.GetComponent <TowerBasic>();
                tower.turretType  = "Yeeter";
                tower.turretPrice = yeeterPrice;
                tower.turretValue = yeeterPrice;
                towerPlaced       = true;
            }
            Money.UpdateBalance();
        }
        if (ConnectedTurret != null)
        {
            TowerBasic tower = ConnectedTurret.GetComponent <TowerBasic>();
            tower.MouseClick();
        }
    }