Example #1
0
    public void SaveFaction()
    {
        if ((faction.factionName != null) && (faction.playerName != null) && (faction.voice != VoiceType.COUNT) && (faction.style != FactionStyle.COUNT) && (faction.attribute != Attribute.COUNT))
        {
            Debug.Log("You can move on to faction screen");
            createFactionPanel.SetActive(false);
            factionPanel.SetActive(true);
            FactionData.ExportJSON(faction, faction.factionName + ".json");
            GameObject newButton = Instantiate(buttonprefab);
            newButton.transform.SetParent(content.transform);
            newButton.GetComponent <Button>().onClick.AddListener(delegate { factionScript.FactionSelection(newButton.GetComponent <Button>()); });
            newButton.transform.localScale = new Vector3(1, 1, 1);
            content.sizeDelta = new Vector2(content.rect.width, content.rect.height + 20);

            for (int i = 0; i < newButton.transform.childCount; i++)
            {
                Transform child      = newButton.transform.GetChild(i);
                Image     childImage = null;
                Debug.Log(child.name);
                if ((childImage = child.GetComponent <Image>()) != null)
                {
                    if (child.name == "Pic")
                    {
                        childImage.GetComponent <Image>().sprite = faction.playerPortrait;
                    }
                    if (child.name == "FoodPic")
                    {
                        switch (faction.style)
                        {
                        case FactionStyle.AMERICAN:
                            child.gameObject.GetComponent <Image>().sprite = burgerSprite;
                            break;

                        case FactionStyle.ITALIAN:
                            child.gameObject.GetComponent <Image>().sprite = pizzaSprite;
                            break;

                        case FactionStyle.MEXICAN:
                            child.gameObject.GetComponent <Image>().sprite = tacoSprite;
                            break;
                        }
                    }
                }
            }

            newButton.GetComponentInChildren <Text>().text = faction.factionName;

            factionScript.ResetFactionCreation();
        }
        else
        {
            Debug.Log("You can't move on");
        }
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        FactionData Jeffe = new FactionData();

        Jeffe.playerName     = "Jeffe Silverbum";
        Jeffe.factionName    = "Silverbum Kitchens";
        Jeffe.style          = FactionStyle.MEXICAN; // Mexican
        Jeffe.voice          = VoiceType.GUY;        // Guy Ferriari
        Jeffe.playerPortrait = presetFaction1.Find("JeffePic").GetComponent <Image>().sprite;
        Jeffe.attribute      = Attribute.MANAGERRIGHT;
        FactionData.ExportJSON(Jeffe, "Jeffe.json");

        FactionData Ramsey = new FactionData();

        Ramsey.playerName     = "Gordon Ramsey";
        Ramsey.factionName    = "Ramsey Enterprises";
        Ramsey.style          = FactionStyle.AMERICAN; // American
        Ramsey.voice          = VoiceType.GORDON;      // Gordon Ramsay
        Ramsey.playerPortrait = presetFaction2.Find("GordonPic").GetComponent <Image>().sprite;
        Ramsey.attribute      = Attribute.QUALITY;
        FactionData.ExportJSON(Ramsey, "Ramsey.json");
    }