116 lines
4.0 KiB
C#
116 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.IO;
|
|
using BrewMonster;
|
|
using ModelRenderer.Scripts.Common;
|
|
using ModelRenderer.Scripts.GameData;
|
|
using UnityEngine;
|
|
using PerfectWorld.Scripts.Managers;
|
|
using BrewMonster.Network;
|
|
using BrewMonster.Scripts.Managers;
|
|
using BrewMonster.Scripts;
|
|
namespace BrewMonster.Scripts
|
|
{
|
|
/// <summary>
|
|
/// Skill tome item class(sach ky nang). This is a part of CEC_IvtrScroll(C++)
|
|
/// </summary>
|
|
public class EC_IvtrSkilltome : EC_IvtrItem
|
|
{
|
|
|
|
protected SKILLTOME_ESSENCE m_pDBEssence;
|
|
protected SKILLTOME_SUB_TYPE m_pDBSubType;
|
|
/// <summary>
|
|
/// Create skill tome item(sach ky nang)
|
|
/// </summary>
|
|
/// <param name="tid">Template id</param>
|
|
/// <param name="expire_date">Expire date</param>
|
|
public EC_IvtrSkilltome(int tid, int expire_date) : base(tid, expire_date)
|
|
{
|
|
m_iCID = (int)InventoryClassId.ICID_SKILLTOME;
|
|
|
|
// Get database data
|
|
elementdataman pDB = ElementDataManProvider.GetElementDataMan();
|
|
DATA_TYPE DataType = DATA_TYPE.DT_INVALID;
|
|
m_pDBEssence = (SKILLTOME_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
|
|
m_pDBSubType = (SKILLTOME_SUB_TYPE)pDB.get_data_ptr(m_pDBEssence.id_sub_type, 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 = 0;
|
|
m_bNeedUpdate = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copy constructor for skill tome item(sach ky nang)
|
|
/// </summary>
|
|
/// <param name="other">Other skill tome item</param>
|
|
public EC_IvtrSkilltome(EC_IvtrSkilltome other) : base(other)
|
|
{
|
|
m_pDBEssence = other.m_pDBEssence;
|
|
m_pDBSubType = other.m_pDBSubType;
|
|
}
|
|
|
|
public override bool SetItemInfo(byte[] pInfoData, int iDataLen)
|
|
{
|
|
base.SetItemInfo(pInfoData, iDataLen);
|
|
return true;
|
|
}
|
|
|
|
public override string GetIconFile()
|
|
{
|
|
return m_pDBEssence.FileIcon;
|
|
}
|
|
|
|
// Get item name
|
|
public override string GetName()
|
|
{
|
|
// Try Unicode first (for Vietnamese/wide char names), then fallback to CP936
|
|
if (m_pDBEssence.name != null && m_pDBEssence.name.Length > 0)
|
|
{
|
|
string s = ByteToStringUtils.UshortArrayToUnicodeString(m_pDBEssence.name);
|
|
if (!string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s))
|
|
return s;
|
|
// Fallback to legacy CP936 if Unicode was empty
|
|
s = ByteToStringUtils.UshortArrayToCP936String(m_pDBEssence.name);
|
|
if (!string.IsNullOrEmpty(s))
|
|
return s;
|
|
}
|
|
return base.GetName(); // Fallback to base class method
|
|
}
|
|
|
|
protected override string GetNormalDesc(bool bRepair)
|
|
{
|
|
m_strDesc = "";
|
|
|
|
// Try to build item description
|
|
CECStringTab pDescTab = EC_Game.GetItemDesc();
|
|
int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE;
|
|
int namecol = DecideNameCol();
|
|
|
|
if (m_iCount > 1)
|
|
AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMENUMBER), GetName(), m_iCount);
|
|
else
|
|
AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName());
|
|
|
|
AddIDDescText();
|
|
|
|
AddExpireTimeDesc();
|
|
|
|
// Price
|
|
AddPriceDesc(white, bRepair);
|
|
|
|
// Extend description
|
|
AddExtDescText();
|
|
|
|
return m_strDesc;
|
|
}
|
|
|
|
public override string GetDropModel()
|
|
{
|
|
return m_pDBEssence.FileMatter;
|
|
}
|
|
}
|
|
} |