private void ResizeCollider() { objectToMerge.GetComponent <BoxCollider>().enabled = false; var boxcol = GetComponent <BoxCollider>(); boxcol.size = new Vector3(boxcol.size.x * 2, boxcol.size.y, boxcol.size.z); }
public virtual void MergeAdjacentRooms(SceneObject type) //split in 2 methods. Try merge and merge, add resourcepertime from adjacent object; { Debug.Log("Merging"); List <AdjacentObject> adjacents = new List <AdjacentObject>(); if (adjacent.leftObj != null) { adjacents.Add(adjacent.leftObj); } if (adjacent.rightObj != null) { adjacents.Add(adjacent.rightObj); } if (adjacent.upperObj != null) { adjacents.Add(adjacent.upperObj); } if (adjacent.lowerObj != null) { adjacents.Add(adjacent.lowerObj); } foreach (AdjacentObject nearObj in adjacents) { if (!nearObj.GetComponent <SceneObject>().hasJointedObject&& objectToMerge == null && type.GetType() == nearObj.GetComponent <SceneObject>().GetType() && nearObj.GetComponent <SceneObject>().lvl == lvl && lvl == 2) { if (nearObj.GetComponent <SceneObject>().lvl > 2 || nearObj.GetComponent <SceneObject>().id != id) { continue; } if (nearObj == adjacent.leftObj) { direction = new Vector2(-1, 0); } if (nearObj == adjacent.rightObj) { direction = new Vector2(1, 0); } if (nearObj == adjacent.upperObj) { direction = new Vector2(0, 1); } if (nearObj == adjacent.lowerObj) { direction = new Vector2(0, -1); } hasJointedObject = true; nearObj.GetComponent <SceneObject>().hasJointedObject = true; objectToMerge = nearObj; Debug.Log("ID: " + id + " " + "MERGED ID: " + objectToMerge.GetComponent <SceneObject>().id); if (!isMerged) { Debug.Log("why here?"); id = GetUniqueID(); objectToMerge.GetComponent <SceneObject>().id = id; ResizeObject(1.042f); TurnObject(); // dont do it after loading. Dont forget to turn finished production image RecenterObject(0.5f); isMerged = true; objectToMerge.GetComponent <SceneObject>().isMerged = true; } else { Debug.Log("right here"); if (direction.y != 0) { RotateViewObjects(); } ResizeCollider(); } return; } } }