Battle in SuperTiles consist of 3 main components: BattleSettings, BattleEntity and BattleView

Information about BattleSettings is here.

BattleView is the main class which defines communication between all entities and visual game representation (View suffix indicates that this class is usually a MonoBehaviour successor and has corresponding entity class, this time it will be BattleEntity). This class is an implementation of Finite State Machine (FSM) which controls the Battle state.

In the picture below you could see a diagram of the FSM.

Preparations

BattleView starts from the Idle state where it does nothing. It only waits for internal actions (UI initializing, caching, etc.) to be done. After these actions are completed State Machine will go to the Main Loop.

Main Loop

Main Loop begins in the Spectator state for all players. Players wait at this state until BattleView receives the signal about the player which could make actions. This player could move freely between available Player actions: Move, Item and UnitSelection. Other players still are in the Spectator state (Waiting other actions). When current player's turn is finished (at a will or the time is up), current player is sent to the Spectator state and BattleView receives another signal of the next selected player.

BattleFinish state is similiar to Idle state except predefined scripting behaviour (calculating battle winners, spawning finish UI, etc.)

BattleEntity handles business game logic and contains current Battle state including:

  • The number of current turn
  • Current turn state (Starting, Started, Finishing, Finished)
  • Battle state (Started, Finished)
  • Players who participate in current Battle
  • Dead and alive units
  • Ai instances
  • and more

Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle