Exemplo n.º 1
0
        private Quest.Quest LoadQuestItem(QuestUIComponets questUIComponent, SaveData.QuestInfo savedQuestInfo = null, int lvl = 1)
        {
            if (questUIComponent.quest == null)
            {
                if (savedQuestInfo != null)
                {
                    Quest.Quest quest = new Quest.Quest(savedQuestInfo.id, savedQuestInfo.level).SetupRandomQuest();
                    quest.mainCondition.UpdateProgress(savedQuestInfo.progress);

                    questUIComponent.quest = quest;
                    questUIComponent.ShowQuestData(questUIComponent.quest);
                }
                else
                {
                    questUIComponent.quest = new Quest.Quest(0, lvl).SetupRandomQuest();
                    questUIComponent.ShowQuestData(questUIComponent.quest);
                }
            }
            else
            {
                Debug.Log($"{GetType().FullName} :: Quest in component is not null");
                questUIComponent.ShowQuestData(questUIComponent.quest);
            }

            //Setup claim btn
            questUIComponent.claimBTN.onClick.AddListener(() => OnClaimClicked(questUIComponent, questUIComponent.quest));

            return(questUIComponent.quest);
        }
Exemplo n.º 2
0
        public void UpdateQuestProgress(QuestUIComponets p_questUIC)
        {
            if (p_questUIC.quest.mainCondition.progress >= p_questUIC.quest.mainCondition.progessGoal)
            {
                p_questUIC.ShowQuestData(p_questUIC.quest);
                return;
            }

            p_questUIC.progressText.text = $"{Math.Round(p_questUIC.quest.mainCondition.progress, 1)} / {p_questUIC.quest.mainCondition.progessGoal}";
        }
Exemplo n.º 3
0
        private void OnClaimClicked(QuestUIComponets questUIComponent, Quest.Quest quest)
        {
            if (quest.completed)
            {
                questUIComponent.claimBTN.onClick.RemoveAllListeners();

                questUIComponent.quest = null;
                if (saveData.quest1.id == quest.id)
                {
                    saveData.quest1 = null;
                    saveData.quest1 = LoadQuestItem(questUIComponent, null, 1).GetQuestInfo();
                }

                if (saveData.quest2.id == quest.id)
                {
                    saveData.quest2 = null;
                    saveData.quest2 = LoadQuestItem(questUIComponent, null, 2).GetQuestInfo();
                }

                if (saveData.quest3.id == quest.id)
                {
                    saveData.quest3 = null;
                    saveData.quest3 = LoadQuestItem(questUIComponent, null, 3).GetQuestInfo();
                }


                quest.mainCondition.GiveAllRewards();

                UpdateAllQuestDisplays();

                SaveJson();
            }
            else
            {
                Debug.LogError($"{GetType().FullName} :: Quest is not completed and is trying to be redeemed");
            }
        }
Exemplo n.º 4
0
        public override void Init(MenuData menuData, Menu menu)
        {
            base.Init(menuData, menu);

            //Setup commands for reloading json =)

            IngameDebugConsole.DebugLogConsole.AddCommand("reloadblood", "Reloads the blood save json", delegate
            {
                InitSaveJSON();
                SetupAllQuests();
                UpdateAllStats();
            });


            Instance = this;

            //Get quest ui components
            questUI1 = menu.GetCustomReference("Quest1").GetComponent <QuestUIComponets>();
            questUI2 = menu.GetCustomReference("Quest2").GetComponent <QuestUIComponets>();
            questUI3 = menu.GetCustomReference("Quest3").GetComponent <QuestUIComponets>();


            darkChoicePage  = menu.GetCustomReference("DarkChoice").gameObject;
            lightChoicePage = menu.GetCustomReference("LightChoice").gameObject;
            page1Picked     = menu.GetCustomReference("Page1Picked").gameObject;
            page2Picked     = menu.GetCustomReference("Page2Picked").gameObject;

            lightSkillTree = menu.GetCustomReference("LightSkillTree").gameObject;
            darkSkillTree  = menu.GetCustomReference("DarkSkillTree").gameObject;

            LP = menu.GetCustomReference("LP").GetComponent <Text>();
            DP = menu.GetCustomReference("DP").GetComponent <Text>();

            InitSaveJSON();

            QuestHandler.globalRandom = new System.Random(UnityEngine.Random.Range(1, 10000000));

            menu.GetCustomReference("SkillTreeBTN").GetComponent <Button>().onClick.AddListener(delegate
            {
                LoadSkillTree();
                AbilityInfo.gameObject.SetActive(false);
            });

            menu.GetCustomReference("OtherSkill").GetComponent <Button>().onClick.AddListener(delegate
            {
                LoadSkillTree();
                AbilityInfo.gameObject.SetActive(false);
            });

            menu.GetCustomReference("QuestBTN").GetComponent <Button>().onClick.AddListener(delegate
            {
                LoadQuestPage();
                AbilityInfo.gameObject.SetActive(false);
            });

            SetupAllQuests();


            menu.GetCustomReference("DebugNewQuest").GetComponent <Button>().onClick.AddListener(delegate
            {
                saveData.quest1 = null;
                saveData.quest2 = null;
                saveData.quest3 = null;

                questUI1.quest = null;
                questUI2.quest = null;
                questUI3.quest = null;

                SetupAllQuests();
            });
            menu.GetCustomReference("DebugNewQuest").gameObject.SetActive(false);

            UpdateAllStats();

            MainCondition.OnAnyMainConditionProgressedEvent += OnAnyMainConditionCompleted;

            EventManager.onCreatureKill += AddDrainComponentOnKill;
        }