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


Golang ICreature.GetType方法代码示例

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


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

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

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

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

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

示例5: 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

示例6: AddCreature

func (g *Game) AddCreature(_creature pul.ICreature) {
	// TODO: Maybe only take the creatues from the area the new creature is in. This saves some extra iterating

	g.mutexCreatureList.Lock()
	defer g.mutexCreatureList.Unlock()
	for _, value := range g.Creatures {
		value.OnCreatureAppear(_creature, true)
	}

	g.Creatures[_creature.GetUID()] = _creature

	if _creature.GetType() == CTYPE_PLAYER {
		g.mutexPlayerList.Lock()
		defer g.mutexPlayerList.Unlock()
		g.Players[_creature.GetUID()] = _creature.(*Player)

		// Join default channels
		g.Chat.AddUserToChannel(_creature.(*Player), pnet.CHANNEL_WORLD)
		g.Chat.AddUserToChannel(_creature.(*Player), pnet.CHANNEL_TRADE)
	}
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:21,代码来源:game.go

示例7: OnCreatureTurn

func (n *Npc) OnCreatureTurn(_creature pul.ICreature) {
	// Check if _creature is a Player, otherwise return
	if _creature.GetType() != CTYPE_PLAYER {
		return
	}
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:6,代码来源:npc.go

示例8: checkForWildEncounter

func (g *Game) checkForWildEncounter(_creature pul.ICreature) {
	if _creature.GetType() == CTYPE_PLAYER {
		// Do some checkin'
	}
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:5,代码来源:game.go


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