Exemplo n.º 1
0
    public void  SetXPBarUI()
    {
        if (XPManager == null)
        {
            XPManager = FindObjectOfType(typeof(ExperienceManagerC)) as ExperienceManagerC;

            BarWidth = FullBar.rect.width;
            PosX     = FullBar.localPosition.x;
        }

        FullBar.sizeDelta     = new Vector2((XPManager.XP / (XPManager.Level * XPManager.Level1XP)) * BarWidth, FullBar.sizeDelta.y);
        FullBar.localPosition = new Vector3(-(BarWidth - FullBar.rect.width) / 2 + PosX, FullBar.localPosition.y, FullBar.localPosition.z);

        LevelText.text = "Level: " + XPManager.Level.ToString();
    }
Exemplo n.º 2
0
        public bool SaveQuestProgress = false;  //if true, the objectives progress for this quest will be saved when abandonned.

        void  Start()
        {
            if (QuestCode == "")
            {
                Debug.LogError("S-Quest Error: Quest desactivated - Reason: Please give the quest a code.");
                gameObject.SetActive(false);
            }
            if (QuestObjective == "")
            {
                Debug.LogError("S-Quest Error: Quest desactivated - Reason: The quest objective is required.");
                gameObject.SetActive(false);
            }
            if (Goal.Length < 1)
            {
                Debug.LogError("S-Quest Error: Quest desactivated - Reason: Your quest must have at least one goal.");
                gameObject.SetActive(false);
            }


            Manager          = FindObjectOfType(typeof(QuestManager)) as QuestManager;
            XPManager        = FindObjectOfType(typeof(ExperienceManagerC)) as ExperienceManagerC;
            InvQuest         = FindObjectOfType(typeof(InventoryQuest)) as InventoryQuest;
            QuestUI          = FindObjectOfType(typeof(QuestUIManager)) as QuestUIManager;
            CustomEvents     = FindObjectOfType(typeof(QuestEvents)) as QuestEvents;
            InventoryManager = FindObjectOfType(typeof(InventoryManager)) as InventoryManager;

            MyTransform = gameObject.transform;             //Set the object tranform.
            QuestActive = false; if (Manager.LogOpen == true && Manager.ShowQuestLog == true)
            {
                Manager.LogUI.LoadActiveQuests();
            }
            QuestOpen = false;
            Progress  = 0;

            if (Manager.SaveAndLoad == true)
            {
                if (PlayerPrefs.GetInt(QuestCode) == 1)
                {
                    if (Repeatable == false)
                    {
                        QuestFinished = true;
                    }

                    //Make the next quest available for the player if it's not already finished.
                    Quest[] Quests = FindObjectsOfType(typeof(Quest)) as Quest[];
                    foreach (Quest NextQuest in Quests)
                    {
                        if (NextQuest.ParentQuest == this)
                        {
                            if (NextQuest.QuestFinished == false)
                            {
                                NextQuest.IsAvailable = true;
                            }
                        }
                    }
                }
                else if (PlayerPrefs.GetInt(QuestCode + "Active", 0) == 1)
                {
                    AcceptQuest();
                    if (PlayerPrefs.GetInt(QuestCode + "ReturnToGiver", 0) == 1)
                    {
                        ReturningToGiver = true;
                    }
                    else
                    {
                        Progress = PlayerPrefs.GetInt(QuestCode + "Progress", 0);
                        Goal[Progress].Amount = PlayerPrefs.GetInt(QuestCode + "Amount", 0);
                    }
                }
            }

            if (ParentQuest == null && QuestFinished == false)
            {
                IsAvailable = true;
            }

            if (QuestFinished == false && ActivateOnStart == true)
            {
                QuestActive = true; if (Manager.LogOpen == true && Manager.ShowQuestLog == true)
                {
                    Manager.LogUI.LoadActiveQuests();
                }
            }
        }