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)
|
function Use_Item(table, urod, itemid, amount)
|
||||||
{
|
{
|
||||||
Add_MissionCount(table, urod, "CONSUME_GOODS", itemid, amount, false);
|
var success = false;
|
||||||
Add_MissionCount(table, urod, "CONSUME_GOODS_ACC", itemid, amount, 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)
|
Add_MissionCount(table, urod, "CONSUME_GOODS", itemid, amount, false);
|
||||||
{
|
Add_MissionCount(table, urod, "CONSUME_GOODS_ACC", itemid, amount, false);
|
||||||
urod.Item[itemid][0] -= amount;
|
|
||||||
urod.Item[itemid][2] = Add_Amount(urod.Item[itemid][2], amount); // 총 사용량
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (urod.Equipment[itemid])
|
|
||||||
{
|
//log.info('use ' + itemid + ', ' + amount + ', result : ' + success);
|
||||||
//log.info('장비 사용 ' + itemid + ' ' + urod.Equipment[itemid][0]);
|
return success;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
function Get_ItemAmount(urod, itemid)
|
function Get_ItemAmount(urod, itemid)
|
||||||
{
|
{
|
||||||
|
|
@ -318,9 +290,7 @@ function Get_ItemAmount(urod, itemid)
|
||||||
}
|
}
|
||||||
function Check_ItemAmount(urod, itemid, amount)
|
function Check_ItemAmount(urod, itemid, amount)
|
||||||
{
|
{
|
||||||
//log.info("Check_ItemAmount : " + itemid + ", " + amount);
|
|
||||||
var obtainAmount = Get_ItemAmount(urod, itemid);
|
var obtainAmount = Get_ItemAmount(urod, itemid);
|
||||||
//log.info("obtainAmount : " + obtainAmount);
|
|
||||||
return obtainAmount >= amount;
|
return obtainAmount >= amount;
|
||||||
}
|
}
|
||||||
function IsObtainItem(urod, itemid)
|
function IsObtainItem(urod, itemid)
|
||||||
|
|
@ -1805,18 +1775,11 @@ handlers.Save_Gacha = function(args)
|
||||||
{
|
{
|
||||||
gachaType = 1;
|
gachaType = 1;
|
||||||
Use_Item(table, urod, gachaData.n_GachaTicketID, ticketAmount);
|
Use_Item(table, urod, gachaData.n_GachaTicketID, ticketAmount);
|
||||||
Use_Item(table, urod, gachaData.n_GachaTicketID, needgem);
|
Use_Item(table, urod, gachaData.n_GachaGoodsID, 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (Use_Item(table, urod, gachaData.n_GachaGoodsID, m_Count * gachaData.n_GachaPrice))
|
||||||
|
gachaType = 1;
|
||||||
|
|
||||||
if (gachaType > 0)
|
if (gachaType > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3005,6 +3005,7 @@ public class SC_CollectionResultData
|
||||||
}
|
}
|
||||||
public class SC_GachaResult
|
public class SC_GachaResult
|
||||||
{
|
{
|
||||||
|
public int useticketamount, usegemamount;
|
||||||
public List<int> gacha;
|
public List<int> gacha;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -37,7 +37,8 @@ public class btn_gacha : MonoBehaviour
|
||||||
moneyForms[0].gameObject.SetActive(true);
|
moneyForms[0].gameObject.SetActive(true);
|
||||||
moneyForms[0].Set_Need(m_Data.n_GachaTicketID, m_Count);
|
moneyForms[0].Set_Need(m_Data.n_GachaTicketID, m_Count);
|
||||||
moneyForms[1].gameObject.SetActive(true);
|
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;
|
break;
|
||||||
case eGachaBtnType.OnlyCash:
|
case eGachaBtnType.OnlyCash:
|
||||||
case eGachaBtnType.CantGacha:
|
case eGachaBtnType.CantGacha:
|
||||||
|
|
@ -68,32 +69,75 @@ public class btn_gacha : MonoBehaviour
|
||||||
|
|
||||||
public void OnClick_Gacha()
|
public void OnClick_Gacha()
|
||||||
{
|
{
|
||||||
ServerInfo.Ins.Save_Gacha(m_Data.n_ID, m_Count, result =>
|
|
||||||
{
|
|
||||||
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
var sdata = ServerInfo.Ins.m_ServerData;
|
var sdata = ServerInfo.Ins.m_ServerData;
|
||||||
switch (Get_BtnType())
|
switch (Get_BtnType())
|
||||||
{
|
{
|
||||||
case eGachaBtnType.OnlyTicket:
|
case eGachaBtnType.OnlyTicket:
|
||||||
sdata.Use_Item(m_Data.n_GachaTicketID, m_Count);
|
sdata.Use_Item(m_Data.n_GachaTicketID, m_Count);
|
||||||
Gacha_Process();
|
|
||||||
break;
|
break;
|
||||||
case eGachaBtnType.TicketAndCash:
|
case eGachaBtnType.TicketAndCash:
|
||||||
var ticketamount = sdata.Get_ItemAmount(m_Data.n_GachaTicketID);
|
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_GachaGoodsID, (m_Count - ticketamount) * m_Data.n_GachaPrice);
|
||||||
sdata.Use_Item(m_Data.n_GachaTicketID, ticketamount);
|
sdata.Use_Item(m_Data.n_GachaTicketID, ticketamount);
|
||||||
Gacha_Process();
|
|
||||||
break;
|
break;
|
||||||
case eGachaBtnType.OnlyCash:
|
case eGachaBtnType.OnlyCash:
|
||||||
sdata.Use_Item(m_Data.n_GachaGoodsID, m_Count * m_Data.n_GachaPrice);
|
sdata.Use_Item(m_Data.n_GachaGoodsID, m_Count * m_Data.n_GachaPrice);
|
||||||
Gacha_Process();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ToastUI.Ins.Set(388);
|
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()
|
void Gacha_Process()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue