public void CopyFromEdgeSave(SaveEdgeTile tileToCopy) { transform.localScale = new Vector3(1, 1, 0); transform.localPosition = new Vector2(0, 0); colorArrayNumber = tileToCopy.colorArrayNumber; mainTileColour = GameBoard.instance.primaryColours.Find(c => c.colourName == tileToCopy.colourName); if (mainTileColour == null) { mainTileColour = GameBoard.instance.secondaryColours.Find(c => c.colourName == tileToCopy.colourName); } foreach (Sprite sprite in GameBoard.instance.possibleEdgeAttributes) { if (sprite.name == tileToCopy.type) { SetSprite(sprite); } } type = tileToCopy.type; if (type == "LightReceiver" || type == "LightReceiverStar") { //flip the arrow so it points in edgeTileArrow.transform.Rotate(180, 0, 0); } SetColour(); lockedImage.SetActive(isLocked); }
public void saveBoardToFile() { saveBoard = new SaveBoardObject(tileColumns, tileRows); //saves the edge tiles: for (int i = 0; i < 4; i++) { for (int j = 0; j < edgeTiles[i].Length; j++) { var currentTile = edgeTiles[i][j].GetComponent <EdgeTile>(); if (currentTile.edgeTileAttribute) { var currentAttribute = currentTile.edgeTileAttribute.GetComponent <TileAttribute>(); if (currentAttribute) { Debug.Log(currentAttribute.name); var saveEdgeTile = new SaveEdgeTile(); saveEdgeTile.side = currentTile.side; saveEdgeTile.index = currentTile.index; saveEdgeTile.type = currentAttribute.type; saveEdgeTile.colorArrayNumber = currentAttribute.colorArrayNumber; saveEdgeTile.colourName = currentAttribute.mainTileColour.colourName; //saveEdgeTile.isLocked = currentAttribute.isLocked; saveBoard.edgeTiles.Add(saveEdgeTile); } } } } //saves the game tiles: for (int i = 0; i < tileColumns; i++) { for (int j = 0; j < tileRows; j++) { var currentTile = tiles[i, j].GetComponent <Tile>(); if (currentTile.tileAttribute) { var currentAttribute = currentTile.tileAttribute.GetComponent <TileAttribute>(); if (currentAttribute) { Debug.Log(currentAttribute.name); var saveGameTile = new SaveGameTile(); saveGameTile.positionX = (int)currentTile.position.x; saveGameTile.positionY = (int)currentTile.position.y; saveGameTile.type = currentAttribute.type; saveGameTile.colorArrayNumber = currentAttribute.colorArrayNumber; saveGameTile.colourName = currentAttribute.mainTileColour.colourName; saveGameTile.rotation = currentAttribute.rotation; saveGameTile.isLocked = currentAttribute.isLocked; saveBoard.gameTiles.Add(saveGameTile); } } } } // Create an instance of the XmlSerializer class; // specify the type of object to serialize. XmlSerializer serializer = new XmlSerializer(typeof(SaveBoardObject)); TextWriter writer = new StreamWriter(filename); // Serialize the purchase order, and close the TextWriter. serializer.Serialize(writer, saveBoard); writer.Close(); ReturnToMenu(); }