public static DumboCar getInstance(MatrixCoords topLeft, Lane lane, int speed) { if (instance == null) instance = new DumboCar(topLeft,lane,speed); return instance; }
protected GameObject(MatrixCoords topLeft, char[,] body, Lane lane) { this.TopLeft = topLeft; this.lane = lane; int imageRows = body.GetLength(0); int imageCols = body.GetLength(1); this.body = this.CopyBodyMatrix(body); }
public Cone(MatrixCoords topLeft, Lane lane) : base(topLeft, new char[,] { {' ',' ',' ',' ',' ',' ',' ',' '}, {' ',' ',' ','/','\\',' ',' ',' '}, {'|','-','/','-','-','\\','-','|'}, {'|','-','-','-','-','-','-','|'}, }, lane) { this.speed = 1; }
public TimeBonus(MatrixCoords topLeft, Lane lane) : base(topLeft, new char[,] { {' ',' ','_','_',' ',' '}, {' ','/',' ',' ','\\',' '}, {'|','t','i','m','e','|'}, {' ','\\','_','_','/',' '}, }, lane) { this.speed = 1; }
public OtherCar(MatrixCoords topLeft, Lane lane) : base(topLeft, new char[,] { {' ',' ','_','_','_',' ',' '}, {' ','/','_','_','_','\\',' '}, {'.','"',' ','|',' ','"','.'}, {'(','o','_','|','_','o',')'}, {' ','u',' ',' ',' ','u',' '}, }, lane) { this.speed = 1; }
public Reward(MatrixCoords topLeft, Lane lane, int value) : base(topLeft, new char[,] { {' ',' ','_','_',' ',' '}, {' ','/',' ',' ','\\',' '}, {'|',' ',(char)(value+48),'0',' ','|'}, {' ','\\','_','_','/',' '}, }, lane) { this.value = value; this.speed = 1; }
private DumboCar(MatrixCoords topLeft, Lane lane, int speed) : base(topLeft, new char[,] { {' ',' ','_','_','_',' ',' '}, {' ','/','_','_','_','\\',' '}, {'.','"',' ','|',' ','"','.'}, {'(','o','_','|','_','o',')'}, {' ','u',' ',' ',' ','u',' '}, }, lane) { this.speed = speed; this.points = 0; }
public Spill(MatrixCoords topLeft, Lane lane) : base(topLeft, new char[,] { {' ',' ',' ','.','.',' ',' '}, {' ',' ','.','.','.','.',' '}, {' ','.','.','.','.','.','.'}, {'.','.','.','.','.','.','.'}, {'.','.','.','.','.','.','.'}, {' ','.','.','.','.','.',' '}, {' ',' ','.','.','.',' ',' '}, }, lane) { this.speed = 1; }
public void EnqueueForRendering(IRenderable obj) { char[,] objImage = obj.GetImage(); int imageRows = objImage.GetLength(0); int imageCols = objImage.GetLength(1); MatrixCoords objTopLeft = obj.GetTopLeft(); int lastRow = Math.Min(objTopLeft.Row + imageRows, this.renderContextMatrixRows); int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderContextMatrixCols); for (int row = obj.GetTopLeft().Row; row < lastRow; row++) { for (int col = obj.GetTopLeft().Col; col < lastCol; col++) { if (row >= 0 && row < renderContextMatrixRows && col >= 0 && col < renderContextMatrixCols) { renderContextMatrix[row, col] = objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col]; } } } }
public Obstacle(MatrixCoords topLeft, char[,] body, Lane lane) : base(topLeft, body, lane) { }
public List <GameObject> GenerateObjects(DumboCar car) // Generates one or many objects { List <GameObject> objList = new List <GameObject>(); List <Lane> occupiedLanes = new List <Lane>(); int chanceObj = randomGenerator.Next(1, 4); //randomize number of obj produced for (int i = 0; i < chanceObj; i++) { // initial value, no effect Lane lane = Lane.Left; bool isLaneFound = false; Array values = Enum.GetValues(typeof(Lane)); Random random = new Random(); while (!isLaneFound) { lane = (Lane)values.GetValue(random.Next(values.Length)); //randomize lane if (!occupiedLanes.Contains(lane)) { isLaneFound = true; } } MatrixCoords topLeft; if (lane == Lane.Left) { occupiedLanes.Add(Lane.Left); topLeft = new MatrixCoords(0, 14); } else if (lane == Lane.MiddleLeft) { occupiedLanes.Add(Lane.MiddleLeft); topLeft = new MatrixCoords(0, 25); } else if (lane == Lane.MiddleRight) { occupiedLanes.Add(Lane.MiddleRight); topLeft = new MatrixCoords(0, 36); } else { occupiedLanes.Add(Lane.Right); topLeft = new MatrixCoords(0, 47); } GameObject obj; int chance = randomGenerator.Next(0, 100); //randomize TimeBonus or else if (Timer.TimeLeft < 25 && chance < 20 - car.Points / 100) { obj = new TimeBonus(topLeft, lane); } else { chance = randomGenerator.Next(0, 100); //randomize object types if (chance < 25) { obj = new Reward(topLeft, lane, randomGenerator.Next(1, 10)); //randomize reward values } else if (chance < 50) { obj = new Cone(topLeft, lane); } else if (chance < 75) { obj = new OtherCar(topLeft, lane); } else { obj = new Spill(topLeft, lane); } } objList.Add(obj); } return(objList); }
public Field(MatrixCoords topLeft) { this.topLeft = topLeft; }
public Field( MatrixCoords topLeft) { this.topLeft = topLeft; }
// Generates one or many objects public List<GameObject> GenerateObjects(DumboCar car) { List<GameObject> objList = new List<GameObject>(); List<Lane> occupiedLanes = new List<Lane>(); int chanceObj = randomGenerator.Next(1, 4); //randomize number of obj produced for (int i = 0; i < chanceObj; i++) { // initial value, no effect Lane lane = Lane.Left; bool isLaneFound = false; Array values = Enum.GetValues(typeof(Lane)); Random random = new Random(); while (!isLaneFound) { lane = (Lane)values.GetValue(random.Next(values.Length)); //randomize lane if (!occupiedLanes.Contains(lane)) { isLaneFound = true; } } MatrixCoords topLeft; if (lane == Lane.Left) { occupiedLanes.Add(Lane.Left); topLeft = new MatrixCoords(0, 14); } else if (lane == Lane.MiddleLeft) { occupiedLanes.Add(Lane.MiddleLeft); topLeft = new MatrixCoords(0, 25); } else if (lane == Lane.MiddleRight) { occupiedLanes.Add(Lane.MiddleRight); topLeft = new MatrixCoords(0, 36); } else { occupiedLanes.Add(Lane.Right); topLeft = new MatrixCoords(0, 47); } GameObject obj; int chance = randomGenerator.Next(0, 100); //randomize TimeBonus or else if (Timer.TimeLeft<25 && chance < 20 - car.Points/100) { obj = new TimeBonus(topLeft, lane); } else { chance = randomGenerator.Next(0, 100); //randomize object types if (chance < 25) { obj = new Reward(topLeft, lane, randomGenerator.Next(1, 10)); //randomize reward values } else if (chance < 50) { obj = new Cone(topLeft, lane); } else if (chance < 75) { obj = new OtherCar(topLeft, lane); } else { obj = new Spill(topLeft, lane); } } objList.Add(obj); } return objList; }