示例#1
0
 public void Init(string textString = null, string imageSprite = null, GameObject _objectToCall = null, string _functionNameToCall = null, UIModeTypes _modeType = UIModeTypes.None)
 {
     if (!string.IsNullOrEmpty(textString))
     {
         text.text = textString;
     }
     if (!string.IsNullOrEmpty(imageSprite))
     {
         image.sprite = SpriteCacheManager.GetSprite(imageSprite);
     }
     if (_objectToCall != null)
     {
         objectToCall = _objectToCall;
         if (!string.IsNullOrEmpty(_functionNameToCall))
         {
             functionNameToCall = _functionNameToCall;
         }
         button.modeType1    = _modeType;
         button.interactable = true;
     }
     else
     {
         if (button != null)
         {
             button.interactable = false;
         }
     }
 }
示例#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
    public void OnBuyAnimation(Item itemData, GameObject sprite)
    {
        Vector3 origin      = new Vector3(sprite.transform.position.x, sprite.transform.position.y, 0f);
        Vector3 endPosition = origin;

        // depending on what type of item the user bought, the animation has the item going to different places
        switch (itemData.Type)
        {
        case ItemType.Decorations:
            endPosition = DecoInventoryUIManager.Instance.itemFlyToTransform.position;
            break;

        case ItemType.Accessories:
            Debug.LogError("Not implemented yet!");
            break;

        default:                    // Everything else
            endPosition = InventoryUIManager.Instance.itemFlyToTransform.position;
            break;
        }

        GameObject animationSprite = GameObjectUtils.AddChild(sprite.transform.parent.gameObject, boughtItemTweenPrefab);

        animationSprite.transform.position   = origin;
        animationSprite.transform.localScale = new Vector3(90, 90, 1);
        animationSprite.GetComponentInChildren <Image>().sprite = SpriteCacheManager.GetItemSprite(secretItem.ID);
        animationSprite.name = secretItem.ID;

        LeanTween.move(animationSprite, endPosition, 0.666f)
        .setEase(LeanTweenType.easeOutQuad)
        .setOnComplete(OnBuyAnimationDone)
        .setOnCompleteParam(animationSprite);
    }
 public void Init(string miniGameKey, int score)
 {
     //string titleKey = "HIGHSCORE_BOARD_" + miniGameKey;
     miniGameImage.sprite = SpriteCacheManager.GetMinigameEntranceSprite(miniGameKey);
     //miniGameName.text = Localization.Localize(titleKey);
     miniGameHighScore.text = score.ToString();
 }
示例#5
0
    public void Init(Item _itemData)
    {
        itemData = _itemData;

        // set the proper values on the entry
        gameObject.name = itemData.ID;

        string costText = itemData.Cost.ToString();

        labelCost.text    = costText;
        labelName.text    = itemData.Name;
        spriteIcon.sprite = SpriteCacheManager.GetSprite(itemData.TextureName);

        BuyButtonStateCheck();

        // set the description
        SetDescription(itemData);

        // if this item is currently locked...
        if (itemData.IsLocked())
        {
            // show the UI
            LevelLockObject.CreateLock(spriteIcon.gameObject.transform.parent.gameObject, itemData.UnlockAtLevel);

            // delete the buy button
            button.gameObject.SetActive(false);
        }
    }
示例#6
0
    private bool isClickable = true;            // When the card is showing/animating lock the click, internal check of card state

    public void Initialize(ImmutableDataMemoryTrigger triggerData, bool isSprite)
    {
        triggerName = triggerData.Name;

        tweeningCoverParent = coverSprite.transform.parent.gameObject;

        // Set components on start
        if (isSprite)
        {
            triggerSprite.sprite  = SpriteCacheManager.GetSprite(triggerData.SpriteName);
            triggerSprite.name    = triggerData.SpriteName;
            tweeningContentParent = triggerSprite.transform.parent.parent.gameObject;           // Get grandfather
            triggerLabelLocalize.transform.parent.gameObject.SetActive(false);                  // Disable the unused half
        }
        else
        {
            triggerLabelLocalize.key = triggerData.DisplayKey;
            triggerLabelLocalize.Localize();
            tweeningContentParent = triggerLabelLocalize.transform.parent.gameObject;           // Get grandfather
            triggerSprite.transform.parent.parent.gameObject.SetActive(false);                  // Disable the unused half
        }

        // Hide the original card content until its clicked
        tweeningContentParent.SetActive(false);

        // Assign the respective trigger type particle
        GameObject particlePrefab = Resources.Load(triggerData.TypeParticlePrefab) as GameObject;

        triggerTypeParticle = GameObjectUtils.AddChild(gameObject, particlePrefab).GetComponent <ParticleSystem>();
    }
 public void Init(InventoryItem _itemData, Transform _originalParent)
 {
     inventoryData     = _itemData;
     tokenImage.sprite = SpriteCacheManager.GetItemSprite(_itemData.ItemID);
     originalParent    = _originalParent;
     itemType          = _itemData.ItemType;
 }
