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


Golang Itemer.GetAmount方法代碼示例

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


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

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

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

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


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