本文整理汇总了Golang中MonsterQuest/gameObjectsBase.Activer类的典型用法代码示例。如果您正苦于以下问题:Golang Activer类的具体用法?Golang Activer怎么用?Golang Activer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Activer类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NotifyAboutAttack
func (g *Game) NotifyAboutAttack(attacker, target gameObjectsBase.Activer, msg consts.JsonType) {
g.notifyInRadius(attacker.GetCenter().X, attacker.GetCenter().Y, msg)
t, isMob := target.(*gameObjects.Mob)
if msg["killed"] == true && isMob {
go g.mobs.takeAwayMob(t)
}
}
示例2: Do
func (k *KillWallFlag) Do(obj gameObjectsBase.Activer) {
if pt := obj.GetAttackPoint(); pt != nil {
x, y := int(math.Ceil(pt.X)), int(math.Ceil(pt.Y))
if !k.field.IsBlocked(x, y) {
k.field.SetCell(x, y, consts.GRASS_SYMBOL)
}
}
}
示例3: checkCollisionWithActors
func (m *MoveFlag) checkCollisionWithActors(obj gameObjectsBase.Activer, dir int, shift float64) (bool, geometry.Point) {
segment, pos := obj.GetCollisionableSide(dir, shift)
col1, row1 := int(segment.Point1.X), int(segment.Point1.Y)
col2, row2 := int(segment.Point2.X), int(segment.Point2.Y)
res := m.checkCollisionWithActorsInCell(col1, row1, &segment) || m.checkCollisionWithActorsInCell(col2, row2, &segment)
if res {
pos = obj.GetCenter()
}
return res, pos
}
示例4: Do
func (h *HateFlag) Do(obj gameObjectsBase.Activer) {
if _, exists := obj.GetTarget(); exists {
return
}
center := obj.GetCenter()
lt, rb := h.field.GetSquareArea(center.X, center.Y, obj.GetRadiusVision())
for i := int(lt.Y); i < int(rb.Y); i++ {
for j := int(lt.X); j < int(rb.X); j++ {
for _, m := range h.field.GetActors(j, i) {
if m.GetKind().GetRace() == h.hated && obj.GetID() != m.GetID() {
obj.SetTarget(m)
return
}
}
}
}
}
示例5: GetHit
func (m *Mob) GetHit(blow fightBase.Blower, attacker gameObjectsBase.Activer) consts.JsonType {
res := m.ActiveObject.GetHit(blow, attacker)
if t, isExist := m.GetTarget(); isExist {
if t.GetType() != consts.PLAYER_TYPE {
if attacker.GetType() == consts.PLAYER_TYPE {
m.SetTarget(attacker)
} else {
dice.Shake()
ary := [2]gameObjectsBase.Activer{t, attacker}
m.SetTarget(ary[dice.Throw(2, 1)-1])
}
}
} else {
m.SetTarget(attacker)
}
return res
}
示例6: setCharacteristicsToActiveObject
func (g *Game) setCharacteristicsToActiveObject(obj gameObjectsBase.Activer, characteristics map[string]interface{}) bool {
res := true
func() {
defer func() {
if r := recover(); r != nil {
res = false
}
}()
for c, v := range consts.CharacteristicDefaultValueMapping {
if characteristics[consts.CharacteristicNameMapping[c]] == nil {
obj.SetCharacteristic(c, v)
} else {
obj.SetCharacteristic(c, int(characteristics[consts.CharacteristicNameMapping[c]].(float64)))
}
}
}()
return res
}
示例7: checkCollisionWithWalls
func (m *MoveFlag) checkCollisionWithWalls(obj gameObjectsBase.Activer, dir int, shift float64) (bool, geometry.Point) {
pos := obj.GetShiftedFrontSide(dir, shift)
if m.field.IsBlocked(int(math.Floor(pos.X)), int(math.Floor(pos.Y))) {
switch dir {
case consts.NORTH_DIR:
pos.Y = math.Ceil(pos.Y) + consts.OBJECT_HALF
case consts.SOUTH_DIR:
pos.Y = math.Floor(pos.Y) - consts.OBJECT_HALF
case consts.EAST_DIR:
pos.X = math.Floor(pos.X) - consts.OBJECT_HALF
case consts.WEST_DIR:
pos.X = math.Ceil(pos.X) + consts.OBJECT_HALF
}
return false, pos
}
eps := consts.SLIDE_THRESHOLD
side, pos := obj.GetCollisionableSide(dir, shift)
res1 := m.field.IsBlocked(int(side.Point1.X), int(side.Point1.Y))
res2 := m.field.IsBlocked(int(side.Point2.X), int(side.Point2.Y))
var near float64
if res1 || res2 {
switch dir {
case consts.NORTH_DIR, consts.SOUTH_DIR:
if res1 {
near = math.Ceil(side.Point1.X) - side.Point1.X
} else {
near = math.Floor(side.Point1.X) - side.Point1.X
}
if math.Abs(near) <= eps {
side.Point1.X = side.Point1.X + near
side.Point2.X = side.Point2.X + near
} else {
return false, obj.GetCenter()
}
pos.X = (side.Point1.X + side.Point2.X) / 2
case consts.EAST_DIR, consts.WEST_DIR:
if res1 {
near = math.Ceil(side.Point1.Y) - side.Point1.Y
} else {
near = math.Floor(side.Point1.Y) - side.Point1.Y
}
if math.Abs(near) <= eps {
side.Point1.Y = side.Point1.Y + near
side.Point2.Y = side.Point2.Y + near
} else {
return false, obj.GetCenter()
}
pos.Y = (side.Point1.Y + side.Point2.Y) / 2
}
}
return true, pos
}
示例8: setInventoryToActiveObject
func (g *Game) setInventoryToActiveObject(obj gameObjectsBase.Activer, inventory map[string]interface{}) bool {
res := true
func() {
defer func() {
if r := recover(); r != nil {
res = false
}
}()
for _, v := range inventory {
json, ok := v.(consts.JsonType)
if !ok {
res = false
return
}
x := gameObjectsBase.ItemFromJson(json)
obj.AddItem(x)
}
}()
return res
}
示例9: Do
func (r *ReviveFlag) Do(obj gameObjectsBase.Activer) {
if obj.Killed() && obj.GetRevivePoint() != nil {
r.field.UnlinkFromCells(obj)
obj.Revive()
r.field.LinkToCells(obj)
}
}