public void DisplayActionButtons(Card.CardType cardType, bool newCard = false) { foreach (GameObject button in actionButtons) { if (button.name.Equals(cardType.ToString())) { button.SetActive(true); if (newCard) { foreach (Transform child in button.GetComponentInChildren <Transform>()) { if (cardType.Equals(Card.CardType.NPC) && child.name.Equals("Button Run")) { child.gameObject.SetActive(false); } else { child.gameObject.SetActive(true); } } } } else { button.SetActive(false); } } }
public string PasangItem(RaycastHit2D hit, GameObject item, Card.CardType itemType, Card cardOnHand) { int[] boardPosItemPlaced; Vector3 itemPosition = new Vector3(hit.transform.position.x, hit.transform.position.y, hit.transform.position.z); if (hit.collider.gameObject.name == "Waypoint") { boardPosItemPlaced = new int[] { 1 }; } else { string resultString = Regex.Match(hit.collider.gameObject.name, @"\d+").Value; int clickPosisi = int.Parse(resultString) + 1; if (itemType == Card.CardType.Ladder2Tail || itemType == Card.CardType.Snake2Head) { boardPosItemPlaced = new int[] { clickPosisi - 1, clickPosisi + 1 }; } else { boardPosItemPlaced = new int[] { clickPosisi }; } } // DICOMMENT KARENA TESTING if (GameObject.Find(item.name + "(Clone)") != null) { PhotonNetwork.Destroy(GameObject.Find(item.name + "(Clone)")); } string itemPrefabPath = "Items/" + cardOnHand.Level.ToString() + "/" + itemType.ToString() + "/" + item.name; this.ItemOnHand = new Item { Owner = PlayerScript.PlayerNickname, Age = 0, BoardPosition = boardPosItemPlaced[0], Type = itemType, ItemObject = PhotonNetwork.Instantiate(itemPrefabPath, itemPosition, item.transform.rotation), }; if (!this.ItemOnHand.ItemObject.activeSelf) { this.ItemOnHand.ItemObject.SetActive(true); } // DICOMMENT KARENA TESTING if (CheckTailTrigger.TriggerByTail) { CheckTailTrigger.TriggerByTail = false; } this.ItemOnHand.ItemObject.transform.Find("gambar").gameObject.SetActive(false); this.ItemOnHand.Spawn(hit.collider.gameObject.transform.position); ClickMousePlaceItem = true; return("snake/ladder putted"); }