public Direction enteringCorridor; // The direction of the corridor entering the room public void setupRoom(RandInt widthRange, RandInt heightRange, int columns, int rows) { // Generate room dimensions roomWidth = widthRange.Random; roomHeight = heightRange.Random; // Set the x and z coordinates to place the room roughly in the center of the board xPos = Mathf.RoundToInt(columns / 2f - roomWidth / 2f) + 1; zPos = Mathf.RoundToInt(rows / 2f - roomHeight / 2f) + 1; }
/// <summary> /// Triggered by timer SnailTimer /// </summary> /// <param name="source"></param> /// <param name="e"></param> private void MoveASnail(Object source, System.Timers.ElapsedEventArgs e) { int whichSnail = RandInt.Next(0, NumberOfSnails); //below line: if it isn't an instant win for this exact snail, if speedup is on, move 200 pixels, otherwise move 20 pixels Snails[whichSnail].Picture.Location = new Point(DevMode.Win[0] == 0 || DevMode.Win[1] != whichSnail ? DevMode.Speed ? Snails[whichSnail].Picture.Location.X + 200 : Snails[whichSnail].Picture.Location.X + 20 : Snails[whichSnail].Picture.Location.X + 9999999, Snails[whichSnail].Picture.Location.Y); sound.Play(); //(below line) the +16 is due to the borders of the form itself, which are not part of the drawn area but still count for the width of the form if (Snails[whichSnail].Picture.Location.X + Snails[whichSnail].Picture.Width + 16 >= Width) //if the right side of the snail is at least touching the right side of the form... { RaceOver(whichSnail); //...this snail wins } }
private static void GenerateCircles(Window window) { var radius = Radius.Max; for (var i = 0; i < Circles.Length; i++) { var x = new RandInt(radius, window.Width - radius).Value; var y = new RandInt(radius, window.Height - radius).Value; var speedX = GetCircleSpeed(); var speedY = GetCircleSpeed(); Circles[i] = new Circle(x, y, Radius.Value, speedX, speedY, Color.Value); } }
public void setupCorridor(Room room, RandInt length, RandInt roomWidth, RandInt roomHeight, int columns, int rows, bool firstCorridor) { // Set a random direction direction = (Direction)Random.Range(0, 4); // Calculate the opposite direction Direction oppositeDirection = (Direction)(((int)room.enteringCorridor + 2) % 4); if (!firstCorridor && direction == oppositeDirection) { int newDir = (int)direction; newDir = (newDir + 1) % 4; direction = (Direction)newDir; } // Generate random length corridorLength = length.Random; // Create a max for how long the length can be int maxLength = length.m_Max; switch (direction) { case Direction.North: startXPos = Random.Range(room.xPos, room.xPos + room.roomWidth - 1); startZPos = room.zPos + room.roomHeight; maxLength = rows - startZPos - roomHeight.m_Min; break; case Direction.East: startXPos = room.xPos + room.roomWidth; startZPos = Random.Range(room.zPos, room.zPos + room.roomHeight - 1); maxLength = columns - startXPos - roomWidth.m_Min; break; case Direction.South: startXPos = Random.Range(room.xPos, room.xPos + room.roomWidth); startZPos = room.zPos; maxLength = startZPos - roomHeight.m_Min; break; case Direction.West: startXPos = room.xPos; startZPos = Random.Range(room.zPos, room.zPos + room.roomHeight); maxLength = startXPos - roomWidth.m_Min; break; } // Clamp the length of the corridor to make sure it doesn't go out of bounds corridorLength = Mathf.Clamp(corridorLength, 1, maxLength); }
public void setupRoom(RandInt widthRange, RandInt heightRange, int columns, int rows, Corridor corridor) { enteringCorridor = corridor.direction; // Generate room dimensions roomWidth = widthRange.Random; roomHeight = heightRange.Random; switch (corridor.direction) { case Direction.North: roomHeight = Mathf.Clamp(roomHeight, 1, rows - corridor.EndPositionZ); zPos = corridor.EndPositionZ; xPos = Random.Range(corridor.EndPositionX - roomWidth + 1, corridor.EndPositionX); xPos = Mathf.Clamp(xPos, 0, columns - roomWidth); break; case Direction.East: roomWidth = Mathf.Clamp(roomWidth, 1, columns - corridor.EndPositionX); xPos = corridor.EndPositionX; zPos = Random.Range(corridor.EndPositionZ - roomHeight + 1, corridor.EndPositionZ); zPos = Mathf.Clamp(zPos, 0, rows - roomHeight); break; case Direction.South: roomHeight = Mathf.Clamp(roomHeight, 1, corridor.EndPositionZ); zPos = corridor.EndPositionZ - roomHeight + 1; xPos = Random.Range(corridor.EndPositionX - roomWidth + 1, corridor.EndPositionX); xPos = Mathf.Clamp(xPos, 0, columns - roomWidth); break; case Direction.West: roomWidth = Mathf.Clamp(roomWidth, 1, corridor.EndPositionX); xPos = corridor.EndPositionX - roomWidth + 1; zPos = Random.Range(corridor.EndPositionZ - roomHeight + 1, corridor.EndPositionZ); zPos = Mathf.Clamp(zPos, 0, rows - roomHeight); break; } xPos += 1; zPos += 1; }
public Rander(int Seed) { random = makeRandInt(Seed); }