當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Game.HoveredEnt方法代碼示例

本文整理匯總了Golang中github.com/MobRulesGames/haunts/game.Game.HoveredEnt方法的典型用法代碼示例。如果您正苦於以下問題:Golang Game.HoveredEnt方法的具體用法?Golang Game.HoveredEnt怎麽用?Golang Game.HoveredEnt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/MobRulesGames/haunts/game.Game的用法示例。


在下文中一共展示了Game.HoveredEnt方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: HandleInput

func (a *Interact) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		bx, by := g.GetViewer().WindowToBoard(gin.In().GetCursor("Mouse").Point())
		room_num := a.ent.CurrentRoom()
		room := g.House.Floors[0].Rooms[room_num]
		for door_num, door := range room.Doors {
			rect := makeRectForDoor(room, door)
			if rect.Contains(float64(bx), float64(by)) {
				var exec interactExec
				exec.Toggle_door = true
				exec.SetBasicData(a.ent, a)
				exec.Room = room_num
				exec.Door = door_num
				return true, &exec
			}
		}
	}
	target := g.HoveredEnt()
	if target == nil {
		return false, nil
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		for i := range a.targets {
			if a.targets[i] == target && distBetweenEnts(a.ent, target) <= a.Range {
				var exec interactExec
				exec.SetBasicData(a.ent, a)
				exec.Target = target.Id
				return true, &exec
			}
		}
		return true, nil
	}
	return false, nil
}
開發者ID:genbattle,項目名稱:haunts,代碼行數:34,代碼來源:interact.go

示例2: HandleInput

func (a *BasicAttack) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	target := g.HoveredEnt()
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		if target == nil || !a.validTarget(a.ent, target) {
			return true, nil
		}
		return true, a.makeExec(a.ent, target)
	}
	return false, nil
}
開發者ID:genbattle,項目名稱:haunts,代碼行數:10,代碼來源:basic_attack.go


注:本文中的github.com/MobRulesGames/haunts/game.Game.HoveredEnt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。