tweaks
This commit is contained in:
@@ -30,6 +30,10 @@ func (d *Domain) InitDialog() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Domain) GetDialogMap() entity.DialogMap {
|
||||||
|
return d.DialogMap
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Domain) GetDialog(name string) entity.Dialog {
|
func (d *Domain) GetDialog(name string) entity.Dialog {
|
||||||
value, _ := d.DialogMap[name]
|
value, _ := d.DialogMap[name]
|
||||||
return value
|
return value
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ func (d *Domain) InitLevel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Domain) GetLevels() []entity.Level {
|
||||||
|
return d.Levels
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Domain) GetLevel(index int) entity.Level {
|
func (d *Domain) GetLevel(index int) entity.Level {
|
||||||
return d.Levels[index]
|
return d.Levels[index]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ func (d *Domain) InitMenu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Domain) GetMenuMap() entity.MenuMap {
|
||||||
|
return d.MenuMap
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Domain) GetMenu(name string) entity.Menu {
|
func (d *Domain) GetMenu(name string) entity.Menu {
|
||||||
value, _ := d.MenuMap[name]
|
value, _ := d.MenuMap[name]
|
||||||
return value
|
return value
|
||||||
|
|||||||
@@ -18,32 +18,28 @@ func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
|
|||||||
return e.Settings.Screen.Width, e.Settings.Screen.Height
|
return e.Settings.Screen.Width, e.Settings.Screen.Height
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) ScreenTypeIs(name string) bool {
|
|
||||||
return e.KContext.Screen.Type == name
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Engine) Update(screen *ebiten.Image) error {
|
func (e *Engine) Update(screen *ebiten.Image) error {
|
||||||
e.WatchKeyPress()
|
e.WatchKeyPress()
|
||||||
if e.ScreenTypeIs("menu") {
|
if e.KContext.ScreenTypeIs("menu") {
|
||||||
e.MenuUpdate()
|
e.MenuUpdate()
|
||||||
}
|
}
|
||||||
if e.ScreenTypeIs("dialog") {
|
if e.KContext.ScreenTypeIs("dialog") {
|
||||||
e.DialogUpdate()
|
e.DialogUpdate()
|
||||||
}
|
}
|
||||||
if e.ScreenTypeIs("playground") {
|
if e.KContext.ScreenTypeIs("playground") {
|
||||||
e.PlaygroundUpdate()
|
e.PlaygroundUpdate()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) Draw(screen *ebiten.Image) {
|
func (e *Engine) Draw(screen *ebiten.Image) {
|
||||||
if e.ScreenTypeIs("menu") {
|
if e.KContext.ScreenTypeIs("menu") {
|
||||||
e.MenuDraw(screen)
|
e.MenuDraw(screen)
|
||||||
}
|
}
|
||||||
if e.ScreenTypeIs("dialog") {
|
if e.KContext.ScreenTypeIs("dialog") {
|
||||||
e.DialogDraw(screen)
|
e.DialogDraw(screen)
|
||||||
}
|
}
|
||||||
if e.ScreenTypeIs("playground") {
|
if e.KContext.ScreenTypeIs("playground") {
|
||||||
e.PlaygroundDraw(screen)
|
e.PlaygroundDraw(screen)
|
||||||
}
|
}
|
||||||
if e.Action3Pressed() {
|
if e.Action3Pressed() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (e *Engine) DialogDraw(screen *ebiten.Image) {
|
func (e *Engine) DialogDraw(screen *ebiten.Image) {
|
||||||
dialog := e.Domain.GetDialog(e.KContext.Screen.Value)
|
dialog := e.Domain.GetDialog(e.KContext.ScreenValue)
|
||||||
|
|
||||||
face := GetFontFace(dialog.Layout.ChoiceFont)
|
face := GetFontFace(dialog.Layout.ChoiceFont)
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ func (e *Engine) DialogDraw(screen *ebiten.Image) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) DialogUpdate() {
|
func (e *Engine) DialogUpdate() {
|
||||||
dialog := e.Domain.GetDialog(e.KContext.Screen.Value)
|
dialog := e.Domain.GetDialog(e.KContext.ScreenValue)
|
||||||
|
|
||||||
if e.UpPressed() && dialog.CurrentSelected != 0 {
|
if e.UpPressed() && dialog.CurrentSelected != 0 {
|
||||||
dialog.CurrentSelected--
|
dialog.CurrentSelected--
|
||||||
@@ -30,5 +30,5 @@ func (e *Engine) DialogUpdate() {
|
|||||||
if e.Action0Pressed() {
|
if e.Action0Pressed() {
|
||||||
dialog.Choices[dialog.CurrentSelected].Handler()
|
dialog.Choices[dialog.CurrentSelected].Handler()
|
||||||
}
|
}
|
||||||
e.Domain.SetDialog(e.KContext.Screen.Value, dialog)
|
e.Domain.SetDialog(e.KContext.ScreenValue, dialog)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (e *Engine) MenuDraw(screen *ebiten.Image) {
|
func (e *Engine) MenuDraw(screen *ebiten.Image) {
|
||||||
menu := e.Domain.GetMenu(e.KContext.Screen.Value)
|
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
|
||||||
face := GetFontFace(menu.Layout.MenuItemFont)
|
face := GetFontFace(menu.Layout.MenuItemFont)
|
||||||
|
|
||||||
for i, menu_item := range menu.MenuItems {
|
for i, menu_item := range menu.MenuItems {
|
||||||
@@ -17,7 +17,7 @@ func (e *Engine) MenuDraw(screen *ebiten.Image) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) MenuUpdate() {
|
func (e *Engine) MenuUpdate() {
|
||||||
menu := e.Domain.GetMenu(e.KContext.Screen.Value)
|
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
|
||||||
|
|
||||||
if e.UpPressed() && menu.CurrentSelected != 0 {
|
if e.UpPressed() && menu.CurrentSelected != 0 {
|
||||||
menu.CurrentSelected--
|
menu.CurrentSelected--
|
||||||
@@ -31,5 +31,5 @@ func (e *Engine) MenuUpdate() {
|
|||||||
menu.MenuItems[menu.CurrentSelected].Handler()
|
menu.MenuItems[menu.CurrentSelected].Handler()
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Domain.SetMenu(e.KContext.Screen.Value, menu)
|
e.Domain.SetMenu(e.KContext.ScreenValue, menu)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,18 @@ package entity
|
|||||||
|
|
||||||
type DomainInterface interface {
|
type DomainInterface interface {
|
||||||
Init()
|
Init()
|
||||||
|
|
||||||
|
GetMenuMap() MenuMap
|
||||||
GetMenu(name string) Menu
|
GetMenu(name string) Menu
|
||||||
SetMenu(name string, menu Menu)
|
SetMenu(name string, menu Menu)
|
||||||
|
|
||||||
|
GetDialogMap() DialogMap
|
||||||
GetDialog(name string) Dialog
|
GetDialog(name string) Dialog
|
||||||
SetDialog(name string, menu Dialog)
|
SetDialog(name string, menu Dialog)
|
||||||
|
|
||||||
|
GetLevels() []Level
|
||||||
GetLevel(index int) Level
|
GetLevel(index int) Level
|
||||||
|
|
||||||
AddToInventory(item *Item) bool
|
AddToInventory(item *Item) bool
|
||||||
RemoveFromInventory(item *Item) bool
|
RemoveFromInventory(item *Item) bool
|
||||||
UseInventoryItem(item *Item) bool
|
UseInventoryItem(item *Item) bool
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
type KContextScreen struct {
|
type KContext struct {
|
||||||
Type string
|
ScreenType string
|
||||||
Value string
|
ScreenValue string
|
||||||
|
CurrentLevel int
|
||||||
|
Players []Player
|
||||||
}
|
}
|
||||||
|
|
||||||
type KContext struct {
|
func (c *KContext) getPrimaryPlayer() Player {
|
||||||
Screen KContextScreen
|
return c.Players[0]
|
||||||
CurrentLevel int
|
}
|
||||||
|
|
||||||
|
func (c *KContext) ScreenTypeIs(name string) bool {
|
||||||
|
return c.ScreenType == name
|
||||||
}
|
}
|
||||||
|
|||||||
6
main.go
6
main.go
@@ -23,10 +23,8 @@ func main() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
KContext: &entity.KContext{
|
KContext: &entity.KContext{
|
||||||
Screen: entity.KContextScreen{
|
ScreenType: "menu",
|
||||||
Type: "menu",
|
ScreenValue: "MainMenu",
|
||||||
Value: "MainMenu",
|
|
||||||
},
|
|
||||||
CurrentLevel: 0,
|
CurrentLevel: 0,
|
||||||
},
|
},
|
||||||
Settings: entity.Settings{
|
Settings: entity.Settings{
|
||||||
|
|||||||
Reference in New Issue
Block a user