101 lines
2.2 KiB
Go
101 lines
2.2 KiB
Go
![]() |
package logic
|
||
|
|
||
|
import (
|
||
|
"ecs/proto/old"
|
||
|
"ecs/proto/pb"
|
||
|
"math/rand"
|
||
|
)
|
||
|
|
||
|
type PlayerThirdData struct {
|
||
|
NickName string
|
||
|
AvatarUrl string
|
||
|
}
|
||
|
|
||
|
type PlayerTemp struct {
|
||
|
Address string
|
||
|
|
||
|
WechatSessionKey string
|
||
|
|
||
|
ThirdData *PlayerThirdData
|
||
|
|
||
|
SceneId uint32
|
||
|
Fighting bool
|
||
|
RandSeed int64
|
||
|
|
||
|
//ArenaEnemy *RankingPlayer
|
||
|
|
||
|
//ChosenPlanetId uint32
|
||
|
//ChosenCivilizationId uint32
|
||
|
//
|
||
|
//requestTime map[int]int64
|
||
|
//adFunction map[uint32]int64
|
||
|
}
|
||
|
|
||
|
func (this *Player) initTemp() {
|
||
|
this.Temp.SceneId = 0
|
||
|
this.Temp.Fighting = false
|
||
|
this.Temp.RandSeed = 0
|
||
|
//this.Temp.ArenaEnemy = nil
|
||
|
//this.Temp.ChosenPlanetId = 0
|
||
|
//this.Temp.ChosenCivilizationId = 0
|
||
|
//this.Temp.requestTime = map[int]int64{}
|
||
|
//this.Temp.adFunction = map[uint32]int64{}
|
||
|
}
|
||
|
|
||
|
func (this *Player) EnterScene(sceneId uint32) {
|
||
|
this.Temp.SceneId = sceneId
|
||
|
_ = this.Send(uint16(pb.ModId_ModuleLevel), uint16(pb.MsgId_ModLevelSceneEnter), &pb.SceneEnterAck{SceneId: this.Temp.SceneId})
|
||
|
}
|
||
|
|
||
|
func (this *Player) EnterBattle() {
|
||
|
this.Temp.Fighting = true
|
||
|
this.Temp.RandSeed = int64(rand.Int31())
|
||
|
|
||
|
_ = this.Send(old.ModIdBattle, old.MsgIdBattleEnter, &old.MsgBattleEnterAck{SceneId: this.Temp.SceneId, RandSeed: this.Temp.RandSeed})
|
||
|
}
|
||
|
|
||
|
func (this *Player) EndBattle() {
|
||
|
this.Temp.Fighting = false
|
||
|
this.Temp.RandSeed = 0
|
||
|
this.EnterScene(1)
|
||
|
}
|
||
|
|
||
|
//func (this *Player) CheckRequestTime(reqType int) bool {
|
||
|
// var now = util.Unix()
|
||
|
// if now-this.Temp.requestTime[reqType] < 3 {
|
||
|
// return false
|
||
|
// }
|
||
|
// this.Temp.requestTime[reqType] = now
|
||
|
// return true
|
||
|
//}
|
||
|
//
|
||
|
//func (this *Player) ResetRequestTime(reqType int) {
|
||
|
// delete(this.Temp.requestTime, reqType)
|
||
|
//}
|
||
|
|
||
|
//func (this *Player) AddAdFunction(adTable *data.Ad) {
|
||
|
// this.Temp.adFunction[uint32(adTable.Id)] = util.Unix()
|
||
|
//}
|
||
|
|
||
|
//func (this *Player) CheckAdFunction(tipe proto.AdFunctionType, arg1, arg2, arg3 uint32) bool {
|
||
|
// var adTable = this.manager.tables.AdExtend.Get(int(tipe), int(arg1), int(arg2), int(arg3))
|
||
|
// if adTable == nil {
|
||
|
// return false
|
||
|
// }
|
||
|
//
|
||
|
// var time, ok = this.Temp.adFunction[uint32(adTable.Id)]
|
||
|
// if !ok {
|
||
|
// return false
|
||
|
// }
|
||
|
//
|
||
|
// delete(this.Temp.adFunction, uint32(adTable.Id))
|
||
|
//
|
||
|
// if util.Unix()-time > 90 {
|
||
|
// return false
|
||
|
// }
|
||
|
//
|
||
|
// this.AddCounter(proto.CounterTypeAdWatching, uint32(adTable.Id), 1)
|
||
|
//
|
||
|
// return true
|
||
|
//}
|