//Set the info given by the CharacterSelectionTable
 public void SetInfo(LevelCharactersInfo.Character info)
 {
     myInfo = info;
     if (info != null)
     {
         Enable_CharacterSlot();
     } else
     {
         Set_EmptySprite();
     }
 }
    //Character has been confirmed, display character sprite
    public void SetSprite(LevelCharactersInfo.Character info)
    {
        charInfo = info;

        myIcon.spriteName = charInfo.npcTexture;
        myIcon.enabled = true;

        myStretch.initialSize.Set(myIcon.GetAtlasSprite().inner.width, myIcon.GetAtlasSprite().inner.height);

        nameLabel.text = charInfo.npcName;
        nameLabel.enabled = true;

        myBorder.enabled = true;

        cancelSprite.enabled = true;

        backgroundLabel.enabled = false;
        myBackground.spriteName = backgroundSpriteName_Blank;
    }
    //Slot has been selected, display character and corresponding info (from server)
    public void Set_CurrentCharacter(LevelCharactersInfo.Character info)
    {
        charInfo = info;
        currentCharacterSprite.enabled = true;
        currentCharacterSprite.spriteName = charInfo.npcTexture;
        characterNameLabel.text = charInfo.npcName;
        UIStretch stretch = currentCharacterSprite.gameObject.GetComponent<UIStretch>();
        stretch.initialSize.Set(currentCharacterSprite.GetAtlasSprite().inner.width,
                                currentCharacterSprite.GetAtlasSprite().inner.height);

        characterBubbleSprite.spriteName = characterBubbleBlankSpriteName;
        descriptionBubbleSprite.spriteName = descriptionCategoriesSprite;

        #if !UNITY_WEBPLAYER
        if (charInfo.npcId != -1)
        {
            if (ApplicationState.Instance.previousLevel == ApplicationState.LevelNames.MAIN_MENU)
            {
                DBNPCMiniGameInfo npcInfo = MainDatabase.Instance.getNPCInfo(charInfo.npcId);
                characterLessonLabel.text = MainDatabase.Instance.getCategory(charInfo.npcId);
                characterStarLabel.text = npcInfo.Stars.ToString();
                characterMinigameNameLabel.text = npcInfo.MiniGame;
                characterMinigameDescriptionLabel.text = npcInfo.MiniGameDescription;
                List<float> scorePercentages = MainDatabase.Instance.calTotalPercentage(charInfo.npcId, ApplicationState.Instance.userID);

                if (scorePercentages != null)
                {
                    for (int i = 0; i < scoreLabelsList.Count; i++)
                    {

                        if (float.IsNaN(scorePercentages [i]))
                        {
                            scoreLabelsList [i].text = "--";
                            scoreLabelsList [i].color = Color.black;
                        } else
                            scoreLabelsList [i].text = Mathf.Round(scorePercentages [i]).ToString() + "%";

                        if (scorePercentages [i] < 50)
                            scoreLabelsList [i].color = Color.red;
                        else if (scorePercentages [i] < 70)
                            scoreLabelsList [i].color = new Color(255, 193, 0);
                        else if (scorePercentages [i] <= 100f)
                            scoreLabelsList [i].color = Color.green;
                        else
                        {
                            scoreLabelsList [i].color = Color.black;
                        }
                    }
                } else
                {
                    Debug.LogWarning("No aggregated data found");
                    for (int i = 0; i < scoreLabelsList.Count; i++)
                    {
                        scoreLabelsList [i].text = "--";
                        scoreLabelsList [i].color = Color.black;
                    }
                }
            }
            else
            {
                descriptionBubbleSprite.spriteName = descriptionCategoriesSpriteChild;
                descriptionToySprite.spriteName = charInfo.toyInfo.Filename;
                descriptionToyStretch.initialSize = new Vector2 (descriptionToySprite.mInner.width, descriptionToySprite.mInner.height);

                float r = (float) charInfo.toyInfo.ToyColorR/255;
                float g = (float) charInfo.toyInfo.ToyColorG/255;
                float b = (float) charInfo.toyInfo.ToyColorB/255;

                Color col = new Color(r, g, b, 1);
                descriptionToySprite.color = col;
                descriptionToySprite.enabled = true;

            }
        }
        #endif

        //red: 0 - 49
        //yellow 50 - 74
        //green 75 - 100

        if (occupiedSlots < availableSlots.Count)
        {
            gameObject.SetActive(true);
            setActiveWithButtonSound();
        }
    }