shootbase

package
v0.0.0-...-fb1ba6c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2019 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const WorldSize = 500
View Source
const WorldSizeY = 500

Variables

View Source
var GameConst = defaultConfig
View Source
var TopHtmlTemplate *htemplate.Template
View Source
var WorldHtmlTemplate *htemplate.Template
View Source
var WorldTextTemplate *ttemplate.Template

Functions

This section is empty.

Types

type AIActor

type AIActor interface {
	MakeAction(*RspGamePacket) *ReqGamePacket
	String() string
}

func AIstr2AIActor

func AIstr2AIActor(aistr string) AIActor

func NewAIAdv

func NewAIAdv(name string, act [ActionEnd]int) AIActor

type AIAdv

type AIAdv struct {
	AIAdvFns

	ActionPoint int
	Score       int
	HomePos     go4game.Vector3D
	// contains filtered or unexported fields
}

func (*AIAdv) AimAdjedIntoCube

func (a *AIAdv) AimAdjedIntoCube(estpos *go4game.Vector3D, o *SPObj, bulletType GameObjectType) *go4game.Vector3D

func (*AIAdv) CheckAct

func (a *AIAdv) CheckAct(act ClientActionType) bool

func (*AIAdv) CheckActn

func (a *AIAdv) CheckActn(act ClientActionType, actcount int) bool

func (*AIAdv) MakeAction

func (a *AIAdv) MakeAction(packet *RspGamePacket) *ReqGamePacket

func (AIAdv) String

func (a AIAdv) String() string

func (*AIAdv) UseAP

func (a *AIAdv) UseAP(act ClientActionType) bool

func (*AIAdv) UseAPn

func (a *AIAdv) UseAPn(act ClientActionType, actcount int) bool

type AIAdvAimTarget

type AIAdvAimTarget struct {
	*SPObj
	// contains filtered or unexported fields
}

type AIAdvAimTargetList

type AIAdvAimTargetList []*AIAdvAimTarget

func (AIAdvAimTargetList) Len

func (s AIAdvAimTargetList) Len() int

func (AIAdvAimTargetList) Less

func (s AIAdvAimTargetList) Less(i, j int) bool

func (AIAdvAimTargetList) Swap

func (s AIAdvAimTargetList) Swap(i, j int)

type AIAdvFns

type AIAdvFns struct {
	SuperFns   []AIVector3DAct
	BulletFns  []AIVector3DAct
	AccelFns   []AIVector3DAct
	HommingFns []AIIDListAct
	BurstFns   []AIIntAct
}

type AIIDListAct

type AIIDListAct struct {
	CalcFn FactorCalcFn
	Fn     IDListMakeFn
}

type AIIntAct

type AIIntAct struct {
	CalcFn IntMakeFn
	Fn     IntMakeFn
}

type AIVector3DAct

type AIVector3DAct struct {
	CalcFn FactorCalcFn
	Fn     VectorMakeFn
}

type ActionFnEnvInfo

type ActionFnEnvInfo struct {
	// contains filtered or unexported fields
}

type ByTeamScore

type ByTeamScore []TeamInfoWeb

func (ByTeamScore) Len

func (s ByTeamScore) Len() int

func (ByTeamScore) Less

func (s ByTeamScore) Less(i, j int) bool

func (ByTeamScore) Swap

func (s ByTeamScore) Swap(i, j int)

type ClientActionPacket

type ClientActionPacket struct {
	Accel           *go4game.Vector3D
	NormalBulletMv  *go4game.Vector3D
	BurstShot       int
	HommingTargetID go4game.IDList
	SuperBulletMv   *go4game.Vector3D
}

type ClientActionType

type ClientActionType int
const (
	ActionAccel ClientActionType = iota
	ActionBullet
	ActionSuperBullet
	ActionHommingBullet
	ActionBurstBullet
	ActionEnd
)

type ConnInfo

type ConnInfo struct {
	ReadCh  chan *ReqGamePacket
	WriteCh chan *RspGamePacket
	// contains filtered or unexported fields
}

func NewAIConnInfo

func NewAIConnInfo(aiconn AIActor) *ConnInfo

func NewTcpConnInfo

func NewTcpConnInfo(conn net.Conn) *ConnInfo

func NewWsConnInfo

func NewWsConnInfo(conn *websocket.Conn) *ConnInfo

func (ConnInfo) String

func (c ConnInfo) String() string

type ConnType

type ConnType int

client conn type

const (
	TCPConn ConnType
	WebSockConn
	AIConn
)

type FactorCalcFn

type FactorCalcFn func(a *AIAdv, o *AIAdvAimTarget) float64

