void ActiveSupplyKeyPress() { if (ActiveSupplyUI.activeSelf == true) { if (Input.GetKeyDown(KeyCode.Mouse0)) //Left click (or primary click) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction); if (Physics2D.Raycast(ray.origin, ray.direction)) { if (hit.transform.gameObject.GetComponent <OnCardScript>()) { ASbuyButton.SetActive(true); cardSeleceted = int.Parse(hit.transform.gameObject.name); ASNotEnoughResource.gameObject.SetActive(false); } else if (!hit.transform.gameObject.GetComponent <OnCardScript>() && !ASbuyButton) { ASNotEnoughResource.gameObject.SetActive(false); ASbuyButton.SetActive(false); } } } } }
public void BuyCard() { if (activePlayer.resourceValue < copyOfCompleteDeckOfCards[cardSeleceted].cardCost) { ASNotEnoughResource.gameObject.SetActive(true); ASNotEnoughResource.text = "Not Enough " + activePlayer.resourceName; ASbuyButton.SetActive(false); } else if (activePlayer.resourceValue >= copyOfCompleteDeckOfCards[cardSeleceted].cardCost) { copyOfCompleteDeckOfCards[cardSeleceted].cardCount -= 1; activePlayer.grave.Add(cardSeleceted); activePlayer.resourceValue -= copyOfCompleteDeckOfCards[cardSeleceted].cardCost; ActiveSupplyRef.DisplayActiveSupply(activePlayer); //refresh activePlayer.activeSupplyResourceUI.GetComponent <Animator>().ResetTrigger("resourceChange"); activePlayer.activeSupplyResourceUI.transform.GetChild(0).GetComponent <Text>().text = "-" + copyOfCompleteDeckOfCards[cardSeleceted].cardCost.ToString(); activePlayer.activeSupplyResourceUI.GetComponent <Animator>().SetTrigger("resourceChange"); } }
public void ShowActiveSupply() { cardSeleceted = -1; setActiveBool = !setActiveBool; ActiveSupplyUI.SetActive(setActiveBool); MainUI.SetActive(!setActiveBool); if (setActiveBool == true) { ActiveSupplyRef.DisplayActiveSupply(activePlayer); activePlayer.activeSupplyResourceUI.GetComponent <Animator>().ResetTrigger("resourceChange"); activePlayer.activeSupplyResourceUI.transform.GetChild(0).GetComponent <Text>().text = ""; } if (setActiveBool == false) { ASbuyButton.SetActive(false); resourceNameandvalue.text = activePlayer.resourceName + ": " + activePlayer.resourceValue; activePlayer.resourceUI.GetComponent <Animator>().ResetTrigger("resourceChange"); activePlayer.resourceUI.transform.GetChild(0).GetComponent <Text>().text = ""; } }