当前位置: 首页>>代码示例>>Golang>>正文


Golang Game.GetViewer方法代码示例

本文整理汇总了Golang中github.com/runningwild/haunts/game.Game.GetViewer方法的典型用法代码示例。如果您正苦于以下问题:Golang Game.GetViewer方法的具体用法?Golang Game.GetViewer怎么用?Golang Game.GetViewer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/runningwild/haunts/game.Game的用法示例。


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

示例1: HandleInput

func (a *SummonAction) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		bx, by := g.GetViewer().WindowToBoard(cursor.Point())
		bx += 0.5
		by += 0.5
		if bx < 0 {
			bx--
		}
		if by < 0 {
			by--
		}
		a.cx = int(bx)
		a.cy = int(by)
	}

	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		if g.IsCellOccupied(a.cx, a.cy) {
			return true, nil
		}
		if a.Personal_los && !a.ent.HasLos(a.cx, a.cy, 1, 1) {
			return true, nil
		}
		if a.ent.Stats.ApCur() >= a.Ap {
			var exec summonExec
			exec.SetBasicData(a.ent, a)
			exec.Pos = a.ent.Game().ToVertex(a.cx, a.cy)
			return true, &exec
		}
		return true, nil
	}
	return false, nil
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:33,代码来源:summon.go

示例2: Prep

func (a *Move) Prep(ent *game.Entity, g *game.Game) bool {
	a.ent = ent
	fx, fy := g.GetViewer().WindowToBoard(gin.In().GetCursor("Mouse").Point())
	a.findPath(ent, int(fx), int(fy))
	a.threshold = a.ent.Stats.ApCur()
	return true
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:7,代码来源:move.go

示例3: 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:RickDakan,项目名称:haunts,代码行数:34,代码来源:interact.go

示例4: Prep

func (a *AoeAttack) Prep(ent *game.Entity, g *game.Game) bool {
	if !a.Preppable(ent, g) {
		return false
	}
	a.ent = ent
	bx, by := g.GetViewer().WindowToBoard(gin.In().GetCursor("Mouse").Point())
	a.tx = int(bx)
	a.ty = int(by)
	return true
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:10,代码来源:aoe_attack.go

示例5: HandleInput

func (a *AoeAttack) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil && cursor.Name() == "Mouse" {
		bx, by := g.GetViewer().WindowToBoard(cursor.Point())
		a.tx = int(bx)
		a.ty = int(by)
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		ex, ey := a.ent.Pos()
		if dist(ex, ey, a.tx, a.ty) <= a.Range && a.ent.HasLos(a.tx, a.ty, 1, 1) {
			var exec aoeExec
			exec.SetBasicData(a.ent, a)
			exec.X, exec.Y = a.tx, a.ty
			return true, &exec
		} else {
			return true, nil
		}
		return true, nil
	}
	return false, nil
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:21,代码来源:aoe_attack.go

示例6: HandleInput

func (a *Move) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		fx, fy := g.GetViewer().WindowToBoard(cursor.Point())
		a.findPath(a.ent, int(fx), int(fy))
	}
	if found, _ := group.FindEvent(gin.MouseLButton); found {
		if len(a.path) > 0 {
			if a.cost <= a.ent.Stats.ApCur() {
				var exec moveExec
				exec.SetBasicData(a.ent, a)
				algorithm.Map2(a.path, &exec.Path, func(v [2]int) int {
					return g.ToVertex(v[0], v[1])
				})
				return true, &exec
			}
			return true, nil
		} else {
			return false, nil
		}
	}
	return false, nil
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:23,代码来源:move.go


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