示例#8
0
    protected abstract void _SetDecoration(string decoID, bool isPlacedFromDecoMode);       // set the deco to this node

    void Start()
    {
        DecoModeUIManager.Instance.OnManagerOpen     += ShowDecoZones;
        InventoryTokenDragElement.OnDecoItemPickedUp += OnDecorationPickedUp;
        InventoryTokenDragElement.OnDecoItemDropped  += OnDecorationDropped;

        spriteIcon.sprite = SpriteCacheManager.GetDecoIconSprite(nodeType);
        nodeID            = transform.parent.name;
        CheckSaveData();
    }
示例#9
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();
    }
示例#10
0
 public void OnBuyButton()
 {
     if (DataManager.Instance.GameData.Inventory.InventoryItems.ContainsKey("Usable1"))
     {
         DataManager.Instance.GameData.Inventory.InventoryItems.Remove("Usable1");
         openingScreen.Hide();
         ImmutableDataRareDeco capsule = DataLoaderRareDeco.GetDecoAtTier(level);
         decoImage.sprite = SpriteCacheManager.GetItemSprite(capsule.ItemId);
         rewardScreen.Show();
         InventoryManager.Instance.AddItemToInventory(capsule.ItemId);
     }
 }
示例#11
0
    public void Init(int deltaPoints, int deltaHealth, int deltaMood, int deltaStars)
    {
        // Turn everything off
        foreach (Image image in imageList)
        {
            image.enabled = false;
        }

        foreach (Text text in textList)
        {
            text.enabled = false;
        }

        int currentListIndex = 0;

        if (deltaPoints != 0)
        {
            string strDeltaPoints = (deltaPoints > 0) ? "+" + deltaPoints : deltaPoints.ToString();
            textList[currentListIndex].enabled  = true;
            imageList[currentListIndex].enabled = true;
            textList[currentListIndex].text     = strDeltaPoints;
            imageList[currentListIndex].sprite  = SpriteCacheManager.GetSprite("IconStarBlank");
            currentListIndex++;
        }
        if (deltaHealth != 0)
        {
            string strDeltaHealth = (deltaHealth > 0) ? "+" + deltaHealth : deltaHealth.ToString();
            textList[currentListIndex].enabled  = true;
            imageList[currentListIndex].enabled = true;
            textList[currentListIndex].text     = strDeltaHealth;
            imageList[currentListIndex].sprite  = SpriteCacheManager.GetSprite("IconHealthBlank");
            currentListIndex++;
        }
        if (deltaMood != 0)
        {
            string strDeltaMood = (deltaMood > 0) ? "+" + deltaMood : deltaMood.ToString();
            textList[currentListIndex].enabled  = true;
            imageList[currentListIndex].enabled = true;
            textList[currentListIndex].text     = strDeltaMood;
            imageList[currentListIndex].sprite  = SpriteCacheManager.GetSprite("IconHungerBlank");
            currentListIndex++;
        }
        if (deltaStars != 0)
        {
            string strDeltaStars = (deltaStars > 0) ? "+" + deltaStars : deltaStars.ToString();
            textList[currentListIndex].enabled  = true;
            imageList[currentListIndex].enabled = true;
            textList[currentListIndex].text     = strDeltaStars;
            imageList[currentListIndex].sprite  = SpriteCacheManager.GetSprite("IconCoinBlank");
            currentListIndex++;
        }
    }
    private MiniPetGameMaster gameMasterScript;                 // Reference to minipet logic

    public void InitializeContent(string taskID, MinigameTypes type, MiniPetGameMaster gameMasterScript)
    {
        this.gameMasterScript = gameMasterScript;
        task = WellapadMissionController.Instance.GetTask(taskID);
        ImmutableDataWellapadTask missionTask = DataLoaderWellapadTasks.GetTask(task.TaskID);
        string desc = missionTask.GetText();

        if (task.Amount > 0)
        {
            desc = String.Format(desc, task.Amount);
        }
        label.text        = desc;
        spriteIcon.sprite = SpriteCacheManager.GetSprite("mapIcons" + type.ToString());
        rewardButton.SetActive(false);
        SetCheckboxSprite(true);
    }
示例#13
0
    /// <summary>
    /// This function does the work and actually sets the UI labels, sprites, etc for this entry based on
    /// the incoming item data.
    /// </summary>
    public void Init(Item newItemData)
    {
        // set the proper values on the entry
        gameObject.name = newItemData.ID;

        // Cache this information
        itemData = (AccessoryItem)newItemData;

        string costText = newItemData.Cost.ToString();

        labelCost.text    = costText;
        labelName.text    = newItemData.Name;
        spriteIcon.sprite = SpriteCacheManager.GetSprite(newItemData.TextureName);

        CheckState();
    }
