Example #1
0
    void PlaceWallColliders(GameObject piece)
    {
        if (piece.name[0] != 'i' && piece.name[1] != '9')
        {
            Vector3    newVerticalPos        = new Vector3(piece.transform.position.x + 2.43f, piece.transform.position.y + 4.9f, -0.6f);
            Vector3    newHorizontalPos      = new Vector3(piece.transform.position.x, piece.transform.position.y + 2.43f, -0.6f);
            GameObject wallCollHorizontal    = Instantiate(wallColliderHorizontalPrefab) as GameObject;
            GameObject wallCollVertical      = Instantiate(wallColliderVerticalPrefab) as GameObject;
            GameObject wallOutlineHorizontal = Instantiate(wallPlacementOutlineHorizontalPrefab) as GameObject;
            GameObject wallOutlineVertical   = Instantiate(wallPlacementOutlineVerticalPrefab) as GameObject;

            wallCollHorizontal.transform.position = newHorizontalPos;
            wallCollHorizontal.name = piece.name + "h";
            wallOutlineHorizontal.transform.position = new Vector3(newHorizontalPos.x + 2.5f, newHorizontalPos.y, newHorizontalPos.z);
            wallOutlineHorizontal.transform.SetParent(wallCollHorizontal.transform);
            wallOutlineHorizontal.GetComponent <SpriteRenderer>().color = Color.clear;

            wallCollVertical.transform.position = newVerticalPos;
            wallCollVertical.name = piece.name + "v";
            wallOutlineVertical.transform.position = new Vector3(newVerticalPos.x, newVerticalPos.y - 2.5f, newVerticalPos.z);
            wallOutlineVertical.transform.SetParent(wallCollVertical.transform);
            wallOutlineVertical.GetComponent <SpriteRenderer>().color = Color.clear;

            wallCollVertical.transform.SetParent(wallColliderWrapper.transform);
            wallCollHorizontal.transform.SetParent(wallColliderWrapper.transform);

            interfaceController.AddToWallMap(wallCollHorizontal);
            interfaceController.AddToWallMap(wallCollVertical);
        }
    }