public void BuildTrap()
    {
        if (isEmpty)
        {
            isEmpty = false;
        }
        else
        {
            Destroy(trapSpot.GetChild(0).gameObject);
        }

        trapType = selectedTrap;

        isCraftable = isCurrentCraftable;

        GameObject trap = Instantiate(currentTrapPrefab, trapSpot);

        trap.transform.position = transform.position;

        levelManager.UpdateMoney(-currentPrice);

        AudioManagerScript.instance.PlaySound(trapPlaceSound, name);

        uIManager.CollapseTrapMenu();
    }
Exemple #2
0
    public void Repair()
    {
        if (levelManager.currentMoney >= repairPrice)
        {
            levelManager.UpdateMoney(-repairPrice);
            repairButton.UpdateButton();

            currentLife += (life * repairPercent);
            if (currentLife > life)
            {
                currentLife = life;
            }
            UpdateUI();
            ShowRepairCanvas();
            uIManager.UpdateTrapMenu();
        }
    }
Exemple #3
0
    protected virtual void Die()
    {
        if (isAlive)
        {
            isAlive = false;
            myRigidBody2D.velocity = Vector2.zero;

            AudioManagerScript.instance.PlaySound(deathSound, name);

            myAnimator.SetBool("Is Alive", false);
            myAnimator.SetTrigger("Die");

            myCollider2D.enabled      = false;
            myRigidBody2D.isKinematic = true;

            LevelManager.UpdateMoney(money);
            waveManager.UpdateEnemiesAlive();
        }
    }