/** * Takes a string, formatted in json, of all of the items that * the player has this round. */ void resetHand(string itemsText) { //TODO: clear current cards JSONNode items = JSON.Parse(itemsText); int len = items["destructive"]["public"].Count; allWeapons = new WeaponCard[len]; for (System.Int32 i = 0; i < len; i++) { //Debug.Log(items["destructive"]["public"][i].ToString()); WeaponCard card = Instantiate <WeaponCard>(itemCardPrefab); card.transform.parent = canvas.transform; card.initCard(items["destructive"]["public"][i]); card.transform.localPosition = new Vector3(LEFTMOST_CARD + i * CARD_SPACING, CARD_Y, CARD_Z); card.transform.localScale = new Vector3(CARD_SCALE, CARD_SCALE, CARD_SCALE); card.GetComponent <Button>().onClick.AddListener(() => playerClickWeapon(card)); allWeapons[i] = card; } }
public void playerClickCountry(CountryCard card) { currentWeapon.attacking = card; LineRenderer lr = currentWeapon.GetComponent <LineRenderer>(); lr.enabled = true; lr.SetPosition(0, currentWeapon.transform.position); lr.SetPosition(1, card.transform.position); foreach (WeaponCard c in allWeapons) { if (c.attacking == null) { c.GetComponent <Button>().interactable = true; } else { c.GetComponent <Button>().interactable = false; } } foreach (CountryCard c in allCountries) { c.GetComponent <Button>().interactable = false; } }