game

package
v0.0.0-...-c50a420 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SCENE_CHAN_BUFFER_SIZE = 2048
)

Variables

This section is empty.

Functions

func Startup

func Startup(scenes string)

Startup 初始化游戏服务器

Types

type BlockInfo

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

二维格子数据

func NewBlockInfo

func NewBlockInfo() *BlockInfo

func (*BlockInfo) FindPath

func (b *BlockInfo) FindPath(sx, sy, ex, ey int32) (path [][]int32, block, turn int, err error)

func (*BlockInfo) GetBlockTable

func (b *BlockInfo) GetBlockTable() [][]int32

func (*BlockInfo) GetHeight

func (b *BlockInfo) GetHeight() uint32

func (*BlockInfo) GetRandomXY

func (b *BlockInfo) GetRandomXY(rect shape.Rect, cnt int) (shape.Coord, shape.Coord, error)

func (*BlockInfo) GetWidth

func (b *BlockInfo) GetWidth() uint32

func (*BlockInfo) IsWalkable

func (b *BlockInfo) IsWalkable(i, j int32) bool

func (*BlockInfo) ReadFrom

func (b *BlockInfo) ReadFrom(bytebuffer *bytes.Buffer) error

type Buffer

type Buffer struct {
	*object.BufferObject
	// contains filtered or unexported fields
}

func NewBuffer

func NewBuffer(target IEntity, state *model.BufferState) *Buffer

func (*Buffer) Add

func (buf *Buffer) Add(state *model.BufferState)

func (*Buffer) Remove

func (buf *Buffer) Remove()

type Entity

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

func (*Entity) Destroy

func (e *Entity) Destroy()

func (*Entity) GetEntityType

func (e *Entity) GetEntityType() int

func (*Entity) GetID

func (e *Entity) GetID() int64

func (*Entity) GetPos

func (e *Entity) GetPos() shape.Vector3

func (*Entity) GetScene

func (e *Entity) GetScene() *Scene

func (*Entity) GetUUID

func (e *Entity) GetUUID() string

func (*Entity) IsDestroyed

func (e *Entity) IsDestroyed() bool

func (*Entity) PushTask

func (e *Entity) PushTask(task scheduler.Task)

func (*Entity) SetPos

func (e *Entity) SetPos(x, y, z shape.Coord)

func (*Entity) ToString

func (e *Entity) ToString() string

type Hero

type Hero struct {
	*object.HeroObject
	// contains filtered or unexported fields
}

func NewHero

func NewHero(s *session.Session, data *model.Hero) *Hero

func (*Hero) AttackAction

func (h *Hero) AttackAction()

func (*Hero) AttackTarget

func (h *Hero) AttackTarget(targetId int64) error

func (*Hero) BeenAttacked

func (h *Hero) BeenAttacked(damage int64) (int, error)

func (*Hero) Broadcast

func (h *Hero) Broadcast(route string, msg interface{}, includeSelf bool)

广播给所有能看见自己的对象

func (*Hero) CanAttackTarget

func (h *Hero) CanAttackTarget(target IEntity) bool

func (*Hero) CanSee

func (m *Hero) CanSee(target IEntity) bool

func (*Hero) Destroy

func (h *Hero) Destroy()

func (*Hero) DestroyWithoutSession

func (h *Hero) DestroyWithoutSession()

func (*Hero) Die

func (h *Hero) Die()

func (*Hero) GetAttack

func (h *Hero) GetAttack() int64

func (*Hero) GetBuffers

func (m *Hero) GetBuffers() []*object.BufferObject

func (*Hero) GetCanSeeMeViewList

func (m *Hero) GetCanSeeMeViewList() map[string]IMovableEntity

func (*Hero) GetData

func (h *Hero) GetData() *object.HeroObject

func (*Hero) GetDefense

func (h *Hero) GetDefense() int64

func (*Hero) GetID

func (h *Hero) GetID() int64

func (*Hero) GetState

