//카메라가 바라보는 방향을 방의 타입에 따라, 현관은 입구를, 거실은 창을, 방은 창문을 바라본다. protected virtual void CreateCamera(int cameraNumber) { double rotation = 0; Data.Cord a = new Data.Cord(Location.X + (0.5 * Size.Length), Location.Y + (0.5 * Size.Width), Location.Z + 170); Data.SideType current = Data.SideType.Wall; foreach (Data.SideCardinalDirection sideDirection in Enum.GetValues(typeof(Data.SideCardinalDirection))) { foreach (Data.Side side in this.Sides[sideDirection]) { if (current < side.Type) { Data.Cord b = side.GetMidCord(); double y = b.Y - a.Y; double x = b.X - a.X; if (x == 0) { if (y > 0) { rotation = 90; } else { rotation = 270; } } else { rotation = (Math.Acos(y / x) * (180 / Math.PI)); if (rotation < 0) { rotation += 360; } } current = side.Type; } } } this.Components.Add(new Model.Camera(new Data.Cord(Location.X + (0.5 * Size.Length), Location.Y + (0.5 * Size.Width), Location.Z + 170), new Data.Rot(0, 0, rotation), cameraNumber)); }
public static void OccupySides(Room r1, Room r2, ConnectionType type) { foreach (Data.SideCardinalDirection i in Enum.GetValues(typeof(Data.SideCardinalDirection))) { Data.SideCardinalDirection j = Data.SideCardinalDirection.West; switch (i) { case (Data.SideCardinalDirection.West): j = Data.SideCardinalDirection.East; break; case (Data.SideCardinalDirection.North): j = Data.SideCardinalDirection.South; break; case (Data.SideCardinalDirection.East): j = Data.SideCardinalDirection.West; break; case (Data.SideCardinalDirection.South): j = Data.SideCardinalDirection.North; break; } Data.Side[] r1Sides = r1.Sides[i].ToArray(); Data.Side[] r2Sides = r2.Sides[j].ToArray(); foreach (Data.Side a in r1Sides) { foreach (Data.Side b in r2Sides) { if (a.IsContact(b)) { r1.Sides[i].Remove(a); r2.Sides[j].Remove(b); //접촉하는 부분을 추출 Data.Side contacted = a.GetContact(b); //두 공간의 관계에 따라, 점령될 SideType을 결정 Data.SideType sType = Data.SideType.Wall; if (type == ConnectionType.Open) { sType = Data.SideType.Open; } else if (type == ConnectionType.Door) { sType = Data.SideType.Door; } //Side 점령 foreach (Data.Side newA in a.OccupyPart(contacted, sType)) { r1.Sides[i].Add(newA); } //r1.Sides[(int)i] = a.OccupyPart(contacted, sType); foreach (Data.Side newB in b.OccupyPart(contacted, sType)) { r2.Sides[j].Add(newB); } //r2.Sides[(int)j] = b.OccupyPart(contacted, sType); } } } } }