Files
test/Assets/Scripts/CECHostPlayer.Pet.cs
T
Tungdv 708f33bfe4 Merge branch 'develop' into feature/hp_pet
# Conflicts:
#	Assets/PerfectWorld/Prefab/UIManager.prefab
#	Assets/PerfectWorld/Resources/UI/DialogScriptTableObject.asset
#	Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs
#	Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs
#	Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs
#	Assets/Scripts/CECHostPlayer.cs
2026-02-26 16:39:23 +07:00

170 lines
5.9 KiB
C#

using BrewMonster.Network;
using BrewMonster.Scripts;
using BrewMonster.Scripts.Pet;
using BrewMonster.UI;
using CSNetwork;
using CSNetwork.GPDataType;
using System;
using System.Runtime.InteropServices;
using BrewMonster.Assets.PerfectWorld.Scripts.Players;
using UnityEngine;
using static BrewMonster.Scripts.Pet.CECPetData;
namespace BrewMonster
{
public partial class CECHostPlayer
{
private void OnMsgPlayerFly(ECMSG Msg)
{
if (Convert.ToInt32(Msg.dwParam2) == CommandID.OBJECT_TAKEOFF)
{
if ((m_dwStates & PlayerNPCState.GP_STATE_FLY) == 0)
{
m_dwStates |= PlayerNPCState.GP_STATE_FLY;
m_bRushFly = false;
CECHPWorkFly pWork = (CECHPWorkFly)m_pWorkMan.CreateWork(CECHPWork.Host_work_ID.WORK_FLYOFF);
if (m_pWorkMan.IsFreeFalling())
{
pWork.m_bContinueFly = true;
m_pWorkMan.StartWork_p1(pWork);
}
else
{
pWork.m_bContinueFly = false;
m_pWorkMan.StartWork_p2(pWork);
}
}
}
else if (Convert.ToInt32(Msg.dwParam2) == CommandID.OBJECT_LANDING)
{
if ((m_dwStates & PlayerNPCState.GP_STATE_FLY) != 0)
{
m_dwStates &= ~(uint)PlayerNPCState.GP_STATE_FLY;
if (IsDead() || m_bCandHangerOn || IsHangerOn())
ShowWing(false);
else
{
CECHPWorkFall pWork =
(CECHPWorkFall)m_pWorkMan.CreateWork(CECHPWork.Host_work_ID.WORK_FREEFALL);
pWork.SetFallType(CECHPWorkFall.Fall_type.TYPE_FLYFALL);
m_pWorkMan.StartWork_p1(pWork);
}
// Below two lines will fix the "host stand in air" bug.
m_iMoveEnv = Move_environment.MOVEENV_GROUND;
m_CDRInfo.vTPNormal.Clear();
}
}
else // HOST_RUSH_FLY
{
cmd_host_rush_fly pCmd = GPDataTypeHelper.FromBytes<cmd_host_rush_fly>((byte[])Msg.dwParam1);
m_bRushFly = pCmd.is_active != 0 ? true : false;
}
}
/* Is host operating pet ?
return value:
0: host doesn't operating pet.
1: host is summoning pet.
2: host is recalling pet.
3: host is banishing pet.
*/
public int IsOperatingPet()
{
if (m_pWorkMan == null)
{
return 0;
}
CECHPWorkConcentrate pWork = (m_pWorkMan.GetRunningWork(CECHPWork.Host_work_ID.WORK_CONCENTRATE)) as CECHPWorkConcentrate;
if (pWork != null)
{
if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_SUMMONPET)
return 1;
else if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_RECALLPET)
return 2;
else if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_BANISHPET)
return 3;
else if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_RESTOREPET)
return 4;
}
return 0;
}
// Summon pet
public bool SummonPet(int iPetIdx)
{
if (m_pActionSwitcher != null)
m_pActionSwitcher.PostMessge((int)EMsgActionSwitcher.MSG_MOUNTPET);
CECGameRun pGameRun = EC_Game.GetGameRun();
CECUIManager pGameUI = pGameRun.GetUIManager();
CECPetData pPet = m_pPetCorral.GetPetData(iPetIdx);
if (pPet == null)
return false;
if (!CanDo(ActionCanDo.CANDO_SUMMONPET))
return false;
// Couldn't summon daed pet
if (pPet.IsDead())
{
//pGameRun.AddFixedMessage(FIXMSG_PET_DEAD);
//Debug.LogError("FIXMSG_PET_DEAD");
pGameUI.ShowMessageBox("MessageBox", "PET_DEAD", MessageBoxType.YesButton);
return false;
}
// If host could't stop naturally, cancel summoning
if (!NaturallyStopMoving())
return false;
// ¼ì²éµ±Ç°ÊÇ·ñ½ûÖ¹ÕÙ»½Æï³è
if (pPet.IsMountPet() && m_playerLimits[(int)PLAYER_LIMIT.PLAYER_LIMIT_NOMOUNT])
return false;
if (m_ReincarnationCount != 0)
{
int iLevelRequired = pPet.GetLevel() - 35 - m_ReincarnationCount * 5;
if (m_BasicProps.iLevel < iLevelRequired)
{
if (pGameUI != null)
{
string strText = "";
strText = string.Format(pGameUI.GetInGameUIMan().GetStringFromTable(10787), iLevelRequired);
pGameUI.ShowMessageBox("MessageBox", strText, MessageBoxType.YesButton);
}
return false;
}
}
UnityGameSession.c2s_CmdPetSummon(iPetIdx);
return true;
}
// Recall pet
public bool RecallPet()
{
if (m_pActionSwitcher != null)
m_pActionSwitcher.PostMessge((int)EMsgActionSwitcher.MSG_MOUNTPET);
// If host could't stop naturally, cancel recalling
if (!NaturallyStopMoving())
return false;
UnityGameSession.c2s_CmdPetRecall();
return true;
}
// Get pet operation time counter
public CECCounter GetPetOptTime() { return m_PetOptCnt; }
public CECPetCorral GetPetCorral()
{
return m_pPetCorral;
}
}
}