Example #1
0
        public KeyboardActionProcessorModel Execute(KeyEventArgs e, IPlayer player = null, List <Image> weaponImages = null, List <Image> potionImages = null)
        {
            //Here we compare if two objects INTERSECT
            Image playerPickedUpWeapon = GetSelectedItem(player.ShooterImage, weaponImages);
            Image playerPickedUpPotion = GetSelectedItem(player.ShooterImage, potionImages);

            KeyboardActionProcessorModel keyboardActionProcessor = new KeyboardActionProcessorModel();

            keyboardActionProcessor.ImagesCollected     = new List <Image>();
            keyboardActionProcessor.ActionExecuted      = new List <Enum>();
            keyboardActionProcessor.PlayerRelatedAction = PlayerRelatedActionsEnum.CollectItem;
            if (playerPickedUpWeapon != null)
            {
                keyboardActionProcessor.ImagesCollected.Add(playerPickedUpWeapon);
                keyboardActionProcessor.ActionExecuted.Add(WeaponActionsEnum.PickupWeapon);
            }

            if (playerPickedUpPotion != null)
            {
                keyboardActionProcessor.ImagesCollected.Add(playerPickedUpPotion);
                keyboardActionProcessor.ActionExecuted.Add(PotionActionsEnum.PickupPotion);
            }

            return(keyboardActionProcessor);
        }
Example #2
0
        public KeyboardActionProcessorModel Execute(KeyEventArgs e, IPlayer player = null, List <Image> weaponImages = null, List <Image> potionImages = null)
        {
            var result = player.DropWeapon_RemoveObserver();
            var keyboardActionProcessor = new KeyboardActionProcessorModel()
            {
                PlayerRelatedAction = PlayerRelatedActionsEnum.Weapon,
                ActionExecuted      = new List <Enum>()
                {
                    WeaponActionsEnum.DropWeapon
                },
            };

            return(null);
        }
Example #3
0
        public KeyboardActionProcessorModel SelectCommandKey(KeyEventArgs e, IPlayer player, List <Image> weaponImages, List <Image> potionImages)
        {
            KeyboardActionProcessorModel KeyboardActionProcessor = null;

            if (e.Key == Key.Space)
            {
                // WEAPON Strike
                var selectedCommand = _commandInvoker.GetCommand(Enums.CommandsEnum.Key_StrikeEnemy);
                KeyboardActionProcessor = selectedCommand.Execute(e, player, weaponImages, potionImages);
                return(KeyboardActionProcessor);
            }
            if (e.Key == Key.LeftShift)
            {
                // ITEM Pickup
                var selectedCommand = _commandInvoker.GetCommand(Enums.CommandsEnum.Key_PickupItem);
                KeyboardActionProcessor = selectedCommand.Execute(e, player, weaponImages, potionImages);
                return(KeyboardActionProcessor);
            }
            if (e.Key == Key.LeftCtrl)
            {
                // ITEM Drop
                var selectedCommand = _commandInvoker.GetCommand(Enums.CommandsEnum.Key_DropItem);
                KeyboardActionProcessor = selectedCommand.Execute(e, player, weaponImages, potionImages);
                //NO MORE code required
                return(null);
            }
            if (e.Key == Key.Up || e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right)
            {
                if (e.Key == Key.Left || e.Key == Key.Right)
                {
                    player.ShootingDirection_Player = e.Key;
                }

                //MOVEMENT Arrow Keys
                var selectedCommand = _commandInvoker.GetCommand(Enums.CommandsEnum.ArrowKeys_Movement);
                KeyboardActionProcessor = selectedCommand.Execute(e);
                return(KeyboardActionProcessor);
            }
            return(null);
        }
Example #4
0
        public void Form1_KeyDown_Event(KeyEventArgs e, IPlayer player, List <Image> allWeaponsImages, List <Image> allPotionsImages)
        {
            KeyboardActionProcessorModel keyboardActionProcessor = _KeyboardMediator.SelectCommandKey(e, player, allWeaponsImages, allPotionsImages);

            if (keyboardActionProcessor != null)
            {
                //Player Pickup Items
                if (keyboardActionProcessor.PlayerRelatedAction == PlayerRelatedActionsEnum.CollectItem)
                {
                    if (keyboardActionProcessor.ActionExecuted.Count > 0)
                    {
                        foreach (var actionExecuted in keyboardActionProcessor.ActionExecuted)
                        {
                            if (actionExecuted.ToString() == PotionActionsEnum.PickupPotion.ToString())
                            {
                                CollectItem(player, allPotionsImages, keyboardActionProcessor.ImagesCollected);
                            }

                            if (actionExecuted.ToString() == WeaponActionsEnum.PickupWeapon.ToString())
                            {
                                CollectItem(player, allWeaponsImages, keyboardActionProcessor.ImagesCollected);
                            }
                        }
                    }
                }

                //Player moves around
                if (keyboardActionProcessor.PlayerRelatedAction == PlayerRelatedActionsEnum.Movement)
                {
                    foreach (MovementDirectionEnum movement in keyboardActionProcessor.ActionExecuted)
                    {
                        player.PlayerMove(movement);
                    }
                }
            }
        }