• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang gin.EventGroup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/runningwild/glop/gin.EventGroup的典型用法代码示例。如果您正苦于以下问题:Golang EventGroup类的具体用法?Golang EventGroup怎么用?Golang EventGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了EventGroup类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Respond

func (pm *placeMine) Respond(gid game.Gid, group gin.EventGroup) bool {
	if found, event := group.FindEvent(gin.AnySpace); found && event.Type == gin.Press {
		pm.fire++
		return true
	}
	return false
}
开发者ID:runningwild,项目名称:magnus,代码行数:7,代码来源:place_mine.go


示例2: Respond

func (rw *riftWalk) Respond(gid game.Gid, group gin.EventGroup) bool {
	if found, event := group.FindEvent(gin.AnySpace); found && event.Type == gin.Press {
		rw.trigger = true
		return true
	}
	return false
}
开发者ID:runningwild,项目名称:magnus,代码行数:7,代码来源:rift_walk.go


示例3: handleEventGroupArchitect

func (l *LocalData) handleEventGroupArchitect(group gin.EventGroup) {
	keys := []gin.KeyId{gin.AnyKey1, gin.AnyKey2, gin.AnyKey3, gin.AnyKey4, gin.AnyKey5, gin.AnyKey6, gin.AnyKey7, gin.AnyKey8, gin.AnyKey9}
	for i := range l.architect.abs.abilities {
		if found, event := group.FindEvent(keys[i]); found && event.Type == gin.Press {
			l.activateAbility(&l.architect.abs, "", i, true)
		}
	}
	if l.architect.abs.activeAbility != nil {
		l.architect.abs.activeAbility.Respond("", group)
	}
}
开发者ID:runningwild,项目名称:magnus,代码行数:11,代码来源:local.go


示例4: handleEventGroupInvaders

func (l *LocalData) handleEventGroupInvaders(group gin.EventGroup) {
	if l.mode != LocalModeMoba {
		panic("Need to implement controls for multiple players on a single screen")
	}
	k0 := gin.In().GetKeyFlat(gin.Key6, gin.DeviceTypeKeyboard, gin.DeviceIndexAny)
	k1 := gin.In().GetKeyFlat(gin.Key7, gin.DeviceTypeKeyboard, gin.DeviceIndexAny)
	k2 := gin.In().GetKeyFlat(gin.Key8, gin.DeviceTypeKeyboard, gin.DeviceIndexAny)
	k3 := gin.In().GetKeyFlat(gin.Key9, gin.DeviceTypeKeyboard, gin.DeviceIndexAny)
	if found, event := group.FindEvent(k0.Id()); found {
		l.activateAbility(&l.moba.currentPlayer.abs, l.moba.currentPlayer.gid, 0, event.Type == gin.Press)
		return
	}
	if found, event := group.FindEvent(k1.Id()); found {
		l.activateAbility(&l.moba.currentPlayer.abs, l.moba.currentPlayer.gid, 1, event.Type == gin.Press)
		return
	}
	if found, event := group.FindEvent(k2.Id()); found {
		l.activateAbility(&l.moba.currentPlayer.abs, l.moba.currentPlayer.gid, 2, event.Type == gin.Press)
		return
	}
	if found, event := group.FindEvent(k3.Id()); found {
		l.activateAbility(&l.moba.currentPlayer.abs, l.moba.currentPlayer.gid, 3, event.Type == gin.Press)
		return
	}
	if l.moba.currentPlayer.abs.activeAbility != nil {
		if l.moba.currentPlayer.abs.activeAbility.Respond(l.moba.currentPlayer.gid, group) {
			return
		}
	}
}
开发者ID:runningwild,项目名称:magnus,代码行数:30,代码来源:local.go


示例5: Respond

