entity

package
v0.0.0-...-620f6c9 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FRAME_INTERVAL         = 60 * time.Millisecond
	PHYSIC_UPDATE_INTERVAL = 10 * time.Millisecond
)
View Source
const (
	ExplosionRadius = 5.0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttackBase

type AttackBase struct {
	AutoAttackable   bool
	CoolDownLeftTime int32
	MaxValue         float64
	MaxCombo         int32
}

func (*AttackBase) Attack

func (atk *AttackBase) Attack(FromPos Position, Value float64)

func (*AttackBase) AutoAttack

func (atk *AttackBase) AutoAttack(targetId int64)

type AttackBehavier

type AttackBehavier interface {
	Attack(FromPos Position, Value int64)
	AutoAttack(targetId int64)
}

type Enemy

type Enemy struct {
	Player
	CD int64
}

func (*Enemy) FindTargetAndAttack

func (e *Enemy) FindTargetAndAttack(searchRadius float64)

func (*Enemy) PhysicUpdate

func (e *Enemy) PhysicUpdate()

func (*Enemy) Tick

func (e *Enemy) Tick()

type Entity

type Entity struct {
	sync.RWMutex
	EntityInfo *Character
	TypeName   string
	Health     float32
	Alive      bool
	I          IEntity
	GM         *GameManager
	Room       *Room
	World      *physic.World
	Obj        *physic.Obj
	Skill      map[string]AttackBehavier
}

func (*Entity) Destroy

func (e *Entity) Destroy()

func (*Entity) GetInfo

func (e *Entity) GetInfo() *Character

func (*Entity) GetTransform

func (e *Entity) GetTransform() *TransForm

func (*Entity) Harm

func (e *Entity) Harm(blood float32)

func (*Entity) Hit

func (e *Entity) Hit(damage int32)

func (*Entity) Init

func (e *Entity) Init(gm *GameManager, room *Room, entityInfo *Character)

func (*Entity) Move

func (e *Entity) Move(in *Input)

func (*Entity) PhysicUpdate

func (e *Entity) PhysicUpdate()

func (*Entity) Run

func (e *Entity) Run()

func (*Entity) Tick

func (e *Entity) Tick()

type GameManager

type GameManager struct {
	////basic information
	Uuid int64

	ReflectFunc sync.Map

	TypeMapRoom map[string]reflect.Type
	IdMapRoom   map[int64]IRoom

	TypeMapEntity     map[string]reflect.Type
	IdMapEntity       map[int64]IEntity
	UserIdMapEntityId map[int64]int64
	UserIdMapRoomId   sync.Map

	////rpc channel
	SendFuncToClient   map[int64](chan *CallFuncInfo)
	RecvFuncFromClient chan *CallFuncInfo
	PosToClient        map[int64](chan *Position)
	InputFromClient    chan *Input
	ErrToClient        map[int64](chan *Error)
	ErrFromClient      chan *Error
	// contains filtered or unexported fields
}

func (*GameManager) Calibrate

func (gm *GameManager) Calibrate(f *CallFuncInfo)

func (*GameManager) Call

func (gm *GameManager) Call(f *CallFuncInfo)

func (*GameManager) CreateEntity

func (gm *GameManager) CreateEntity(room *Room, entityInfo *Character, entityType string) IEntity

func (*GameManager) CreateNewRoom

func (gm *GameManager) CreateNewRoom(f *CallFuncInfo)

func (*GameManager) CreatePlayer

func (gm *GameManager) CreatePlayer(room *Room, entityType string, userInfo *UserInfo) IEntity

func (*GameManager) DestroyEntity

func (gm *GameManager) DestroyEntity(entityId int64)

func (*GameManager) EnterRoom

func (gm *GameManager) EnterRoom(f *CallFuncInfo)

func (*GameManager) Entity

func (gm *GameManager) Entity(f *CallFuncInfo)

func (*GameManager) ErrorHandle

func (gm *GameManager) ErrorHandle(err *Error)

func (*GameManager) GetAllRoomInfo

func (gm *GameManager) GetAllRoomInfo(f *CallFuncInfo)

func (*GameManager) GetLoginData

func (gm *GameManager) GetLoginData(f *CallFuncInfo)

func (*GameManager) GetRoomStatus

func (gm *GameManager) GetRoomStatus(f *CallFuncInfo)

Not Done Yet

func (*GameManager) Init

func (gm *GameManager) Init(rpc *service.Rpc)

func (*GameManager) LeaveRoom

func (gm *GameManager) LeaveRoom(f *CallFuncInfo)

func (*GameManager) ReadyRoom

func (gm *GameManager) ReadyRoom(f *CallFuncInfo)

func (*GameManager) RegistEnitity

func (gm *GameManager) RegistEnitity(EntityTypeName string, iEntity IEntity)

func (*GameManager) RegistRoom

func (gm *GameManager) RegistRoom(roomTypeName string, iRoom IRoom)

func (*GameManager) Run

func (gm *GameManager) Run()

func (*GameManager) SyncPos

func (gm *GameManager) SyncPos(input *Input)

func (*GameManager) UserDisconnect

func (gm *GameManager) UserDisconnect(f *CallFuncInfo)

type IEntity

type IEntity interface {
	IGameBehavier
	Hit(int32)
	GetInfo() *Character
	Init(*GameManager, *Room, *Character)
	Move(in *Input)
	GetTransform() *TransForm
	Harm(blood float32)
}

type IGameBehavier

type IGameBehavier interface {
	Tick()
	PhysicUpdate()
	Destroy()
	Run()
}

type IRoom

type IRoom interface {
	IGameBehavier
	Init(*GameManager, *RoomInfo)
	//CreateEnitity()
	UserDisconnect(userId int64)
	UserReconnect(userId int64)
	GetInfo() *RoomInfo
	EnterRoom(int64) bool
	LeaveRoom(int64) int64
	Ready(int64) bool
	GetUserInRoom() []int64
}

type Player

type Player struct {
	Entity
}

func (*Player) Init

func (e *Player) Init(gm *GameManager, room *Room, entityInfo *Character)

func (*Player) PhysicUpdate

func (e *Player) PhysicUpdate()

func (*Player) Shoot

func (e *Player) Shoot(f *CallFuncInfo)

type Room

type Room struct {
	RoomInfo *RoomInfo
	sync.RWMutex
	EntityInRoom map[int64]IEntity
	GM           *GameManager
	EntityOfUser map[int64]int64 //map[id]id
	World        *physic.World
	PosChans     map[int64](chan *Position)
	FuncChans    map[int64](chan *CallFuncInfo)
	// contains filtered or unexported fields
}

func (*Room) CreateEnemies

func (r *Room) CreateEnemies()

func (*Room) CreateEnemy

func (r *Room) CreateEnemy()

func (*Room) CreateShell

func (r *Room) CreateShell(iEntity IEntity, entityInfo *Character, p *Vector3, q *Quaternion)

TODO : These two function should be combined

func (*Room) Destroy

func (r *Room) Destroy()

func (*Room) DestroyEntity

func (r *Room) DestroyEntity(id int64)

func (*Room) EnterRoom

func (r *Room) EnterRoom(userId int64) bool

func (*Room) GetAllTransform

func (r *Room) GetAllTransform()

func (*Room) GetInfo

func (r *Room) GetInfo() *RoomInfo

func (*Room) GetUserInRoom

func (r *Room) GetUserInRoom() (ids []int64)

func (*Room) Init

func (r *Room) Init(gm *GameManager, roomInfo *RoomInfo)

func (*Room) LeaveRoom

func (r *Room) LeaveRoom(userId int64) int64

func (*Room) PhysicUpdate

func (r *Room) PhysicUpdate()

func (*Room) Ready

func (r *Room) Ready(userId int64) bool

func (*Room) Run

func (r *Room) Run()

func (*Room) SendFuncToAll

func (r *Room) SendFuncToAll(f *CallFuncInfo)

func (*Room) Tick

func (r *Room) Tick()

func (*Room) UserDisconnect

func (r *Room) UserDisconnect(userId int64)

func (*Room) UserReconnect

func (r *Room) UserReconnect(userId int64)

type Shell

type Shell struct {
	Entity
	State int
}

func (*Shell) PhysicUpdate

func (s *Shell) PhysicUpdate()

type ShootBehavier

type ShootBehavier struct {
	AttackBase
}

func NewShootBehavier

func NewShootBehavier(autoAttackable bool, coolDownLeftTime int32, maxValue float64, maxCombo int32) *ShootBehavier

func (*ShootBehavier) Attack

func (atk *ShootBehavier) Attack(FromPos Position, Value float64)

func (*ShootBehavier) AutoAttack

func (atk *ShootBehavier) AutoAttack(targetId int64)

type Treasure

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

func (*Treasure) BeAttracted

func (t *Treasure) BeAttracted()

func (*Treasure) BeCollected

func (t *Treasure) BeCollected()

func (*Treasure) Disapear

func (t *Treasure) Disapear()

func (*Treasure) Tick

func (t *Treasure) Tick()

Jump to

Keyboard shortcuts

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