예제 #1
0
 private void SetQuestStateByQuestID(int questID)
 {
     Quest quest = QuestEngine.Instance.GetQuest(_activeQuestID);
     if (quest != null)
     {
         if (quest.IsDone)
         {
             QuestState = winDialogStory.QuestStateType.Done;
         }
         else
         {
             QuestState = quest.IsActive ? QuestStateType.Active : QuestStateType.Normal;
         }
         return;
     }
     QuestState = winDialogStory.QuestStateType.None;
 }
예제 #2
0
    /// <summary>
    /// Generate button based on the dialog option
    /// </summary>
    /// <param name="rect"></param>
    /// <param name="opt"></param>
    /// <returns></returns>
    private bool MakeButton(Rect rect, DialogOption opt)
    {
        bool result = false;

        List<string> urls = new List<string>();

        switch (opt.Tipe)
        {
        case DialogEngine.DIALOG_OPTION_CHOICE:	// Plain Choice
            {
                string content;
                urls = DecodeEmbeddedUrl(opt.Content, out content);

                float hintWidth = rect.height;

                result = GUI.Button(new Rect(rect.x + hintWidth, rect.y, rect.width - hintWidth * 2, rect.height), content);

                if (result)
                {
                    foreach (string url in urls)
                    {
                        if (Application.isWebPlayer)
                        {
                            Application.ExternalEval("window.open('" + url + "', '_blank')");
                        }
                        else
                        {
                            Application.OpenURL(url);
                        }
                    }
                }
            }
            break;

        case DialogEngine.DIALOG_OPTION_QUEST: // Quest button
            {
                // Get the quest
                Quest quest = QuestEngine.Instance.GetQuest(opt.Next);

                // Check if Quest required for this quest is valid
                bool isQuestValid = QuestEngine.Instance.IsQuestRequirementValid(opt.Next);

                // Check for date range
                bool isQuestDateTimeRangeValid = QuestEngine.Instance.IsQuestDateTimeRangeValid(opt.Next, PBGameMaster.GameTime);

                // Proceed only when requirements and date range valid
                if (quest != null && isQuestValid && isQuestDateTimeRangeValid)
                {
                    float hintWidth = rect.height;

                    GUI.Box(new Rect(rect.x, rect.y, hintWidth-2, rect.height), "", _questHintStyle);

                    string desc;
                    urls = DecodeEmbeddedUrl(quest.Description, out desc);

                    // Render the button
                    result = GUI.Button(new Rect(rect.x + hintWidth, rect.y, rect.width - hintWidth * 2, rect.height), desc, _questButtonStyle);

                    if (result)
                    {
                        dlgIsQuest = true;
                        _activeQuestID = quest.ID;
                        QuestState = GetState(_activeQuestID);

                        // Open the URLs
                        if (result)
                        {
                            foreach (string url in urls)
                            {
                                Application.OpenURL(url);
                            }
                        }
                    }

                }
            }
            break;
        }

        return result;
    }
예제 #3
0
    private void DisplayQuestPassiveState(float gap, float buttonHeight)
    {
        int energy = InventoryEngine.Instance.GetEquipmentCount(Equipments.EquipmentType.Energy);

        int energyReq = QuestEngine.Instance.GetEnergyRequirement(_activeQuestID);

        float startOffset = WindowRect.height - gap - buttonHeight - Margin.height;

        if (energy < energyReq)
        {
            DisplayDescription(Lang.Localized("Untuk menjalankan quest ini kamu butuh Energi ") + energyReq.ToString(), gap, buttonHeight);

            if (GUI.Button(new Rect(Margin.x * 2, startOffset, WindowRect.width - Margin.width * 4, buttonHeight),
                           Lang.Localized("OK")))
            {
                dlgIsQuest = false;
                Close();
            }
        }
        else
        {
            DisplayDescription(Lang.Localized("Mau terima Quest ini?"), gap, buttonHeight);

            if (GUI.Button(new Rect(Margin.x * 2, startOffset, WindowRect.width - Margin.width * 4, buttonHeight),
                           Lang.Localized("No")))
            {
                dlgIsQuest = false;
            }

            startOffset -= buttonHeight + gap;

            if (GUI.Button(new Rect(Margin.x * 2, startOffset, WindowRect.width - Margin.width * 4, buttonHeight),
                           Lang.Localized("Yes")))
            {
                QuestState = winDialogStory.QuestStateType.Normal;

                if (energyReq > 0)
                {
                    InventoryEngine.Instance.SyncEquipment("energy", energy - energyReq);
                }
            }
        }
    }