func (b *Button) Respond(eventGroup gin.EventGroup) {
	// Only respond to mouse events if the mouse is hovering over the button
	if !b.Hover && eventGroup.Events[0].Key.Id().Device.Type == gin.DeviceTypeMouse {
		return
	}
	if found, event := eventGroup.FindEvent(gin.AnyMouseLButton); found && event.Type == gin.Press {
		if b.Callback != nil {
			b.Callback()
		}
		return
	}
	for trigger := range b.Triggers {
		if found, event := eventGroup.FindEvent(trigger); found && event.Type == gin.Press {
			if b.Callback != nil {
				b.Callback()
			}
			return
		}
	}
}
开发者ID:runningwild,项目名称:jota,代码行数:20,代码来源:button.go


示例6: HandleEventGroupSetup

func (game *Game) HandleEventGroupSetup(group gin.EventGroup) {
	if found, event := group.FindEvent(control.hat.up.Id()); found && event.Type == gin.Press {
		game.Setup.local.Lock()
		defer game.Setup.local.Unlock()
		if game.Setup.local.Index > 0 {
			game.Setup.local.Index--
		}
		return
	}
	if found, event := group.FindEvent(control.hat.down.Id()); found && event.Type == gin.Press {
		game.Setup.local.Lock()
		defer game.Setup.local.Unlock()
		if game.Setup.local.Index < len(game.Setup.EngineIds) {
			game.Setup.local.Index++
		}
		return
	}

	if found, event := group.FindEvent(control.hat.left.Id()); found && event.Type == gin.Press {
		game.local.Engine.ApplyEvent(SetupChampSelect{game.local.Engine.Id(), -1})
		return
	}
	if found, event := group.FindEvent(control.hat.right.Id()); found && event.Type == gin.Press {
		game.local.Engine.ApplyEvent(SetupChampSelect{game.local.Engine.Id(), 1})
		return
	}
	if found, event := group.FindEvent(control.hat.enter.Id()); found && event.Type == gin.Press {
		game.Setup.local.Lock()
		defer game.Setup.local.Unlock()
		if game.Setup.local.Index < len(game.Setup.EngineIds) {
			id := game.Setup.EngineIds[game.Setup.local.Index]
			side := (game.Setup.Players[id].Side + 1) % 2
			game.local.Engine.ApplyEvent(SetupChangeSides{id, side})
		} else {
			if game.local.Engine.Id() == game.Manager || game.local.Engine.IsHost() {
				game.local.Engine.ApplyEvent(SetupComplete{time.Now().UnixNano()})
			}
		}
		return
	}
}
开发者ID:runningwild,项目名称:jota,代码行数:41,代码来源:game_graphics.go


示例7: Respond

func (tsm *ThunderSubMenu) Respond(eventGroup gin.EventGroup) {
	var up, down bool
	for _, keyIndex := range tsm.downs {
		id := gin.In().GetKeyFlat(keyIndex, gin.DeviceTypeAny, gin.DeviceIndexAny).Id()
		if found, event := eventGroup.FindEvent(id); found && event.Type == gin.Press {
			down = true
		}
	}
	for _, keyIndex := range tsm.ups {
		id := gin.In().GetKeyFlat(keyIndex, gin.DeviceTypeAny, gin.DeviceIndexAny).Id()
		if found, event := eventGroup.FindEvent(id); found && event.Type == gin.Press {
			up = true
		}
	}
	if down {
		tsm.selected++
	}
	if up {
		if tsm.selected == -1 {
			tsm.selected = len(tsm.Options) - 1
		} else {
			tsm.selected--
		}
	}
	if tsm.selected >= len(tsm.Options) || tsm.selected < 0 {
		tsm.selected = -1
	}
	if eventGroup.Events[0].Key.Id().Device.Type != gin.DeviceTypeMouse {
		if tsm.selected >= 0 && tsm.selected < len(tsm.Options) {
			tsm.Options[tsm.selected].Respond(eventGroup)
		}
	} else {
		for _, option := range tsm.Options {
			option.Respond(eventGroup)
		}
	}
}
开发者ID:runningwild,项目名称:magnus,代码行数:37,代码来源:thunder_menu.go


