示例#1
0
    void Start()
    {
        var e = ContentItem.GetComponentsInChildren <Text>();

        foreach (var item in e)
        {
            if (item.gameObject.name.Contains("Name"))
            {
                item.text = myItem.NameItem;
            }
            if (item.gameObject.name.Contains("tion"))
            {
                item.text = myItem.Description;
            }
        }

        GameObject[] g = SceneManager.GetSceneByName("PlayCampaing").GetRootGameObjects();
        foreach (var item in g)
        {
            if (item.tag.Contains("Player"))
            {
                main = item.GetComponent <mainController>();
                break;
            }
        }
        RightItem.GetComponentInChildren <Text>().text = myItem.UpCoin.ToString();
        RightItem.GetComponentInChildren <Button>().onClick.AddListener(BuyItem);
        LeftItem.GetComponentInChildren <Image>().sprite = (Sprite)Resources.Load <Sprite>("UI/Shop/" + myItem.TypeItem.ToString());
        OnLoad();
    }
示例#2
0
 void OnLoad()
 {
     GameObject.Find("textGold").GetComponent <Text>().text = main.MyPlayer.Player.Coin.ToString();
     if (RightItem.GetComponentInChildren <Button>().interactable)
     {
         RightItem.GetComponentInChildren <Button>().interactable
             = main.MyPlayer.Player.Coin >= myItem.UpCoin ? true : false;
     }
 }
示例#3
0
 void BuyItem()
 {
     main.GetComponent <mainItemControll>().GetItem(myItem);
     RightItem.GetComponentInChildren <Button>().interactable = false;
 }