Documentation ¶
Index ¶
- Constants
- func New(ctx context.Context, ad *ActionDispatcher, rs *RouterStore, opt Options) error
- type ActionDispatcher
- func (ac *ActionDispatcher) CameraZoom(d int)
- func (ac *ActionDispatcher) ChangeUnitLine(uid string)
- func (ac *ActionDispatcher) CheckedPath(cp bool)
- func (ac *ActionDispatcher) CloseTowerMenu()
- func (ac *ActionDispatcher) CursorMove(x, y int)
- func (ac *ActionDispatcher) DeselectTower(t string)
- func (ac *ActionDispatcher) Dispatch(a *action.Action)
- func (ac *ActionDispatcher) ExitWaitingRoom(un string)
- func (ac *ActionDispatcher) GoHome()
- func (ac *ActionDispatcher) IncomeTick()
- func (ac *ActionDispatcher) JoinWaitingRoom(un string)
- func (ac *ActionDispatcher) NavigateTo(route string)
- func (ac *ActionDispatcher) OpenTowerMenu(tid string)
- func (ac *ActionDispatcher) PlaceTower(t, pid string, x, y int)
- func (ac *ActionDispatcher) RemovePlayer(pid string)
- func (ac *ActionDispatcher) RemoveTower(pid, tid, tt string)
- func (ac *ActionDispatcher) RemoveUnit(uid string)
- func (ac *ActionDispatcher) SelectTower(t string, x, y int)
- func (ac *ActionDispatcher) SelectedTowerInvalid(i bool)
- func (ac *ActionDispatcher) SignUpSubmit(un string)
- func (ac *ActionDispatcher) StealLive(fpid, tpid string)
- func (ac *ActionDispatcher) SummonUnit(unit, pid string, plid, clid int)
- func (ac *ActionDispatcher) TPS()
- func (ac *ActionDispatcher) ToggleStats()
- func (ac *ActionDispatcher) TowerAttack(uid, tt string)
- func (ac *ActionDispatcher) UnitKilled(pid, ut string)
- func (ac *ActionDispatcher) WindowResizing(w, h int)
- type CameraState
- type CameraStore
- type Game
- type HUDState
- type HUDStore
- type LobbyState
- type LobbyStore
- type LoggerStore
- type Map
- type Options
- type RouterState
- type RouterStore
- type SelectedTower
- type SignUpState
- type SignUpStore
- type Store
- type Towers
- type Units
- type UserState
- type UserStore
- type WaitingRoomState
- type WaitingRoomStore
Constants ¶
const ( SignUpRoute = "sign_up" LobbyRoute = "lobby" GameRoute = "game" WaitingRoomRoute = "waiting_room" )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(ctx context.Context, ad *ActionDispatcher, rs *RouterStore, opt Options) error
Types ¶
type ActionDispatcher ¶
type ActionDispatcher struct {
// contains filtered or unexported fields
}
ActionDispatcher is in charge of dispatching actions to the application dispatcher
func NewActionDispatcher ¶
func NewActionDispatcher(d *flux.Dispatcher, s *store.Store, opt Options) *ActionDispatcher
NewActionDispatcher initializes the action dispatcher with the give dispatcher
func (*ActionDispatcher) CameraZoom ¶
func (ac *ActionDispatcher) CameraZoom(d int)
CameraZoom zooms the camera the direction 'd'
func (*ActionDispatcher) ChangeUnitLine ¶
func (ac *ActionDispatcher) ChangeUnitLine(uid string)
ChangeUnitLine will move the unit to the next line
func (*ActionDispatcher) CheckedPath ¶
func (ac *ActionDispatcher) CheckedPath(cp bool)
CheckedPath will set the value of the path checked
func (*ActionDispatcher) CloseTowerMenu ¶
func (ac *ActionDispatcher) CloseTowerMenu()
CloseTowerMenu when a tower menu needs to be closed
func (*ActionDispatcher) CursorMove ¶
func (ac *ActionDispatcher) CursorMove(x, y int)
CursorMove dispatches an action of moving the Cursor to the new x,y coordinates
func (*ActionDispatcher) DeselectTower ¶
func (ac *ActionDispatcher) DeselectTower(t string)
DeelectTower cleans the current selected tower
func (*ActionDispatcher) Dispatch ¶
func (ac *ActionDispatcher) Dispatch(a *action.Action)
Dispatch is a helper to access to the internal dispatch directly with an action. This should only be used from the WS Handler to forward server actions directly
func (*ActionDispatcher) ExitWaitingRoom ¶
func (ac *ActionDispatcher) ExitWaitingRoom(un string)
func (*ActionDispatcher) GoHome ¶
func (ac *ActionDispatcher) GoHome()
GoHome will move the camera to the current player home line
func (*ActionDispatcher) IncomeTick ¶
func (ac *ActionDispatcher) IncomeTick()
IncomeTick a new tick for the income
func (*ActionDispatcher) JoinWaitingRoom ¶
func (ac *ActionDispatcher) JoinWaitingRoom(un string)
func (*ActionDispatcher) NavigateTo ¶
func (ac *ActionDispatcher) NavigateTo(route string)
NavigateTo navigates to the given route
func (*ActionDispatcher) OpenTowerMenu ¶
func (ac *ActionDispatcher) OpenTowerMenu(tid string)
OpenTowerMenu when a tower is clicked and the menu of the tower is displayed
func (*ActionDispatcher) PlaceTower ¶
func (ac *ActionDispatcher) PlaceTower(t, pid string, x, y int)
PlaceTower places the tower 't' on the position X and Y of the player pid
func (*ActionDispatcher) RemovePlayer ¶
func (ac *ActionDispatcher) RemovePlayer(pid string)
func (*ActionDispatcher) RemoveTower ¶
func (ac *ActionDispatcher) RemoveTower(pid, tid, tt string)
RemoveTower removes the tower tid
func (*ActionDispatcher) RemoveUnit ¶
func (ac *ActionDispatcher) RemoveUnit(uid string)
RemoveUnit removes the unit with the id 'uid'
func (*ActionDispatcher) SelectTower ¶
func (ac *ActionDispatcher) SelectTower(t string, x, y int)
SelectTower selects the tower 't' on the position x, y
func (*ActionDispatcher) SelectedTowerInvalid ¶
func (ac *ActionDispatcher) SelectedTowerInvalid(i bool)
SelectTower selects the tower 't' on the position x, y
func (*ActionDispatcher) SignUpSubmit ¶
func (ac *ActionDispatcher) SignUpSubmit(un string)
func (*ActionDispatcher) StealLive ¶
func (ac *ActionDispatcher) StealLive(fpid, tpid string)
StealLive removes one live from the player with id 'fpid' and adds it to the player with id 'tpid'
func (*ActionDispatcher) SummonUnit ¶
func (ac *ActionDispatcher) SummonUnit(unit, pid string, plid, clid int)
SummonUnit summons the 'unit' from the player id 'pid' to the line 'plid' and with the current line id 'clid'
func (*ActionDispatcher) TPS ¶
func (ac *ActionDispatcher) TPS()
TPS is the call for every TPS event
func (*ActionDispatcher) ToggleStats ¶
func (ac *ActionDispatcher) ToggleStats()
func (*ActionDispatcher) TowerAttack ¶
func (ac *ActionDispatcher) TowerAttack(uid, tt string)
TowerAttack issues a attack to the Unit with uid
func (*ActionDispatcher) UnitKilled ¶
func (ac *ActionDispatcher) UnitKilled(pid, ut string)
UnitKilled adds gold to the user
func (*ActionDispatcher) WindowResizing ¶
func (ac *ActionDispatcher) WindowResizing(w, h int)
WindowResizing new sizes of the window
type CameraState ¶
CameraState is the store data on the Camera
type CameraStore ¶
type CameraStore struct { *flux.ReduceStore Store *store.Store // contains filtered or unexported fields }
CameraStore is in charge of what it's seen on the screen, it also tracks the position of the cursor and the wheel scroll
func NewCameraStore ¶
func NewCameraStore(d *flux.Dispatcher, s *store.Store, w, h int) *CameraStore
NewCameraStore creates a new CameraState linked to the Dispatcher d with the Game g and with width w and height h which is the size of the viewport
func (*CameraStore) Draw ¶
func (cs *CameraStore) Draw(screen *ebiten.Image)
func (*CameraStore) Reduce ¶
func (cs *CameraStore) Reduce(state, a interface{}) interface{}
func (*CameraStore) Update ¶
func (cs *CameraStore) Update() error
type Game ¶
type Game struct { Store *store.Store Camera *CameraStore HUD *HUDStore Units *Units Towers *Towers Map *Map }
Game is the main struct that is the initializer of the main loop. It holds all the other Stores and the Map
type HUDState ¶
type HUDState struct { SelectedTower *SelectedTower TowerOpenMenuID string LastCursorPosition utils.Object CheckedPath bool ShowStats bool }
HUDState stores the HUD state
type HUDStore ¶
type HUDStore struct { *flux.ReduceStore // contains filtered or unexported fields }
HUDStore is in charge of keeping track of all the elements on the player HUD that are static and always seen
func NewHUDStore ¶
NewHUDStore creates a new HUDStore with the Dispatcher d and the Game g
type LobbyState ¶
type LobbyState struct {
TotalUsers int
}
type LobbyStore ¶
type LobbyStore struct { *flux.ReduceStore Store *Store // contains filtered or unexported fields }
func NewLobbyStore ¶
func NewLobbyStore(d *flux.Dispatcher, i inputer.Inputer, s *Store) (*LobbyStore, error)
func (*LobbyStore) Draw ¶
func (ls *LobbyStore) Draw(screen *ebiten.Image)
func (*LobbyStore) Reduce ¶
func (ls *LobbyStore) Reduce(state, a interface{}) interface{}
func (*LobbyStore) Update ¶
func (ls *LobbyStore) Update() error
type LoggerStore ¶
type LoggerStore struct {
*flux.ReduceStore
}
LoggerStore is a logger store in charge of logging all the actions
func NewLoggerStore ¶
func NewLoggerStore(d *flux.Dispatcher) *LoggerStore
NewLoggerStore creates a new LoggerStore with the Dispatcher d
func (*LoggerStore) Reduce ¶
func (ss *LoggerStore) Reduce(cstate, a interface{}) interface{}
type RouterState ¶
type RouterState struct {
Route string
}
type RouterStore ¶
type RouterStore struct { *flux.ReduceStore // contains filtered or unexported fields }
func NewRouterStore ¶
func NewRouterStore(d *flux.Dispatcher, su *SignUpStore, l *LobbyStore, wr *WaitingRoomStore, g *Game) *RouterStore
func (*RouterStore) Draw ¶
func (rs *RouterStore) Draw(screen *ebiten.Image)
func (*RouterStore) Layout ¶
func (rs *RouterStore) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)
func (*RouterStore) Reduce ¶
func (rs *RouterStore) Reduce(state, a interface{}) interface{}
func (*RouterStore) Update ¶
func (rs *RouterStore) Update() error
type SelectedTower ¶
type SignUpState ¶
type SignUpState struct {
Error string
}
type SignUpStore ¶
type SignUpStore struct { *flux.ReduceStore Store *store.Store Camera *CameraStore // contains filtered or unexported fields }
func NewSignUpStore ¶
func (*SignUpStore) Draw ¶
func (su *SignUpStore) Draw(screen *ebiten.Image)
func (*SignUpStore) Reduce ¶
func (su *SignUpStore) Reduce(state, a interface{}) interface{}
func (*SignUpStore) Update ¶
func (su *SignUpStore) Update() error
type Towers ¶
type Towers struct {
// contains filtered or unexported fields
}
type Units ¶
type Units struct {
// contains filtered or unexported fields
}
type UserStore ¶
type UserStore struct {
*flux.ReduceStore
}
func NewUserStore ¶
func NewUserStore(d *flux.Dispatcher) *UserStore
type WaitingRoomState ¶
type WaitingRoomStore ¶
type WaitingRoomStore struct { *flux.ReduceStore Store *Store // contains filtered or unexported fields }
func NewWaitingRoomStore ¶
func NewWaitingRoomStore(d *flux.Dispatcher, s *Store) *WaitingRoomStore
func (*WaitingRoomStore) Draw ¶
func (wr *WaitingRoomStore) Draw(screen *ebiten.Image)
func (*WaitingRoomStore) Reduce ¶
func (wr *WaitingRoomStore) Reduce(state, a interface{}) interface{}
func (*WaitingRoomStore) Update ¶
func (wr *WaitingRoomStore) Update() error