示例8: HandleEventGroupEditor

func (g *Game) HandleEventGroupEditor(group gin.EventGroup) {
	g.editor.Lock()
	defer g.editor.Unlock()

	if found, event := group.FindEvent(control.editor.Id()); found && event.Type == gin.Press {
		// Can't call editor.Toggle() here because we already hold the lock.
		g.editor.active = false
		g.editor.action = editorActionNone
		return
	}

	if found, event := group.FindEvent(gin.AnyKeyB); found && event.Type == gin.Press {
		g.editor.placeBlockAction()
		return
	}

	if found, event := group.FindEvent(gin.AnyKeyS); found && event.Type == gin.Press {
		g.editor.saveAction(&g.Level.Room)
		return
	}

	if found, event := group.FindEvent(gin.AnyKeyP); found && event.Type == gin.Press {
		g.editor.pathingAction()
		return
	}

	switch g.editor.action {
	case editorActionNone:
		return
	case editorActionPlaceBlock:
		if found, event := group.FindEvent(gin.AnyMouseLButton); found && event.Type == gin.Press {
			g.editor.placeBlockDo(g)
			return
		}
	}
}
开发者ID:runningwild,项目名称:jota,代码行数:36,代码来源:editor_graphics.go


示例9: HandleEventGroupGame

func (g *Game) HandleEventGroupGame(group gin.EventGroup) {
	g.local.RLock()
	defer g.local.RUnlock()

	if found, event := group.FindEvent(control.editor.Id()); found && event.Type == gin.Press {
		g.editor.Toggle()
		return
	}

	if found, _ := group.FindEvent(control.any.Id()); found {
		dir := getControllerDirection(gin.DeviceId{gin.DeviceTypeController, gin.DeviceIndexAny})
		g.local.Engine.ApplyEvent(&Move{
			Gid:       g.local.Gid,
			Angle:     dir.Angle(),
			Magnitude: dir.Mag(),
		})
	}

	// ability0Key := gin.In().GetKeyFlat(gin.ControllerButton0+2, gin.DeviceTypeController, gin.DeviceIndexAny)
	// abilityTrigger := gin.In().GetKeyFlat(gin.ControllerButton0+1, gin.DeviceTypeController, gin.DeviceIndexAny)
	buttons := []gin.Key{
		gin.In().GetKeyFlat(gin.ControllerButton0+2, gin.DeviceTypeController, gin.DeviceIndexAny),
		gin.In().GetKeyFlat(gin.ControllerButton0+3, gin.DeviceTypeController, gin.DeviceIndexAny),
		gin.In().GetKeyFlat(gin.ControllerButton0+4, gin.DeviceTypeController, gin.DeviceIndexAny),
		gin.In().GetKeyFlat(gin.ControllerButton0+5, gin.DeviceTypeController, gin.DeviceIndexAny),
	}
	abilityTrigger := gin.In().GetKeyFlat(gin.ControllerButton0+6, gin.DeviceTypeController, gin.DeviceIndexAny)
	for i, button := range buttons {
		foundButton, _ := group.FindEvent(button.Id())
		foundTrigger, triggerEvent := group.FindEvent(abilityTrigger.Id())
		// TODO: Check if any abilities are Active before sending events to other abilities.
		if foundButton || foundTrigger {
			g.local.Engine.ApplyEvent(UseAbility{
				Gid:     g.local.Gid,
				Index:   i,
				Button:  button.CurPressAmt(),
				Trigger: foundTrigger && triggerEvent.Type == gin.Press,
			})
		}
	}
}
开发者ID:runningwild,项目名称:jota,代码行数:41,代码来源:game_graphics.go



注:本文中的github.com/runningwild/glop/gin.EventGroup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gui.EventGroup类代码示例发布时间:2022-05-28
下一篇:
Golang gin.In函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap