public void MovePlateSpawn(int matrixX, int matrixY, Tipos tipo, string name) { /*Recebe os valores do tabuleiro para converter para * coordenadas x e y*/ float x = matrixX; float y = matrixY; //Adjust by variable offset x *= 0.66f; y *= 0.66f; //Adiciona constantes (posição 0,0) x += -2.3f; y += -2.3f; //Objeto mp recebe o "objeto" moveplate no xyz //(ainda não está no tabuleiro,e sim possui um x y e z teorico ) movePlate = FindObjectOfType <Chessman>().MovePlate; GameObject mp = Instantiate(movePlate, new Vector3(x, y, -3.0f), Quaternion.identity); //Mpscript recebe o Component do moveplate MovePlate mpScript = mp.GetComponent <MovePlate>(); switch (tipo) { case Tipos.Attack: mpScript.Attack = true; break; case Tipos.Castling: mpScript.Castling = true; break; case Tipos.DoubleMovePawn: mpScript.DoubleMovePawn = true; break; case Tipos.EnPassant: mpScript.EnPassant = true; break; case Tipos.Normal: mpScript.Normal = true; break; } GameObject objeto = GameObject.Find(name); //Coloca a peça atual como peça ligada ao Moveplate mpScript.SetReference(objeto); /*setamos as coordenadas no tabuleiro,logo * agora o moveplate existe*/ mpScript.SetCoords(matrixX, matrixY); }
/* * Denne funktion spawner "moveplatesne". Den bruger lidt matematik i starten for at være sikker på de er placeret rigtigt * i felterne. Derefter placerer den moveplaten og gør det til et objekt. */ public void MovePlateSpawn(int matrixX, int matrixY) { float x = matrixX; float y = matrixY; x *= 1.105f; y *= 1.105f; x += -6.08f; y += -3.87f; GameObject mp = Instantiate(movePlate, new Vector3(x, y, -3.0f), Quaternion.identity); MovePlate mpScript = mp.GetComponent <MovePlate>(); mpScript.SetReference(gameObject); mpScript.SetCoords(matrixX, matrixY); }
public void MovePlateAttackSpawn(int matrixX, int matrixY) { float x = matrixX; float y = matrixY; x *= 0.66f; y *= 0.66f; x += -2.3f; y += 0.71f; GameObject mp = Instantiate(movePlate, new Vector3(x, y - 3.0f), Quaternion.identity); MovePlate mpScript = mp.GetComponent <MovePlate>(); mpScript.attack = true; mpScript.SetReference(gameObject); mpScript.SetCoords(matrixX, matrixY); }
public void MovePlateSpawn(int matrixX, int matrixY) { //Get the board value in order to convert to xy coords float x = matrixX; float y = matrixY; //Adjust by variable offset x *= 0.66f; y *= 0.66f; //Add constants (pos 0,0) x += -2.3f; y += -2.3f; //Set actual unity values GameObject mp = Instantiate(movePlate, new Vector3(x, y, -3.0f), Quaternion.identity); MovePlate mpScript = mp.GetComponent <MovePlate>(); mpScript.SetReference(gameObject); mpScript.SetCoords(matrixX, matrixY); }
public void MovePlateSpawn(int matrixX, int matrixY, bool isAtacking = false) { float x = matrixX; float y = matrixY; x *= 0.66f; y *= 0.66f; x += -2.3f; y += -2.3f; Vector3 moveCoords = new Vector3(x, y, -3.0f); GameObject mp = Instantiate(movePlate, moveCoords, Quaternion.identity); MovePlate mpScript = mp.GetComponent <MovePlate>(); mpScript.attack = isAtacking; mpScript.SetReference(gameObject); mpScript.SetCoords(matrixX, matrixY); }
// Create the move plate sprites using the positions deemed possible to move to private void MovePlateSpawn(Move m) { // Change the given indexes on the board to location in unity space that match the boards location float x = m.moveto.x; float y = m.moveto.y; x *= 1.255f; y *= 1.255f; x += -4.39f; y += -4.39f; // Create a move plate GameObject mp = Instantiate(moveplate, new Vector3(x, y, -3f), Quaternion.identity); MovePlate mpScript = mp.GetComponent <MovePlate>(); // Call script to change move plates color if move is an attack move if (m.attack) { mpScript.attack = true; } // Save the origin piece game object in the move plate script mpScript.SetReference(gameObject); // Set move plate location according to move mpScript.SetCoords(m.moveto); }