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


Golang ICreature.RemoveVisibleCreature方法代码示例

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


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

示例1: 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)
	}
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:29,代码来源:player.go

示例2: OnCreatureMove

func (n *Npc) OnCreatureMove(_creature pul.ICreature, _from pul.ITile, _to pul.ITile, _teleport bool) {
	// Check if _creature is a Player, otherwise return
	if _creature.GetType() != CTYPE_PLAYER {
		return
	}

	canSeeFromTile := CanSeePosition(n.GetPosition(), _from.GetPosition())
	canSeeToTile := CanSeePosition(n.GetPosition(), _to.GetPosition())

	if canSeeFromTile && !canSeeToTile { // Leaving viewport
		n.RemoveVisibleCreature(_creature)
		_creature.RemoveVisibleCreature(n)
	} else if canSeeToTile && !canSeeFromTile { // Entering viewport
		n.AddVisibleCreature(_creature)
		_creature.RemoveVisibleCreature(n)
	} else { // Moving inside viewport
		n.AddVisibleCreature(_creature)
		_creature.AddVisibleCreature(n)
	}
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:20,代码来源:npc.go


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