c# - Help on implementing how creatures and items interact in a computer role playing game -
I am playing a simple role playing game (for learning and fun) and I am at that point where I am Trying to make a way to interact with each other for game objects, there are two things that I am trying to avoid.
- Creating a huge game object It can also be done and everything can be done
- Complexity - That's why I like a component based on your I'm staying away from Jhain
If you need to give advice to act on each other for me game objects with those standards in mind. For example
- Creatures (characters, monsters, NPCs) can act on animals or items (weapons, drugs, traps, doors)
- Items on beings or items An example can also be going to be a trap when a character tries to open a chest
What I have come together is a PerformAction
method That creature can take the item as parameters such as
PerformAction (animal source c, item source i, q Lead target C, Item goal I) // should usually do 2 taps will conclude the parameter as // only one source and one target valid
or me instead?
Enter to correct the display action (object source, object target) // type and continue
Or should I completely Should you think differently from? This is a "double dispatch" problem In regular OO programming, you can control the operation of virtual method calls " The concrete type of class that enforces that object installation through "dispatch" does not need to know the type of actual implementation of a customer, it is only calling a method against a summary of a type of type. Single despatch ".
Most of the OO languages are anything Dual-dispatch occurs when the operation requires calling, depending on two different objects. Without dual dispatch support, implementing dual transmission in OO languages. For the standard mechanism design pattern, refer to the link to use this method.
Comments
Post a Comment