コード例 #1
0
ファイル: ItemBombs.cs プロジェクト: radtek/ZeldaOracle
        //-----------------------------------------------------------------------------
        // Virtual
        //-----------------------------------------------------------------------------

        public override void OnButtonPress()
        {
            if (bombTracker.IsEmpty)
            {
                if (HasAmmo())
                {
                    // Conjure a new bomb.
                    UseAmmo();
                    Bomb bomb = new Bomb();
                    bombTracker.TrackEntity(bomb);
                    Player.CarryState.SetCarryObject(bomb);
                    Player.BeginState(Player.CarryState);
                }
            }
            else
            {
                // Pickup a bomb from the ground.
                Bomb bomb = bombTracker.GetEntity();
                if (bomb != null && Player.Physics.IsSoftMeetingEntity(bomb))
                {
                    Player.BeginState(new PlayerCarryState(bomb));
                    bomb.RemoveFromRoom();
                }
            }
        }