public void MakeButton(Vector3 position, DiceSkin dS)
    {
        GameObject newButton = Instantiate(buttonPrefab, this.GetComponent <RectTransform>(), false);

        newButton.GetComponent <RectTransform>().position = position;

        newButton.GetComponent <DiceButtonDiceSelection>().ChangeButton(dS.GetDiceImage(), dS.GetDiceName(), unlockImage, dS.GetDiceButtonColour());
    }
    private DiceSkin FindDiceSkin(string name)
    {
        DiceSkin newDiceSkin = null;

        foreach (DiceSkin dS in GameObject.Find("DiceSkinHolder").GetComponents <DiceSkin>())
        {
            if (dS.GetDiceName().ToUpper().Contains(name.ToUpper()))
            {
                newDiceSkin = dS;
            }
        }

        return(newDiceSkin);
    }
Example #3
0
 public void ShowPopupInfo()
 {
     if (_myDiceName != null && FindDiceSkin(_myDiceName) != null)
     {
         DiceSkin dS = FindDiceSkin(_myDiceName);
         GameObject.Find("PopupCanvas").GetComponent <PopupCanvasDiceSelection>().Popup(dS.GetDiceInfoTitle(), dS.GetDiceInfoBody(), dS.GetDiceImage());
     }
     else if (this.gameObject.name.Contains("DefaultDice"))
     {
         GameObject.Find("PopupCanvas").GetComponent <PopupCanvasDiceSelection>().Popup("Default Dice", "Dice for scrubs", null);
     }
     else
     {
         GameObject.Find("PopupCanvas").GetComponent <PopupCanvasDiceSelection>().Popup("DICE LOCKED", "You need a higher relationship level to unlock this dice", null);
     }
 }
    public void SetupDiceCanvas(string characterName)
    {
        //Finding the relationship and character dice profile we are working with
        Relationship         currRelationship = FindRelationship(characterName);
        CharacterDiceProfile currCDP          = FindCharacterDiceProfile(characterName);

        //Getting starting position of button

        for (int i = 0; i < this.transform.childCount; i++)
        {
            if (!this.transform.GetChild(i).name.Contains("DontClear"))
            {
                Destroy(this.transform.GetChild(i).gameObject);
            }
        }

        Vector3 tempButtonPos = _buttonPos;

        //Get Level
        int level = currRelationship.GetCurrLevel();

        //For each unlock level, instantiate a new dice button
        for (int i = 0; i < currCDP.GetUnlockLevels().Count; i++)
        {
            if (level >= currCDP.GetUnlockLevels()[i])
            {
                DiceSkin newDiceSkin = FindDiceSkin(currCDP.GetDiceTypes()[i]);
                MakeButton(tempButtonPos, newDiceSkin);
            }
            else
            {
                MakeLockedButton(tempButtonPos, currCDP.GetUnlockLevels()[i]);
            }

            //Increase the gap between buttons
            tempButtonPos.y -= buttonGap;
        }

        //Get the objects that aren't destroyed on reset
        GameObject dontClear = Utilities.SearchChild("DontClear", this.gameObject);

        //Change the character image
        Utilities.SearchChild("CharacterImage", dontClear).GetComponent <Image>().sprite = currCDP.GetCharacterImage();

        //Change superficial info
        Utilities.SearchChild("CharactersDice", dontClear).GetComponent <Text>().text = currCDP.GetCharacterName() + "'s Dice (Relationship Lvl: " + currRelationship.GetCurrLevel() + ")";
    }