本文整理汇总了Golang中pulogic.ICreature类的典型用法代码示例。如果您正苦于以下问题:Golang ICreature类的具体用法?Golang ICreature怎么用?Golang ICreature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ICreature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: internalCreatureTeleport
func (g *Game) internalCreatureTeleport(_creature pul.ICreature, _from pul.ITile, _to pul.ITile) (ret int) {
ret = RET_NOERROR
if _from == nil || _to == nil {
ret = RET_NOTPOSSIBLE
} else {
// Move creature object to destination tile
if ret = _from.RemoveCreature(_creature, true); ret == RET_NOTPOSSIBLE {
return
}
if ret = _to.AddCreature(_creature, false); ret == RET_NOTPOSSIBLE {
_from.AddCreature(_creature, false) // Something went wrong, put creature back on old tile
return
}
_creature.SetTile(_to)
// Tell creatures this creature has been teleported
g.mutexCreatureList.RLock()
defer g.mutexCreatureList.RUnlock()
for _, value := range g.Creatures {
if value != nil {
value.OnCreatureMove(_creature, _from, _to, true)
}
}
}
// No error, played succesfully teleported
if ret == RET_NOERROR {
ret = RET_PLAYERISTELEPORTED
}
return
}
示例2: internalCreatureSay
func (g *Game) internalCreatureSay(_creature pul.ICreature, _speakType int, _message string) bool {
list := make(pul.CreatureList)
if _speakType == pnet.SPEAK_YELL {
position := _creature.GetPosition() // Get position of speaker
g.mutexPlayerList.RLock()
defer g.mutexPlayerList.RUnlock()
for _, player := range g.Players {
if player != nil {
if position.IsInRange3p(player.GetPosition(), pos.NewPositionFrom(27, 21, 0)) {
list[player.GetUID()] = player
}
}
}
} else {
list = _creature.GetVisibleCreatures()
}
// Send chat message to all visible players
for _, creature := range list {
if creature.GetType() == CTYPE_PLAYER {
player := creature.(*Player)
// player.sendCreatureSay(_creature, _speakType, _message)
player.sendToChannel(_creature, _speakType, _message, pnet.CHANNEL_LOCAL, 0)
}
}
return true
}
示例3: AddCreature
// AddCreature adds a new active creature to this tile
func (t *Tile) AddCreature(_creature pul.ICreature, _checkEvents bool) (ret int) {
ret = RET_NOERROR
if _checkEvents && t.Events.Len() > 0 {
var i int = 0
for e := t.Events.Front(); e != nil; e = e.Next() {
event, valid := e.Value.(ITileEvent)
if valid {
ret = event.OnCreatureEnter(_creature, ret)
}
if ret == RET_NOTPOSSIBLE {
return
}
i++
}
}
_, found := t.Creatures[_creature.GetUID()]
if !found {
t.Creatures[_creature.GetUID()] = _creature
}
return
}
示例4: internalCreatureChangeVisible
func (g *Game) internalCreatureChangeVisible(_creature pul.ICreature, _visible bool) {
list := _creature.GetVisibleCreatures()
for _, tmpCreature := range list {
if tmpCreature.GetType() == CTYPE_PLAYER {
tmpCreature.(*Player).sendCreatureChangeVisibility(_creature, _visible)
}
}
}
示例5: OnCreatureDisappear
func (n *Npc) OnCreatureDisappear(_creature pul.ICreature, _isLogout bool) {
// Check if _creature is a Player, otherwise return
if _creature.GetType() != CTYPE_PLAYER {
return
}
n.RemoveVisibleCreature(_creature)
}
示例6: sendCreatureChangeVisibility
func (p *Player) sendCreatureChangeVisibility(_creature pul.ICreature, _visible bool) {
if _creature.GetUID() != p.GetUID() {
if _visible {
p.AddVisibleCreature(_creature)
} else if !p.HasFlag(PlayerFlag_CanSenseInvisibility) {
p.RemoveVisibleCreature(_creature)
}
}
}
示例7: OnCreatureEnter
func (e *Warp) OnCreatureEnter(_creature pul.ICreature, _prevRet int) (ret int) {
currentTile := _creature.GetTile()
destinationTile, found := g_map.GetTileFromPosition(e.destination)
if found {
ret = g_game.internalCreatureTeleport(_creature, currentTile, destinationTile)
} else {
ret = RET_NOTPOSSIBLE
}
return
}
示例8: OnCreatureDisappear
func (p *Player) OnCreatureDisappear(_creature pul.ICreature, _isLogout bool) {
if _creature.GetUID() == p.GetUID() {
return
}
if _isLogout {
// Check if creature is in friendlist
p.UpdateFriend(_creature.GetName(), false)
}
p.RemoveVisibleCreature(_creature)
}
示例9: OnPlayerMove
func (g *Game) OnPlayerMove(_creature pul.ICreature, _direction int, _sendMap bool) {
ret := g.OnCreatureMove(_creature, _direction)
player := _creature.(*Player)
if ret == RET_NOTPOSSIBLE {
player.sendCreatureMove(_creature, _creature.GetTile(), _creature.GetTile())
} else if ret == RET_PLAYERISTELEPORTED {
player.sendPlayerWarp()
player.sendMapData(DIR_NULL)
} else {
player.sendMapData(_direction)
}
}
示例10: OnCreatureMove
func (p *Player) OnCreatureMove(_creature pul.ICreature, _from pul.ITile, _to pul.ITile, _teleport bool) {
if _creature.GetUID() == p.GetUID() {
p.lastStep = PUSYS_TIME()
return
}
from := _from.(*Tile)
to := _to.(*Tile)
canSeeFromTile := CanSeePosition(p.GetPosition(), from.Position)
canSeeToTile := CanSeePosition(p.GetPosition(), to.Position)
if canSeeFromTile && !canSeeToTile { // Leaving viewport
p.sendCreatureMove(_creature, from, to)
p.RemoveVisibleCreature(_creature)
_creature.RemoveVisibleCreature(p)
} else if canSeeToTile && !canSeeFromTile { // Entering viewport
p.AddVisibleCreature(_creature)
_creature.RemoveVisibleCreature(p)
p.sendCreatureMove(_creature, from, to)
} else { // Moving inside viewport
p.AddVisibleCreature(_creature)
_creature.AddVisibleCreature(p)
p.sendCreatureMove(_creature, from, to)
}
}
示例11: RemoveVisibleCreature
func (n *Npc) RemoveVisibleCreature(_creature pul.ICreature) {
// Check if _creature is a Player, otherwise return
if _creature.GetType() != CTYPE_PLAYER {
return
}
// Check if the player was interacting with this npc
if n.HasInteractingPlayer(_creature.(*Player)) {
n.RemoveInteractingPlayer(_creature.(*Player))
}
// No need to check if the key actually exists because Go is awesome
// http://golang.org/doc/effective_go.html#maps
delete(n.VisibleCreatures, _creature.GetUID())
}
示例12: OnCreatureAppear
func (n *Npc) OnCreatureAppear(_creature pul.ICreature, _isLogin bool) {
// Check if _creature is a Player, otherwise return
if _creature.GetType() != CTYPE_PLAYER {
return
}
canSeeCreature := CanSeeCreature(n, _creature)
if !canSeeCreature {
return
}
// We're checking the existence of _creature inside the AddVisibleCreature method
// so no need to check here
n.AddVisibleCreature(_creature)
_creature.AddVisibleCreature(n)
}
示例13: RemoveCreature
// RemoveCreature removes an active creature from this tile
func (t *Tile) RemoveCreature(_creature pul.ICreature, _checkEvents bool) (ret int) {
ret = RET_NOERROR
if _checkEvents && t.Events.Len() > 0 {
for e := t.Events.Front(); e != nil; e = e.Next() {
event, valid := e.Value.(ITileEvent)
if valid {
ret = event.OnCreatureLeave(_creature, ret)
}
if ret == RET_NOTPOSSIBLE {
return
}
}
}
delete(t.Creatures, _creature.GetUID())
return
}
示例14: CheckMovement
// CheckMovement checks if a creature can move to this tile
func (t *Tile) CheckMovement(_creature pul.ICreature, _dir int) int {
movement := _creature.GetMovement()
blocking := t.Blocking
if blocking != TILEBLOCK_WALK {
if blocking == TILEBLOCK_BLOCK ||
(blocking == TILEBLOCK_SURF && movement != MOVEMENT_SURF) ||
(blocking == TILEBLOCK_TOP && _dir == DIR_SOUTH) ||
(blocking == TILEBLOCK_BOTTOM && _dir == DIR_NORTH) ||
(blocking == TILEBLOCK_LEFT && _dir == DIR_EAST) ||
(blocking == TILEBLOCK_RIGHT && _dir == DIR_WEST) ||
(blocking == TILEBLOCK_TOPLEFT && (_dir == DIR_EAST || _dir == DIR_SOUTH)) ||
(blocking == TILEBLOCK_TOPRIGHT && (_dir == DIR_WEST || _dir == DIR_SOUTH)) ||
(blocking == TILEBLOCK_BOTTOMLEFT && (_dir == DIR_EAST || _dir == DIR_NORTH)) ||
(blocking == TILEBLOCK_BOTTOMRIGHT && (_dir == DIR_WEST || _dir == DIR_NORTH)) {
return RET_NOTPOSSIBLE
}
}
return RET_NOERROR
}
示例15: AddVisibleCreature
func (n *Npc) AddVisibleCreature(_creature pul.ICreature) {
// Check if _creature is a Player, otherwise return
if _creature.GetType() != CTYPE_PLAYER {
return
}
if _, found := n.VisibleCreatures[_creature.GetUID()]; !found {
n.VisibleCreatures[_creature.GetUID()] = _creature
}
}