This commit is contained in:
parent
c055fed841
commit
55f0e5aada
|
|
@ -249,62 +249,34 @@ function Add_Item(table, itemtable, urod, itemid, amount, isCheat)
|
|||
}
|
||||
function Use_Item(table, urod, itemid, amount)
|
||||
{
|
||||
Add_MissionCount(table, urod, "CONSUME_GOODS", itemid, amount, false);
|
||||
Add_MissionCount(table, urod, "CONSUME_GOODS_ACC", itemid, amount, false);
|
||||
var success = false;
|
||||
|
||||
if (urod.Item[itemid])
|
||||
// 아이템 루트별 처리
|
||||
const tryUse = (dict, useIndex, totalIndex = null) => {
|
||||
if (!dict[itemid]) return false;
|
||||
if (dict[itemid][useIndex] < amount) return false;
|
||||
|
||||
dict[itemid][useIndex] -= amount;
|
||||
if (totalIndex !== null)
|
||||
dict[itemid][totalIndex] = Add_Amount(dict[itemid][totalIndex], amount);
|
||||
return true;
|
||||
};
|
||||
|
||||
if (urod.Item && tryUse(urod.Item, 0, 2)) success = true;
|
||||
else if (urod.Equipment && tryUse(urod.Equipment, 0)) success = true;
|
||||
else if (urod.Skill && tryUse(urod.Skill, 0)) success = true;
|
||||
else if (urod.Pet && tryUse(urod.Pet, 0)) success = true;
|
||||
else if (urod.Enchant && tryUse(urod.Enchant, 0, 3)) success = true;
|
||||
else if (urod.Relic && tryUse(urod.Relic, 0)) success = true;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (urod.Item[itemid][0] >= amount)
|
||||
{
|
||||
urod.Item[itemid][0] -= amount;
|
||||
urod.Item[itemid][2] = Add_Amount(urod.Item[itemid][2], amount); // 총 사용량
|
||||
return true;
|
||||
}
|
||||
Add_MissionCount(table, urod, "CONSUME_GOODS", itemid, amount, false);
|
||||
Add_MissionCount(table, urod, "CONSUME_GOODS_ACC", itemid, amount, false);
|
||||
}
|
||||
else if (urod.Equipment[itemid])
|
||||
{
|
||||
//log.info('장비 사용 ' + itemid + ' ' + urod.Equipment[itemid][0]);
|
||||
if (urod.Equipment[itemid][0] >= amount)
|
||||
{
|
||||
urod.Equipment[itemid][0] -= amount;
|
||||
//log.info('장비 사용 ' + itemid + ' ' + urod.Equipment[itemid][0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (urod.Skill[itemid])
|
||||
{
|
||||
if (urod.Skill[itemid][0] >= amount)
|
||||
{
|
||||
urod.Skill[itemid][0] -= amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (urod.Pet[itemid])
|
||||
{
|
||||
if (urod.Pet[itemid][0] >= amount)
|
||||
{
|
||||
urod.Pet[itemid][0] -= amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (urod.Enchant[itemid])
|
||||
{
|
||||
if (urod.Enchant[itemid][0] >= amount)
|
||||
{
|
||||
urod.Enchant[itemid][0] -= amount;
|
||||
urod.Enchant[itemid][3] = Add_Amount(urod.Enchant[itemid][3], amount);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (urod.Relic[itemid])
|
||||
{
|
||||
if (urod.Relic[itemid][0] >= amount)
|
||||
{
|
||||
urod.Relic[itemid][0] -= amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
//log.info('use ' + itemid + ', ' + amount + ', result : ' + success);
|
||||
return success;
|
||||
}
|
||||
function Get_ItemAmount(urod, itemid)
|
||||
{
|
||||
|
|
@ -318,9 +290,7 @@ function Get_ItemAmount(urod, itemid)
|
|||
}
|
||||
function Check_ItemAmount(urod, itemid, amount)
|
||||
{
|
||||
//log.info("Check_ItemAmount : " + itemid + ", " + amount);
|
||||
var obtainAmount = Get_ItemAmount(urod, itemid);
|
||||
//log.info("obtainAmount : " + obtainAmount);
|
||||
return obtainAmount >= amount;
|
||||
}
|
||||
function IsObtainItem(urod, itemid)
|
||||
|
|
@ -1805,18 +1775,11 @@ handlers.Save_Gacha = function(args)
|
|||
{
|
||||
gachaType = 1;
|
||||
Use_Item(table, urod, gachaData.n_GachaTicketID, ticketAmount);
|
||||
Use_Item(table, urod, gachaData.n_GachaTicketID, needgem);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var need = m_Count * gachaData.n_GachaPrice;
|
||||
if (Check_ItemAmount(urod, gachaData.n_GachaGoodsID, need))
|
||||
{
|
||||
gachaType = 1;
|
||||
Use_Item(table, urod, gachaData.n_GachaTicketID, need);
|
||||
Use_Item(table, urod, gachaData.n_GachaGoodsID, needgem);
|
||||
}
|
||||
}
|
||||
else if (Use_Item(table, urod, gachaData.n_GachaGoodsID, m_Count * gachaData.n_GachaPrice))
|
||||
gachaType = 1;
|
||||
|
||||
if (gachaType > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3005,6 +3005,7 @@ public class SC_CollectionResultData
|
|||
}
|
||||
public class SC_GachaResult
|
||||
{
|
||||
public int useticketamount, usegemamount;
|
||||
public List<int> gacha;
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -37,7 +37,8 @@ public class btn_gacha : MonoBehaviour
|
|||
moneyForms[0].gameObject.SetActive(true);
|
||||
moneyForms[0].Set_Need(m_Data.n_GachaTicketID, m_Count);
|
||||
moneyForms[1].gameObject.SetActive(true);
|
||||
moneyForms[1].Set_Need(m_Data.n_GachaGoodsID, m_Count - (int)sdata.Get_ItemAmount(m_Data.n_GachaTicketID) * m_Data.n_GachaPrice);
|
||||
var remaincount = m_Count - (int)sdata.Get_ItemAmount(m_Data.n_GachaTicketID);
|
||||
moneyForms[1].Set_Need(m_Data.n_GachaGoodsID, remaincount * m_Data.n_GachaPrice);
|
||||
break;
|
||||
case eGachaBtnType.OnlyCash:
|
||||
case eGachaBtnType.CantGacha:
|
||||
|
|
@ -68,32 +69,75 @@ public class btn_gacha : MonoBehaviour
|
|||
|
||||
public void OnClick_Gacha()
|
||||
{
|
||||
ServerInfo.Ins.Save_Gacha(m_Data.n_ID, m_Count, result =>
|
||||
{
|
||||
|
||||
});
|
||||
return;
|
||||
var sdata = ServerInfo.Ins.m_ServerData;
|
||||
switch (Get_BtnType())
|
||||
{
|
||||
case eGachaBtnType.OnlyTicket:
|
||||
sdata.Use_Item(m_Data.n_GachaTicketID, m_Count);
|
||||
Gacha_Process();
|
||||
break;
|
||||
case eGachaBtnType.TicketAndCash:
|
||||
var ticketamount = sdata.Get_ItemAmount(m_Data.n_GachaTicketID);
|
||||
sdata.Use_Item(m_Data.n_GachaGoodsID, (m_Count - ticketamount) * m_Data.n_GachaPrice);
|
||||
sdata.Use_Item(m_Data.n_GachaTicketID, ticketamount);
|
||||
Gacha_Process();
|
||||
break;
|
||||
case eGachaBtnType.OnlyCash:
|
||||
sdata.Use_Item(m_Data.n_GachaGoodsID, m_Count * m_Data.n_GachaPrice);
|
||||
Gacha_Process();
|
||||
break;
|
||||
default:
|
||||
ToastUI.Ins.Set(388);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
ServerInfo.Ins.Save_Gacha(m_Data.n_ID, m_Count, result =>
|
||||
{
|
||||
List<ItemSimpleData> items = new List<ItemSimpleData>();
|
||||
for (int i = 0; i < result.gacha.Count; i++)
|
||||
{
|
||||
items.Add(new ItemSimpleData { itemid = result.gacha[i], amount = 1 });
|
||||
sdata.Add_Item(result.gacha[i], 1);
|
||||
sdata.Add_Gacha(m_Data.n_ID, 1);
|
||||
}
|
||||
|
||||
sdata.Add_MissionCount(ePurpose.GACHA_ALL, 0, m_Count);
|
||||
if (m_Data.isSkillGacha)
|
||||
{
|
||||
sdata.Add_MissionCount(ePurpose.GACHA_SKILL, 0, m_Count);
|
||||
sdata.Add_MissionCount(ePurpose.GACHA_SKILL_ACC, 0, m_Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
sdata.Add_MissionCount(ePurpose.GACHA_EQUIP, 0, m_Count);
|
||||
sdata.Add_MissionCount(ePurpose.GACHA_EQUIP_ACC, 0, m_Count);
|
||||
}
|
||||
|
||||
ObtainItemUI.Ins.Set(items);
|
||||
NewGameUI.Ins.m_GachaUI.Set_Money();
|
||||
NewGameUI.Ins.m_GachaUI.m_gachaBase.Set_UI();
|
||||
});
|
||||
return;
|
||||
|
||||
// 클라 기반
|
||||
//var sdata = ServerInfo.Ins.m_ServerData;
|
||||
//switch (Get_BtnType())
|
||||
//{
|
||||
// case eGachaBtnType.OnlyTicket:
|
||||
// sdata.Use_Item(m_Data.n_GachaTicketID, m_Count);
|
||||
// Gacha_Process();
|
||||
// break;
|
||||
// case eGachaBtnType.TicketAndCash:
|
||||
// var ticketamount = sdata.Get_ItemAmount(m_Data.n_GachaTicketID);
|
||||
// sdata.Use_Item(m_Data.n_GachaGoodsID, (m_Count - ticketamount) * m_Data.n_GachaPrice);
|
||||
// sdata.Use_Item(m_Data.n_GachaTicketID, ticketamount);
|
||||
// Gacha_Process();
|
||||
// break;
|
||||
// case eGachaBtnType.OnlyCash:
|
||||
// sdata.Use_Item(m_Data.n_GachaGoodsID, m_Count * m_Data.n_GachaPrice);
|
||||
// Gacha_Process();
|
||||
// break;
|
||||
// default:
|
||||
// ToastUI.Ins.Set(388);
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
void Gacha_Process()
|
||||
|
|
|
|||
Loading…
Reference in New Issue