public GameObject Create(string name, int x, int y, TiposPeca tipo) { Game game = FindObjectOfType <Game>(); ChessPiece = game.GetComponent <Game>().ChessPiece; GameObject obj = Instantiate(ChessPiece, new Vector3(0, 0, -1), Quaternion.identity); Chessman cm = obj.GetComponent <Chessman>(); //We have access to the GameObject, we need the script cm.name = name; //This is a built in variable that Unity has, so we did not have to declare it before cm.SetXBoard(x); cm.SetYBoard(y); cm.SetTipoPeca(tipo); cm.Activate(name); //It has everything set up so it can now Activate() return(obj); }
//Auxiliares bool PieceExist(int x, int y, TiposPeca tipo) { GameObject Controller = GameObject.FindGameObjectWithTag("GameController"); Game jogo = Controller.GetComponent <Game>(); GameObject posicao = jogo.GetPosition(x, y); if (posicao == null) { return(false); } TiposPeca tipoPecaInimiga = posicao.GetComponent <Chessman>().GetTiposPeca(); if (jogo.PositionOnBoard(x, y) && !(jogo.GetPosition(x, y) == null) && tipoPecaInimiga == tipo) { return(true); } else { return(false); } }
public bool VerifyPromotion(string name) { GameObject peca = GameObject.Find(name); TiposPeca tipoPeca = peca.GetComponent <Chessman>().tipo; if (peca.GetComponent <Chessman>().promovida == true) { return(false); } else if (tipoPeca == TiposPeca.white_pawn && peca.GetComponent <Chessman>().GetYBoard() == 7) { promotionPanel.GetComponent <PromotionButtons>().SetChesspiece(peca); promotionPanel.SetActive(true); return(true); } else if (tipoPeca == TiposPeca.black_pawn && peca.GetComponent <Chessman>().GetYBoard() == 0) { promotionPanel.GetComponent <PromotionButtons>().SetChesspiece(peca); promotionPanel.SetActive(true); return(true); } return(false); }
public void SetTipoPeca(TiposPeca tipopeca) { tipo = tipopeca; }