예제 #4
0
    private void DisplayQuestDoneState(float gap, float buttonHeight)
    {
        Quest quest = QuestEngine.Instance.GetQuest(_activeQuestID);

        if (quest == null)
        {
            return;
        }

        bool isUsingRedeems = false;

        //Dictionary<string, int> rewardEquipments, rewardInventories;
        QuestReward reward;
        if (rewardRedeems == null)
        {
            QuestEngine.Instance.GetRewards(_activeQuestID, out reward);//out rewardEquipments, out rewardInventories, out rewardRedeems);
            rewardRedeems = reward.AvatarRedeems;
        }

        if (rewardRedeems != null)
        {
            isUsingRedeems = rewardRedeems.Count > 0;
        }

        if (isUsingRedeems)
        {
            DisplayDescriptionWithRedeem(quest.DescriptionDone, rewardRedeems, gap, buttonHeight);
        }
        else
        {
            DisplayDescription(quest.DescriptionDone, gap, buttonHeight);
        }

        float startOfffest = WindowRect.height - gap - buttonHeight - Margin.height;

        if (GUI.Button(new Rect(Margin.x * 2, startOfffest, WindowRect.width - Margin.width * 4, buttonHeight),
                       Lang.Localized("OK")))
        {
            /***********************
             * VERSION 1 (OBSOLETE)
             ***********************

            // Steal the item from the inventory
            string code;
            int count;
            QuestEngine.GetQuestItemRequirementsv1(_activeQuestID, out code, out count);

            for (int i = 0; i < count; i++)
            {
                InventoryEngine.StealItem(code);
            }
            */

            //Dictionary<string, int> equipments, inventories;

            QuestEngine.Instance.GetQuestItemRequirements(_activeQuestID, out reward);//out equipments, out inventories);

            if (reward.InventoryCount() > 0) //inventories.Keys.Count > 0)
            {
                InventoryEngine.Instance.StealItems(reward.Inventories);
            }

            if (reward.EquipmentCount() > 0)//equipments.Keys.Count > 0)
            {
                InventoryEngine.Instance.StealEquipments(reward.Equipments);
            }

            // Disable the dialog
            dlgIsQuest = false;

            QuestEngine.Instance.SetQuestDone(_activeQuestID, true);

            // Reset the state
            QuestState = winDialogStory.QuestStateType.None;

            RewardPlayer(_activeQuestID);

            // Clos the dialog
            Close();
        }
    }
예제 #5
0
    private void DisplayQuestActiveState(float gap, float buttonHeight)
    {
        Quest quest = QuestEngine.Instance.GetQuest(_activeQuestID);

        if (quest == null) return;

        /// Deskripsi perintah untuk player untuk mencarikan sesuatu
        DisplayDescription(quest.DescriptionActive, gap, buttonHeight);

        float startOfffest = WindowRect.height - gap - buttonHeight - Margin.height;

        if (GUI.Button(new Rect(Margin.x * 2, startOfffest, WindowRect.width - Margin.width * 4, buttonHeight),
            Lang.Localized("Tidak")))
        {
            Close();
        }

        startOfffest -= buttonHeight + gap;

        if (GUI.Button(new Rect(Margin.x * 2, startOfffest, WindowRect.width - Margin.width * 4, buttonHeight),
            Lang.Localized("Ya")))
        {
            QuestState = winDialogStory.QuestStateType.Done;
        }
    }
예제 #6
0
    private void DisplayQuestNormalState(float gap, float buttonHeight)
    {
        Quest quest = QuestEngine.Instance.GetQuest(_activeQuestID);

        if (quest == null) return;

        string desc = quest.DescriptionNormal;
        DisplayDescription(desc, gap, buttonHeight);

        float startOffset = WindowRect.height - gap - buttonHeight - Margin.height;

        if (GUI.Button(new Rect(Margin.x * 2, startOffset, WindowRect.width - Margin.width * 4, buttonHeight),
                       Lang.Localized("OK")))
        {
            dlgIsQuest = false;
            QuestEngine.Instance.SetQuestActive(_activeQuestID, true);
            SetQuestStateByQuestID(_activeQuestID);

            if (quest.IsReturn == false)
            {
                Debug.Log("quest done");
                RewardPlayer(_activeQuestID);
                QuestEngine.Instance.SetQuestDone(_activeQuestID, true);
                QuestState = QuestStateType.None;
            }

            Close();
        }
    }