Exemple #1
0
    public void Use()
    {
        if (!pressed)
        {
            pressed = true;

            if (placed && placedMine == null)
            {
                placed = false;
                playerUI?.AbilityCooldown(timeout, controller.playerNr);
            }

            if (!placed && canPlace)
            {
                AudioManager1.instance.Play(toxicMineSound);
                placedMine = Instantiate(minePrefab, transform.position, Quaternion.identity).GetComponent <Explosive_ContactDamage>();
                placedMine.gameObject.layer = mineLayer;
                placedMine.transform.Find("Outline").GetComponent <SpriteRenderer>().color = controller.playerColor;
                //StartCoroutine(Cooldown());
                placed   = true;
                canPlace = false;
            }
            else if (placed)
            {
                placedMine.Explode();
                placed = false;
                playerUI?.AbilityCooldown(timeout, controller.playerNr);
            }
        }
    }
    private void Start()
    {
        rb2d = GetComponent <Rigidbody2D>();
        Explosive_ContactDamage explosive = GetComponent <Explosive_ContactDamage>();

        explosive.hitMask = explosive.hitMask & ~(1 << playerLayer);
    }