public void buyInvItem() { GameObject lastHit = UICamera.hoveredObject.transform.parent.gameObject; string title = lastHit.transform.Find("title").GetComponent<UILabel>().text; string spriteName = lastHit.transform.Find("icon_back/item_icon").GetComponent<UISprite>().spriteName; int quantityStr = int.Parse(lastHit.transform.Find("quantity").GetComponent<UILabel>().text); int priceStr = int.Parse(lastHit.transform.Find("price").GetComponent<UILabel>().text); Debug.Log(title + "," + spriteName + "," + quantityStr + "," + priceStr); Inventory.Row newItemRow = new Inventory.Row(title, spriteName, quantityStr, priceStr); GO_Player.GetComponent<PlayerController>().BuyItem(newItemRow); }
public bool BuyItem(Inventory.Row itemRow) { if(mCredits >= itemRow.credits){ mCurrentItem = itemRow; mCredits -= itemRow.credits; mState = PlayerState.Navigation; mDOCK_ENABLED = false; GameObject[] all_stations = GameObject.FindGameObjectsWithTag("Station"); GameObject oldStation = mDestinationStation; while(mDestinationStation == oldStation){ int randIndex = (int)(Random.value * all_stations.Length); mDestinationStation = all_stations[randIndex]; } mClosestStation.GetComponent<StationController>().tearDownShopPanel(); mClosestStation = null; return true; } return false; }