游戏玩法游戏结束特性实现
This commit is contained in:
parent
09268e00f7
commit
edb2c0e21f
|
@ -0,0 +1,27 @@
|
||||||
|
package builtin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"minotaur/game"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewGameplayOver() *GameplayOver {
|
||||||
|
return &GameplayOver{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameplayOver struct {
|
||||||
|
gameplayOverEventHandles []game.GameplayOverEventHandle
|
||||||
|
}
|
||||||
|
|
||||||
|
func (slf *GameplayOver) GameOver() {
|
||||||
|
slf.OnGameplayOverEvent()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (slf *GameplayOver) RegGameplayOverEvent(handle game.GameplayOverEventHandle) {
|
||||||
|
slf.gameplayOverEventHandles = append(slf.gameplayOverEventHandles, handle)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (slf *GameplayOver) OnGameplayOverEvent() {
|
||||||
|
for _, handle := range slf.gameplayOverEventHandles {
|
||||||
|
handle()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package game
|
||||||
|
|
||||||
|
type GameplayOver interface {
|
||||||
|
// GameOver 游戏玩法结束
|
||||||
|
GameOver()
|
||||||
|
|
||||||
|
// RegGameplayOverEvent 游戏玩法结束时将立即调用被注册的事件处理函数
|
||||||
|
RegGameplayOverEvent(handle GameplayOverEventHandle)
|
||||||
|
OnGameplayOverEvent()
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
GameplayOverEventHandle func()
|
||||||
|
)
|
Loading…
Reference in New Issue