using UnityEngine;
using System.IO;
namespace PerfectWorld.Scripts.Task
{
///
/// Completion Method
///
public enum TaskMethod
{
enumTMNone = 0, // None
enumTMKillNumMonster, // Kill a number of monsters
enumTMCollectNumArticle, // Collect a number of items
enumTMTalkToNPC, // Talk to a specific NPC
enumTMReachSite, // Reach a specific location
enumTMWaitTime, // Wait for a specified time
enumTMAnswerQuestion, // Answer a question
enumTMTinyGame, // Mini-game
enumTMProtectNPC, // Protect a specific NPC
enumTMNPCReachSite, // NPC reaches a specific location
enumTMGlobalValOK, // Global variable condition satisfied
enumTMLeaveSite, // Leave a specific location
enumTMReachTreasureZone, // Reach the treasure area
enumTMKillPlayer, // Kill another player
enumTMTransform, // Transform state
enumTMReachLevel, // Check level: normal level, rebirth count, realm level
enumTMSimpleClientTask, // Simple client task (only client-side validation, currently just checks UI triggers)
enumTMSimpleClientTaskForceNavi // Force navigation
}
public class ATaskTemplFixedData
{
public ulong m_ID;
public ulong m_ulNPCToProtect;
public ulong m_ulProtectTimeLen;
public ulong m_enumMethod;
public ulong m_enumFinishType;
//Hierarchy
public ATaskTempl m_pParent;
public ATaskTempl m_pPrevSibling;
public ATaskTempl m_pNextSibling;
public ATaskTempl m_pFirstChild;
// Required items
public ulong m_ulPremItems;
// public ItemWanted[] m_PremItems; // [MAX_ITEM_WANTED]
public bool m_bShowByItems;
public bool m_bPremItemsAnyOne;
// Level condition
public ulong m_ulPremise_Lev_Min;
public ulong m_ulPremise_Lev_Max;
public ulong m_bPremCheckMaxHistoryLevel;
public bool m_bShowByLev;
// Monster controller
public long m_lMonsCtrl;
public bool m_bTrigCtrl;
// Auto trigger when conditions are met
public bool m_bAutoDeliver;
// Whether to display in exclusive UI
public bool m_bDisplayInExclusiveUI;
public bool m_bReadyToNotifyServer;
// Whether used in token shop
public bool m_bUsedInTokenShop;
// Trigger on death
public bool m_bDeathTrig;
// Whether clear all acquired items
public bool m_bClearAcquired;
// Recommended level
public ulong m_ulSuitableLevel;
// Whether to show prompt
public bool m_bShowPrompt;
// Whether it is a key task
public bool m_bKeyTask;
// Deliver NPC
public ulong m_ulDelvNPC;
// Award NPC
public ulong m_ulAwardNPC;
// Whether it is a skill task
public bool m_bSkillTask;
// Can be sought out
public bool m_bCanSeekOut;
// Whether to show direction
public bool m_bShowDirection;
// Marriage
public bool m_bMarriage;
// Change global key/value
public ulong m_ulChangeKeyCnt;
public long[] m_plChangeKey; // [TASK_AWARD_MAX_CHANGE_VALUE]
public long[] m_plChangeKeyValue;
public bool[] m_pbChangeType;
// Switch scene fail
public bool m_bSwitchSceneFail;
// Hidden task
public bool m_bHidden;
// Whether to deliver skill [Yongdong, 2010-1-6]
public bool m_bDeliverySkill;
public int m_iDeliveredSkillID;
public int m_iDeliveredSkillLevel;
// Whether to show task finished effect [Yongdong, 2010-1-21]
public bool m_bShowGfxFinished; // Show effect when task is completed
// Whether change PQ ranking
public bool m_bChangePQRanking;
// Compare items with player inventory before delivery
public bool m_bCompareItemAndInventory;
public ulong m_ulInventorySlotNum; // Required number of inventory slots
// Whether it is a PQ task
public bool m_bPQTask;
// PQ task global variable display
public ulong m_ulPQExpCnt;
// Dynamic task type
public string m_DynTaskType;
// Special award ID, used for events
public ulong m_ulSpecialAward;
// Whether to display in the title task UI
public bool m_bDisplayInTitleTaskUI;
// Maximum number of receivers
public ulong m_ulMaxReceiver;
}
public class ATaskTempl : ATaskTemplFixedData
{
const int MAX_TASK_NAME_LEN = 30;
public byte m_uValidCount;
public bool LoadFromBinFile(FileStream fp)
{
LoadBinary(fp);
// CheckDepth();
return true;
}
private void LoadBinary(FileStream fp)
{
LoadFixedDataFromBinFile(fp);
// LoadDescriptionBin(fp);
// LoadTributeBin(fp);
//# ifndef _TASK_CLIENT
// CheckMask();
//#else
// SyncTaskType();
//#endif
// namechar code = (namechar)m_ID;
// m_DelvTaskTalk.load(fp);
// convert_talk_text(&m_DelvTaskTalk, code);
// m_UnqualifiedTalk.load(fp);
// convert_talk_text(&m_UnqualifiedTalk, code);
// m_DelvItemTalk.load(fp);
// convert_talk_text(&m_DelvItemTalk, code);
// m_ExeTalk.load(fp);
// convert_talk_text(&m_ExeTalk, code);
// m_AwardTalk.load(fp);
// convert_talk_text(&m_AwardTalk, code);
// fread(&m_nSubCount, sizeof(m_nSubCount), 1, fp);
// for (int i = 0; i < m_nSubCount; i++)
// {
// ATaskTempl* pSub = new ATaskTempl;
// g_ulNewCount++;
// AddSubTaskTempl(pSub);
// pSub->LoadBinary(fp);
// }
// SynchID();
//return true;
}
private bool LoadFixedDataFromBinFile(FileStream fp)
{
// LOG_DELETE(m_Award_S);
// LOG_DELETE(m_Award_F);
// LOG_DELETE(m_AwByRatio_S);
// LOG_DELETE(m_AwByRatio_F);
// LOG_DELETE(m_AwByItems_S);
// LOG_DELETE(m_AwByItems_F);
// LOG_DELETE_ARR(m_tmStart);
// LOG_DELETE_ARR(m_tmEnd);
// LOG_DELETE_ARR(m_plChangeKey);
// LOG_DELETE_ARR(m_plChangeKeyValue);
// LOG_DELETE_ARR(m_pbChangeType);
// LOG_DELETE_ARR(m_PremItems);
// LOG_DELETE_ARR(m_GivenItems);
// LOG_DELETE_ARR(m_TeamMemsWanted);
// LOG_DELETE_ARR(m_ItemsWanted);
// LOG_DELETE_ARR(m_PlayerWanted);
// LOG_DELETE_ARR(m_MonsterWanted);
// LOG_DELETE_ARR(m_pszSignature);
// LOG_DELETE_ARR(m_pszExp);
// LOG_DELETE_ARR(m_pExpArr);
// LOG_DELETE_ARR(m_pTaskChar);
// LOG_DELETE_ARR(m_pszPQExp);
// LOG_DELETE_ARR(m_pPQExpArr);
// LOG_DELETE_ARR(m_MonstersContrib);
// LOG_DELETE_ARR(m_pDelvRegion);
// LOG_DELETE_ARR(m_pEnterRegion);
// LOG_DELETE_ARR(m_pLeaveRegion);
// LOG_DELETE_ARR(m_pReachSite);
// LOG_DELETE_ARR(m_pLeaveSite);
// LOG_DELETE_ARR(m_PremTitles);
ulong i;
//write method FRead convert this to c#
//fread(this, sizeof(*this), 1, fp);
//convert_txt(m_szName, MAX_TASK_NAME_LEN, (namechar)m_ID);
// m_Award_S = new AWARD_DATA;
// g_ulNewCount++;
// m_Award_F = new AWARD_DATA;
// g_ulNewCount++;
// m_AwByRatio_S = new AWARD_RATIO_SCALE;
// g_ulNewCount++;
// m_AwByRatio_F = new AWARD_RATIO_SCALE;
// g_ulNewCount++;
// m_AwByItems_S = new AWARD_ITEMS_SCALE;
// g_ulNewCount++;
// m_AwByItems_F = new AWARD_ITEMS_SCALE;
// g_ulNewCount++;
// m_tmStart = NULL;
// m_tmEnd = NULL;
// m_plChangeKey = NULL;
// m_plChangeKeyValue = NULL;
// m_pbChangeType = NULL;
// m_PremItems = NULL;
// m_GivenItems = NULL;
// m_TeamMemsWanted= NULL;
// m_ItemsWanted = NULL;
// m_PlayerWanted = NULL;
// m_MonsterWanted = NULL;
// m_pszSignature = NULL;
// m_pszExp = NULL;
// m_pExpArr = NULL;
// m_pTaskChar = NULL;
// m_pszPQExp = NULL;
// m_pPQExpArr = NULL;
// m_MonstersContrib = NULL;
// m_PremTitles = NULL;
// if (m_bHasSign)
// {
// m_pszSignature = new task_char[MAX_TASK_NAME_LEN];
// g_ulNewCount++;
// fread(m_pszSignature, sizeof(task_char), MAX_TASK_NAME_LEN, fp);
// convert_txt(m_pszSignature, MAX_TASK_NAME_LEN, (namechar)m_ID);
// }
// if (m_ulTimetable)
// {
// m_tmStart = new task_tm[m_ulTimetable];
// g_ulNewCount++;
// m_tmEnd = new task_tm[m_ulTimetable];
// g_ulNewCount++;
// }
// for (i = 0; i < m_ulTimetable; i++)
// {
// fread(&m_tmStart[i], sizeof(task_tm), 1, fp);
// fread(&m_tmEnd[i], sizeof(task_tm), 1, fp);
// }
// if (m_ulChangeKeyCnt)
// {
// m_plChangeKey = new long[m_ulChangeKeyCnt];
// m_plChangeKeyValue = new long[m_ulChangeKeyCnt];
// m_pbChangeType = new bool[m_ulChangeKeyCnt];
// }
// for (i=0; i0)
// {
// m_pDelvRegion = new Task_Region[m_ulDelvRegionCnt];
// g_ulNewCount++;
// }
// else m_pDelvRegion = NULL;
// for (i=0;i0)
// {
// m_pEnterRegion = new Task_Region[m_ulEnterRegionCnt];
// g_ulNewCount++;
// }
// else m_pEnterRegion = NULL;
// for (i=0;i0)
// {
// m_pLeaveRegion = new Task_Region[m_ulLeaveRegionCnt];
// g_ulNewCount++;
// }
// else m_pLeaveRegion = NULL;
// for (i=0;i0)
// {
// m_pReachSite = new Task_Region[m_ulReachSiteCnt];
// g_ulNewCount++;
// }
// else m_pReachSite = NULL;
// for (i=0;i0)
// {
// m_pLeaveSite = new Task_Region[m_ulLeaveSiteCnt];
// g_ulNewCount++;
// }
// else m_pLeaveSite = NULL;
// for (i=0;i