176 lines
5.8 KiB
C#
176 lines
5.8 KiB
C#
///////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Define and Macro
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Reference to External variables and functions
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Local Types and Variables and Global variables
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Local functions
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Implement CECIvtrDecoration
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////
|
|
using BrewMonster;
|
|
using ModelRenderer.Scripts.GameData;
|
|
using System.Collections.Generic;
|
|
using BrewMonster.Network;
|
|
using BrewMonster.Scripts.Managers;
|
|
using BrewMonster.Scripts;
|
|
using System.Runtime.InteropServices;
|
|
using System;
|
|
using CSNetwork.GPDataType;
|
|
namespace PerfectWorld.Scripts.Managers
|
|
{
|
|
/// <summary>
|
|
/// Auto HP item class (tu dong hoi mau). This is a part of CEC_IvtrEquipMatter(C++)
|
|
/// </summary>
|
|
public class EC_IvtrAutoHp : EC_IvtrEquip
|
|
{
|
|
public IVTR_ESSENCE_AUTOHP m_Essence;
|
|
|
|
// Data in database
|
|
public AUTOHP_ESSENCE m_pDBEssence;
|
|
/// <summary>
|
|
/// Constructor for auto HP item (tu dong hoi mau) / Constructor for auto HP item (automatic HP recovery)
|
|
/// </summary>
|
|
/// <param name="tid">Template id</param>
|
|
/// <param name="expire_date">Expire date</param>
|
|
public EC_IvtrAutoHp(int tid, int expire_date) : base(tid, expire_date)
|
|
{
|
|
m_iCID = (int)InventoryClassId.ICID_AUTOHP;
|
|
|
|
// Get database data
|
|
elementdataman pDB = ElementDataManProvider.GetElementDataMan();
|
|
DATA_TYPE DataType = DATA_TYPE.DT_INVALID;
|
|
m_pDBEssence = (AUTOHP_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
|
|
m_iPileLimit = m_pDBEssence.pile_num_max;
|
|
m_iPrice = m_pDBEssence.price;
|
|
m_iShopPrice = m_pDBEssence.shop_price;
|
|
m_iProcType = (int)m_pDBEssence.proc_type;
|
|
m_i64EquipMask = (long)EC_IvtrType.EQUIP_MASK64_AUTOHP;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copy constructor for auto HP item (tu dong hoi mau) / Copy constructor for auto HP item (automatic HP recovery)
|
|
/// </summary>
|
|
/// <param name="other">Other auto HP item to copy from</param>
|
|
public EC_IvtrAutoHp(EC_IvtrAutoHp other) : base(other)
|
|
{
|
|
m_pDBEssence = other.m_pDBEssence;
|
|
m_Essence = other.m_Essence;
|
|
}
|
|
|
|
public override bool SetItemInfo(byte[] pInfoData, int iDataLen)
|
|
{
|
|
base.SetItemInfo(pInfoData, iDataLen);
|
|
|
|
if (pInfoData == null || iDataLen == 0)
|
|
return true;
|
|
|
|
try
|
|
{
|
|
CECDataReader dr = new CECDataReader(pInfoData, iDataLen);
|
|
|
|
m_Essence = new IVTR_ESSENCE_AUTOHP(dr.ReadData(Marshal.SizeOf<IVTR_ESSENCE_AUTOHP>()));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
BMLogger.LogError("CECIvtrAutoHP::SetItemInfo, data read error (" + e.GetType() + ")");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// Get item icon file name
|
|
public override string GetIconFile()
|
|
{
|
|
return m_pDBEssence.FileIcon;
|
|
}
|
|
|
|
// Get item name
|
|
public override string GetName()
|
|
{
|
|
return m_pDBEssence.Name;
|
|
}
|
|
|
|
|
|
// Get item description text
|
|
protected override string GetNormalDesc(bool bRepair)
|
|
{
|
|
if (m_bNeedUpdate)
|
|
return null;
|
|
|
|
m_strDesc = string.Empty;
|
|
|
|
// Try to build item description
|
|
CECStringTab pDescTab = EC_Game.GetItemDesc();
|
|
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
|
|
|
|
int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE;
|
|
int red = (int)DescriptipionMsg.ITEMDESC_COL_RED;
|
|
|
|
if (m_iCount > 1)
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMENUMBER), GetName(), m_iCount);
|
|
else
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName());
|
|
|
|
AddIDDescText();
|
|
|
|
AddBindDescText();
|
|
|
|
AddExpireTimeDesc();
|
|
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_AUTOHP1), m_Essence.hp_left, m_pDBEssence.total_hp);
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_AUTOHP2), (int)(m_pDBEssence.trigger_amount * 100.0f + 0.5f));
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_COOLTIME), m_pDBEssence.cool_time / 1000);
|
|
|
|
// Price
|
|
AddPriceDesc(white, bRepair);
|
|
|
|
// Suite description
|
|
AddSuiteDesc();
|
|
|
|
// Extend description
|
|
AddExtDescText();
|
|
|
|
return m_strDesc;
|
|
}
|
|
|
|
// Get drop model for shown
|
|
public override string GetDropModel()
|
|
{
|
|
return m_pDBEssence.FileMatter;
|
|
}
|
|
|
|
// Get item cool time
|
|
public override int GetCoolTime(out int piMax)
|
|
{
|
|
piMax = 0;
|
|
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
|
|
return pHost != null ? pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_AUTOHP, out piMax) : 0;
|
|
}
|
|
}
|
|
}
|