コード例 #1
0
ファイル: Player.cs プロジェクト: zack-hill/bomberman-unity
    protected void PlaceBomb()
    {
        if (ActiveBombCount == MaxBombCount)
        {
            return;
        }

        var bombGameObject = Instantiate(Bomb, transform.position, Quaternion.identity);
        var bomb           = bombGameObject.GetComponent <Bomb>();

        bomb.OwningPlayer = gameObject;
        bomb.Exploded    += BombOnExploded;

        BombPlaced?.Invoke(this, bombGameObject);

        ActiveBombCount += 1;
    }
コード例 #2
0
ファイル: GameController.cs プロジェクト: iridinite/ld42
    public static bool PlaceBombAt(int x, int y, Pawn owner)
    {
        // check that no bomb has already been placed here
        foreach (var other in m_bombs)
        {
            if (other.GetMapX() == x && other.GetMapY() == y)
            {
                return(false);
            }
        }

        // create and configure new bomb
        var bomb = m_root.CreateBomb(x, y);

        bomb.SetOwner(owner);
        bomb.SetRange(owner.BombRange);

        m_bombs.Add(bomb);
        BombPlaced?.Invoke(bomb, owner);
        return(true);
    }