コード例 #1
0
ファイル: DumboCar.cs プロジェクト: veronik/DumboDriver
        public static DumboCar getInstance(MatrixCoords topLeft, Lane lane, int speed)
        {
            if (instance == null)
                instance = new DumboCar(topLeft,lane,speed);

            return instance;
        }
コード例 #2
0
ファイル: GameObject.cs プロジェクト: veronik/DumboDriver
 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);
 }
コード例 #3
0
ファイル: Cone.cs プロジェクト: veronik/DumboDriver
 public Cone(MatrixCoords topLeft, Lane lane)
     : base(topLeft, new char[,] 
     { 
         {' ',' ',' ',' ',' ',' ',' ',' '},
         {' ',' ',' ','/','\\',' ',' ',' '},
         {'|','-','/','-','-','\\','-','|'},
         {'|','-','-','-','-','-','-','|'},
     }, lane)
 {
     this.speed = 1;
 }
コード例 #4
0
ファイル: TimeBonus.cs プロジェクト: veronik/DumboDriver
 public TimeBonus(MatrixCoords topLeft, Lane lane)
     : base(topLeft, new char[,] 
     { 
         {' ',' ','_','_',' ',' '},
         {' ','/',' ',' ','\\',' '},
         {'|','t','i','m','e','|'},
         {' ','\\','_','_','/',' '},
     }, lane)
 {
     this.speed = 1;
 }
コード例 #5
0
ファイル: OtherCar.cs プロジェクト: veronik/DumboDriver
 public OtherCar(MatrixCoords topLeft, Lane lane)
     : base(topLeft, new char[,] 
     { 
         {' ',' ','_','_','_',' ',' '},
         {' ','/','_','_','_','\\',' '},
         {'.','"',' ','|',' ','"','.'},
         {'(','o','_','|','_','o',')'},
         {' ','u',' ',' ',' ','u',' '},
     }, lane)
 {
     this.speed = 1;
 }
コード例 #6
0
ファイル: Reward.cs プロジェクト: veronik/DumboDriver
 public Reward(MatrixCoords topLeft, Lane lane, int value)
     : base(topLeft, new char[,] 
     { 
         {' ',' ','_','_',' ',' '},
         {' ','/',' ',' ','\\',' '},
         {'|',' ',(char)(value+48),'0',' ','|'},
         {' ','\\','_','_','/',' '},
     }, lane)
 {
     this.value = value;
     this.speed = 1;
 }
コード例 #7
0
ファイル: DumboCar.cs プロジェクト: veronik/DumboDriver
 private DumboCar(MatrixCoords topLeft, Lane lane, int speed)
     : base(topLeft, new char[,] 
     { 
         {' ',' ','_','_','_',' ',' '},
         {' ','/','_','_','_','\\',' '},
         {'.','"',' ','|',' ','"','.'},
         {'(','o','_','|','_','o',')'},
         {' ','u',' ',' ',' ','u',' '},
     }, lane)
 {
     this.speed = speed;
     this.points = 0;
 }
コード例 #8
0
ファイル: Spill.cs プロジェクト: veronik/DumboDriver
 public Spill(MatrixCoords topLeft, Lane lane)
     : base(topLeft, new char[,] 
     { 
         {' ',' ',' ','.','.',' ',' '},
         {' ',' ','.','.','.','.',' '},
         {' ','.','.','.','.','.','.'},
         {'.','.','.','.','.','.','.'},
         {'.','.','.','.','.','.','.'},
         {' ','.','.','.','.','.',' '},
         {' ',' ','.','.','.',' ',' '},
     }, lane)
 {
     this.speed = 1;
 }
コード例 #9
0
        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];
                    }
                }
            }
        }
コード例 #10
0
ファイル: Obstacle.cs プロジェクト: veronik/DumboDriver
 public Obstacle(MatrixCoords topLeft, char[,] body, Lane lane)
     : base(topLeft, body, lane)
 {
 }
コード例 #11
0
        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);
        }
コード例 #12
0
 public Field(MatrixCoords topLeft)
 {
     this.topLeft = topLeft;
 }
コード例 #13
0
ファイル: Field.cs プロジェクト: veronik/DumboDriver
 public Field( MatrixCoords topLeft)
 {
     this.topLeft = topLeft;
 }
コード例 #14
0
        // 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;
        }