Ejemplo n.º 1
0
        public void TestIfElevatorIsCloser()
        {
            SettingsModel g = new SettingsModel()
            {
                AmountOfMaids      = 3,
                ElevatorDuration   = 3,
                ElevatorCapicity   = 3,
                HTEPerSeconds      = 3,
                StairsDuration     = 3,
                CinemaDuration     = 3,
                RestaurantCapicity = 3,
                RestaurantDuration = 3,
                EatingDuration     = 3,
                FitnessCapicity    = 3,
            };

            Hotel hotel = new Hotel(null, g, new StubedHotelBuilder());

            IMovable t = new Receptionist(new Point(2, 4), hotel);

            IArea a = Dijkstra.IsElevatorCloser(t.Area, hotel.GetAreaByID(21));

            Assert.AreEqual(a.GetType(), typeof(Elevator));

            IMovable p = new Receptionist(new Point(8, 4), hotel);

            IArea q = Dijkstra.IsElevatorCloser(p.Area, hotel.GetAreaByID(21));

            Assert.AreNotEqual(g.GetType(), typeof(Elevator));
        }
Ejemplo n.º 2
0
 // TODO: Make SaveGame method better (add shop, ...)
 public static void SaveGame(
     string path,
     IPlayer player,
     IArea area,
     int areaNumber,
     int savePointX,
     int savePointY,
     IMonster monster = null)
 {
     using (StreamWriter writer = new StreamWriter(path))
     {
         writer.WriteLine(player.Name);
         writer.WriteLine(player.Level);
         writer.WriteLine(player.Points);
         writer.WriteLine(player.MagicRobbers);
         writer.Write(player.X);
         writer.WriteLine(player.Y);
         writer.WriteLine(player.MaxHP);
         writer.WriteLine(player.HP);
         writer.WriteLine(player.MaxMP);
         writer.WriteLine(player.MP);
         writer.WriteLine(player.MaxDamage);
         writer.WriteLine(player.MaxDefense);
         writer.WriteLine(player.MaxAccuracy);
         writer.WriteLine(player.CriticalChance);
         writer.WriteLine(player.NormalAttacks.Count > 0 ? player.NormalAttacks[0].GetType().Name : "-");
         writer.WriteLine(player.NormalAttacks.Count > 1 ? player.NormalAttacks[1].GetType().Name : "-");
         writer.WriteLine(player.NormalAttacks.Count > 2 ? player.NormalAttacks[2].GetType().Name : "-");
         writer.WriteLine(player.NormalAttacks.Count > 3 ? player.NormalAttacks[3].GetType().Name : "-");
         writer.WriteLine(player.MagicAttacks.Count > 0 ? player.MagicAttacks[0].GetType().Name : "-");
         writer.WriteLine(player.MagicAttacks.Count > 1 ? player.MagicAttacks[1].GetType().Name : "-");
         writer.WriteLine(player.MagicAttacks.Count > 2 ? player.MagicAttacks[2].GetType().Name : "-");
         writer.WriteLine(player.MagicAttacks.Count > 3 ? player.MagicAttacks[3].GetType().Name : "-");
         writer.WriteLine(player.MagicAttacks.Count > 4 ? player.MagicAttacks[4].GetType().Name : "-");
         writer.WriteLine(player.MagicAttacks.Count > 5 ? player.MagicAttacks[5].GetType().Name : "-");
         writer.WriteLine(area.GetType().Name);
         writer.Write(areaNumber);
         writer.Write(savePointX);
         writer.Write(savePointY);
         if (monster != null)
         {
             writer.WriteLine("true");
             writer.WriteLine(monster.Name);
             writer.WriteLine(monster.Level);
         }
         else
         {
             writer.WriteLine("false");
         }
     }
 }
        public Double CalcularArea(IArea figura)
        {
            return(figura.Area());

            if (figura.GetType() == typeof(Triangulo))
            {
                var figuraReal = (Triangulo)figura;
                return(triangulo.Base * triangulo.Altura / 2);
            }

            else if (figura.GetType() == typeof(Cuadrado))
            {
                var figuraReal = (Cuadrado)figura;
                return(Math.Pow(cuadrado.lado, 2));
            }

            else if (figura.GetType() == typeof(Circulo))
            {
                var figuraReal = (Circulo)figura;
                return(Math.Pow(circulo.Radio, 2));
            }
            throw new ArgumentException("Tipo de figura no definida");
        }
Ejemplo n.º 4
0
 public static string GetName(this IArea area) => area.GetType().GetAreaName();