fight

package
v0.0.0-...-ee7ecfe Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

README

Fight包介绍(持续开发中)

fight包可以用来构建各种类型的游戏。
fight包把一场战斗抽象成5个主进程(标准的请求应答模式):
调度进程fightscheduler:主要用于集中调度aoi,以及处理分发客户端指令
伤害计算进程fightdamagecalc:主要用于异步接受伤害消息,统一进行伤害计算
定时器进程fighttimer:主要用于独立的定时器任务处理
奖励进程fightaward:主要用于异步接受奖励消息,统一进行奖励计算
消息推送进程fightpost:主要用于推送游戏消息给玩家
如何调优:
每种进程都支持帧函数,对性能优化有很好的效果,同时开放了进程初始化、清理接口,方便对接数据库。
进程间通信:
采用标准actor模式,提供了异步和同步接口,具体原理请参考gserver/goroutine包

Documentation

Overview

FIXME 非线程安全

Index

Constants

View Source
const (
	TIMER_SCHEDULER = "timer_scheduler" // scheduler帧函数
	TIMER_AWARD     = "timer_award"     // award帧函数
	TIMER_DAMAGE    = "timer_damage"    // damage帧函数
	TIMER_POST      = "timer_post"      // post帧函数
	INIT_SCHEDULER  = "init_scheduler"  // scheduler初始化函数
	INIT_AWARD      = "init_award"      // award初始化函数
	INIT_DAMAGE     = "init_damage"     // damage初始化函数
	INIT_POST       = "init_post"       // post初始化函数
	CLOSE_SCHEDULER = "close_scheduler" // scheduler清理函数
	CLOSE_AWARD     = "close_award"     // award清理函数
	CLOSE_DAMAGE    = "close_damage"    // damage清理函数
	CLOSE_POST      = "close_post"      // post清理函数
)

内置开放函数标识

Variables

This section is empty.

Functions

func CallFighPost

func CallFighPost(fightid FightId, msg string, args []interface{}) ([]interface{}, error)

同步调用 default timeout 1s @params fightid:战斗id msg:消息类型 args:自定义参数

func CallFightAward

func CallFightAward(fightid FightId, msg string, args []interface{}) ([]interface{}, error)

同步调用 default timeout 1s @params fightid:战斗id msg:消息类型 args:自定义参数

func CallFightDamageCalc

func CallFightDamageCalc(fightid FightId, msg string, args []interface{}) ([]interface{}, error)

同步调用 default timeout 1s @params fightid:战斗id msg:消息类型 args:自定义参数

func CallFightScheduler

func CallFightScheduler(fightid FightId, msg string, args []interface{}) ([]interface{}, error)

同步调用 default timeout 1s @params fightid:战斗id msg:消息类型 args:自定义参数

func CastFighPost

func CastFighPost(fightid FightId, msg string, args []interface{})

异步调用 @params fightid:战斗id msg:消息类型 args:自定义参数

func CastFightAward

func CastFightAward(fightid FightId, msg string, args []interface{})

异步调用 @params fightid:战斗id msg:消息类型 args:自定义参数

func CastFightDamageCalc

func CastFightDamageCalc(fightid FightId, msg string, args []interface{})

异步调用 @params fightid:战斗id msg:消息类型 args:自定义参数

func CastFightScheduler

func CastFightScheduler(fightid FightId, msg string, args []interface{})

异步调用 @params fightid:战斗id msg:消息类型 args:自定义参数

func CreateFight

func CreateFight(fightid FightId, flag int, fmap IFightMap) error

创建一场战斗 @params fightid:战斗id flag:战斗标识(3v3 or 5v5) fmap:自定义的地图数据

func DestroyFight

func DestroyFight(fightid FightId) error

销毁一场战斗 @params fightid:战斗id

func GetHandler

func GetHandler(msg string) handler

func NewAwardAlias

func NewAwardAlias(fightid FightId) string

新建一个战斗奖励计算进程别名 @params fightid:战斗id

func NewDamageCalcAlias

func NewDamageCalcAlias(fightid FightId) string

新建一个战斗伤害计算进程别名 @params fightid:战斗id

func NewDefaultSpace

func NewDefaultSpace() *Space

创建一个默认的场景

func NewFightSchedulerAlias

func NewFightSchedulerAlias(fightid FightId) string

新建一个战斗调度器进程别名 @params fightid:战斗id

func NewPostAlias

func NewPostAlias(fightid FightId) string

新建一个post进程别名 @params fightid:战斗id

func ParseSchedulerInner

func ParseSchedulerInner(inner []interface{}) (IFightMap, int, FightId, *Space,
	map[*Entity]struct{}, map[*Entity]struct{}, map[*Entity]struct{},
	*FightTimer)

解析

func RegisterHandler

func RegisterHandler(msg string, hand handler)

func UnRegisterHandler

func UnRegisterHandler(msg string)

Types

type FightId

type FightId string

func ParseAwardInner

func ParseAwardInner(inner []interface{}) (FightId, map[EntityId][]EntityId, map[EntityId][]int)

解析

func ParseDamageCalcInner

func ParseDamageCalcInner(inner []interface{}) FightId

解析

type FightTimer

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

func (*FightTimer) AddOneJob

func (f *FightTimer) AddOneJob(entity *Entity, jobInterval time.Duration, jobFunc MessageHandler1,
	args []interface{})

func (*FightTimer) AddRepeatJob

func (f *FightTimer) AddRepeatJob(entityId EntityId, jobInterval time.Duration, times uint64,
	jobFunc MessageHandler1, args []interface{})

func (*FightTimer) DelAiJob

func (f *FightTimer) DelAiJob(entityId EntityId)

type IFightMap

type IFightMap interface {
	Load()
	Unload()
}

Jump to

Keyboard shortcuts

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