type GameConfig

type GameConfig struct {
	TcpListen            string
	WsListen             string
	FramePerSec          float64
	AICountPerWorld      int
	AINames              []string
	MaxTcpClientPerWorld int
	MaxWsClientPerWorld  int
	StartWorldCount      int
	RemoveEmptyWorld     bool
	SetTerrain           bool
	SetFood              bool
	TcpClientEncode      string // gob , json
	WorldCube            *go4game.HyperRect
	WorldDiag            float64
	WorldCube2           *go4game.HyperRect // for octree
	WorldDiag2           float64
	APIncFrame           int
	KillScore            int
	ShieldCount          int
	MaxObjectRadius      float64
	MinObjectRadius      float64

	MoveLimit  [GameObjEnd]float64
	Radius     [GameObjEnd]float64
	ObjSqd     [GameObjEnd][GameObjEnd]float64
	IsInteract [GameObjEnd][GameObjEnd]bool // harmed obj : can harm obj
	NoInteract [GameObjEnd]bool
	AP         [ActionEnd]int
}

func (*GameConfig) Load

func (config *GameConfig) Load(filename string) bool

func (*GameConfig) Save

func (config *GameConfig) Save(filename string) bool

func (*GameConfig) SaveLoad

func (config *GameConfig) SaveLoad(filename string)

func (*GameConfig) Validate

func (config *GameConfig) Validate()

type GameObject

type GameObject struct {
	*SPObj
	// contains filtered or unexported fields
}

func NewGameObject

func NewGameObject(teamID int64) *GameObject

func (*GameObject) ActByTime

func (o *GameObject) ActByTime(world *World, t time.Time) go4game.IDList

func (*GameObject) MakeBullet

func (o *GameObject) MakeBullet(mo *GameObject, MoveVector go4game.Vector3D) *GameObject

func (*GameObject) MakeFoodObj

func (o *GameObject) MakeFoodObj(pos go4game.Vector3D) *GameObject

func (*GameObject) MakeHardObj

func (o *GameObject) MakeHardObj(pos go4game.Vector3D) *GameObject

func (*GameObject) MakeHomeMarkObj

func (o *GameObject) MakeHomeMarkObj() *GameObject

func (*GameObject) MakeHommingBullet

func (o *GameObject) MakeHommingBullet(mo *GameObject, targetteamid int64, targetid int64) *GameObject

func (*GameObject) MakeMainObj

func (o *GameObject) MakeMainObj() *GameObject

func (*GameObject) MakeRevolutionDecoObj

func (o *GameObject) MakeRevolutionDecoObj() *GameObject

func (*GameObject) MakeShield

func (o *GameObject) MakeShield(mo *GameObject) *GameObject

func (*GameObject) MakeSuperBullet

func (o *GameObject) MakeSuperBullet(mo *GameObject, MoveVector go4game.Vector3D) *GameObject

func (GameObject) String

func (o GameObject) String() string

func (*GameObject) ToOctreeObj

func (o *GameObject) ToOctreeObj() go4game.OctreeObjI

func (*GameObject) ToSPObj

func (o *GameObject) ToSPObj() *SPObj

type GameObjectActFn

type GameObjectActFn func(m *GameObject, envInfo *ActionFnEnvInfo) bool

type GameObjectDisp

type GameObjectDisp struct {
	ID int64
	P  [3]int32
	R  int
}

func NewGameObjectDisp

func NewGameObjectDisp(o *GameObject) *GameObjectDisp

type GameObjectType

type GameObjectType int
const (
	GameObjNil GameObjectType = iota
	GameObjMain
	GameObjShield
	GameObjBullet
	GameObjHommingBullet
	GameObjSuperBullet
	GameObjDeco
	GameObjMark
	GameObjHard
	GameObjFood
	GameObjEnd
)

type GameService

type GameService struct {
	ID     int64
	CmdCh  chan go4game.GoCmd
	Worlds map[int64]*World
	// contains filtered or unexported fields
}

func NewGameService

func NewGameService() *GameService

func (*GameService) Loop

func (g *GameService) Loop()

func (*GameService) Stat

func (g *GameService) Stat(w http.ResponseWriter, r *http.Request)

func (GameService) String

func (m GameService) String() string

type IDListMakeFn

type IDListMakeFn func(a *AIAdv) go4game.IDList

type IDecoder

type IDecoder interface {
	Decode(v interface{}) error
}

type IEncoder

type IEncoder interface {
	Encode(v interface{}) error
}

type IntMakeFn

type IntMakeFn func(a *AIAdv) int

type NearInfo

type NearInfo struct {
	// contains filtered or unexported fields
}

