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); } }
public void SetUpAnEnemy(EnemyType inSprite) { //set default material EnemyRenderer = this.GetComponent <SpriteRenderer>(); GameObject tempRenderer; EnemyMovementType = (int)inSprite; tempRenderer = GameObject.Find("ScriptsToAttach"); if (tempRenderer != null) { theMaterial = tempRenderer.GetComponent <BoardMaterials>(); EnemyRenderer.sprite = theMaterial.getEnemyMaterials(((int)inSprite)); } //temp this is just to pick one of the cameras that will be in the scene GameObject temp; GameObject temp2; temp = GameObject.Find("Main Camera"); temp2 = GameObject.Find("Camera"); //the Camera will be different depending on where you are running the game from (debug code to be removed later) if (temp != null) { cam = temp.GetComponentInParent <Camera>(); } else if (temp2 != null) { cam = temp2.GetComponentInParent <Camera>(); } if (temp2 != null || temp != null) { SetEnemySize(); this.transform.position = new Vector3(ScreenEdgeLeft + ((screenWidth / BoardWidthSections) * Postion.x), ScreenEdgeBot + ((screenWidth / BoardWidthSections) * Postion.y), 0); this.transform.localScale = new Vector3(LocalScaleX, LocalScaleX, 0); } }