當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ICreature.GetUID方法代碼示例

本文整理匯總了Golang中pulogic.ICreature.GetUID方法的典型用法代碼示例。如果您正苦於以下問題:Golang ICreature.GetUID方法的具體用法?Golang ICreature.GetUID怎麽用?Golang ICreature.GetUID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pulogic.ICreature的用法示例。


在下文中一共展示了ICreature.GetUID方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:26,代碼來源:tile.go

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

示例3: 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)
		}
	}
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:9,代碼來源:playernetwork.go

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

示例5: 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)
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:12,代碼來源:player.go

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

示例7: OnCreatureAppear

func (p *Player) OnCreatureAppear(_creature pul.ICreature, _isLogin bool) {
	if _creature.GetUID() == p.GetUID() {
		return
	}

	if _isLogin {
		// Check if creature is in friendlist
		p.UpdateFriend(_creature.GetName(), true)
	}

	canSeeCreature := CanSeeCreature(p, _creature)
	if !canSeeCreature {
		return
	}

	// We're checking inside the AddVisibleCreature method so no need to check here
	p.AddVisibleCreature(_creature)
	_creature.AddVisibleCreature(p)
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:19,代碼來源:player.go

示例8: 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
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:21,代碼來源:tile.go

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

示例10: SendCreatureRemove

func (c *Connection) SendCreatureRemove(_creature pul.ICreature) {
	if _creature.GetUID() != c.Owner.GetUID() {
		msg := pnetmsg.NewCreatureRemoveMessage(_creature)
		c.SendMessage(msg)
	}
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:6,代碼來源:connection.go

示例11: KnowsVisibleCreature

func (c *Creature) KnowsVisibleCreature(_creature pul.ICreature) (found bool) {
	_, found = c.VisibleCreatures[_creature.GetUID()]
	return
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:4,代碼來源:creature.go

示例12: RemoveVisibleCreature

func (c *Creature) RemoveVisibleCreature(_creature pul.ICreature) {
	if _, found := c.VisibleCreatures[_creature.GetUID()]; !found {
		c.VisibleCreatures[_creature.GetUID()] = _creature
	}
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:5,代碼來源:creature.go

示例13: RemoveVisibleCreature

func (p *Player) RemoveVisibleCreature(_creature pul.ICreature) {
	// No need to check if the key actually exists because Go is awesome
	// http://tip.golang.org/doc/effective_go.html#maps
	delete(p.VisibleCreatures, _creature.GetUID())
	p.sendCreatureRemove(_creature)
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:6,代碼來源:player.go

示例14: AddVisibleCreature

func (p *Player) AddVisibleCreature(_creature pul.ICreature) {
	if _, found := p.VisibleCreatures[_creature.GetUID()]; !found {
		p.VisibleCreatures[_creature.GetUID()] = _creature
		p.sendCreatureAdd(_creature)
	}
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:6,代碼來源:player.go

示例15: OnCreatureTurn

func (p *Player) OnCreatureTurn(_creature pul.ICreature) {
	if _creature.GetUID() != p.GetUID() {
		p.sendCreatureTurn(_creature)
	}
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:5,代碼來源:player.go


注:本文中的pulogic.ICreature.GetUID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。