private void RefreshCoinDisplay()
    {
        Text coinTxt = InGameUICanvasGroup.GetComponentInChildren <Text> ();

        Debug.Log("player data is " + playerDataController.GetPlayerData().coins);
        coinTxt.text = playerDataController.GetPlayerData().coins.ToString();
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        playerDataController = GameObject.FindGameObjectWithTag("Persistent")
                               .GetComponent <PlayerDataController>();
        PlayerData playerData = playerDataController.GetPlayerData();

        equippedItemNames = playerData.equippedItems;
        foreach (string thisItemName in equippedItemNames)
        {
            Debug.Log("(HomeScreenController)" + thisItemName);
        }


        foreach (GameObject thisFurniture in furnitures)
        {
            thisFurniture.SetActive(false);
        }

        foreach (string itemName in equippedItemNames)
        {
            Debug.Log("name of equipped items when HomeScreen is loaded: " + itemName);

            foreach (GameObject thisFurniture in furnitures)
            {
                if (thisFurniture.name.Equals(itemName))
                {
                    Debug.Log("Setting furniture to equipped");
                    thisFurniture.SetActive(true);
                }
            }
        }
    }
Beispiel #3
0
    public void Initialize()                                                  //One bug lies here: when loaded, the equipped items data is not cleared
    {
        playerDataController = GameObject.FindGameObjectWithTag("Persistent") //Get the PlayerDataController
                               .GetComponent <PlayerDataController>();

        if (playerDataController)
        {
            Debug.Log("playerDataController is found successfully");
        }

        purchasedItemsData = new List <EditorModeItemData>();
        equippedItemsData  = new List <EditorModeItemData> ();

        PlayerData playerData = playerDataController.GetPlayerData();

        equippedItemNames = playerData.equippedItems;
        foreach (string str in equippedItemNames)
        {
            Debug.Log("equippedItemName is: " + str);
        }

        purchasedItemNames = playerData.purchasedShopItems;
        foreach (string str in equippedItemNames)
        {
            Debug.Log("purchasedShopItemName is: " + str);
        }

        TextAsset          dataAsJson         = Resources.Load <TextAsset> ("EditorMode/EditorModeData");//Load textual data for EditorModeItemData
        EditorModeJsonData editorModeJsonData = JsonUtility.FromJson <EditorModeJsonData>(dataAsJson.text);

        itemsDataArray = editorModeJsonData.editorModeItemsData;

        itemsData = new List <EditorModeItemData> ();       //Convert to list, fill up the rest of the EditorModeItemData
        foreach (EditorModeItemData itemData in itemsDataArray)
        {
            itemsData.Add(itemData);
        }

        equippedItemsData = ParseItems(equippedItemNames, "equippedItems");
        Debug.Log("When initializing, equippedItemsData.Count = " + (0 + equippedItemsData.Count));
        purchasedItemsData = ParseItems(purchasedItemNames, "purchasedItems");
        Debug.Log("When initializing, purchasedItemsData.Count = " + (0 + purchasedItemsData.Count));
    }
Beispiel #4
0
    public void Initialize()                                                  //One bug lies here: when loaded, the equipped items data is not cleared
    {
        playerDataController = GameObject.FindGameObjectWithTag("Persistent") //Get the PlayerDataController
                               .GetComponent <PlayerDataController>();

        if (playerDataController)
        {
            Debug.Log("playerDataController is found successfully");
        }
        else
        {
            Debug.Log("Did not find playerDataController, please ensure that the playDataController has a tag 'persistent'");
        }


        purchasedItemsData = new List <ShopItemData>();

        playerData         = playerDataController.GetPlayerData();
        purchasedItemNames = playerData.purchasedShopItems;
        displayedItemNames = playerData.displayedShopItems;

        TextAsset    dataAsJson   = Resources.Load <TextAsset> ("Shop/ShopData");  //Load textual data for ShopItemData
        ShopJsonData shopJsonData = JsonUtility.FromJson <ShopJsonData>(dataAsJson.text);

        itemsDataArray = shopJsonData.shopItemsData;
        Debug.Assert(itemsDataArray.Length > 5);
        itemsData = new List <ShopItemData> ();       //Convert to list, fill up the rest of the ShopSItemData
        foreach (ShopItemData itemData in itemsDataArray)
        {
            itemsData.Add(itemData);
        }
        Debug.Assert(itemsData.Count > 5);
        purchasedItemsData = ParseItems(purchasedItemNames, "purchasedItems");
        displayedItemsData = ParseItems(displayedItemNames, "displayedItems");
        Debug.Assert(displayedItemsData.Count > 5);
    }