void pecaReceived(Peca peca) { GlobalConfigInfo.movesCount += 1; MovesCount.text = GlobalConfigInfo.movesCount.ToString(); GlobalConfigInfo.currentPlayerTurn = GlobalConfigInfo.playingIdentifier; if (GlobalConfigInfo.blockchain.TransactionPool.Count != 0) { GameObject instance = Instantiate(TransactionPrefab); instance.GetComponent <TransactionViewModel>().transaction = GlobalConfigInfo.blockchain.TransactionPool[GlobalConfigInfo.blockchain.TransactionPool.Count - 1]; instance.GetComponent <TransactionViewModel>().StartViewModel(); } //Process the UI PecaViewModel pvm = Instantiate(PecaPrefab).GetComponent <PecaViewModel>(); pvm.peca = peca; pvm.StartViewModel(); pvm.fatherTransform = GameObject.FindGameObjectWithTag("baralhoPecaAdversarioUIVisualizer").transform; pvm.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); GlobalConfigInfo.dominoAdm.JogadaValida(pvm); Debug.Log("Moves count: " + GlobalConfigInfo.movesCount); Debug.Log($"A : {peca.ValorA} | B : {peca.ValorB}"); }
public bool JogadaValida(PecaViewModel p) { RectTransform rect = p.GetComponent <RectTransform>(); if (p.peca.ValorA == ValorExtremidadeA) { p.transform.SetParent(posicaoExtremidadeA); rect.anchoredPosition = new Vector2(0, 0); p.transform.SetParent(p.fatherTransform); ValorExtremidadeA = p.peca.ValorB; rect.Rotate(new Vector3(0, 0, 270)); posicaoExtremidadeA.GetComponent <RectTransform>().anchoredPosition = new Vector2(posicaoExtremidadeA.GetComponent <RectTransform>().anchoredPosition.x - 100, posicaoExtremidadeA.GetComponent <RectTransform>().anchoredPosition.y); return(true); } else if (p.peca.ValorA == ValorExtremidadeB) { p.transform.SetParent(posicaoExtremidadeB); rect.anchoredPosition = new Vector2(0, 0); p.transform.SetParent(p.fatherTransform); ValorExtremidadeB = p.peca.ValorB; rect.Rotate(new Vector3(0, 0, 90)); posicaoExtremidadeB.GetComponent <RectTransform>().anchoredPosition = new Vector2(posicaoExtremidadeB.GetComponent <RectTransform>().anchoredPosition.x + 100, posicaoExtremidadeB.GetComponent <RectTransform>().anchoredPosition.y); return(true); } else if (p.peca.ValorB == ValorExtremidadeA) { p.transform.SetParent(posicaoExtremidadeA); rect.anchoredPosition = new Vector2(0, 0); p.transform.SetParent(p.fatherTransform); ValorExtremidadeA = p.peca.ValorA; rect.Rotate(new Vector3(0, 0, 90)); posicaoExtremidadeA.GetComponent <RectTransform>().anchoredPosition = new Vector2(posicaoExtremidadeA.GetComponent <RectTransform>().anchoredPosition.x - 100, posicaoExtremidadeA.GetComponent <RectTransform>().anchoredPosition.y); return(true); } else if (p.peca.ValorB == ValorExtremidadeB) { p.transform.SetParent(posicaoExtremidadeB); rect.anchoredPosition = new Vector2(0, 0); p.transform.SetParent(p.fatherTransform); ValorExtremidadeB = p.peca.ValorA; rect.Rotate(new Vector3(0, 0, 270)); posicaoExtremidadeB.GetComponent <RectTransform>().anchoredPosition = new Vector2(posicaoExtremidadeB.GetComponent <RectTransform>().anchoredPosition.x + 100, posicaoExtremidadeB.GetComponent <RectTransform>().anchoredPosition.y); return(true); } else { return(false); } }