func (h *Hero) GetState() constants2.ActionState

func (*Hero) GetUID

func (h *Hero) GetUID() int64

func (*Hero) GetViewList

func (m *Hero) GetViewList() map[string]IMovableEntity

func (*Hero) GetViewRange

func (m *Hero) GetViewRange() (int, int)

func (*Hero) GetViewRect

func (m *Hero) GetViewRect() shape.Rect

func (*Hero) Idle

func (h *Hero) Idle()

func (*Hero) IsInViewList

func (m *Hero) IsInViewList(target IMovableEntity) bool

func (*Hero) IsOffline

func (h *Hero) IsOffline() bool

func (*Hero) MoveByPaths

func (h *Hero) MoveByPaths(targetx, targety, targetz int, paths [][]int32) error

前端移动到目标位置

func (*Hero) MoveStop

func (h *Hero) MoveStop(x, y, z shape.Coord) error

func (*Hero) Run

func (h *Hero) Run()

func (*Hero) SendMsg

func (h *Hero) SendMsg(route string, msg interface{})

func (*Hero) SetPos

func (h *Hero) SetPos(x, y, z shape.Coord)

func (*Hero) SetState

func (h *Hero) SetState(state constants2.ActionState)

动作状态

func (*Hero) SetViewRange

func (h *Hero) SetViewRange(width int, height int)

func (*Hero) ToString

func (h *Hero) ToString() string

func (*Hero) Walk

func (h *Hero) Walk()

type IAiManager

type IAiManager interface {
	GetAiData() interface{}
	GetOwner() IMovableEntity
	// contains filtered or unexported methods
}

type IAoiManager

type IAoiManager interface {
	Enter(entity IMovableEntity)
	Leave(entity IMovableEntity)
	Moved(entity IMovableEntity, oldX, oldY shape.Coord)
}

type IEntity

type IEntity interface {
	GetScene() *Scene
	SetPos(x, y, z shape.Coord)
	GetPos() shape.Vector3
	GetID() int64
	// 不存储在数据库,只作为运行对象的唯一值
	GetUUID() string
	GetEntityType() int
	Destroy()
	IsDestroyed() bool
	// contains filtered or unexported methods
}

type IMovableEntity

type IMovableEntity interface {
	IEntity

	GetViewList() map[string]IMovableEntity
	GetCanSeeMeViewList() map[string]IMovableEntity
	GetViewRect() shape.Rect
	SetViewRange(int, int)
	GetViewRange() (int, int)
	CanSee(target IEntity) bool
	IsInViewList(target IMovableEntity) bool
	// contains filtered or unexported methods
}

type Monster

type Monster struct {
	*object.MonsterObject
	// contains filtered or unexported fields
}

func NewMonster

func NewMonster(data *model.Monster, offset int) *Monster

func (*Monster) AttackAction

func (m *Monster) AttackAction()

func (*Monster) Broadcast

func (m *Monster) Broadcast(route string, msg interface{})

广播给所有能看见自己的对象

func (*Monster) CanAttackTarget

func (m *Monster) CanAttackTarget(target IEntity) bool

func (*Monster) CanSee

func (m *Monster) CanSee(target IEntity) bool

func (*Monster) Chase

func (m *Monster) Chase()

func (*Monster) Destroy

func (m *Monster) Destroy()

func (*Monster) Die

func (m *Monster) Die()

func (*Monster) Escape

func (m *Monster) Escape()

func (*Monster) GetBuffers

func (m *Monster) GetBuffers() []*object.BufferObject

func (*Monster) GetCanAttackPos

func (m *Monster) GetCanAttackPos(target IEntity, offset int) (v shape.Vector3, err error)

返回对目标点的可攻击位置

func (*Monster) GetCanSeeMeViewList

func (m *Monster) GetCanSeeMeViewList() map[string]IMovableEntity

func (*Monster) GetCanUseSpell

func (m *Monster) GetCanUseSpell(spellType int) *object.SpellObject

