コード例 #1
0
ファイル: BadgeManager.cs プロジェクト: aliken9/MyZooPets
    /// <summary>
    /// Checks the unlock progress meets the unlock condition
    /// </summary>
    /// <returns><c>true</c>, if new badge unlocked.</returns>
    /// <param name="badge">Badge.</param>
    /// <param name="progress">Progress.</param>
    private bool CheckUnlockProgress(ImmutableDataBadge badge, int progress)
    {
        bool unlockNewBadge = false;

        if (progress >= badge.UnlockCondition) //Check if progress matches unlock conditions
        {
            bool isUnlocked = IsBadgeUnlocked(badge.ID);

            if (!isUnlocked) //Unlock new badges
            {
                DataManager.Instance.GameData.Badge.UpdateBadgeStatus(badge.ID, true, true);
                // Debug.Log("Unlock: " + badge.Name);

                //Send analytics
                Analytics.Instance.BadgeUnlocked(badge.ID);

                //Fire event for UI update
                if (OnNewBadgeUnlocked != null)
                {
                    BadgeEventArgs arg = new BadgeEventArgs(badge);
                    OnNewBadgeUnlocked(this, arg);
                }
                unlockNewBadge = true;
            }
        }
        return(unlockNewBadge);
    }
コード例 #2
0
 public void InitializeAndPlay(GameObject poppedBadge, ImmutableDataBadge badgeData)
 {
     poppedBadgeController = poppedBadge.GetComponent <BadgeController>();
     imageAux.sprite       = SpriteCacheManager.GetBadgeSprite(badgeData.ID);
     transform.position    = poppedBadge.transform.position;
     popAnimation.Play();
 }
コード例 #3
0
    // Show the badge board pop queue board if any
    private IEnumerator TryPopBadgeQueue()
    {
        if (badgeUnlockQueue.Count != 0)
        {
            // If the badge board is not opened already, open the UI and wait a while
            if (!IsOpen)
            {
                float sceneSpecificDelay = Constants.GetConstant <float>("BadgeBoardDelay_" + SceneUtils.CurrentScene);
                yield return(new WaitForSeconds(sceneSpecificDelay));

                OpenUI();
                yield return(new WaitForSeconds(1f));
            }

            ImmutableDataBadge unlockingBadge   = badgeUnlockQueue.Dequeue();
            Transform          badgeGOTransform = badgeGrid.transform.Find(unlockingBadge.ID);
            if (badgeGOTransform != null)
            {
                badgePopController.InitializeAndPlay(badgeGOTransform.gameObject, unlockingBadge);
            }
            else
            {
                Debug.LogWarning("Can not find badge name: " + unlockingBadge.ID);
                CloseUI();                  // Try to fail gracefully
            }
        }
    }
コード例 #4
0
    public void BadgeClicked(GameObject go)
    {
        // Get the information from the populated controller
        AudioManager.Instance.PlayClip("BadgeClicked");
        ImmutableDataBadge clickedBadge = DataLoaderBadges.GetData(go.name);

        descBadgeSprite.sprite = SpriteCacheManager.GetBadgeSprite(BadgeManager.Instance.IsBadgeUnlocked(clickedBadge.ID) ? clickedBadge.ID : null);
        descBadgeTitle.text    = clickedBadge.Name;
        descBadgeInfo.text     = clickedBadge.Description;
        ShowDescriptionPanel();
    }
コード例 #5
0
ファイル: DataLoaderBadges.cs プロジェクト: aliken9/MyZooPets
    protected override void XMLNodeHandler(string id, IXMLNode xmlNode, Hashtable hashData, string errorMessage)
    {
        ImmutableDataBadge data = new ImmutableDataBadge(id, xmlNode, errorMessage);

        // store the data
        if (hashData.ContainsKey(id))
        {
            Debug.LogError(errorMessage + "Duplicate keys!");
        }
        else
        {
            hashData.Add(id, data);
        }
    }
