本文整理匯總了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--
}
}
}