2022-09-20 15:50:01 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
. "server/common"
|
|
|
|
"server/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
var relativePath string
|
|
|
|
|
|
|
|
func loadTMX(fp string, pTmxMapIns *models.TmxMap) {
|
|
|
|
if !filepath.IsAbs(fp) {
|
|
|
|
panic("Tmx filepath must be absolute!")
|
|
|
|
}
|
|
|
|
|
|
|
|
byteArr, err := ioutil.ReadFile(fp)
|
2022-10-14 08:08:22 +00:00
|
|
|
if nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-09-20 15:50:01 +00:00
|
|
|
models.DeserializeToTmxMapIns(byteArr, pTmxMapIns)
|
|
|
|
for _, info := range pTmxMapIns.TreasuresInfo {
|
|
|
|
fmt.Printf("treasuresInfo: %v\n", info)
|
|
|
|
}
|
|
|
|
for _, info := range pTmxMapIns.HighTreasuresInfo {
|
|
|
|
fmt.Printf("treasuresInfo: %v\n", info)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func loadTSX(fp string, pTsxIns *models.Tsx) {
|
|
|
|
if !filepath.IsAbs(fp) {
|
|
|
|
panic("Tmx filepath must be absolute!")
|
|
|
|
}
|
|
|
|
|
|
|
|
byteArr, err := ioutil.ReadFile(fp)
|
2022-10-14 08:08:22 +00:00
|
|
|
if nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-09-20 15:50:01 +00:00
|
|
|
models.DeserializeToTsxIns(byteArr, pTsxIns)
|
|
|
|
for _, Pos := range pTsxIns.TrapPolyLineList {
|
|
|
|
fmt.Printf("%v\n", Pos)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getTMXInfo() {
|
|
|
|
relativePath = "../frontend/assets/resources/map/treasurehunter.tmx"
|
|
|
|
execPath, err := os.Executable()
|
2022-10-14 08:08:22 +00:00
|
|
|
if nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-09-20 15:50:01 +00:00
|
|
|
|
|
|
|
pwd, err := os.Getwd()
|
2022-10-14 08:08:22 +00:00
|
|
|
if nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-09-20 15:50:01 +00:00
|
|
|
|
|
|
|
fmt.Printf("execPath = %v, pwd = %s, returning...\n", execPath, pwd)
|
|
|
|
|
|
|
|
tmxMapIns := models.TmxMap{}
|
|
|
|
pTmxMapIns := &tmxMapIns
|
|
|
|
fp := filepath.Join(pwd, relativePath)
|
|
|
|
fmt.Printf("fp == %v\n", fp)
|
|
|
|
loadTMX(fp, pTmxMapIns)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getTSXInfo() {
|
|
|
|
|
|
|
|
relativePath = "../frontend/assets/resources/map/tile_1.tsx"
|
|
|
|
execPath, err := os.Executable()
|
2022-10-14 08:08:22 +00:00
|
|
|
if nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-09-20 15:50:01 +00:00
|
|
|
|
|
|
|
pwd, err := os.Getwd()
|
2022-10-14 08:08:22 +00:00
|
|
|
if nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-09-20 15:50:01 +00:00
|
|
|
|
|
|
|
fmt.Printf("execPath = %v, pwd = %s, returning...\n", execPath, pwd)
|
|
|
|
tsxIns := models.Tsx{}
|
|
|
|
pTsxIns := &tsxIns
|
|
|
|
fp := filepath.Join(pwd, relativePath)
|
|
|
|
fmt.Printf("fp == %v\n", fp)
|
|
|
|
loadTSX(fp, pTsxIns)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
getTSXInfo()
|
|
|
|
}
|