Пример #1
0
    IEnumerator Damage(GroundTile target)
    {
        GameObject cannonBall = Instantiate(cannon, new Vector3(target.transform.position.x, target.transform.position.y + GroundGrid.gridSize.y, 0), Quaternion.identity);

        cannonBall.GetComponent <CannonBall>().InitCannon(target.transform.position, warningSeconds);
        GameObject warningShot = Instantiate(warning, target.transform.position, Quaternion.identity);

        yield return(new WaitForSeconds(warningSeconds));

        Destroy(warningShot.gameObject);
        Destroy(cannonBall.gameObject);
        if (target.DecrDurability())
        {
            target.Break();
            spawnMaterials(target);
            availableTiles.Remove(target);
            StartCoroutine(playBreakAudio());
        }
    }