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


Golang Area.IsXYPathable方法代码示例

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


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

示例1: Objects

// Objects is a debug function to generate objects.
func Objects(a *area.Area, num int) {
	o := make(map[coord.Coord]area.DrawPather, a.Width*a.Height)

	log.Println(len(object.Objects))
	var objectList = make([]object.Object, len(object.Objects))
	var index int
	for _, o := range object.Objects {
		objectList[index] = o
		index++
	}
	for x := 0; x < a.Width; x++ {
		for y := 0; y < a.Height; y++ {
			if num <= 0 {
				return
			}

			if util.RandInt(0, 50) != 42 {
				continue
			}

			if !a.IsXYPathable(x, y) {
				continue
			}

			c := coord.Coord{X: x, Y: y}
			o[c] = objectList[util.RandInt(0, len(objectList))].New()
		}
	}
	a.Objects = o
}
开发者ID:karlek,项目名称:reason,代码行数:31,代码来源:objects.go

示例2: FOV

func (c *Creature) FOV(a *area.Area) (cs map[coord.Coord]struct{}) {
	radius := c.Sight
	cs = make(map[coord.Coord]struct{})
	for x := c.X() - radius; x <= c.X()+radius; x++ {
		for y := c.Y() - radius; y <= c.Y()+radius; y++ {
			// Distance between creature x and y coordinates and sight radius.
			dx := float64(x - c.X())
			dy := float64(y - c.Y())

			// Distance between creature and sight radius.
			dist := math.Sqrt(math.Pow(dx, 2) + math.Pow(dy, 2))

			// Discriminate coordinates which are outside of the circle.
			if dist > float64(radius) {
				continue
			}

			// Ignore hero.
			for _, p := range get_line(c.X(), c.Y(), x, y)[1:] {
				if !a.ExistsXY(p.X, p.Y) {
					break
				}

				cs[p] = struct{}{}

				// Terrain that breaks line of sight.
				if !a.IsXYPathable(p.X, p.Y) {
					break
				}
			}
		}
	}
	return cs
}
开发者ID:karlek,项目名称:reason,代码行数:34,代码来源:fov.go

示例3: Mobs

// Mobs is a debug function to add mobs to the map.
func Mobs(a *area.Area, num int) {
	var mobList = []creature.Creature{
		// creature.Beastiary["echidna"],
		creature.Beastiary["gobbal"],
		creature.Beastiary["tofu"],
		creature.Beastiary["iop"],
		creature.Beastiary["arachnee"],
	}
	for x := 0; x < a.Width; x++ {
		for y := 0; y < a.Height; y++ {
			if num <= 0 {
				return
			}

			if util.RandInt(0, 50) != 42 {
				continue
			}

			if !a.IsXYPathable(x, y) {
				continue
			}

			g := mobList[util.RandInt(0, len(mobList))]
			g.Inventory = make(creature.Inventory)

			c := coord.Coord{X: x, Y: y}

			g.SetX(x)
			g.SetY(y)

			a.Monsters[c] = &g
			num--
		}
	}
}
开发者ID:karlek,项目名称:reason,代码行数:36,代码来源:mobs.go

示例4: Items

// Items is a debug function to add mobs to the map.
func Items(a *area.Area, num int) {
	var itemList = make([]item.DrawItemer, len(item.Items))
	var index int
	for _, i := range item.Items {
		itemList[index] = i
		index++
	}
	for x := 0; x < a.Width; x++ {
		for y := 0; y < a.Height; y++ {
			if num <= 0 {
				return
			}

			if util.RandInt(0, 50) != 42 {
				continue
			}

			if !a.IsXYPathable(x, y) {
				continue
			}

			c := coord.Coord{x, y}
			i := item.New(itemList[util.RandInt(0, len(itemList))])
			if i == nil {
				continue
			}
			i.SetX(x)
			i.SetY(y)

			if a.Items[c] == nil {
				a.Items[c] = new(area.Stack)
			}
			a.Items[c].Push(i)
			num--
		}
	}
}
开发者ID:karlek,项目名称:reason,代码行数:38,代码来源:items.go


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