using UnityEngine; using System.IO; using System.Runtime.InteropServices; namespace BrewMonster.Scripts.Task { public sealed class TaskConstant { public const int MAX_OCCUPATIONS = 12; public const int MAX_TASK_NAME_LEN = 30; public const int MAX_AWARD_NPC_NUM = 8; public const int MAX_PREM_TASK_COUNT = 20; public const int MAX_MUTEX_TASK_COUNT = 5; public const int MAX_TEAM_MEM_WANTED = MAX_OCCUPATIONS; public const int MAX_TIMETABLE_SIZE = 24; public const int MAX_AWARD_SCALES = 5; public const int MAX_AWARD_CANDIDATES = 12; public const int MAX_LIVING_SKILLS = 4; public const int MAX_CONTRIB_MONSTERS = 100; public const int MAX_AWARD_PQ_RANKING = 32; public const int MAX_TITLE_NUM = 10; public const int MAX_TASKREGION = 8; public const int TASK_GENDER_NONE = 0; public const int TASK_GENDER_MALE = 1; public const int TASK_GENDER_FEMALE = 2; public const int TASK_MAX_PATH = 260; public const int INVALID_VAL = -1; public const int TASK_MAX_LINE_LEN = TASK_MAX_PATH; public const int TASK_MAX_VALID_COUNT = 6; public const int TASK_TREASURE_MAP_SIDE_MULTIPLE = 30; public readonly long[] task_week_map = { 7, 1, 2, 3, 4, 5, 6 }; } public struct task_tm { public int year; public int month; public int day; public int hour; public int min; public int wday; } public struct TASK_PACK_HEADER { public uint magic; public uint version; public int item_count; } public struct MONSTERS_CONTRIB { public ulong m_ulMonsterTemplId; // Monster ID public int m_iWholeContrib; // Team exclusive contribution public int m_iShareContrib; // Team shared contribution public int m_iPersonalWholeContrib; // Personal exclusive contribution public bool Equals(MONSTERS_CONTRIB src) { return (m_ulMonsterTemplId == src.m_ulMonsterTemplId && m_iWholeContrib == src.m_iWholeContrib && m_iShareContrib == src.m_iShareContrib && m_iPersonalWholeContrib == src.m_iPersonalWholeContrib); } } public struct ZONE_VERT { public float x; public float y; public float z; } public enum task_tm_type { enumTaskTimeDate = 0, enumTaskTimeMonth, enumTaskTimeWeek, enumTaskTimeDay }; /// /// 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 struct Task_Region { public ZONE_VERT zvMin; public ZONE_VERT zvMax; public bool Equals(Task_Region src) { return (zvMin.x == src.zvMin.x && zvMin.y == src.zvMin.y && zvMin.z == src.zvMin.z && zvMax.x == src.zvMax.x && zvMax.y == src.zvMax.y && zvMax.z == src.zvMax.z); } public static bool operator ==(Task_Region a, Task_Region b) { return a.Equals(b); } public static bool operator !=(Task_Region a, Task_Region b) { return !a.Equals(b); } public override bool Equals(object obj) { if (obj is Task_Region) return Equals((Task_Region)obj); return false; } public override int GetHashCode() { return zvMin.GetHashCode() ^ zvMax.GetHashCode(); } } public struct ATaskTemplFixedData { /* Task object properties */ // Task ID public uint m_ID; // Task name [MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASK_NAME_LEN)] public ushort[] m_szName; // Task signature public bool m_bHasSign; [MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASK_NAME_LEN)] public ushort[] m_pszSignature; // Task type public uint m_ulType; // Time limit public uint m_ulTimeLimit; // Task fails when offline public bool m_bOfflineFail; // Absolute failure time public bool m_bAbsFail; public task_tm m_tmAbsFailTime; // Do not take items during task validation public bool m_bItemNotTakeOff; // Whether using absolute time public bool m_bAbsTime; // Number of time periods public ulong m_ulTimetable; // Time method [MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TIMETABLE_SIZE)] public byte[] m_tmType; // Start time for delivery public task_tm[] m_tmStart; // [MAX_TIMETABLE_SIZE] // End time for delivery public task_tm[] m_tmEnd; // [MAX_TIMETABLE_SIZE] // Delivery frequency public long m_lAvailFrequency; public long m_lPeriodLimit; // Execute single subtask public bool m_bChooseOne; // Randomly rotate single subtask execution public bool m_bRandOne; // Whether subtasks have order public bool m_bExeChildInOrder; // Whether parent task fails when subtask fails public bool m_bParentAlsoFail; // Whether parent task succeeds when subtask succeeds public bool m_bParentAlsoSucc; // Whether task can be abandoned public bool m_bCanGiveUp; // Whether task can be repeated public bool m_bCanRedo; // Whether task can be redone after failure public bool m_bCanRedoAfterFailure; // Clear task on abandonment public bool m_bClearAsGiveUp; // Whether recording is needed public bool m_bNeedRecord; // Whether task fails when player dies public bool m_bFailAsPlayerDie; // Maximum number of receivers public uint m_ulMaxReceiver; // Delivery zone public bool m_bDelvInZone; public uint m_ulDelvWorld; public uint m_ulDelvRegionCnt; [MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASKREGION)] public Task_Region[] m_pDelvRegion; // Enter region task failure public bool m_bEnterRegionFail; public uint m_ulEnterRegionWorld; public uint m_ulEnterRegionCnt; //public ZONE_VERT m_EnterRegionMinVert; //public ZONE_VERT m_EnterRegionMaxVert; [MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASKREGION)] public Task_Region[] m_pEnterRegion; // Leave region task failure public bool m_bLeaveRegionFail; public uint m_ulLeaveRegionWorld; public uint m_ulLeaveRegionCnt; //public ZONE_VERT m_LeaveRegionMinVert; //public ZONE_VERT m_LeaveRegionMaxVert; [MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASKREGION)] public Task_Region[] m_pLeaveRegion; // Leave force failure public bool m_bLeaveForceFail; // Transport to specific point public bool m_bTransTo; public uint m_ulTransWldId; public ZONE_VERT m_TransPt; // 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; // Death trigger public bool m_bDeathTrig; // Whether clear all acquired items public bool m_bClearAcquired; // Recommended level public uint m_ulSuitableLevel; // Whether to show prompt public bool m_bShowPrompt; // Whether it is a key task public bool m_bKeyTask; // Delivery NPC public uint m_ulDelvNPC; // Award NPC public uint m_ulAwardNPC; // Whether it is a skill task public bool m_bSkillTask; // Whether can be searched public bool m_bCanSeekOut; // Whether show direction public bool m_bShowDirection; // Marriage public bool m_bMarriage; // Change global key/value public uint m_ulChangeKeyCnt; public long[] m_plChangeKey; // [TASK_AWARD_MAX_CHANGE_VALUE] public long[] m_plChangeKeyValue; public bool[] m_pbChangeType; // Fail on scene switch public bool m_bSwitchSceneFail; // Hidden task public bool m_bHidden; // Whether deliver skill public bool m_bDeliverySkill; public int m_iDeliveredSkillID; public int m_iDeliveredSkillLevel; // Whether show task completion effect public bool m_bShowGfxFinished; // Whether change player ranking in PQ public bool m_bChangePQRanking; // Compare delivery items with player inventory slots public bool m_bCompareItemAndInventory; public uint m_ulInventorySlotNum; /////////////////////////////////////////////// PQ Task start // 是否是PQ任务 public bool m_bPQTask; // PQ任务全局变量显示 public uint m_ulPQExpCnt; public uint m_ulNPCToProtect; public uint m_ulProtectTimeLen; public uint m_enumMethod; public uint m_enumFinishType; // 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; // 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; } public class ATaskTempl { public ATaskTemplFixedData m_FixedData; //Hierarchy public ATaskTempl m_pParent; public ATaskTempl m_pPrevSibling; public ATaskTempl m_pNextSibling; public ATaskTempl m_pFirstChild; 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) { ulong i; long readBytes = 0; ATaskTemplFixedData fixedData = AAssit.ReadFromBinaryOf(fp, ref readBytes); //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