public bool _getCollisionCell(Vector3 pos) { if (pos.x < 0 || pos.x > gameBoardWidth || pos.y < 0 || pos.y > gameBoardHeight) { return(true); } else if (gameBoard[(int)(pos.x / cellWidth), (int)(pos.y / cellHeight)]) { cellControl = gameBoard[(int)(pos.x / cellWidth), (int)(pos.y / cellHeight)].GetComponent <cellController>(); return(cellControl.collision); } return(false); }
public bool _getCollisionCell(Vector3 posLeft, Vector3 posRight, int direction) { if (posLeft.x < 0 || posLeft.x > gameBoardWidth || posLeft.y < 0 || posLeft.y > gameBoardHeight) // столкновение с краем { return(true); } else { bool collisionLeft = false; bool collisionRight = false; // one if (gameBoard[(int)(posLeft.x / cellWidth), (int)(posLeft.y / cellHeight)]) // cell !NULL { cellControl = gameBoard[(int)(posLeft.x / cellWidth), (int)(posLeft.y / cellHeight)].GetComponent <cellController>(); collisionLeft = (cellControl.hitCellFirst(direction, true)); } if (gameBoard[(int)(posRight.x / cellWidth), (int)(posRight.y / cellHeight)]) // cell !NULL { cellControl = gameBoard[(int)(posRight.x / cellWidth), (int)(posRight.y / cellHeight)].GetComponent <cellController>(); collisionRight = (cellControl.hitCellFirst(direction, false)); } if (collisionLeft || collisionRight) { return(true); } // two if (gameBoard[(int)(posLeft.x / cellWidth), (int)(posLeft.y / cellHeight)]) // cell !NULL { cellControl = gameBoard[(int)(posLeft.x / cellWidth), (int)(posLeft.y / cellHeight)].GetComponent <cellController>(); collisionLeft = (cellControl.hitCellSecond(direction, true)); } if (gameBoard[(int)(posRight.x / cellWidth), (int)(posRight.y / cellHeight)]) // cell !NULL { cellControl = gameBoard[(int)(posRight.x / cellWidth), (int)(posRight.y / cellHeight)].GetComponent <cellController>(); collisionRight = (cellControl.hitCellSecond(direction, false)); } if (collisionLeft || collisionRight) { return(true); } } return(false); }
public bool _getCollisionCell(Vector3 posLeft, Vector3 posRight, int direction) { if (posLeft.x < 0 || posLeft.x > gameBoardWidth || posLeft.y < 0 || posLeft.y > gameBoardHeight) // столкновение с краем return true; else { bool collisionLeft = false; bool collisionRight = false; // one if (gameBoard[(int)(posLeft.x / cellWidth), (int)(posLeft.y / cellHeight)]) // cell !NULL { cellControl = gameBoard[(int)(posLeft.x / cellWidth), (int)(posLeft.y / cellHeight)].GetComponent<cellController>(); collisionLeft = (cellControl.hitCellFirst(direction, true)); } if (gameBoard[(int)(posRight.x / cellWidth), (int)(posRight.y / cellHeight)]) // cell !NULL { cellControl = gameBoard[(int)(posRight.x / cellWidth), (int)(posRight.y / cellHeight)].GetComponent<cellController>(); collisionRight = (cellControl.hitCellFirst(direction, false)); } if (collisionLeft || collisionRight) return true; // two if (gameBoard[(int)(posLeft.x / cellWidth), (int)(posLeft.y / cellHeight)]) // cell !NULL { cellControl = gameBoard[(int)(posLeft.x / cellWidth), (int)(posLeft.y / cellHeight)].GetComponent<cellController>(); collisionLeft = (cellControl.hitCellSecond(direction, true)); } if (gameBoard[(int)(posRight.x / cellWidth), (int)(posRight.y / cellHeight)]) // cell !NULL { cellControl = gameBoard[(int)(posRight.x / cellWidth), (int)(posRight.y / cellHeight)].GetComponent<cellController>(); collisionRight = (cellControl.hitCellSecond(direction, false)); } if (collisionLeft || collisionRight) return true; } return false; }
public bool _getCollisionCell(Vector3 pos) { if (pos.x < 0 || pos.x > gameBoardWidth || pos.y < 0 || pos.y > gameBoardHeight) return true; else if (gameBoard[(int)(pos.x / cellWidth), (int)(pos.y / cellHeight)]) { cellControl = gameBoard[(int)(pos.x / cellWidth), (int)(pos.y / cellHeight)].GetComponent<cellController>(); return (cellControl.collision); } return false; }