func (*Monster) GetData

func (m *Monster) GetData() *object.MonsterObject

func (*Monster) GetMovableRect

func (m *Monster) GetMovableRect() shape.Rect

func (*Monster) GetState

func (m *Monster) GetState() constants.ActionState

func (*Monster) GetViewList

func (m *Monster) GetViewList() map[string]IMovableEntity

func (*Monster) GetViewRange

func (m *Monster) GetViewRange() (int, int)

func (*Monster) GetViewRect

func (m *Monster) GetViewRect() shape.Rect

func (*Monster) Idle

func (m *Monster) Idle()

func (*Monster) IsInAttackRange

func (m *Monster) IsInAttackRange(x, y shape.Coord) bool

func (*Monster) IsInSpellAttackRange

func (m *Monster) IsInSpellAttackRange(spell *object.SpellObject, x, y shape.Coord) bool

func (*Monster) IsInViewList

func (m *Monster) IsInViewList(target IMovableEntity) bool

func (*Monster) IsNpc

func (m *Monster) IsNpc() bool

func (*Monster) MoveByPaths

func (m *Monster) MoveByPaths(paths [][]int32) error

func (*Monster) MoveTo

func (m *Monster) MoveTo(x, y, z shape.Coord) error

移动到目标位置

func (*Monster) Run

func (m *Monster) Run()

func (*Monster) SetAiData

func (m *Monster) SetAiData(aimgr IAiManager)

func (*Monster) SetMovableRect

func (m *Monster) SetMovableRect(rect shape.Rect)

func (*Monster) SetPos

func (m *Monster) SetPos(x, y, z shape.Coord)

func (*Monster) SetPreparePaths

func (m *Monster) SetPreparePaths(p *path.SerialPaths)

func (*Monster) SetSceneMonsterConfig

func (m *Monster) SetSceneMonsterConfig(cfg *model.SceneMonsterConfig)

func (*Monster) SetSpells

func (m *Monster) SetSpells(spells []*object.SpellObject)

func (*Monster) SetState

func (m *Monster) SetState(state constants.ActionState)

动作状态

func (*Monster) SetViewRange

func (m *Monster) SetViewRange(width int, height int)

func (*Monster) SpellAttack

func (m *Monster) SpellAttack(spell *object.SpellObject, target IMovableEntity) error

func (*Monster) Stop

func (m *Monster) Stop()

func (*Monster) ToString

func (m *Monster) ToString() string

func (*Monster) Walk

func (m *Monster) Walk()

type PathFinder

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

这个非线程安全,需要单线程一个执行

func NewPathFinder

func NewPathFinder(grids [][]int32) *PathFinder

func (*PathFinder) FindPath

func (f *PathFinder) FindPath(sx, sy, ex, ey int) ([][]int32, error)

type Scene

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

func NewScene

func NewScene(sceneData *SceneData) *Scene

func (*Scene) CreateSpellEntity

func (s *Scene) CreateSpellEntity(caster IMovableEntity, spell *object.SpellObject, target IMovableEntity) *SpellEntity

func (*Scene) FindPath

func (s *Scene) FindPath(sx, sy, ex, ey shape.Coord) ([][]int32, error)

这个是线程安全的,可并发调用, 注意区别PathFinder

func (*Scene) GetHeight

func (s *Scene) GetHeight() uint32

func (*Scene) GetRandomXY

func (s *Scene) GetRandomXY(rect shape.Rect, cnt int) (shape.Coord, shape.Coord, error)

func (*Scene) GetSceneData

func (s *Scene) GetSceneData() *SceneData

func (*Scene) GetSceneId

func (s *Scene) GetSceneId() int

func (*Scene) GetWidth

func (s *Scene) GetWidth() uint32

func (*Scene) IsWalkable

func (s *Scene) IsWalkable(x, y shape.Coord) bool

func (*Scene) PushTask

func (s *Scene) PushTask(task scheduler.Task)

func (*Scene) Stop

