My on couch co-op platform game is nearing its first Alpha stage after working hard for almost a year. At the moment, I'm implementing some of the final mechanics to make it a fully working build, representing all the core elements of the game.
One of which is a mechanic that allows the players to pick up different weapons (swords, bows, guns etc) and items (shields, bombs, passive buff items etc) and steal them from one another. I'm struggling to implement this mechanic and would like to see how you would go about it.
Let me first line out what the general idea is before giving you all a blow by blow.
Each player may hold, at any time, only ONE weapon and ONE item. Each weapon may be used to perform attacks or, if it is a melee weapon, be thrown at a 4 direction angle (up,down,left and right). Same goes for items, they may be used (shields block, bombs are placed and buffs are cast) or thrown for an alternative effect.
Weapons and items can be stolen from enemies and other players by jumping on top of them (mario style). When jumped on from the front (i.e. the player is looking in the opposite direction that the enemy is looking) the enemy will drop its current weapon, which is vectorY'ed upwards. If jumped on from the back (i.e. the player is looking in the same direction as the enemy) the enemy will drop its current item which is vectorY'ed upwards.
So here is the blow by blow and the problem I'm having
1) Player has no weapon/item
2) Player overlaps with weapon/item and presses "DownArrow" (for example)
3) Weapon is "picked up", meaning it is set to the player sprite's "hand" image point and its angle adjusted etc
So far so good...
But here is where I get in trouble and would like some help:
4) Player ownes weapon/item
5) Player overlaps with weapon/item and presses "DownArrow" again.
6) The weapon held is "discarded" (vectored back and upwards, fade out into destroy in x seconds)
7) The weapon on the floor is picked up, insert step 3, rinse repeat.
In short: I would like for each player to be able to cycle from 1)no weapon 2)weapon 3)new weapon using only one pick up key.
As always, thank you all ever so much for reading and I look forward to your input.