Ejemplo n.º 1
0
 public Engine(IFrog frog, IConsoleWriter consoleWriter, IRowCollection rowCollection, ISettings settings)
 {
     this.settings      = settings;
     this.frog          = frog;
     this.consoleWriter = consoleWriter;
     this.rowCollection = rowCollection;
 }
Ejemplo n.º 2
0
 public Engine(IConsoleKeyReader consoleKeyReader, IFrog frog, IConsoleWriter consoleWriter, IRowCollection rowCollection, IModelFactory modelFactory)
 {
     this.gameSpeed        = GlobalConstants.gameSpeedMin;
     this.gameScore        = GlobalConstants.initialGameScore;
     this.consoleKeyReader = consoleKeyReader;
     this.frog             = frog;
     this.consoleWriter    = consoleWriter;
     this.rowCollection    = rowCollection;
     this.modelFactory     = modelFactory;
 }
Ejemplo n.º 3
0
        public static IRow Find(this IRowCollection rows, params object[] keyValues)
        {
            var keys = rows.Table.Keys;

            if (keys.Length != keyValues.Length)
            {
                throw new ArgumentException("키 갯수가 맞지 않습니다.", "keyValues");
            }

            var query = from item in rows
                        where IsEqual(item.GetKeys(), keyValues)
                        select item;

            return(query.Single());
        }
Ejemplo n.º 4
0
        private void CheckForCollision(IFrog frog, IRowCollection rowcollection) //to refactor it with dictionarri<rowID,Irow>
        {
            //this can be done more elegantly with an event
            if ((frog.Row >= (int)RowID.Row2 && frog.Row <= (int)RowID.Row7)
                ||
                (frog.Row >= (int)RowID.Row9 && frog.Row <= (int)RowID.Row14))
            {
                IVehicle vehicle = ((ILaneRow)rowCollection.Rows.ElementAt(frog.Row)).VehicleOnTheRow;

                if ((frog.X >= vehicle.X && frog.X <= vehicle.VehicleEndX)
                    ||
                    (frog.X + frog.FrogDisplayLength - 1 >= vehicle.X && frog.X + frog.FrogDisplayLength - 1 <= vehicle.VehicleEndX))
                {
                    frog.Lives--;
                    {
                        //GlobalMethods.GameFreeze();//toq metod da premestq v renderer-a
                        consoleWriter.Execute();
                        ConsoleKeyInfo enterAnyKey = Console.ReadKey();
                    }
                    ResetFrogPosition(frog);
                }
            }
        }
Ejemplo n.º 5
0
 public ConsoleWriter(IRowCollection rowCollection, ISettings settings, IFrog frog)
 {
     this.rowCollection = rowCollection;
     this.settings      = settings;
     this.frog          = frog;
 }
Ejemplo n.º 6
0
 public ConsoleWriter(IRowCollection rowCollection)
 {
     this.rowCollection = rowCollection;
 }