func (s *Scene) Stop()

type SceneData

type SceneData struct {
	model.Scene
	DoorList          []model.SceneDoor
	MonsterConfigList []model.SceneMonsterConfig
}

type SceneManager

type SceneManager struct {
	component.Base
	// contains filtered or unexported fields
}

func NewSceneManager

func NewSceneManager() *SceneManager

func (*SceneManager) AfterInit

func (manager *SceneManager) AfterInit()

func (*SceneManager) Attack

func (manager *SceneManager) Attack(s *session.Session, req *protocol.AttackRequest) error

func (*SceneManager) DynamicResetMonsters

func (manager *SceneManager) DynamicResetMonsters(s *session.Session, req *protocol.DynamicResetMonstersRequest) error

动态重置怪物

func (*SceneManager) GetScene

func (manager *SceneManager) GetScene(sceneId int) *Scene

func (*SceneManager) HeroEnterScene

func (manager *SceneManager) HeroEnterScene(s *session.Session, req *protocol.HeroEnterSceneRequest) error

func (*SceneManager) HeroLeaveScene

func (manager *SceneManager) HeroLeaveScene(s *session.Session, req *protocol.HeroLeaveSceneRequest) error

func (*SceneManager) HeroMove

func (manager *SceneManager) HeroMove(s *session.Session, req *protocol.HeroMoveRequest) error

func (*SceneManager) HeroMoveStop

func (manager *SceneManager) HeroMoveStop(s *session.Session, req *protocol.HeroMoveStopRequest) error

func (*SceneManager) HeroSetViewRange

func (manager *SceneManager) HeroSetViewRange(s *session.Session, req *protocol.HeroSetViewRangeRequest) error

func (*SceneManager) RecordingVoice

func (manager *SceneManager) RecordingVoice(s *session.Session, msg *protocol.RecordingVoice) error

玩家录制完语音

func (*SceneManager) SceneInfo

func (manager *SceneManager) SceneInfo(s *session.Session, req *protocol.SceneInfoRequest) error

func (*SceneManager) TextMessage

func (manager *SceneManager) TextMessage(s *session.Session, msg *protocol.TextMessageRequest) error

玩家文字消息

func (*SceneManager) VoiceMessage

func (manager *SceneManager) VoiceMessage(s *session.Session, msg []byte) error

玩家语音消息

type SpellEntity

type SpellEntity struct {
	*object.SpellObject
	// contains filtered or unexported fields
}

func NewSpellEntity

func NewSpellEntity(spellObject *object.SpellObject, caster IMovableEntity) *SpellEntity

func (*SpellEntity) CanSee

func (m *SpellEntity) CanSee(target IEntity) bool

func (*SpellEntity) Destroy

func (e *SpellEntity) Destroy()

func (*SpellEntity) GetBuffers

func (m *SpellEntity) GetBuffers() []*object.BufferObject

func (*SpellEntity) GetCanSeeMeViewList

func (m *SpellEntity) GetCanSeeMeViewList() map[string]IMovableEntity

func (*SpellEntity) GetViewList

func (m *SpellEntity) GetViewList() map[string]IMovableEntity

func (*SpellEntity) GetViewRange

func (m *SpellEntity) GetViewRange() (int, int)

func (*SpellEntity) GetViewRect

func (m *SpellEntity) GetViewRect() shape.Rect

func (*SpellEntity) IsInViewList

func (m *SpellEntity) IsInViewList(target IMovableEntity) bool

func (*SpellEntity) SetPos

func (e *SpellEntity) SetPos(x, y, z shape.Coord)

func (*SpellEntity) SetTarget

func (e *SpellEntity) SetTarget(target IMovableEntity)

需要在添加到场景内之前执行

func (*SpellEntity) SetTargetPos

func (e *SpellEntity) SetTargetPos(target shape.Vector3)

需要在添加到场景内之前执行

func (*SpellEntity) SetViewRange

func (m *SpellEntity) SetViewRange(width int, height int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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