本文整理汇总了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
}
示例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
}
示例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--
}
}
}
示例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--
}
}
}