本文整理匯總了Golang中MonsterQuest/gameObjectsBase.Itemer.GetID方法的典型用法代碼示例。如果您正苦於以下問題:Golang Itemer.GetID方法的具體用法?Golang Itemer.GetID怎麽用?Golang Itemer.GetID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MonsterQuest/gameObjectsBase.Itemer
的用法示例。
在下文中一共展示了Itemer.GetID方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Equip
func (p *Player) Equip(item gameObjectsBase.Itemer, slotIota int) (int, consts.JsonType) {
var res consts.JsonType = nil
slot := p.slots[slotIota]
if slot == nil || !slot.isSuitableType(item.GetItemType()) {
return consts.BADSLOT, res
}
if item.GetItemClass() != consts.ITEM_CLASS_GARMENT || p.Equipped(item) {
return consts.BADID, res
}
p.Unequip(slotIota)
db := connect.CreateConnect()
_, err := db.Exec("CALL equip_item(?, ?, ?, ?)", p.DBId, item.GetKindId(), item.EquipItem(p.Inventory), slotIota)
if err == nil {
if ok, s := p.getNearbySlot(slotIota, item.GetItemSubtype()); ok {
if p.slots[s].item != nil && p.slots[s].item.GetID() != item.GetID() {
p.Unequip(s)
}
res = consts.JsonType{}
res[consts.SlotNameMapping[s]] = item.GetID()
p.slots[s].item = nil
} else {
p.Unequip(slotIota)
}
slot.item = item
}
if err == nil {
return consts.OK, res
} else {
return consts.BADID, res
}
}
示例2: Equipped
func (p *Player) Equipped(item gameObjectsBase.Itemer) bool {
for _, slot := range p.slots {
if slot.item != nil && slot.item.GetID() == item.GetID() {
return true
}
}
return false
}
示例3: getSlotByItem
func (p *Player) getSlotByItem(item gameObjectsBase.Itemer) int {
var slot int = consts.SLOT_DEFAULT
for i, s := range p.slots {
if s.item != nil && (s.item.GetID() == item.GetID()) {
slot = i
break
}
}
return slot
}
示例4: MoveItem
func (p *Player) MoveItem(item gameObjectsBase.Itemer, to_cell int) bool {
if owner := item.GetOwner(); (owner != nil && owner.GetID() != p.GetID()) || p.Equipped(item) {
return false
}
from_cell := p.Inventory.GetPlace(item.GetID())
if from_cell == to_cell {
return true
} else {
db := connect.CreateConnect()
_, err := db.Exec("CALL move_item(?, ?, ?)", p.DBId, from_cell, to_cell)
if err == nil {
p.Inventory.MoveItem(item, from_cell, to_cell)
}
return err == nil
}
}
示例5: deleteItem
func (il *itemList) deleteItem(i gameObjectsBase.Itemer) {
delete(il.items, i.GetID())
}
示例6: addItem
func (il *itemList) addItem(i gameObjectsBase.Itemer) {
il.items[i.GetID()] = i
}
示例7: IsEquippedItem
func (p *Player) IsEquippedItem(item gameObjectsBase.Itemer) bool {
return (item.GetID() == p.fist.GetID() && (p.slots[consts.SLOT_LEFT_HAND].item == nil || p.slots[consts.SLOT_RIGHT_HAND].item == nil)) || item.IsEquipped()
}