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


Golang gameObjectsBase.Itemer类代码示例

本文整理汇总了Golang中MonsterQuest/gameObjectsBase.Itemer的典型用法代码示例。如果您正苦于以下问题:Golang Itemer类的具体用法?Golang Itemer怎么用?Golang Itemer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: 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
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:8,代码来源:player.go

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

示例3: 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
	}
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:16,代码来源:player.go

示例4: RestoreSlot

func (p *Player) RestoreSlot(item gameObjectsBase.Itemer, slotIota int) {
	p.Inventory.RestoreItem(item)
	p.slots[slotIota].item = item
	if ok, s := p.getNearbySlot(slotIota, item.GetItemSubtype()); ok {
		if p.slots[s].item != nil {
			p.slots[s].item = nil
		}
		// p.slots[s].item = item
	}
	item.EquipItem(p.Inventory)
	item.SetOwner(p)
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:12,代码来源:player.go

示例5: DropItem

func (p *Player) DropItem(item gameObjectsBase.Itemer, amount int) (int, gameObjectsBase.Itemer) {
	db := connect.CreateConnect()
	place, new_item := p.ActiveObject.DropItem(item, amount)
	if s := p.getSlotByItem(item); s != consts.SLOT_DEFAULT {
		if item.GetAmount()-amount <= 0 {
			p.slots[s].item = nil
		}
		db.Exec("CALL dec_user_slot_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), s, amount)
	} else {
		db.Exec("CALL dec_user_item_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), place, amount)
	}
	return place, new_item
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:13,代码来源:player.go

示例6: PickUpItem

func (p *Player) PickUpItem(item gameObjectsBase.Itemer) (bool, gameObjectsBase.Itemer) {
	var err error = nil
	db := connect.CreateConnect()
	place, i := p.AddItem(item)
	if item.IsHeapItem() && place == -1 {
		_, err = db.Exec("CALL inc_user_slot_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), p.getSlotByItemType(item.GetItemType()), item.GetAmount())
	} else {
		_, err = db.Exec("CALL inc_user_item_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), place, item.GetAmount())
	}
	if err != nil {
		//
		fmt.Println(err)
	}
	return err == nil, i
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:15,代码来源:player.go

示例7: DeleteItem

func (p *Player) DeleteItem(item gameObjectsBase.Itemer, amount int) (bool, gameObjectsBase.Itemer) {
	var (
		i   gameObjectsBase.Itemer = item
		res bool                   = false
	)
	db := connect.CreateConnect()
	var place int
	place, i = p.Inventory.DeleteItem(item, amount)
	if s := p.getSlotByItem(item); s != consts.SLOT_DEFAULT {
		if item.GetAmount() <= 0 {
			p.slots[s].item = nil
			i = nil
		}
		_, err := db.Exec("CALL dec_user_slot_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), s, amount)
		res = err == nil
	} else {
		_, err := db.Exec("CALL dec_user_item_amount(?, ?, ?, ?)", p.DBId, item.GetKindId(), place, amount)
		res = err == nil
	}
	return res, i
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:21,代码来源:player.go

示例8: deleteItem

func (il *itemList) deleteItem(i gameObjectsBase.Itemer) {
	delete(il.items, i.GetID())
}
开发者ID:apanasenko,项目名称:MonsterQuest,代码行数:3,代码来源:itemList.go

示例9: addItem

func (il *itemList) addItem(i gameObjectsBase.Itemer) {
	il.items[i.GetID()] = i
}
开发者ID:apanasenko,项目名称:MonsterQuest,代码行数:3,代码来源:itemList.go

示例10: 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()
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:3,代码来源:player.go

示例11: CanPickUp

func (p *Player) CanPickUp(item gameObjectsBase.Itemer) bool {
	return p.Inventory.GetWeight()+item.GetWeight() <= p.GetCapacity()
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:3,代码来源:player.go

示例12: 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
	}
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:31,代码来源:player.go

示例13: RestoreItem

func (p *Player) RestoreItem(item gameObjectsBase.Itemer, place int) {
	p.Inventory.RestoreItem(item, place)
	item.SetOwner(p)
}
开发者ID:koninka,项目名称:MonsterQuest,代码行数:4,代码来源:player.go


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