public DynamicObject SpawnObject(Objects.ID type, Point position) { DynamicObject dynamicObject = (DynamicObject)GridObject.Create(type, position); AddNewItem(dynamicObject); return(dynamicObject); }
public Room(string description, ICollection <string> roomLines, IEnumerable <GridObjectSetup> gridObjectSetups) { mDescription = description; Debug.Assert(roomLines.Count == Game.numRoomRows); int lineIndex = 0; foreach (string line in roomLines) { List <string> splitLine = StringUtils.SplitEmojiString(line); Debug.Assert(splitLine.Count == Game.numRoomColumns); for (int columnIndex = 0; columnIndex < splitLine.Count; columnIndex++) { GridObject staticObject = GridObject.Create(Emoji.GetID(splitLine[columnIndex]), new Point(lineIndex, columnIndex)); mStaticRoomGrid[lineIndex, columnIndex] = (StaticObject)staticObject; } lineIndex++; } foreach (GridObjectSetup setup in gridObjectSetups) { GridObject gridObject = setup.CreateObject(); if (gridObject as DynamicObject != null) { mDynamicObjects.Add((DynamicObject)gridObject); } else { Point position = gridObject.GetPosition(); mStaticRoomGrid[position.mRow, position.mColumn] = (StaticObject)gridObject; } } }