private int counter = 0; //DEBUG path cizdirirken kullaniliyor public void step() { if (destroyed == false) { if (board.boardState == Board.BoardState.COLLAPSING) { destroyBoard(); return; } boardObject.transform.position = board.position; boardObject.transform.rotation = Quaternion.Euler(board.rotation); #region /////////// DEBUG - pathi kirmizi cizgiyle cizdirmek icin - DEBUG ///////// int end = board.getPath().getPointCount(); counter++; if (counter % 10 == 0) { for (int i = 0; i < 3 * (end - 3) - 1; i++) { MinionPosition mp = new MinionPosition(); mp.board = board; mp.pathPosition = new PathPosition(i / 3, (i % 3) / 3.0f); Vector3 p1 = board.getPath().getWorldPosition(mp); mp.pathPosition = new PathPosition((i + 1) / 3, ((i + 1) % 3) / 3.0f); Vector3 p2 = board.getPath().getWorldPosition(mp); Debug.DrawLine(p1, p2, Color.red, .5f); } } #endregion } }
public Vector3 getWorldPosition(MinionPosition minionPosition) { Board board = minionPosition.board; Vector3 point = getLocalPosition(minionPosition.pathPosition); float Deg2Rad = (float)(Math.PI / 180.0f); float posX = (float)(point.x * Math.Cos(Deg2Rad * board.rotation.y * -1) - point.z * Math.Sin(Deg2Rad * board.rotation.y * -1)); float posZ = (float)(point.x * Math.Sin(Deg2Rad * board.rotation.y * -1) + point.z * Math.Cos(Deg2Rad * board.rotation.y * -1)); return(new Vector3(posX, point.y, posZ) + board.position); }
public Vector3 getWorldPosition(MinionPosition minionPosition) { Board board = minionPosition.board; Vector3 point = getLocalPosition(minionPosition.pathPosition); float posX = point.x * Mathf.Cos(Mathf.Deg2Rad * board.rotation.y * -1) - point.z * Mathf.Sin(Mathf.Deg2Rad * board.rotation.y * -1); float posZ = point.x * Mathf.Sin(Mathf.Deg2Rad * board.rotation.y * -1) + point.z * Mathf.Cos(Mathf.Deg2Rad * board.rotation.y * -1); return(new Vector3(posX, point.y, posZ) + board.position); }
public Vector3 getWorldPosition(MinionPosition minionPosition) { Board board = minionPosition.board; Vector3 point = getLocalPosition(minionPosition.pathPosition); double angle = Deg2Rad * board.rotation.y * -1; float sin = (float)Math.Sin(angle); float cos = (float)Math.Cos(angle); float posX = point.x * cos - point.z * sin; float posZ = point.x * sin + point.z * cos; return(new Vector3(posX, point.y, posZ) + board.position); }