type PacketType

type PacketType int

packet type

const (

	// for ai
	ReqNearInfo PacketType
	RspNearInfo
	// for observer
	ReqWorldInfo
	RspWorldInfo
)

type ReqGamePacket

type ReqGamePacket struct {
	Cmd       PacketType
	ClientAct *ClientActionPacket
}

func (ReqGamePacket) String

func (gp ReqGamePacket) String() string

type RspGamePacket

type RspGamePacket struct {
	Cmd       PacketType
	TeamInfo  *TeamInfoPacket
	WorldInfo *WorldDisp
	NearObjs  SPObjList
}

func (RspGamePacket) String

func (gp RspGamePacket) String() string

type SPObj

type SPObj struct {
	ID         int64
	TeamID     int64
	PosVector  go4game.Vector3D
	MoveVector go4game.Vector3D
	ObjType    GameObjectType
}

func (*SPObj) IsCollision

func (o *SPObj) IsCollision(s *SPObj) bool

func (SPObj) Pos

func (o SPObj) Pos() go4game.Vector3D

func (SPObj) String

func (o SPObj) String() string

func (SPObj) TestMoveByAccel

func (m SPObj) TestMoveByAccel(accelVector go4game.Vector3D) *SPObj

from gameobj moveByTimeFn_accel

type SPObjList

type SPObjList []*SPObj

type Team

type Team struct {
	ID             int64
	Type           TeamType
	GameObjs       map[int64]*GameObject
	ClientConnInfo *ConnInfo
	PacketStat     go4game.ActionStat

	Color         int
	ActionPoint   int
	Score         int
	MainObjID     int64
	HomeObjID     int64
	CollisionStat go4game.ActionStat
	NearStat      go4game.ActionStat
	// contains filtered or unexported fields
}

func NewTeam

func NewTeam(conn interface{}, tt TeamType) *Team

func (*Team) AddConn

func (t *Team) AddConn(conn interface{}) *Team

func (*Team) CalcAP

func (t *Team) CalcAP() int

0(outer max) ~ GameConst.APIncFrame( 0,0,0)

func (*Team) Do1Frame

func (t *Team) Do1Frame(world *World, ftime time.Time) <-chan go4game.IDList

func (*Team) NewTeamInfoWeb

func (t *Team) NewTeamInfoWeb() *TeamInfoWeb

func (*Team) SetType

func (t *Team) SetType(tt TeamType) *Team

func (Team) String

func (m Team) String() string

type TeamDisp

type TeamDisp struct {
	ID     int64
	Color  int
	GOList []GameObjectDisp
}

func NewTeamDisp

func NewTeamDisp(t *Team) *TeamDisp

type TeamInfoPacket

type TeamInfoPacket struct {
	*SPObj
	ActionPoint int
	Score       int
	HomePos     go4game.Vector3D
}

type TeamInfoWeb

type TeamInfoWeb struct {
	ID         int64
	ClientInfo string
	Objs       int
	AP         int
	PacketStat string
	CollStat   string
	NearStat   string
	Color      int
	FontColor  int
	Score      int
}

type TeamType

type TeamType int
const (
	TeamTypeNil TeamType = iota
	TeamTypePlayer
	TeamTypeAI
	TeamTypeObserver
	TeamTypeTerrain
	TeamTypeFood
	TeamTypeDeco
	TeamTypeEnd
)

type VectorMakeFn

type VectorMakeFn func(a *AIAdv) *go4game.Vector3D

type World

type World struct {
	ID    int64
	Teams map[int64]*Team

	CmdCh chan go4game.GoCmd
	// contains filtered or unexported fields
}

func NewWorld

func NewWorld(g *GameService) *World

func (*World) Do1Frame

func (w *World) Do1Frame(ftime time.Time) bool

func (*World) Loop

func (w *World) Loop()

func (*World) MakeOctree

func (w *World) MakeOctree() *go4game.Octree

func (World) String

func (w World) String() string

func (*World) TeamCountByConn

func (w *World) TeamCountByConn(ct ConnType) int

func (*World) TeamCountByType

func (w *World) TeamCountByType(tt TeamType) int

type WorldDisp

type WorldDisp struct {
	ID       int64
	B1       *go4game.HyperRect
	B2       *go4game.HyperRect
	TeamList []TeamDisp
}

func NewWorldDisp

func NewWorldDisp(w *World) *WorldDisp

type WorldInfoWeb

type WorldInfoWeb struct {
	ID    int64
	Disp  string
	Teams []TeamInfoWeb
}

func (WorldInfoWeb) String

func (wi WorldInfoWeb) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL