コード例 #1
0
    private void DoPutBombWithTimer(Player player, BombWithTimer bombPrefab, GameCell gameCell)
    {
        Vector3 bombPosition = levelManager.GetPositionConverter().ConvertBoardPositionToScene(gameCell.GetCoordinates(), true);

        bombPosition.y = bombPrefab.transform.localScale.y / 0.85f;

        BombWithTimer bomb = Instantiate(bombPrefab, bombPosition, Quaternion.identity) as BombWithTimer;

        bomb.player         = player.gameObject;
        bomb.detonateDelay  = GameManager.instance.GetBombDetonateDelay();
        bomb.explosionRange = GameManager.instance.GetPlayer().bombRange;
        gameCell.bomb       = bomb;

        AddToBombMap(player, bomb, gameCell);
        StartCoroutine(HandleBombPlaced(player, bomb, gameCell));
    }
コード例 #2
0
    private IEnumerator HandleBombPlaced(Player player, BombWithTimer bomb, GameCell gameCell)
    {
        // decrement counter value
        int timeLeft = bomb.detonateDelay;

        while (timeLeft > 0)
        {
            bomb.SetCountValue(timeLeft);
            yield return(new WaitForSeconds(1));

            timeLeft--;
        }

        // handle explosion
        if (!bomb.HasBeenDetonated())
        {
            DetonateBomb(bomb, player);
        }
    }