Merge branch 'feature/select-last-role' into feature/Addessable_CDN
This commit is contained in:
@@ -128,7 +128,6 @@ namespace BrewMonster
|
||||
|
||||
private void OnMsgHstHurtResult(ECMSG Msg)
|
||||
{
|
||||
//BMLogger.LogError("HoangDev : OnMsgHstHurtResult");
|
||||
int cmd = Convert.ToInt32(Msg.dwParam2);
|
||||
if (cmd == CommandID.BE_HURT)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
using BrewMonster.Managers;
|
||||
using BrewMonster.Network;
|
||||
using BrewMonster.Scripts;
|
||||
using BrewMonster.UI;
|
||||
using CSNetwork.GPDataType;
|
||||
using PerfectWorld.Scripts.Managers;
|
||||
using UnityEngine;
|
||||
using static BrewMonster.Scripts.CECHPWork;
|
||||
using static BrewMonster.CECHPWorkTrace;
|
||||
|
||||
namespace BrewMonster
|
||||
{
|
||||
public partial class CECHostPlayer
|
||||
{
|
||||
public bool GetWalkRunFlag() => m_bWalkRun;
|
||||
public bool GetRushFlyFlag() => m_bRushFly;
|
||||
|
||||
CECCounter m_BindCmdCoolCnt = new CECCounter();
|
||||
|
||||
public CECCounter GetBindCmdCoolCnt() => m_BindCmdCoolCnt;
|
||||
|
||||
void InitBindCmdCoolCnt()
|
||||
{
|
||||
m_BindCmdCoolCnt.SetPeriod(35000);
|
||||
m_BindCmdCoolCnt.Reset(true);
|
||||
}
|
||||
|
||||
// Sit down / Stand up
|
||||
// 坐下 / 站起
|
||||
public bool CmdSitDown(bool bSitDown)
|
||||
{
|
||||
if (!CanDo(ActionCanDo.CANDO_SITDOWN))
|
||||
return false;
|
||||
|
||||
if (bSitDown)
|
||||
UnityGameSession.c2s_CmdSitDown();
|
||||
else
|
||||
UnityGameSession.c2s_CmdStandUp();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Switch walk and run state
|
||||
// 切换走/跑状态
|
||||
public bool CmdWalkRun(bool bRun)
|
||||
{
|
||||
m_bWalkRun = bRun;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Find a near target (stub)
|
||||
// 寻找附近目标(占位)
|
||||
public bool CmdFindTarget()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Select other player's attacked target
|
||||
// 选择队友正在攻击的目标
|
||||
public bool CmdAssistAttack()
|
||||
{
|
||||
if (m_pWorkMan.IsSitting())
|
||||
{
|
||||
UnityGameSession.c2s_CmdStandUp();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CanDo(ActionCanDo.CANDO_ASSISTSEL))
|
||||
UnityGameSession.c2s_CmdTeamAssistSel(m_idSelTarget);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invite selected player to join team
|
||||
// 邀请选中的玩家入队
|
||||
public bool CmdInviteToTeam()
|
||||
{
|
||||
if (IsDead() || !GPDataTypeHelper.ISPLAYERID(m_idSelTarget) || m_idSelTarget == GetCharacterID())
|
||||
return false;
|
||||
|
||||
UnityGameSession.c2s_CmdTeamInvite(m_idSelTarget);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Leave current team (confirmation dialog)
|
||||
// 离开当前队伍(确认框)
|
||||
public bool CmdLeaveTeam()
|
||||
{
|
||||
if (IsDead() || m_pTeam == null)
|
||||
return false;
|
||||
|
||||
string szMsg = CECUIManager.Instance?.GetInGameUIMan()?.GetStringFromTable(235)
|
||||
?? "Are you sure you want to leave the team?";
|
||||
CECUIManager.Instance?.ShowMessageBoxYesAndNo("", szMsg, null,
|
||||
() => UnityGameSession.c2s_CmdTeamLeaveParty(), null);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Kick one member of team (stub)
|
||||
// 踢出队员(占位)
|
||||
public bool CmdKickTeamMember()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Search for a team (stub)
|
||||
// 寻找队伍(占位)
|
||||
public bool CmdFindTeam()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Start trade with other selected player
|
||||
// 与选中玩家开始交易
|
||||
public bool CmdStartTrade()
|
||||
{
|
||||
if (m_pWorkMan.IsSitting())
|
||||
{
|
||||
UnityGameSession.c2s_CmdStandUp();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CanDo(ActionCanDo.CANDO_TRADE))
|
||||
return false;
|
||||
|
||||
if (!GPDataTypeHelper.ISPLAYERID(m_idSelTarget) || m_idSelTarget == m_PlayerInfo.cid)
|
||||
return false;
|
||||
|
||||
UnityGameSession.trade_Start(m_idSelTarget);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Open booth for selling items
|
||||
// 开摊出售
|
||||
public bool CmdSellBooth()
|
||||
{
|
||||
if (IsInvisible())
|
||||
{
|
||||
CECGameRun.Instance?.AddFixedMessage((int)FixedMsg.FIXMSG_CANNOT_USE_WHEN_INVISIBLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_pWorkMan.IsSitting())
|
||||
{
|
||||
UnityGameSession.c2s_CmdStandUp();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_pWorkMan.IsFollowing())
|
||||
m_pWorkMan.FinishAllWork(true);
|
||||
|
||||
if (!CanDo(ActionCanDo.CANDO_BOOTH))
|
||||
return false;
|
||||
|
||||
UnityGameSession.c2s_CmdOpenBoothTest();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Open booth for buying items (stub)
|
||||
// 开摊收购(占位)
|
||||
public bool CmdBuyBooth()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invite selected player to join faction (stub)
|
||||
// 邀请入帮(占位)
|
||||
public bool CmdInviteToFaction()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*public bool CmdPickup()
|
||||
{
|
||||
if (m_pWorkMan.IsSitting())
|
||||
{
|
||||
UnityGameSession.c2s_CmdStandUp();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CanDo(ActionCanDo.CANDO_PICKUP))
|
||||
return false;
|
||||
|
||||
CECHPWork pWork = m_pWorkMan.GetWork(Host_work_ID.WORK_TRACEOBJECT);
|
||||
if (pWork is CECHPWorkTrace pTrace &&
|
||||
pTrace.GetTraceReason() == Trace_reason.TRACE_PICKUP)
|
||||
return true;
|
||||
|
||||
EC_ManMatter matterMan = EC_ManMessageMono.Instance?.EC_ManMatter;
|
||||
CECMatter pMatter = matterMan?.FindMatterNearHost(10.0f, true);
|
||||
if (pMatter != null)
|
||||
PickupObject(pMatter.GetMatterID(), false);
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
public bool CmdGather()
|
||||
{
|
||||
if (m_pWorkMan.IsSitting())
|
||||
{
|
||||
UnityGameSession.c2s_CmdStandUp();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CanDo(ActionCanDo.CANDO_GATHER))
|
||||
return false;
|
||||
|
||||
CECHPWork pWork = m_pWorkMan.GetWork(Host_work_ID.WORK_TRACEOBJECT);
|
||||
if (pWork is CECHPWorkTrace pTrace &&
|
||||
pTrace.GetTraceReason() == Trace_reason.TRACE_GATHER)
|
||||
return true;
|
||||
|
||||
PickupObject(m_idSelTarget, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CmdRushFly()
|
||||
{
|
||||
if (m_bAboutToDie || IsDead() || !IsFlying())
|
||||
return false;
|
||||
|
||||
UnityGameSession.c2s_CmdActiveRushFly(!m_bRushFly);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CmdBindBuddy(int idTarget)
|
||||
{
|
||||
if (!m_BindCmdCoolCnt.IsFull())
|
||||
{
|
||||
CECGameRun.Instance?.AddFixedMessage((int)FixedMsg.FIXMSG_CMD_INCOOLTIME);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CanDo(ActionCanDo.CANDO_BINDBUDDY) || !GPDataTypeHelper.ISPLAYERID(idTarget) ||
|
||||
idTarget == GetCharacterID())
|
||||
return false;
|
||||
|
||||
EC_ElsePlayer pPlayer = m_pPlayerMan?.GetElsePlayer(idTarget);
|
||||
if (pPlayer == null || pPlayer.GetGender() == GetGender())
|
||||
return false;
|
||||
|
||||
A3DVECTOR3 vDist = pPlayer.GetServerPos() - GetPos();
|
||||
if (vDist.Magnitude() >= 2.8f)
|
||||
{
|
||||
CECGameRun.Instance?.AddFixedMessage((int)FixedMsg.FIXMSG_TARGETISFAR);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GetGender() == GENDER.GENDER_MALE)
|
||||
UnityGameSession.c2s_CmdBindPlayerInvite(idTarget);
|
||||
else
|
||||
UnityGameSession.c2s_CmdBindPlayerRequest(idTarget);
|
||||
|
||||
m_BindCmdCoolCnt.Reset();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61bcfdcbd8ffcd746b0e59990cc6970b
|
||||
@@ -8,7 +8,7 @@ using CSNetwork.GPDataType;
|
||||
using CSNetwork.S2CCommand;
|
||||
using System;
|
||||
using BrewMonster.UI;
|
||||
using PerfectWorld.Scripts.Managers;
|
||||
using BrewMonster.Scripts.Managers;
|
||||
using UnityEngine;
|
||||
using static BrewMonster.Scripts.CECHPWork;
|
||||
using static BrewMonster.Scripts.EC_Inventory;
|
||||
@@ -88,9 +88,15 @@ namespace BrewMonster
|
||||
{
|
||||
UpdateEquipSkins();
|
||||
}
|
||||
else if (byPackage == InventoryConst.IVTRTYPE_TRASHBOX && m_bUsingTrashBox)
|
||||
{
|
||||
PopupStorageDialog();
|
||||
}
|
||||
|
||||
var ui = GameObject.FindFirstObjectByType<EC_InventoryUI>();
|
||||
ui?.RefreshAll();
|
||||
if (byPackage == InventoryConst.IVTRTYPE_TRASHBOX)
|
||||
EC_StorageUI.RefreshAllStatic();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -131,6 +137,15 @@ namespace BrewMonster
|
||||
{
|
||||
UpdateEquipSkins();
|
||||
}
|
||||
else if (byPackage == InventoryConst.IVTRTYPE_TRASHBOX && m_bUsingTrashBox)
|
||||
{
|
||||
PopupStorageDialog();
|
||||
}
|
||||
|
||||
var uiDetail = GameObject.FindFirstObjectByType<EC_InventoryUI>();
|
||||
uiDetail?.RefreshAll();
|
||||
if (byPackage == InventoryConst.IVTRTYPE_TRASHBOX)
|
||||
EC_StorageUI.RefreshAllStatic();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1598,9 +1613,9 @@ namespace BrewMonster
|
||||
case Inventory_type.IVTRTYPE_PACK: pInventory = m_pPack; break;
|
||||
case Inventory_type.IVTRTYPE_EQUIPPACK: pInventory = m_pEquipPack; break;
|
||||
case Inventory_type.IVTRTYPE_TASKPACK: pInventory = m_pTaskPack; break;
|
||||
//case Inventory_type.IVTRTYPE_TRASHBOX: pInventory = m_pTrashBoxPack; break;
|
||||
//case Inventory_type.IVTRTYPE_TRASHBOX2: pInventory = m_pTrashBoxPack2; break;
|
||||
//case Inventory_type.IVTRTYPE_TRASHBOX3: pInventory = m_pTrashBoxPack3; break;
|
||||
case Inventory_type.IVTRTYPE_TRASHBOX: pInventory = m_pTrashBoxPack; break;
|
||||
case Inventory_type.IVTRTYPE_TRASHBOX2: pInventory = m_pTrashBoxPack2; break;
|
||||
case Inventory_type.IVTRTYPE_TRASHBOX3: pInventory = m_pTrashBoxPack3; break;
|
||||
//case Inventory_type.IVTRTYPE_ACCOUNT_BOX: pInventory = m_pAccountBoxPack; break;
|
||||
//case Inventory_type.IVTRTYPE_GENERALCARD_BOX: pInventory = m_pGeneralCardPack; break;
|
||||
//case IVTRTYPE_PACK_CLIENT_GENERALCAR.IVTRTYPE_CLIENT_GENERALCARD_PACK: pInventory = m_pClientGenCardPack; break;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using BrewMonster.Network;
|
||||
using BrewMonster.Scripts;
|
||||
using BrewMonster.Scripts.Task;
|
||||
using CSNetwork;
|
||||
using CSNetwork.GPDataType;
|
||||
|
||||
namespace BrewMonster
|
||||
{
|
||||
public partial class CECHostPlayer
|
||||
{
|
||||
private void OnMsgPlayerSitDown(ECMSG Msg)
|
||||
{
|
||||
if (Convert.ToInt32(Msg.dwParam2) == CommandID.OBJECT_SIT_DOWN)
|
||||
{
|
||||
if (m_pWorkMan.IsMovingToPosition() ||
|
||||
m_pWorkMan.IsTracing() ||
|
||||
m_pWorkMan.IsFollowing())
|
||||
{
|
||||
m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(GetPos()), GetGroundSpeed(), (int)GPMoveMode.GP_MOVE_RUN);
|
||||
}
|
||||
|
||||
m_dwStates |= (uint)PlayerNPCState.GP_STATE_SITDOWN;
|
||||
CECHPWorkSit pWork = (CECHPWorkSit)m_pWorkMan.CreateWork(CECHPWork.Host_work_ID.WORK_SIT);
|
||||
pWork.SetBeSittingFlag(false);
|
||||
m_pWorkMan.StartWork_p1(pWork);
|
||||
|
||||
GetTaskInterface().SetEmotion((int)TaskInterface.CommandTaskAction.CMD_EMOTION_SITDOWN);
|
||||
}
|
||||
else if (Convert.ToInt32(Msg.dwParam2) == CommandID.OBJECT_STAND_UP)
|
||||
{
|
||||
m_dwStates &= ~(uint)PlayerNPCState.GP_STATE_SITDOWN;
|
||||
CECHPWorkStand pWork = (CECHPWorkStand)m_pWorkMan.CreateWork(CECHPWork.Host_work_ID.WORK_STAND);
|
||||
m_pWorkMan.StartWork_p1(pWork);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b8afadf7e5c78f409d4e8746ef6ea77
|
||||
@@ -603,7 +603,6 @@ namespace BrewMonster
|
||||
}*/
|
||||
else if (GetEquipSkillByID(idSkill) == null)
|
||||
{
|
||||
BMLogger.LogError("HoangDev: pSkill " + pSkill);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1534,8 +1533,8 @@ namespace BrewMonster
|
||||
Info.weapon = (iReason == 5) ? (int)pWeapon.GetDBMajorType().id : 0; }
|
||||
else
|
||||
{
|
||||
|
||||
Info.weapon = (int)pWeapon.GetDBMajorType().id; }
|
||||
Info.weapon = (int)pWeapon.GetDBMajorType().id;
|
||||
}
|
||||
|
||||
//BMLogger.LogError(GetName() + " CheckSkillCastCondition: Weapon major type ID = " + Info.weapon);
|
||||
// Get remaining arrow number
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
using BrewMonster.Managers;
|
||||
using BrewMonster.Network;
|
||||
using BrewMonster.Scripts;
|
||||
using BrewMonster.Scripts.Managers;
|
||||
using CSNetwork;
|
||||
using CSNetwork.GPDataType;
|
||||
using BrewMonster.Scripts.Managers;
|
||||
using BrewMonster.UI;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using static BrewMonster.Scripts.EC_Inventory;
|
||||
|
||||
namespace BrewMonster
|
||||
{
|
||||
/// <summary>
|
||||
/// Host player warehouse / trash box (C++ CECHostPlayer::OnMsgHstTrashBoxOperation, GetTrashBox*).
|
||||
/// </summary>
|
||||
public partial class CECHostPlayer
|
||||
{
|
||||
private readonly EC_Inventory m_pTrashBoxPack = new EC_Inventory();
|
||||
private readonly EC_Inventory m_pTrashBoxPack2 = new EC_Inventory();
|
||||
private readonly EC_Inventory m_pTrashBoxPack3 = new EC_Inventory();
|
||||
|
||||
private bool m_bTrashPsw;
|
||||
private bool m_bFirstTBOpen = true;
|
||||
private int m_iTrashBoxMoneyCnt;
|
||||
|
||||
public bool TrashBoxHasPsw() => m_bTrashPsw;
|
||||
public int GetTrashBoxMoneyCnt() => m_iTrashBoxMoneyCnt;
|
||||
public EC_Inventory GetTrashBox() => m_pTrashBoxPack;
|
||||
public EC_Inventory GetTrashBox2() => m_pTrashBoxPack2;
|
||||
public EC_Inventory GetTrashBox3() => m_pTrashBoxPack3;
|
||||
|
||||
void InitTrashBoxPacks()
|
||||
{
|
||||
if (m_pTrashBoxPack.GetSize() == 0)
|
||||
m_pTrashBoxPack.Init(InventoryConst.IVTRSIZE_TRASHBOX);
|
||||
if (m_pTrashBoxPack2.GetSize() == 0)
|
||||
m_pTrashBoxPack2.Init(0);
|
||||
if (m_pTrashBoxPack3.GetSize() == 0)
|
||||
m_pTrashBoxPack3.Init(0);
|
||||
}
|
||||
|
||||
public void OnMsgHstTrashBoxOperation(ECMSG Msg)
|
||||
{
|
||||
var data = Msg.dwParam1 as byte[];
|
||||
if (data == null || data.Length == 0)
|
||||
return;
|
||||
|
||||
int cmd = Convert.ToInt32(Msg.dwParam2);
|
||||
switch (cmd)
|
||||
{
|
||||
case CommandID.TRASHBOX_OPEN:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_trashbox_open>(data);
|
||||
if (pCmd.is_accountbox != 0)
|
||||
break; // PW_TODO: account box UI
|
||||
|
||||
m_bUsingTrashBox = true;
|
||||
InitTrashBoxPacks();
|
||||
|
||||
if (m_bFirstTBOpen)
|
||||
{
|
||||
m_bFirstTBOpen = false;
|
||||
UnityGameSession.c2s_CmdGetTrashBoxData(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_pTrashBoxPack.GetSize() < pCmd.slot_size)
|
||||
m_pTrashBoxPack.Resize(pCmd.slot_size);
|
||||
if (m_pTrashBoxPack2.GetSize() < pCmd.slot_size2)
|
||||
m_pTrashBoxPack2.Resize(pCmd.slot_size2);
|
||||
if (m_pTrashBoxPack3.GetSize() < pCmd.slot_size3)
|
||||
m_pTrashBoxPack3.Resize(pCmd.slot_size3);
|
||||
PopupStorageDialog();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CommandID.TRASHBOX_CLOSE:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_trashbox_close>(data);
|
||||
if (pCmd.is_accountbox != 0)
|
||||
break;
|
||||
m_bUsingTrashBox = false;
|
||||
PopupStorageDialog(true);
|
||||
break;
|
||||
}
|
||||
case CommandID.TRASHBOX_WEALTH:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_trashbox_wealth>(data);
|
||||
if (pCmd.is_accountbox == 0)
|
||||
m_iTrashBoxMoneyCnt = (int)pCmd.money;
|
||||
EC_StorageUI.RefreshMoneyStatic();
|
||||
break;
|
||||
}
|
||||
case CommandID.EXG_TRASH_MONEY:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_exg_trash_money>(data);
|
||||
if (pCmd.is_accountbox == 0)
|
||||
{
|
||||
AddMoneyAmount(pCmd.inv_delta);
|
||||
m_iTrashBoxMoneyCnt += pCmd.tra_delta;
|
||||
}
|
||||
EC_StorageUI.RefreshMoneyStatic();
|
||||
var invUi = UnityEngine.Object.FindFirstObjectByType<EC_InventoryUI>();
|
||||
invUi?.RefreshAll();
|
||||
break;
|
||||
}
|
||||
case CommandID.EXG_TRASHBOX_ITEM:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_exg_trashbox_item>(data);
|
||||
var pTrash = GetPack(pCmd.where);
|
||||
pTrash?.ExchangeItem(pCmd.idx1, pCmd.idx2);
|
||||
EC_StorageUI.RefreshAllStatic();
|
||||
break;
|
||||
}
|
||||
case CommandID.MOVE_TRASHBOX_ITEM:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_move_trashbox_item>(data);
|
||||
var pTrash = GetPack(pCmd.where);
|
||||
pTrash?.MoveItem(pCmd.src, pCmd.dest, (int)pCmd.amount);
|
||||
EC_StorageUI.RefreshAllStatic();
|
||||
break;
|
||||
}
|
||||
case CommandID.EXG_TRASHBOX_IVTR:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_exg_trashbox_ivtr>(data);
|
||||
var pTrash = GetPack(pCmd.where);
|
||||
if (pTrash == null || m_pPack == null)
|
||||
break;
|
||||
var pItem1 = m_pPack.GetItem(pCmd.idx_inv, true);
|
||||
var pItem2 = pTrash.GetItem(pCmd.idx_tra, true);
|
||||
m_pPack.SetItem(pCmd.idx_inv, pItem2);
|
||||
pTrash.SetItem(pCmd.idx_tra, pItem1);
|
||||
RefreshStorageAndInventoryUi();
|
||||
break;
|
||||
}
|
||||
case CommandID.IVTR_ITEM_TO_TRASH:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_ivty_item_to_trash>(data);
|
||||
var pTrash = GetPack(pCmd.where);
|
||||
if (pTrash == null || m_pPack == null)
|
||||
break;
|
||||
var pItem1 = m_pPack.GetItem(pCmd.src);
|
||||
var pItem2 = pTrash.GetItem(pCmd.dest);
|
||||
if (pItem1 == null)
|
||||
break;
|
||||
if (pItem2 != null)
|
||||
{
|
||||
pItem2.AddAmount((int)pCmd.amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem2 = EC_IvtrItem.CreateItem(pItem1.m_tid, pItem1.m_expire_date, (int)pCmd.amount);
|
||||
pTrash.SetItem(pCmd.dest, pItem2);
|
||||
}
|
||||
m_pPack.RemoveItem(pCmd.src, (int)pCmd.amount);
|
||||
RefreshStorageAndInventoryUi();
|
||||
break;
|
||||
}
|
||||
case CommandID.TRASH_ITEM_TO_IVTR:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_trash_item_to_ivtr>(data);
|
||||
var pTrash = GetPack(pCmd.where);
|
||||
if (pTrash == null || m_pPack == null)
|
||||
break;
|
||||
var pItem1 = pTrash.GetItem(pCmd.src);
|
||||
var pItem2 = m_pPack.GetItem(pCmd.dest);
|
||||
if (pItem1 == null)
|
||||
break;
|
||||
if (pItem2 != null)
|
||||
pItem2.AddAmount((int)pCmd.amount);
|
||||
else
|
||||
{
|
||||
pItem2 = EC_IvtrItem.CreateItem(pItem1.m_tid, pItem1.m_expire_date, (int)pCmd.amount);
|
||||
m_pPack.SetItem(pCmd.dest, pItem2);
|
||||
}
|
||||
pTrash.RemoveItem(pCmd.src, (int)pCmd.amount);
|
||||
RefreshStorageAndInventoryUi();
|
||||
break;
|
||||
}
|
||||
case CommandID.TRASHBOX_PWD_CHANGED:
|
||||
case CommandID.TRASHBOX_PWD_STATE:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_trashbox_pwd_state>(data);
|
||||
m_bTrashPsw = pCmd.has_passwd > 0;
|
||||
break;
|
||||
}
|
||||
case CommandID.TRASHBOX_SIZE:
|
||||
{
|
||||
var pCmd = GPDataTypeHelper.FromBytes<cmd_trashbox_size>(data);
|
||||
int msg = (int)FixedMsg.FIXMSG_TRASHBOX_EXPAND;
|
||||
int iSize = pCmd.iNewSize;
|
||||
if (pCmd.where == Inventory_type.IVTRTYPE_TRASHBOX2)
|
||||
msg = (int)FixedMsg.FIXMSG_TRASHBOX2_EXPAND;
|
||||
else if (pCmd.where == Inventory_type.IVTRTYPE_TRASHBOX3)
|
||||
{
|
||||
msg = (int)FixedMsg.FIXMSG_TRASHBOX3_EXPAND;
|
||||
m_pTrashBoxPack3?.Resize(pCmd.iNewSize);
|
||||
}
|
||||
else if (pCmd.where == Inventory_type.IVTRTYPE_TRASHBOX)
|
||||
m_pTrashBoxPack?.Resize(pCmd.iNewSize);
|
||||
EC_Game.GetGameRun()?.AddFixedMessage(msg, iSize);
|
||||
EC_StorageUI.RefreshAllStatic();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void RefreshStorageAndInventoryUi()
|
||||
{
|
||||
EC_StorageUI.RefreshAllStatic();
|
||||
UnityEngine.Object.FindFirstObjectByType<EC_InventoryUI>()?.RefreshAll();
|
||||
}
|
||||
|
||||
/// <summary>C++ CECGameUIMan::PopupStorageDialog — show warehouse + inventory.</summary>
|
||||
public static void PopupStorageDialog(bool close = false)
|
||||
{
|
||||
if (close)
|
||||
{
|
||||
var host = EC_Game.GetGameRun()?.GetHostPlayer();
|
||||
bool wasUsingTrash = host != null && host.IsUsingTrashBox();
|
||||
if (host != null)
|
||||
host.m_bUsingTrashBox = false;
|
||||
|
||||
EC_StorageUI.ClearSelectionStatic();
|
||||
var invUi = UnityEngine.Object.FindFirstObjectByType<EC_InventoryUI>(FindObjectsInactive.Include);
|
||||
invUi?.DismissItemDetail();
|
||||
|
||||
CECUIManager.Instance?.HideStorageDialogPair();
|
||||
|
||||
if (wasUsingTrash)
|
||||
UnityGameSession.c2s_CmdCancelAction();
|
||||
EC_Game.GetGameRun()?.GetUIManager()?.GetInGameUIMan()?.EndNPCService();
|
||||
return;
|
||||
}
|
||||
|
||||
CECUIManager.Instance?.ShowStorageDialogPair();
|
||||
var storageDlg = EC_Game.GetGameRun()?.GetUIManager()?.GetInGameUIMan()?.GetDialog("EC_StorageUI") as EC_StorageUI;
|
||||
storageDlg?.RefreshAll();
|
||||
|
||||
var invDlg = UnityEngine.Object.FindFirstObjectByType<EC_InventoryUI>(FindObjectsInactive.Include);
|
||||
invDlg?.RefreshAll();
|
||||
}
|
||||
|
||||
/// <summary>Transfer between main pack and trash box (C++ CDlgStorage::OnItemDragDrop).</summary>
|
||||
public bool TransferPackAndTrash(byte trashWhere, int trashSlot, int invSlot, int amount = -1)
|
||||
{
|
||||
if (trashWhere != InventoryConst.IVTRTYPE_TRASHBOX)
|
||||
return false;
|
||||
|
||||
var trash = GetPack(trashWhere);
|
||||
var pack = m_pPack;
|
||||
if (trash == null || pack == null)
|
||||
return false;
|
||||
if (trashSlot < 0 || invSlot < 0)
|
||||
return false;
|
||||
|
||||
var srcInv = pack.GetItem(invSlot);
|
||||
var dstTrash = trash.GetItem(trashSlot);
|
||||
if (srcInv != null && dstTrash == null)
|
||||
{
|
||||
UnityGameSession.c2s_CmdExgTrashBoxIvtrItem(trashWhere, (byte)trashSlot, (byte)invSlot);
|
||||
return true;
|
||||
}
|
||||
|
||||
var srcTrash = trash.GetItem(trashSlot);
|
||||
var dstInv = pack.GetItem(invSlot);
|
||||
if (srcTrash != null && dstInv == null)
|
||||
{
|
||||
UnityGameSession.c2s_CmdExgTrashBoxIvtrItem(trashWhere, (byte)trashSlot, (byte)invSlot);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (srcInv != null && dstTrash != null &&
|
||||
srcInv.m_tid == dstTrash.m_tid && srcInv.GetPileLimitInstance() > 1)
|
||||
{
|
||||
int moveAmt = amount > 0 ? amount : Math.Min(srcInv.m_iCount,
|
||||
dstTrash.GetPileLimitInstance() - dstTrash.m_iCount);
|
||||
if (moveAmt > 0)
|
||||
{
|
||||
UnityGameSession.c2s_CmdMoveIvtrToTrashBox(trashWhere, (byte)invSlot, (byte)trashSlot, (uint)moveAmt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (srcTrash != null && dstInv != null &&
|
||||
srcTrash.m_tid == dstInv.m_tid && srcTrash.GetPileLimitInstance() > 1)
|
||||
{
|
||||
int moveAmt = amount > 0 ? amount : Math.Min(srcTrash.m_iCount,
|
||||
dstInv.GetPileLimitInstance() - dstInv.m_iCount);
|
||||
if (moveAmt > 0)
|
||||
{
|
||||
UnityGameSession.c2s_CmdMoveTrashBoxToIvtr(trashWhere, (byte)trashSlot, (byte)invSlot, (uint)moveAmt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (srcInv != null || srcTrash != null)
|
||||
{
|
||||
UnityGameSession.c2s_CmdExgTrashBoxIvtrItem(trashWhere, (byte)trashSlot, (byte)invSlot);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TransferWithinTrash(byte where, int slotA, int slotB)
|
||||
{
|
||||
var trash = GetPack(where);
|
||||
if (trash == null || slotA < 0 || slotB < 0 || slotA == slotB)
|
||||
return false;
|
||||
var a = trash.GetItem(slotA);
|
||||
var b = trash.GetItem(slotB);
|
||||
if (a != null && b != null && a.m_tid == b.m_tid && a.GetPileLimitInstance() > 1)
|
||||
{
|
||||
int moveAmt = Math.Min(a.m_iCount, b.GetPileLimitInstance() - b.m_iCount);
|
||||
if (moveAmt > 0)
|
||||
{
|
||||
UnityGameSession.c2s_CmdMoveTrashBoxItem(where, (byte)slotA, (byte)slotB, (uint)moveAmt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
UnityGameSession.c2s_CmdExgTrashBoxItem(where, (byte)slotA, (byte)slotB);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f43b17fb174c9ce4bbcdf1eb7637aa91
|
||||
@@ -15,14 +15,12 @@ namespace BrewMonster
|
||||
{
|
||||
public void OnMsgHstCorrectPos(in ECMSG Msg)
|
||||
{
|
||||
//Debug.LogError("HoangDev : OnMsgHstCorrectPos");
|
||||
byte[] buf = (byte[])Msg.dwParam1; // chỗ bạn lưu pDataBuf
|
||||
GCHandle handle = GCHandle.Alloc(buf, GCHandleType.Pinned);
|
||||
cmd_host_correct_pos pCmd = (cmd_host_correct_pos)Marshal.PtrToStructure(
|
||||
handle.AddrOfPinnedObject(), typeof(cmd_host_correct_pos));
|
||||
handle.Free();
|
||||
//cmd_host_correct_pos pCmd = GPDataTypeHelper.FromBytes<cmd_host_correct_pos>((byte[])Msg.dwParam1);
|
||||
// Debug.LogError("HoangDev :pCmd.pos " + pCmd.pos);
|
||||
SetPos(pCmd.pos);
|
||||
m_vVelocity.Clear();
|
||||
m_CDRInfo.vAbsVelocity.Clear();
|
||||
@@ -141,7 +139,13 @@ namespace BrewMonster
|
||||
// }
|
||||
// }
|
||||
|
||||
if (m_bUsingTrashBox || DoingSessionPose())
|
||||
if (m_bUsingTrashBox)
|
||||
{
|
||||
CECHostPlayer.PopupStorageDialog(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DoingSessionPose())
|
||||
{
|
||||
UnityGameSession.c2s_CmdCancelAction();
|
||||
return;
|
||||
|
||||
@@ -321,6 +321,12 @@ namespace BrewMonster
|
||||
return m_pEquipPack;
|
||||
case InventoryConst.IVTRTYPE_TASKPACK:
|
||||
return m_pTaskPack;
|
||||
case InventoryConst.IVTRTYPE_TRASHBOX:
|
||||
return m_pTrashBoxPack;
|
||||
case InventoryConst.IVTRTYPE_TRASHBOX2:
|
||||
return m_pTrashBoxPack2;
|
||||
case InventoryConst.IVTRTYPE_TRASHBOX3:
|
||||
return m_pTrashBoxPack3;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -329,6 +335,7 @@ namespace BrewMonster
|
||||
private void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
InitTrashBoxPacks();
|
||||
m_MoveCtrl = new CECHostMove(this);
|
||||
|
||||
// Cache: không bắt buộc, nhưng gọn tay và ít gọi property lặp.
|
||||
@@ -359,7 +366,6 @@ namespace BrewMonster
|
||||
|
||||
public async Task<bool> LoadResources()
|
||||
{
|
||||
//BMLogger.LogError("HoangDev: CECHostPlayer::LoadResources");
|
||||
RoleInfo RoleInfo = UnityGameSession.Instance.GetRoleInfo();
|
||||
m_iProfession = RoleInfo.occupation;
|
||||
m_iGender = RoleInfo.gender;
|
||||
@@ -489,7 +495,6 @@ namespace BrewMonster
|
||||
public void ProcessMessage(in ECMSG Msg)
|
||||
{
|
||||
var msg = (int)Msg.dwMsg;
|
||||
//Debug.LogError("HoangDev : ProcessMessageProcessMessageProcessMessage " + msg);
|
||||
switch (msg)
|
||||
{
|
||||
case EC_MsgDef.MSG_HST_CORRECTPOS: OnMsgHstCorrectPos(Msg); break;
|
||||
@@ -513,6 +518,9 @@ namespace BrewMonster
|
||||
case EC_MsgDef.MSG_HST_ITEMOPERATION:
|
||||
OnMsgHstItemOperation(Msg);
|
||||
break;
|
||||
case EC_MsgDef.MSG_HST_TRASHBOXOP:
|
||||
OnMsgHstTrashBoxOperation(Msg);
|
||||
break;
|
||||
case EC_MsgDef.MSG_HST_PICKUPITEM:
|
||||
OnMsgHstPickupItem(Msg);
|
||||
break;
|
||||
@@ -565,6 +573,7 @@ namespace BrewMonster
|
||||
case EC_MsgDef.MSG_HST_COOLTIMEDATA: OnMsgHstCoolTimeData(Msg); break;
|
||||
case EC_MsgDef.MSG_HST_PRESSCANCEL: OnMsgHstPressCancel(Msg); break;
|
||||
case EC_MsgDef.MSG_PM_PLAYERFLY: OnMsgPlayerFly(Msg); break;
|
||||
case EC_MsgDef.MSG_PM_PLAYERSITDOWN: OnMsgPlayerSitDown(Msg); break;
|
||||
case EC_MsgDef.MSG_HST_PETOPT: OnMsgHstPetOpt(Msg); break;
|
||||
case EC_MsgDef.MSG_HST_SETPLAYERLIMIT: OnMsgHstSetPlayerLimit(Msg); break;
|
||||
case EC_MsgDef.MSG_PM_PLAYERMOUNT: OnMsgPlayerMount(Msg); break;
|
||||
@@ -1302,7 +1311,6 @@ namespace BrewMonster
|
||||
// Message MSG_HST_SELTARGET handler
|
||||
void OnMsgHstSelTarget(ECMSG Msg)
|
||||
{
|
||||
//BMLogger.LogError("HoangDev: OnMsgHstSelTarget");
|
||||
if (Convert.ToInt32(Msg.dwParam2) == CommandID.SELECT_TARGET)
|
||||
{
|
||||
var data = (byte[])Msg.dwParam1;
|
||||
@@ -1327,6 +1335,7 @@ namespace BrewMonster
|
||||
m_IncantCnt = new CECCounter();
|
||||
m_IncantCnt.SetPeriod(1000);
|
||||
m_IncantCnt.Reset(true);
|
||||
InitBindCmdCoolCnt();
|
||||
m_bEnterGame = false;
|
||||
}
|
||||
|
||||
@@ -2096,14 +2105,12 @@ namespace BrewMonster
|
||||
bRet = true;
|
||||
if (idTarget == 0)
|
||||
{
|
||||
//BMLogger.LogError("HoangDev: HostPlayer Unsetlect npc");
|
||||
UnityGameSession.c2s_CmdUnselect();
|
||||
m_idSelTarget = 0;
|
||||
m_idUCSelTarget = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//BMLogger.LogError("HoangDev: HostPlayer setlect npc");
|
||||
UnityGameSession.c2s_CmdSelectTarget(idTarget);
|
||||
m_idSelTarget = idTarget;
|
||||
m_idUCSelTarget = idTarget;
|
||||
@@ -3091,7 +3098,7 @@ namespace BrewMonster
|
||||
}
|
||||
|
||||
// Is host player open trash box ?
|
||||
bool IsUsingTrashBox()
|
||||
public bool IsUsingTrashBox()
|
||||
{
|
||||
return m_bUsingTrashBox;
|
||||
}
|
||||
@@ -3374,7 +3381,7 @@ namespace BrewMonster
|
||||
|
||||
if (iPose == (int)RoleExpression.ROLEEXP_SITDOWN)
|
||||
{
|
||||
// UnityGameSession.c2s_CmdSessionEmote(iPose);
|
||||
UnityGameSession.c2s_CmdSessionEmote(iPose);
|
||||
}
|
||||
else if (iPose == (int)RoleExpression.ROLEEXP_KISS)
|
||||
{
|
||||
@@ -3655,9 +3662,10 @@ namespace BrewMonster
|
||||
|
||||
m_PetOptCnt.IncCounter(iRealTime);
|
||||
// Bind command cool counter
|
||||
/* if (m_BindCmdCoolCnt.IncCounter(dwDeltaTime))
|
||||
m_BindCmdCoolCnt.Reset(true);
|
||||
if (m_BindCmdCoolCnt.IncCounter(iRealTime))
|
||||
m_BindCmdCoolCnt.Reset(true);
|
||||
|
||||
/*
|
||||
// Auto fashion time counter
|
||||
if (m_bAutoFashion && GetBoothState() != 2 && !IsShapeChanged())
|
||||
{
|
||||
|
||||
@@ -38,6 +38,8 @@ public class CECUIManager : MonoSingleton<CECUIManager>
|
||||
[SerializeField] private DialogScriptTableObject dialogResouce;
|
||||
[SerializeField] private Canvas canvasDlg;
|
||||
|
||||
public Transform DialogCanvasTransform => canvasDlg != null ? canvasDlg.transform : null;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Chat TMP: EmotionLibrarySpriteMap (SO). CECGameUIMan is not a MonoBehaviour — assign here on CECUIManager.")]
|
||||
private EmotionLibrarySpriteMap _emotionLibrarySpriteMap;
|
||||
@@ -248,6 +250,34 @@ public class CECUIManager : MonoSingleton<CECUIManager>
|
||||
return Push(componentName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a modal on top without hiding stack dialogs (e.g. DlgQuantity over storage + inventory).
|
||||
/// </summary>
|
||||
public AUIDialog ShowDialogOverlay(string componentName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(componentName) || canvasDlg == null)
|
||||
return null;
|
||||
|
||||
var dlg = GetInGameUIMan()?.GetDialog(componentName);
|
||||
if (dlg == null)
|
||||
return null;
|
||||
|
||||
dlg.Show(true);
|
||||
dlg.transform.SetAsLastSibling();
|
||||
EC_UIUtility.BringPanelToFront(dlg.gameObject);
|
||||
return dlg;
|
||||
}
|
||||
|
||||
public void HideDialogOverlay(string componentName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(componentName))
|
||||
return;
|
||||
|
||||
var dlg = GetInGameUIMan()?.GetDialog(componentName);
|
||||
if (dlg != null)
|
||||
dlg.Show(false);
|
||||
}
|
||||
|
||||
public void HideCurrentUIInStack()
|
||||
{
|
||||
Pop();
|
||||
@@ -280,6 +310,57 @@ public class CECUIManager : MonoSingleton<CECUIManager>
|
||||
return dlg;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show warehouse + inventory together without hiding the first dialog (C++ PopupStorageDialog).
|
||||
/// </summary>
|
||||
public void ShowStorageDialogPair()
|
||||
{
|
||||
if (canvasDlg == null)
|
||||
return;
|
||||
|
||||
var gui = GetInGameUIMan();
|
||||
if (gui == null)
|
||||
return;
|
||||
|
||||
var storageDlg = gui.GetDialog("EC_StorageUI");
|
||||
var invDlg = gui.GetDialog("Win_Inventory");
|
||||
if (storageDlg == null || invDlg == null)
|
||||
return;
|
||||
_uiStack.Remove("Win_Inventory");
|
||||
_uiStack.Remove("EC_StorageUI");
|
||||
|
||||
invDlg.Show(true);
|
||||
storageDlg.Show(true);
|
||||
|
||||
_uiStack.Insert(0, "Win_Inventory");
|
||||
_uiStack.Insert(0, "EC_StorageUI");
|
||||
|
||||
// Inventory below, storage on top (detail panel uses EC_UIUtility overlay sort).
|
||||
invDlg.transform.SetAsLastSibling();
|
||||
storageDlg.transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
/// <summary>Hide warehouse pair and restore previous stack top if any.</summary>
|
||||
public void HideStorageDialogPair()
|
||||
{
|
||||
_uiStack.Remove("EC_StorageUI");
|
||||
_uiStack.Remove("Win_Inventory");
|
||||
|
||||
var gui = GetInGameUIMan();
|
||||
gui?.GetDialog("Win_Inventory")?.Show(false);
|
||||
gui?.GetDialog("EC_StorageUI")?.Show(false);
|
||||
|
||||
if (_uiStack.Count > 0)
|
||||
{
|
||||
var newTop = gui?.GetDialog(_uiStack[0]);
|
||||
if (newTop != null)
|
||||
{
|
||||
newTop.Show(true);
|
||||
newTop.transform.SetAsLastSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pop the top dialog off the stack: hide it and bring the new top (if any) to front. Returns true if something was popped.
|
||||
/// </summary>
|
||||
@@ -795,7 +876,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
|
||||
}
|
||||
public void GetIconStateMgr()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>Shows the player options menu for the given character. Requires a prefab with id "DlgPlayerOptions" in DialogScriptTableObject.</summary>
|
||||
|
||||
@@ -19,7 +19,8 @@ public class CharacterItemUI : MonoBehaviour
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_goFocusImage.SetActive(false);
|
||||
if(_goFocusImage!=null)
|
||||
_goFocusImage.SetActive(false);
|
||||
}
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
@@ -53,7 +54,11 @@ public class CharacterItemUI : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClickBtn()
|
||||
private void OnClickBtn()
|
||||
{
|
||||
onClick?.Invoke(this);
|
||||
}
|
||||
public void ForceClickBtn()
|
||||
{
|
||||
onClick?.Invoke(this);
|
||||
}
|
||||
|
||||
@@ -33,11 +33,13 @@ namespace BrewMonster
|
||||
private const float FadeTime = 100;
|
||||
private const FadeMode FadeMode = Animancer.FadeMode.FixedDuration;
|
||||
private string previousAnimationName;
|
||||
private string lastQueueAnimationName;
|
||||
private void PlayActionEventHandler(PlayActionEvent @event)
|
||||
{
|
||||
//prevent enqueue the same loop animation
|
||||
bool loopcheck = @event.IsLoop == true && previousAnimationName == @event.AnimationName;
|
||||
if(loopcheck)
|
||||
bool queuecheck = lastQueueAnimationName == @event.AnimationName;
|
||||
if(loopcheck || queuecheck)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -162,7 +164,6 @@ namespace BrewMonster
|
||||
}
|
||||
private void PlayNext()
|
||||
{
|
||||
|
||||
if (_animationQueue.Count == 0)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -6,6 +6,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using BrewMonster;
|
||||
using System.Collections;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BrewMonster.UI
|
||||
{
|
||||
@@ -26,9 +27,11 @@ namespace BrewMonster.UI
|
||||
private Action<RoleInfo> _onCreateCharacterComplete;
|
||||
private Action _onExit;
|
||||
private List<RoleInfo> _roleInfos;
|
||||
private List<CharacterItemUI> _characterItems = new List<CharacterItemUI>();
|
||||
|
||||
private Coroutine _showModelReadyCoroutine;
|
||||
private int _pendingShowModelRoleId = -1;
|
||||
private bool _needFocusLastCharacter;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -42,12 +45,14 @@ namespace BrewMonster.UI
|
||||
|
||||
if (_roleInfos != null && _roleInfos.Count > 0)
|
||||
{
|
||||
PlayerModelPreview.Instance?.ShowAllPlayerModels(_roleInfos);
|
||||
PlayerModelPreview.Instance?.ShowAllPlayerModels(_roleInfos).Forget();
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerModelPreview.Instance?.ClearModels();
|
||||
}
|
||||
|
||||
_needFocusLastCharacter = true;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -71,11 +76,12 @@ namespace BrewMonster.UI
|
||||
}
|
||||
}
|
||||
|
||||
public void InitScreen(List<RoleInfo> roleInfos, Action<RoleInfo> OnClickItemChar, Action<RoleInfo> onCreateCharacterComplete = null, Action onExit = null)
|
||||
public async UniTask<bool> InitScreen(List<RoleInfo> roleInfos, Action<RoleInfo> OnClickItemChar, Action<RoleInfo> onCreateCharacterComplete = null, Action onExit = null)
|
||||
{
|
||||
_onClickItemChar = OnClickItemChar;
|
||||
_onCreateCharacterComplete = onCreateCharacterComplete;
|
||||
_onExit = onExit;
|
||||
_characterItems.Clear();
|
||||
|
||||
// Clear existing items
|
||||
if (parentItems != null)
|
||||
@@ -91,14 +97,24 @@ namespace BrewMonster.UI
|
||||
// Create character items
|
||||
if (roleInfos != null)
|
||||
{
|
||||
RoleInfo lastRoleInfo = null;
|
||||
int lastTimeLogin = int.MinValue;
|
||||
foreach (RoleInfo info in roleInfos)
|
||||
{
|
||||
if (characterItemPrefab != null && parentItems != null)
|
||||
{
|
||||
CharacterItemUI item = Instantiate(characterItemPrefab, parentItems).GetComponent<CharacterItemUI>();
|
||||
item.InitItem(info, OnSelectCharacter);
|
||||
_characterItems.Add(item);
|
||||
if (info.lastlogin_time > lastTimeLogin)
|
||||
{
|
||||
lastTimeLogin = info.lastlogin_time;
|
||||
_selectingCharacterItemUI = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
_selectingCharacterItemUI.ForceClickBtn();
|
||||
_selectingCharacterItemUI.SetFocus(true);
|
||||
|
||||
// If number of roles < 8, spawn addCharacterItemPrefab and hide createCharacterButton
|
||||
if (roleInfos.Count < 8)
|
||||
@@ -137,28 +153,37 @@ namespace BrewMonster.UI
|
||||
}
|
||||
|
||||
// Load player preview 3D models
|
||||
PlayerModelPreview.Instance?.ShowAllPlayerModels(roleInfos);
|
||||
if (PlayerModelPreview.Instance != null)
|
||||
{
|
||||
var success = await PlayerModelPreview.Instance.ShowAllPlayerModels(roleInfos);
|
||||
if (success)
|
||||
{
|
||||
_selectingCharacterItemUI.ForceClickBtn();
|
||||
_selectingCharacterItemUI.SetFocus(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlayerModelPreview.Instance != null)
|
||||
PlayerModelPreview.Instance.ShowAllPlayerModels(null);
|
||||
_ = await PlayerModelPreview.Instance.ShowAllPlayerModels(null);
|
||||
// If roleInfos is null, show createCharacterButton
|
||||
if (createCharacterButton != null)
|
||||
{
|
||||
createCharacterButton.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnSelectCharacter(CharacterItemUI characterItemUI)
|
||||
{
|
||||
if (_selectingCharacterItemUI == characterItemUI)
|
||||
if (_selectingCharacterItemUI == characterItemUI && !_needFocusLastCharacter)
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
if (_selectingCharacterItemUI != null)
|
||||
_needFocusLastCharacter = false;
|
||||
if (_selectingCharacterItemUI != characterItemUI)
|
||||
{
|
||||
_selectingCharacterItemUI.SetFocus(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user