Пример #1
0
    void GenerateList()
    {
        for (int i = 0; i < pickaxeList.Count; i++)
        {
            GameObject  info       = Instantiate(pickaxeInfoPrefab, grid, false);
            PickaxeInfo infoScript = info.GetComponent <PickaxeInfo>();

            Debug.Log("ID: " + pickaxeList[i].pickaxeID);

            infoScript.pickaxePower.text = pickaxeList[i].pickaxePower.ToString();
            infoScript.pickaxeName.text  = pickaxeList[i].pickaxeName;
            infoScript.pickaxeID         = pickaxeList[i].pickaxeID;
            infoScript.pickaxePrice.text = pickaxeList[i].pickaxePrice.ToString();

            Debug.Log("Name: " + pickaxeList[i].pickaxeName);

            infoScript.buyButton.GetComponent <BuyPickaxe>().pickaxeID = pickaxeList[i].pickaxeID;

            pickaxeInfoList.Add(info);
            buyButtonList.Add(infoScript.buyButton);

            if (pickaxeList[i].bought)
            {
                infoScript.pickaxeImage.sprite = Resources.Load <Sprite>("Sprites/" + pickaxeList[i].boughtImageName);
            }
            else
            {
                infoScript.pickaxeImage.sprite = Resources.Load <Sprite>("Sprites/" + pickaxeList[i].unboughtImageName);
            }
        }
    }
Пример #2
0
 public void UpdateImage(int pickaxeID)
 {
     for (int i = 0; i < pickaxeInfoList.Count; i++)
     {
         PickaxeInfo infoScript = pickaxeInfoList[i].GetComponent <PickaxeInfo>();
         if (infoScript.pickaxeID == pickaxeID)
         {
             for (int j = 0; j < pickaxeList.Count; j++)
             {
                 if (pickaxeList[j].pickaxeID == pickaxeID)
                 {
                     if (pickaxeList[j].bought)
                     {
                         infoScript.pickaxeImage.sprite = Resources.Load <Sprite>("Sprites/" + pickaxeList[i].boughtImageName);
                         infoScript.pickaxePrice.text   = "Owned";
                     }
                     else
                     {
                         infoScript.pickaxeImage.sprite = Resources.Load <Sprite>("Sprites/" + pickaxeList[i].unboughtImageName);
                     }
                 }
             }
         }
     }
 }
Пример #3
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        if (gameObject.GetComponent <PickaxeInfo>())
        {
            pickaxeInfo       = GetComponent <PickaxeInfo>();
            thisTooltipString = ("Name: " + pickaxeInfo.pickaxe.name + System.Environment.NewLine +
                                 "Cost: " + pickaxeInfo.pickaxe.goldValue.ToString() + System.Environment.NewLine +
                                 "Mining Power: " + pickaxeInfo.pickaxe.miningPower.ToString() + System.Environment.NewLine +
                                 "Swing Speed: " + pickaxeInfo.pickaxe.swingSpeed.ToString());
        }

        else if (gameObject.GetComponent <WeaponInfo>())
        {
            weaponInfo        = GetComponent <WeaponInfo>();
            thisTooltipString = ("Name: " + weaponInfo.weapon.name + System.Environment.NewLine +
                                 "Cost: " + weaponInfo.weapon.goldValue.ToString() + System.Environment.NewLine +
                                 "Attack Power: " + weaponInfo.weapon.attackPower.ToString() + System.Environment.NewLine +
                                 "Swing Speed: " + weaponInfo.weapon.swingSpeed.ToString());
        }
        tooltip.gameObject.SetActive(true);
        tooltip.ShowTooltip_Static(thisTooltipString);
    }