Exemplo n.º 1
0
        private void SwitchWeapon( Weapon newWeapon, UIShortcutButton button )
        {
            Weapon oldWeapon = button.Weapon;

            if ( oldWeapon != null )
            {
                if ( oldWeapon.Munition != null && player.GetItemCountFromInventar( oldWeapon.Munition.TypeId) >0 )
                {
                    // munition ins Inventar
                    player.AddItemToInventar( oldWeapon.Munition );
                    filteredInventarList.AddItem( oldWeapon.Munition );
                }

                //Waffe ins inventar
                player.RemoveWeaponFromShortcutList( button.Key );
                player.AddItemToInventar( oldWeapon );
                filteredInventarList.AddItem( oldWeapon );
                button.Weapon = null;
            }
            if ( newWeapon != null )
            {
                //Waffe ändern
                player.AddWeaponToShortcutList( button.Key, newWeapon );
                player.RemoveItemFromInventar( newWeapon );
                button.Weapon = newWeapon;

            }
        }
Exemplo n.º 2
0
        private void HandleShortcutButtonClick( UIShortcutButton element )
        {
            UIShortcutButton button = element;

            if ( activeItem == null )
            {
                if ( player.Shortcuts.Values.Count > 1 )
                {
                    SwitchWeapon( null, button );
                }
            }
            else if ( activeItem.GetType() == typeof( Weapon ) )
            {
                SwitchWeapon( ( Weapon ) activeItem, button );
            }
            else if ( activeItem.GetType() == typeof( Munition ) )
            {
                SwitchMun( ( Munition ) activeItem, button );
            }
            else
            {
                if ( player.Shortcuts.Values.Count > 1 )
                {
                    SwitchWeapon( null, button );
                }
            }
            activeItem = null;

            filteredInventarList.RefreshItemList();

            btnOk.IsEnabled = false;
            btnCancel.IsEnabled = false;
        }
Exemplo n.º 3
0
        private void SwitchMun( Munition newMunition, UIShortcutButton button )
        {
            Weapon oldWeapon = button.Weapon;

            if ( oldWeapon != null )
            {
                if ( oldWeapon.Munition != null )
                {
                    Munition oldMun = button.Weapon.Munition;
                    Munition newMun = newMunition.Clone();

                    if ( newMun.TypeId == oldMun.TypeId )
                    {
                        button.Weapon.Reload();
                    }
                    else
                    {
                        //mun setzten
                        player.AddItemToInventar( oldMun );
                        filteredInventarList.AddItem( oldMun );

                        newMun.Count = Math.Min( player.Inventar[ newMun.TypeId ], newMun.MagazineSize );

                        button.Weapon.Munition = newMun;
                        player.RemoveItemFromInventar( newMun );
                    }

                }
                else
                {
                    //mun ändern
                    // Wenn die Waffe, die am Shortcut "klebt" auch munition hat
                    newMunition.Count = Math.Min( player.GetItemCountFromInventar( newMunition.TypeId ), newMunition.MagazineSize );
                    button.Weapon.Munition = newMunition;
                    player.RemoveItemFromInventar( newMunition );
                }
            }
        }
Exemplo n.º 4
0
        private void GenerateShortcuts()
        {
            Dictionary<int, Weapon> shortcuts = player.Shortcuts;

            for ( int i = 0; i < 4; i++ )
            {
                UIShortcutButton shortcutButton = new UIShortcutButton( 300, DEFAULT_HEIGHT, new Vector2( 20, 60 + DEFAULT_HEIGHT * i ), i + 1 );
                shortcutButton.AddActionListener( this );
                Add( shortcutButton );
                shortcutButtons.Add( shortcutButton );
            }

            foreach ( KeyValuePair<int,Weapon> pair in shortcuts )
            {
                shortcutButtons[ pair.Key - 1 ].Weapon = pair.Value;
            }
        }