public void SetUpBoardPiece(BM_Sprite inSprite) { //set default material PieceRenderer = this.GetComponent <SpriteRenderer>(); GameObject tempRenderer; tempRenderer = GameObject.Find("ScriptsToAttach"); if (tempRenderer != null) { theMaterial = tempRenderer.GetComponent <BoardMaterials>(); } PieceRenderer.sprite = theMaterial.getMaterial(((int)inSprite)); //temp this is just to pick one of the probably cameras that will be in the scene GameObject temp; GameObject temp2; temp = GameObject.Find("Main Camera"); temp2 = GameObject.Find("Camera"); // if (temp != null) { cam = temp.GetComponentInParent <Camera>(); } else if (temp2 != null) { cam = temp2.GetComponentInParent <Camera>(); } if (temp2 != null || temp != null) { SetPieceSizes(); //this.transform.position = new Vector3(ScreenEdgeLeft, ScreenEdgeBot, 0); this.transform.position = new Vector3(ScreenEdgeLeft + ((screenWidth / GamePieceSections) * Postion.x), ScreenEdgeBot + ((screenWidth / GamePieceSections) * Postion.y), 0); this.transform.localScale = new Vector3(LocalScaleX, LocalScaleX, 0); TheTileSize = new Vector2(LocalScaleX, LocalScaleX); } }
void BuildBoard() { BoardPiece[] temp = new BoardPiece[(int)BoardSize.x]; for (int i = 0; i < BoardSize.x; i++) { for (int j = 0; j < BoardSize.y; j++) { BoardPiece tempObject = (BoardPiece)Instantiate(theBoardPiece); if (tempObject != null) { tempObject.setBorderPercent(ScreenPercentToUse); tempObject.SetGamePiecesSections((int)BoardSize.x); //BoardPiece material to use BM_Sprite tempMaterial = BM_Sprite.BM_Normal; //change material to the correct one if (BoardPlacements[0, j] == i && j < BoardSize.y - 1) { tempMaterial = BM_Sprite.BM_Window; WindowLocations.Add(new Vector2(i, j)); } else if (j == BoardSize.y - 1) { temp[i] = tempObject; for (int x = 0; x < AmountOfDaughtersRooms; x++) { if (BoardPlacements[x, (int)BoardSize.y - 1] == i) { tempMaterial = BM_Sprite.BM_Daughter; DaughterLocations.Add(i); } } } tempObject.SetPosition(new Vector2(i, j + SpacesFromBottom)); boardPieces[i, j] = tempObject; tempObject.SetUpBoardPiece(tempMaterial); } } player.setMovementLocations(temp); } DaughterDelete = AmountOfDaughtersRooms; List <Vector2> TempWindowLocations; TempWindowLocations = new List <Vector2>(); //Sort the WindowLocations for (int i = 0; i < WindowLocations.Count; i++) { for (int j = 0; j < WindowLocations.Count; j++) { if (WindowLocations[j].y == i) { TempWindowLocations.Add(WindowLocations[j]); } } } WindowLocations = TempWindowLocations; }