示例#14
0
    // Called when item bought, creates a sprite for the item and move it to correct inventory
    public void OnBuyAnimation(StoreItemController storeItemScript)
    {
        Vector3 origin      = storeItemScript.GetSpritePosition();
        Vector3 endPosition = InventoryUIManager.Instance.itemFlyToTransform.position;         // TODO change this

        GameObject animationSprite = GameObjectUtils.AddChild(storeSubPanel, boughtItemTweenPrefab);

        animationSprite.GetComponentInChildren <Image>().sprite = SpriteCacheManager.GetItemSprite(storeItemScript.ItemData.ID);
        animationSprite.transform.position = origin;
        animationSprite.name = storeItemScript.ItemData.ID;

        LeanTween.move(animationSprite, endPosition, 0.666f)
        .setEase(LeanTweenType.easeOutQuad)
        .setOnComplete(OnBuyAnimationDone)
        .setOnCompleteParam(animationSprite);
    }
示例#15
0
 public void BuyButtonStateCheck()
 {
     //Check if wallpaper has already been bought. Disable the buy button if so
     if (itemData.Type == ItemType.Decorations)
     {
         DecorationItem decoItem = (DecorationItem)itemData;
         if (decoItem.DecorationType == DecorationTypes.Wallpaper)
         {
             if (InventoryManager.Instance.IsWallpaperBought(decoItem.ID))
             {
                 button.interactable = false;
                 button.GetComponent <Image>().sprite = SpriteCacheManager.GetSprite("ButtonGray");
             }
         }
     }
 }
示例#16
0
    /// <summary>
    /// Spawns one sprite for the visual curve.
    /// </summary>
    IEnumerator SpawnOneSprite(GameObject tweenParent, float delay, StatType statType,
                               Vector3 fromPos, Vector3 toPos, float duration, bool isPlusAnimation,
                               string strSound, Hashtable hashSoundOverrides)
    {
        yield return(new WaitForSeconds(delay));

        if (!string.IsNullOrEmpty(strSound))
        {
            AudioManager.Instance.PlayClip(strSound, option: hashSoundOverrides);
        }

        // Modify some tweening behaviors based on adding or subtracting a stat
        if (isPlusAnimation)
        {
            GameObject go = GameObjectUtils.AddChildGUI(HUDUIManager.Instance.GetStatTweenParents(statType), tweenSpritePrefab);
//			GameObject go = GameObjectUtils.AddChildGUI(gameObject, tweenSpritePrefab);

            go.transform.localPosition = GameObjectUtils.GetRandomPointOnCircumference(go.transform.localPosition, 200f);
//			go.transform.localPosition = fromPos;

            go.GetComponent <Image>().sprite = SpriteCacheManager.GetHudTweenIcon(statType);

            // Addition tweening behavior
//			Vector3[] path = new Vector3[4];
//			path[0] = go.transform.localPosition;
//			Vector3 randomPoint = GameObjectUtils.GetRandomPointOnCircumference(go.transform.localPosition, 200f);
//			path[1] = randomPoint;
//			path[2] = path[1];
//			path[3] = toPos;

//			LeanTween.moveLocal(go, path, duration)
//				.setEase(customEaseCurve)
//				.setOnComplete(StatTick).setOnCompleteParam(statType)
//				.setDestroyOnComplete(true);

            // Just tweening from circumference for now
            LeanTween.moveLocal(go, toPos, duration)
            .setEase(customEaseCurve)
            .setOnComplete(StatTick).setOnCompleteParam(statType)
            .setDestroyOnComplete(true);
        }
        else
        {
            // Negative anim, just jump to tick and bar animate
            StatTick(statType);
        }
    }
示例#17
0
    private MiniPetMerchant merchantScript;         // Reference to minipet logic

    public void InitializeContent(string itemID, bool isBoughtAlready, ItemType itemType, MiniPetMerchant merchantScript)
    {
        this.merchantScript   = merchantScript;
        secretItem            = DataLoaderItems.GetItem(itemID);
        itemNameLabel.text    = secretItem.Name;
        descriptionLabel.text = secretItem.Description;
        itemImage.sprite      = SpriteCacheManager.GetItemSprite(secretItem.ID);

        cost.text = secretItem.Cost.ToString();

        if (isBoughtAlready)                                // Enable some game components here
        {
            buyButton.gameObject.SetActive(false);
        }

        if (itemType == ItemType.Decorations)
        {
            Invoke("ShowDecoInventoryHelper", 1f);              // NOTE: Special invoke delay needed for update position
        }

        HUDUIManager.Instance.ShowPanel();                  // Show the hud because we are buying stuff
    }
    //----------------------------------------------
    // 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);
        }
    }
