// Start is called before the first frame update void Start() { //Calculate number of bricks in a row based on screen size. //This ensures that while there may be extra bricks out of the screen, there will never be fewer bricks leading to gaps colNum = (int)((Camera.main.orthographicSize * 2 * Camera.main.aspect) / 0.5f); poolSize = rowNum * colNum; float rowHeight = brickHeight + positionYOffset; float colWidth = brickWidth + positionXOffset; bricks = new GameObject[poolSize]; respawnTimeList = new RespawnTime[poolSize]; float totalBrickHeight = (rowNum * brickHeight) + (rowNum - 1) * positionYOffset; currentY = (brickHeight / 2) - (totalBrickHeight / 2); int brickCount = 0; for (int i = 0; i < rowNum; i++) { //Start first brick from left most point in the current row on the screen currentX = ((-1) * Camera.main.orthographicSize * Camera.main.aspect) + ((brickWidth / 2) - (2 * positionXOffset)); for (int j = 0; j < colNum; j++) { Vector2 brickPosition = new Vector2(currentX, currentY); bricks[brickCount] = (GameObject)Instantiate(brickPrefab, brickPosition, Quaternion.identity); respawnTimeList[brickCount] = new RespawnTime(); brickCount++; currentX += colWidth; } currentY += rowHeight; } }
public void ToXml(XmlWriter w) { w.WriteStartElement("SpawnGen"); w.WriteAttributeString("TemplateName", TemplateName); w.WriteAttributeString("RespawnTime", RespawnTime.ToString()); w.WriteAttributeString("NumSpawns", NumSpawn.ToString()); // Server will ignore SpawnRadius w.WriteAttributeString("SpawnRadius", SpawnRadius.ToString()); if (this.nameValuePairs != null && this.nameValuePairs.Count > 0) { nameValuePairs.ToXml(w); } w.WriteEndElement(); }