public DurationSquareDataChain(String loadText, Coordinate startCoordinate, Coordinate endCoordinate) { this.head = new DurationSquareData(loadText); this.tail = new DurationSquareData(loadText); this.body = new List <DurationSquareData>(); for (int pos = (startCoordinate.Y + 1); pos < endCoordinate.Y; pos++) { body.Add(new DurationSquareData(loadText)); } this.enemyType = head.enemyType; this.eventType = head.durationEventType; complete = new List <DurationSquareData>(); complete.Add(head); complete.AddRange(body); complete.Add(tail); this.startCoordinate = startCoordinate; this.endCoordinate = endCoordinate; coordinates = new List <Coordinate>(); for (int y = startCoordinate.Y; y <= endCoordinate.Y; y++) { coordinates.Add(new Coordinate(startCoordinate.X, y)); } }
public DurationSquareDataChain(EnemyType enemyType, DurationEventType eventType, Movement movementType, DurationSquareData head, DurationSquareData tail, List <DurationSquareData> body, Coordinate startCoordinate, Coordinate endCoordinate) { this.enemyType = enemyType; this.eventType = eventType; this.head = head; this.tail = tail; this.body = new List <DurationSquareData>(); this.body = body; complete = new List <DurationSquareData>(); complete.Add(head); complete.AddRange(body); complete.Add(tail); foreach (DurationSquareData data in complete) { data.enemyType = enemyType; data.movement = movementType; data.durationEventType = eventType; data.eventData = new DurationEventData(ActiveData.durationEventState); } this.startCoordinate = startCoordinate; this.endCoordinate = endCoordinate; coordinates = new List <Coordinate>(); for (int y = startCoordinate.Y; y <= endCoordinate.Y; y++) { coordinates.Add(new Coordinate(startCoordinate.X, y)); } }
private void InitializeDurationGridData() { for (int n = 0; n < durationWidth; n++) { for (int m = 0; m < height; m++) { SquareData s = new DurationSquareData(); durationDataGrid[n, m] = s; } } }
protected void ClearDataGrid(SquareData[,] newData) { int localWidth = newData.GetLength(0); int localHeight = newData.GetLength(1); for (int n = 0; n < localWidth; n++) { for (int m = 0; m < localHeight; m++) { SquareData sd = new DurationSquareData(); sd.Initialize(); newData[n, m] = sd; } } }
private DurationSquareData CheckChainForPresentData(List <DurationSquareDataChain> durationData, Coordinate coordinate) { DurationSquareData data = null; foreach (DurationSquareDataChain chain in durationData) { data = chain.GetDataFromCoordinate(coordinate); if (data != null) { break; } } return(data); }
private List <DurationSquareData> GetRange(Coordinate startCoordinate, Coordinate endCoordinate) { if (startCoordinate.X != endCoordinate.X) { throw new ArgumentException("Invalid coordinate range entered!"); } List <DurationSquareData> bodyData = new List <DurationSquareData>(); for (int y = startCoordinate.Y + 1; y < endCoordinate.Y; y++) { DurationSquareData target = (DurationSquareData)(grid[startCoordinate.X, y].data); bodyData.Add(target); } return(bodyData); }
public override void UpdateGridSize(int newWidth, int newHeight) { RemoveChainsOutside(newWidth, newHeight); SquareData[,] newData = new DurationSquareData[newWidth, newHeight]; ClearDataGrid(newData); for (int n = 0; n < newWidth; n++) { for (int m = 0; m < newHeight; m++) { newData[n, m] = new DurationSquareData(); } } data = newData; width = newWidth; height = newHeight; CreateSquareGrid(data, durationDataChains); }
//Creates square grid linked to given SquareData-CHAIN protected void CreateSquareGrid(SquareData[,] data, List <DurationSquareDataChain> newDurationData) { int localWidth = data.GetLength(0); int localHeight = data.GetLength(1); grid = new DurationSquare[localWidth, localHeight]; for (int n = 0; n < localWidth; n++) { for (int m = 0; m < localHeight; m++) { DurationSquareData existingData = CheckChainForPresentData(newDurationData, new Coordinate(n, m)); if (existingData != null) { data[n, m] = existingData; } Square s = new DurationSquare(data[n, m], GetSquarePos(n, m), spriteSheet, new Coordinate(n, m)); s.Initialize(); grid[n, m] = s; } } }