I have a weapon class that want to use it for players and AIs.
Weapon class has several fields (attackpoint,attackspeed,…)and attack method
a player can press a button to attack.(the button color changes to gray when bullets are finished and the player has to wait to reload them).
I have several approaches to implement them.
1-First use IWeapon interface and implement attack method in CWeaponPlayer and CWeaponAI separately.
2- use one CWeapon class and check the player is human or AI so I can access to button attack uis and change the color , etc
3- create a new attack UI Controller component and add them to the player only and change the color button and etc.
…
plz say which approach is standard and intelligently
thx in advance
I would definitely go with interfaces.
You can also add interfaces to MonoBehaviour classes, but the Unity Inspector will ignore them (although you could write a custom inspector to expose their properties). However, they’ll work from code so that might be useful if, for example, you want to drop a particular weapon on some enemy that you place in the level through the editor.