2019-10-27 19:00:38 -04:00
|
|
|
package Scenes
|
|
|
|
|
|
|
|
import (
|
2019-11-02 17:38:39 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/Common"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/Map"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/Sound"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/UI"
|
2019-10-27 19:00:38 -04:00
|
|
|
"github.com/hajimehoshi/ebiten"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MapEngineTest struct {
|
|
|
|
uiManager *UI.Manager
|
|
|
|
soundManager *Sound.Manager
|
|
|
|
fileProvider Common.FileProvider
|
|
|
|
sceneProvider SceneProvider
|
2019-11-01 22:12:07 -04:00
|
|
|
gameState *Common.GameState
|
|
|
|
mapEngine *Map.Engine
|
2019-10-27 19:00:38 -04:00
|
|
|
}
|
|
|
|
|
2019-11-01 14:12:23 -04:00
|
|
|
func CreateMapEngineTest(
|
|
|
|
fileProvider Common.FileProvider,
|
|
|
|
sceneProvider SceneProvider,
|
|
|
|
uiManager *UI.Manager,
|
|
|
|
soundManager *Sound.Manager) *MapEngineTest {
|
2019-10-27 19:00:38 -04:00
|
|
|
result := &MapEngineTest{
|
|
|
|
fileProvider: fileProvider,
|
|
|
|
uiManager: uiManager,
|
|
|
|
soundManager: soundManager,
|
|
|
|
sceneProvider: sceneProvider,
|
|
|
|
}
|
2019-10-31 21:17:13 -04:00
|
|
|
result.gameState = Common.CreateGameState()
|
2019-10-27 19:00:38 -04:00
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *MapEngineTest) Load() []func() {
|
2019-10-31 13:39:05 -04:00
|
|
|
// TODO: Game seed comes from the game state object
|
2019-10-31 21:17:13 -04:00
|
|
|
|
2019-10-27 21:35:16 -04:00
|
|
|
v.soundManager.PlayBGM("")
|
|
|
|
return []func(){
|
|
|
|
func() {
|
2019-10-31 21:17:13 -04:00
|
|
|
v.mapEngine = Map.CreateMapEngine(v.gameState, v.soundManager, v.fileProvider)
|
2019-11-01 22:12:07 -04:00
|
|
|
|
2019-11-01 16:51:50 -04:00
|
|
|
v.mapEngine.GenerateMap(Map.RegionAct1Town, 1)
|
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct1Tristram, 300)
|
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct1Cathedral, 257)
|
2019-11-01 22:12:07 -04:00
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct2Town, 301) // Broken rendering
|
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct2Harem, 353)
|
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct3Town, 529)
|
2019-11-01 16:51:50 -04:00
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct3Jungle, 574)
|
2019-11-02 11:15:02 -04:00
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct4Town, 797)
|
2019-11-01 22:12:07 -04:00
|
|
|
//v.mapEngine.GenerateMap(Map.RegonAct5Town, 863)
|
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct5IceCaves, 1038)
|
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct5Siege, 879)
|
2019-11-01 16:51:50 -04:00
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct5Lava, 1057) // PALETTE ISSUE
|
2019-11-01 22:12:07 -04:00
|
|
|
//v.mapEngine.GenerateMap(Map.RegionAct5Barricade, 880)
|
2019-11-01 16:51:50 -04:00
|
|
|
|
2019-10-27 21:35:16 -04:00
|
|
|
},
|
|
|
|
}
|
2019-10-27 19:00:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *MapEngineTest) Unload() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *MapEngineTest) Render(screen *ebiten.Image) {
|
2019-10-31 21:17:13 -04:00
|
|
|
v.mapEngine.Render(screen)
|
2019-10-27 19:00:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *MapEngineTest) Update(tickTime float64) {
|
2019-11-01 14:12:23 -04:00
|
|
|
if v.uiManager.KeyPressed(ebiten.KeyDown) {
|
|
|
|
v.mapEngine.OffsetY -= tickTime * 800
|
|
|
|
}
|
|
|
|
if v.uiManager.KeyPressed(ebiten.KeyUp) {
|
|
|
|
v.mapEngine.OffsetY += tickTime * 800
|
|
|
|
}
|
|
|
|
if v.uiManager.KeyPressed(ebiten.KeyLeft) {
|
|
|
|
v.mapEngine.OffsetX += tickTime * 800
|
|
|
|
}
|
|
|
|
if v.uiManager.KeyPressed(ebiten.KeyRight) {
|
|
|
|
v.mapEngine.OffsetX -= tickTime * 800
|
|
|
|
}
|
2019-10-27 19:00:38 -04:00
|
|
|
}
|