Ejemplo n.º 1
0
    public static List <GameObject> GetShopItemGameObj(ShopItemKind kind)
    {
        List <ShopItemData> List_Temp = GetShopItemDatas(kind);

        if (List_Temp == null)
        {
            return(null);
        }

        List <GameObject> List_ObjTemp = new List <GameObject>();

        foreach (ShopItemData child in List_Temp)
        {
            if (child.IsOpen)
            {
                List_ObjTemp.Add(Instantiate(child.ShopObj));
                List_ObjTemp[List_ObjTemp.Count - 1].transform.Find("Image").GetComponent <Image>().sprite = child.ShopImage;
                Buy_Button Temp_buy_Button = List_ObjTemp[List_ObjTemp.Count - 1].transform.Find("Button").gameObject.AddComponent <Buy_Button>();
                Temp_buy_Button.setShopItemData(child, kind);
            }
        }
        if (m_ShopItemMenu_ShowOn.ContainsKey(kind))
        {
            m_ShopItemMenu_ShowOn.Remove(kind);
        }
        m_ShopItemMenu_ShowOn.Add(kind, List_ObjTemp);
        return(List_ObjTemp);
    }
Ejemplo n.º 2
0
    static List <ShopItemData> GetShopItemDatas(ShopItemKind kind)
    {
        foreach (KeyValuePair <ShopItemKind, List <ShopItemData> > child in getShopMenuDictionary())
        {
            if (child.Key == kind)
            {
                return(child.Value);
            }
        }

        Debug.Log("No [" + kind.ToString() + "] shopList!!");
        return(null);
    }
Ejemplo n.º 3
0
    public static bool CompareShopItemData(ShopItemKind kind, List <GameObject> Old_shopItemDatas)
    {
        List <GameObject> New_List_Temp = m_ShopItemMenu_ShowOn[kind];

        if (Old_shopItemDatas.Count != New_List_Temp.Count)
        {
            return(false);
        }
        if (New_List_Temp != Old_shopItemDatas)
        {
            return(false);
        }
        return(true);
    }
Ejemplo n.º 4
0
    public static void BuyWithCoin(ShopItemData vShopData, ShopItemKind shopItemKind)
    {
        if (main_playerInfo.GoldCoin < vShopData.ShopPrice)
        {
            Debug.Log("你的金錢不夠喔");
            return;
        }
        //從這裡看
        switch (shopItemKind)
        {
        case ShopItemKind.Man:
        {
            FindObjectOfType <Man>().setManSkin(vShopData.ShopImage);
            break;
        }

        case ShopItemKind.Box:
        {
            Spawner spawner = FindObjectOfType <Spawner>();
            spawner.BoxSkin = vShopData.ShopImage;
            break;
        }

        case ShopItemKind.Lava:
        {
            mainLava m_mainLava = Grid.getGrid.mainLava;
            m_mainLava.setLavaSkin(vShopData.ShopImage);
            break;
        }

        default:
            break;
        }
        //已購買過只要換圖即可
        if (vShopData.ShopPrice == -999)
        {
            Debug.Log("已購買過了");
            main_playerInfo.SetPresetItemData(vShopData);
            SavePlayerInfo_Local(main_playerInfo);
            return;
        }

        main_playerInfo.GoldCoin -= vShopData.ShopPrice;
        main_playerInfo.ItemDatas.Add(vShopData);
        set_Board();
        SavePlayerInfo_Local(main_playerInfo);
    }
Ejemplo n.º 5
0
    public static void RefreshShopItemGameObj(ShopItemKind kind)
    {
        List <ShopItemData> List_Temp = GetShopItemDatas(kind);

        if (List_Temp == null)
        {
            return;
        }
        List <GameObject> List_GameObj = m_ShopItemMenu_ShowOn[kind];

        if (List_GameObj == null)
        {
            return;
        }
        for (int i = 0; i < List_GameObj.Count; i++)
        {
            Buy_Button Temp_buy_Button = List_GameObj[i].transform.Find("Button").gameObject.GetComponent <Buy_Button>();
            Temp_buy_Button.setShopItemData(List_Temp[i], kind);
        }
    }
Ejemplo n.º 6
0
 public void setShopItemData(ShopItemData shopItemData, ShopItemKind m_shopItemKind)
 {
     m_ShopItemData = shopItemData;
     shopItemKind   = m_shopItemKind;
     foreach (ShopItemData child in PlayerManager.get_main_playerInfo().ItemDatas.ToList())
     {
         if (m_ShopItemData.ShopNumber == child.ShopNumber)
         {
             m_ShopItemData.ShopPrice = -999;
             transform.Find("Text").GetComponent <Text>().text = "已購買";
             if (PlayerManager.get_main_playerInfo().PresetItemDatas.Contains(m_ShopItemData))
             {
                 transform.Find("Text").GetComponent <Text>().text = "使用中";
                 Debug.Log("kind:" + shopItemKind + "/data:" + shopItemData.ShopNumber);
                 PlayerManager.BuyWithCoin(m_ShopItemData, shopItemKind);
             }
             return;
         }
     }
     transform.Find("Text").GetComponent <Text>().text = m_ShopItemData.ShopPrice.ToString();
 }