示例#19
0
    public void Init(StatType statType, int amount)
    {
        // set the icon of the stat (a little hacky unless we need to expand further)
        if (statType == StatType.Hunger)
        {
            spriteIcon.sprite = SpriteCacheManager.GetSprite("iconHungerBlank");
        }
        else if (statType == StatType.Health)
        {
            spriteIcon.sprite = SpriteCacheManager.GetSprite("iconHealthBlank");
        }
        else if (statType == StatType.Fire)
        {
            spriteIcon.sprite = SpriteCacheManager.GetSprite("iconFire");
        }
        else
        {
        }

        // set the label to whatever the amount is, with a + or -, and then add the amount for the text
        string prefix = amount > 0 ? "+" : "";

        labelAmount.text = prefix + amount;
    }
示例#20
0
    /// <summary>
    /// Creates the sub category items with string.
    /// </summary>
    /// <param name="page">Page.</param>
    private void CreateSubCategoryItemsWithString(string page, StoreShortcutType shortcutType = StoreShortcutType.None)
    {
        if (page != "Items" && page != "Food" && page != "Decorations")
        {
            Debug.LogError("Illegal store sub category: " + page);
            return;
        }

        currentPage = page;

        // Reset the grid and scrolling
        scrollRect.StopMovement();
        Vector2 auxPosition = grid.GetComponent <RectTransform>().anchoredPosition;

        grid.GetComponent <RectTransform>().anchoredPosition = new Vector2(0f, auxPosition.y);

        //create the tabs for those sub category
        if (currentPage == "Food")
        {
            InventoryUIManager.Instance.ShowPanel(true);
            DecoInventoryUIManager.Instance.HidePanel();

            foreach (Transform tab in tabArea.transform)
            {
                ToggleTab(tab, false);
            }

            CreateSubCategoryItemsTab("foodDefaultTab", shortcutType);
        }
        else if (currentPage == "Items")
        {
            InventoryUIManager.Instance.ShowPanel(true);
            DecoInventoryUIManager.Instance.HidePanel();

            foreach (Transform tab in tabArea.transform)
            {
                ToggleTab(tab, false);
            }

            CreateSubCategoryItemsTab("itemsDefaultTab", shortcutType);
        }
        else if (currentPage == "Decorations")
        {
            InventoryUIManager.Instance.HidePanel();
            DecoInventoryUIManager.Instance.ShowPanel();

            //Get a list of decoration types from Enum
            string[] decorationEnums = Enum.GetNames(typeof(DecorationTypes));
            int      counter         = 0;

            // Set the default category
            string defaultTabName = "Carpet";
            if (SceneUtils.CurrentScene == SceneUtils.YARD)
            {
                defaultTabName = "SmallPlant";
            }

            List <string> unlockedDecoList = PartitionManager.Instance.GetAllowedDecoTypeFromLatestPartition();

            //Rename the tab to reflect the sub category name
            foreach (Transform tab in tabArea.transform)                        // TODO-s CHANGE THIS TO FIT TABS
            {
                if (counter < decorationEnums.Length)
                {
                    tab.name = decorationEnums[counter];
                    if (tab.name == defaultTabName)
                    {
                        tab.GetComponent <Image>().sprite = SpriteCacheManager.GetSprite("buttonCategoryActive");
                    }
                    Image imageSprite = tab.FindChild("TabImage").gameObject.GetComponent <Image>();
                    imageSprite.sprite = SpriteCacheManager.GetDecoIconSprite((DecorationTypes)Enum.Parse(typeof(DecorationTypes), tab.name));

                    //Debug.Log(tabParent.name);
                    // If the gate xml has the deco type allowed, enable button
                    if (unlockedDecoList.Contains(tab.name))
                    {
                        ToggleTab(tab, true);
                    }
                    // Else disable button
                    else
                    {
                        ToggleTab(tab, false);
                    }
                }
                else
                {
                    tab.name = "";
                    ToggleTab(tab, false);
                }
                counter++;
            }

            //After tabs have been set up create items for the first/default tab
            CreateSubCategoryItemsTab(defaultTabName, shortcutType);
        }
        ShowStoreSubPanel();
    }
示例#21
0
 public void Init(ImmutableDataBadge _badgeData)
 {
     badgeData    = _badgeData;
     isUnlocked   = BadgeManager.Instance.IsBadgeUnlocked(_badgeData.ID);
     image.sprite = SpriteCacheManager.GetBadgeSprite(isUnlocked ? _badgeData.ID : null);
 }
示例#22
0
 /// <summary>
 /// Events from BadgePopController
 /// </summary>
 public void FlipSpriteEvent()
 {
     image.sprite = SpriteCacheManager.GetBadgeSprite(badgeData.ID);
 }