コード例 #6
0
ファイル: BadgeManager.cs プロジェクト: aliken9/MyZooPets
    /// <summary>
    /// Gets the badge unlock at next level.
    /// </summary>
    /// <returns>The badge unlock at next level.</returns>
    public ImmutableDataBadge GetBadgeUnlockAtNextLevel()
    {
        int nextLevel = LevelLogic.Instance.NextLevel;
        ImmutableDataBadge selectedBadge = null;

        foreach (ImmutableDataBadge badge in allBadges)
        {
            if (badge.Type == BadgeType.Level && badge.UnlockCondition == nextLevel)
            {
                selectedBadge = badge;
                break;
            }
        }
        return(selectedBadge);
    }
コード例 #7
0
ファイル: BadgeManager.cs プロジェクト: aliken9/MyZooPets
    /// <summary>
    /// Checks the single unlock progress.
    /// </summary>
    /// <param name="badgeID">Badge I.</param>
    /// <param name="currentProgress">Current progress.</param>
    /// <param name="overrideProgress">If set to <c>true</c> override progress.</param>
    public void CheckSingleUnlockProgress(string badgeID, int currentProgress, bool overrideProgress)
    {
        int latestProgress;
        ImmutableDataBadge badge = DataLoaderBadges.GetData(badgeID);

        //Decides to override or add to recorded progress from DataManager
        if (overrideProgress)
        {
            latestProgress = currentProgress;
        }
        else
        {
            int progress = DataManager.Instance.GameData.Badge.GetSingleUnlockProgress(badgeID);
            latestProgress = progress += currentProgress;
        }

        //Update DataManager only if badge with badgeID is still locked
        if (!CheckUnlockProgress(badge, latestProgress))
        {
            DataManager.Instance.GameData.Badge.UpdateSingleUnlockProgress(badgeID, latestProgress);
        }
    }
コード例 #8
0
    //----------------------------------------------
    // RefreshUnlockPredictions()
    // Update the items/badge/flame that will be unlocked for next level
    //----------------------------------------------
    private void RefreshUnlockPredictions(object sender, EventArgs args)
    {
        foreach (Transform child in gridUnlockPredictions.transform)
        {
            child.gameObject.SetActive(false);
            Destroy(child.gameObject);
        }

        ImmutableDataBadge badge = BadgeManager.Instance.GetBadgeUnlockAtNextLevel();

        if (badge != null)
        {
            GameObject go     = GameObjectUtils.AddChildWithPositionAndScale(gridUnlockPredictions, unlockPredictionEntryPrefab);
            Image      sprite = go.GetComponent <Image>();
            sprite.sprite = SpriteCacheManager.GetBadgeSprite(badge.TextureName);
        }

        ImmutableDataSkill skill = FlameLevelLogic.Instance.GetSkillUnlockAtNextLevel();

        if (skill != null)
        {
            GameObject go     = GameObjectUtils.AddChildWithPositionAndScale(gridUnlockPredictions, unlockPredictionEntryPrefab);
            Image      sprite = go.GetComponent <Image>();
            //Place Holder
            sprite.sprite = SpriteCacheManager.GetSprite(skill.TextureName);
        }

        List <Item> items = ItemManager.Instance.GetItemsUnlockAtNextLevel();

        foreach (Item item in items)
        {
            GameObject go     = GameObjectUtils.AddChildWithPositionAndScale(gridUnlockPredictions, unlockPredictionEntryPrefab);
            Image      sprite = go.GetComponent <Image>();
            sprite.sprite = SpriteCacheManager.GetSprite(item.TextureName);
        }
    }
コード例 #9
0
ファイル: BadgeManager.cs プロジェクト: aliken9/MyZooPets
 public BadgeEventArgs(ImmutableDataBadge badge)
 {
     unlockedBadge = badge;
 }
コード例 #10
0
 public void Init(ImmutableDataBadge _badgeData)
 {
     badgeData    = _badgeData;
     isUnlocked   = BadgeManager.Instance.IsBadgeUnlocked(_badgeData.ID);
     image.sprite = SpriteCacheManager.GetBadgeSprite(isUnlocked ? _badgeData.ID : null);
 }