I want to change the cards in the demo game
The demo game uses two prefabs for the cards in your hand, CreatureCard and SpellCard, and one prefab for the creatures on the board, BoardCreature (these prefabs are located in the Demo/Prefabs folder). The corresponding scripts are CreatureCardView, SpellCardView and BoardCreature (located in the Demo/Scripts folder). It is recommended that you study these classes in order to know how the prefabs are populated from the card's information.
If you want a different image for every card you can use the existing "Picture" property all the cards in the demo have. It should be named after the corresponding sprite located in the Resources folder (which will be loaded dynamically).
I want to change the demo game so that creatures have a second "Attack"-like stat that is used when fighting a player
By default, the demo game uses a creature's "Attack" stat when resolving the damage in both player and creature fights. If you want to have two independent combat stats so that player fights will use the secondary stat, you can easily do it by following these steps:
- Create a new creature stat in the visual editor (we are calling it "Power" in this example):
Modify the FightPlayer method of the EffectSolver class so that the line that refers to the "Attack" stat:
attackedPlayer.namedStats["Life"].baseValue -= card.namedStats["Attack"].effectiveValue;
now refers to the "Power" stat:
attackedPlayer.namedStats["Life"].baseValue -= card.namedStats["Power"].effectiveValue;
Of course, you will also need to change the card prefabs to show the value of the "Power" stat in a new label.
I want to create a new scene/popup based off an existing one in the demo game
The user interface in the demo game makes extensive use of Unity's built-in UI system. The scene classes derive from the base BaseScene class, while the popup classes derive from the base Popup class (you can find these classes in the Demo/Scripts/Game folder). You can find the demo scenes in the Demo/Scenes folder and the popup prefabs in the Demo/Prefabs folder.
Please note that if you are creating a new popup and want to base it off an existing one, you should always place the popup prefab as a child of the scene's Canvas object and never directly in the scene hierarchy.
Where is the code that shows the preview of a card when hovering over it during the game located?
The code is located in the DemoHumanPlayer class; more specifically in its Update method. The relevant methods are named CreateCardPreview and DestroyCardPreview.
Where is the code for the game combat mechanics located?
The actual combat resolution code is located in the EffectSolver class; more specifically in its FightPlayer and FightCreature methods. There is an effect solver on the server side and another one on the client side (so that the client can run the game logic locally in order to prevent the perceived lag). Networking-wise, there are two network messages related to the combat: NetworkProtocol.FightPlayer and NetworkProtocol.FightCreature. These messages are handled by the server in the CombatHandler class. On the client side, the BoardCreature and DemoHumanPlayer classes are the ones that ultimately call the appropriate EffectSolver methods.