public Room(SerializationInfo si, StreamingContext sc) { roomPosition = (Vector2)si.GetValue("roomPosition", typeof(Vector2)); position = (Vector2)si.GetValue("position", typeof(Vector2)); sprite = (Drawable)si.GetValue("sprite", typeof(Drawable)); roomTexture = (Texture2D)si.GetValue("roomTexture", typeof(Texture2D)); roomHighlightTexture = (Texture2D)si.GetValue("roomHighlightTexture", typeof(Texture2D)); highlighted = si.GetBoolean("highlighted"); isMannable = si.GetBoolean("isMannable"); roomType = si.GetInt32("roomType"); maxEnergy = si.GetInt32("maxEnergy"); currentAvailableEnergy = si.GetInt32("currentAvailableEnergy"); isManned = si.GetInt32("isManned"); roomHealth = si.GetInt32("roomHealth"); aflame = si.GetBoolean("aflame"); hullBreach = si.GetBoolean("hullBreach"); width = si.GetInt32("width"); height = si.GetInt32("height"); roomO2 = si.GetInt32("roomO2"); roomShape = (Globals.roomShape)si.GetValue("roomShape", typeof(Globals.roomShape)); typeOfRoom = (Globals.roomType)si.GetValue("typeOfRoom", typeof(Globals.roomType)); roomSize = si.GetInt32("roomSize"); roomGrids = (List <int>)si.GetValue("roomGrids", typeof(List <int>)); roomStateMachine = (StateMachine)si.GetValue("roomStateMachine", typeof(StateMachine)); normal = (State)si.GetValue("normal", typeof(State)); damaged = (State)si.GetValue("damaged", typeof(State)); inoperable = (State)si.GetValue("inoperable", typeof(State)); disabled = (State)si.GetValue("disabled", typeof(State)); }
/// <summary> /// constructor for a room /// </summary> /// <param name="texture">texture for the room</param> /// <param name="highlightTexture">texture for the room when its highlighted</param> /// <param name="x">x-position of the top-left grid position</param> /// <param name="y">y-position of the top-left grid position</param> public Room(Texture2D texture, Texture2D highlightTexture, int x, int y, Vector2 shipOffset, Globals.roomShape shape, Globals.roomType type, int w, int h) { #region room state machine setup roomStateMachine = new StateMachine(); normal = new State { Name = "normal" }; damaged = new State { Name = "damaged" }; inoperable = new State { Name = "inoperable" }; disabled = new State { Name = "disabled" }; roomStateMachine.Start(normal); normal.Transitions.Add(damaged.Name, damaged); normal.Transitions.Add(disabled.Name, disabled); normal.Transitions.Add(inoperable.Name, inoperable); damaged.Transitions.Add(normal.Name, normal); damaged.Transitions.Add(inoperable.Name, inoperable); damaged.Transitions.Add(disabled.Name, disabled); inoperable.Transitions.Add(normal.Name, normal); inoperable.Transitions.Add(damaged.Name, damaged); inoperable.Transitions.Add(disabled.Name, disabled); disabled.Transitions.Add(normal.Name, normal); disabled.Transitions.Add(damaged.Name, damaged); disabled.Transitions.Add(inoperable.Name, inoperable); #endregion setupNormal(); setupDamaged(); setupInoperable(); setupDisabled(); position = new Vector2((x * 32) + shipOffset.X, (y * 32) + shipOffset.Y); roomTexture = texture; roomHighlightTexture = highlightTexture; sprite = new Drawable(highlightTexture, position); roomPosition = new Vector2(x, y); isMannable = new bool(); isMannable = false; roomType = (int)type; roomHealth = 200; roomShape = shape; width = w; height = h; aflame = false; hullBreach = false; roomGrids = new List <int>(); }