Esempio n. 1
0
    /// <summary>
    /// Skaito duomenų faila
    /// </summary>
    /// <returns> gražina žemėlapių konteinerį</returns>
    private static MapsContainer Reading()
    {
        using (StreamReader reader = new StreamReader(@data))
        {
            int           count = int.Parse(reader.ReadLine());
            MapsContainer a     = new MapsContainer(count);
            for (int i = 0; i < count; i++)
            {
                string[] dims = reader.ReadLine().Split();
                int[]    dim  = new int[3];
                dim[1] = int.Parse(dims[0]) + 2; // dim[1] - Y ašis ilgis
                dim[2] = int.Parse(dims[1]) + 2; // dim[2] - X ašis ilgis

                int[,] Empty = new int[xMax, yMax];
                int[,] area  = new int[xMax, yMax];

                area = Empty;


                for (int j = 1; j < dim[1] - 1; j++)
                {
                    string line = reader.ReadLine();
                    for (int k = 1; k < dim[2] - 1; k++)
                    {
                        area[k, j] = int.Parse(line[k - 1].ToString());
                    }
                }
                Maps map = new Maps(area, dim[2], dim[1]);
                a.AddMap(map);
            }
            return(a);
        }
    }
Esempio n. 2
0
        private static BaseTile CheckUnoccupied(Coordinates Location, MapsContainer Maps)
        {
            var tile = Maps.Actors.Map.FirstOrDefault(x => x.Location == Location);

            //bool unoccupied = !Maps.Actors.Map.Any(x => x.Location == Location);
            return(tile);
        }
Esempio n. 3
0
        public void InitializeFixture()
        {
            //Bootstrapper.Excluding.Assembly("JONMVC.Core.Configurations").With.AutoMapper().Start();
            MapsContainer.CreateAutomapperMaps();

            mapper = Mapper.Engine;
        }
Esempio n. 4
0
    /// <summary>
    /// Atlieka skaičiavimo veiksmus
    /// </summary>
    /// <param name="Map"> Žemėlapių konteineris</param>
    /// <param name="results"> rezultatų dvimatys masyvas [salų skaičius,2]</param>
    private static void Do(MapsContainer Map, ref int[,] results)
    {
        for (int i = 0; i < Map.Count; i++)
        {
            int[,] Empty = new int[xMax, yMax];
            int[,] area  = new int[xMax, yMax];

            area = Empty;
            area = Map.GetMap(i).Map;

            int IslandCount = 0;
            int MaxTwos     = 0;

            for (int j = 1; j < Map.GetMap(i).ySize - 1; j++)
            {
                for (int k = 1; k < Map.GetMap(i).xSize - 1; k++)
                {
                    if (area[k, j] == 1)
                    {
                        area[k, j] = 2;
                        ConvertNearbySquares(ref area, k, j);
                        IslandCount++;
                        int Twos = CountTwos(area, Map.GetMap(i).xSize, Map.GetMap(i).ySize);
                        if (MaxTwos < Twos)
                        {
                            MaxTwos = Twos;
                        }
                        ClearTwos(ref area, Map.GetMap(i).xSize, Map.GetMap(i).ySize);
                    }
                }
            }
            results[i, 0] = IslandCount;
            results[i, 1] = MaxTwos;
        }
    }
Esempio n. 5
0
        public void InitializeFixture()
        {
            //Bootstrapper.Excluding.Assembly("JONMVC.Core.Configurations").With.AutoMapper().Start();
            MapsContainer.CreateAutomapperMaps();
            mapper = Mapper.Engine;

            fixture = new Fixture();
            MailerBase.IsTestModeEnabled = true;
        }
Esempio n. 6
0
        public void InitializeFixture()
        {
            fixture = new Fixture();

            MapsContainer.CreateAutomapperMaps();

            mapper = Mapper.Engine;

            MailerBase.IsTestModeEnabled = true;
        }
Esempio n. 7
0
        private static BaseTile CheckPassable(Coordinates Location, MapsContainer Maps)
        {
            var tile = Maps.Arena.Map.First(x => x.Location == Location);

            return(tile);// if (tile.Passable)
            //    return true;
            //else
            //{
            //    _currentMsg = String.Format("You hit a {0}", tile.Name);
            //    return false;
            //}
        }
Esempio n. 8
0
    /// <summary>
    /// Skai
    /// </summary>
    /// <param name="count"> Žemėlapių kiekis</param>
    /// <returns> gražina žemėlapius</returns>
    public int[,] Islands(out int count)
    {
        MapsContainer Maps = Reading();

        PrintDataFile(Maps);
        int[,] results = new int[Maps.Count, 2];
        Do(Maps, ref results);


        count = Maps.Count;
        PrintDataWeb();
        return(results);
    }
Esempio n. 9
0
        private static BaseTile CheckMovement(Coordinates Location, MapsContainer Maps)
        {
            var tile  = CheckPassable(Location, Maps);
            var actor = CheckUnoccupied(Location, Maps);

            if (actor != null)
            {
                return(actor);
            }
            else
            {
                return(tile);
            }
        }
Esempio n. 10
0
        private static void MoveActor(Actor Actor, ConsoleKey Key, MapsContainer Maps, InputResponse Response)
        {
            switch (Key)
            {
            case ConsoleKey.W:
            case ConsoleKey.S:
            case ConsoleKey.A:
            case ConsoleKey.D:
                Move(Actor, Response, Maps, Key);
                break;

            default:
                return;
            }
        }
Esempio n. 11
0
        private static void Move(Actor Actor, InputResponse Response, MapsContainer Maps, ConsoleKey Key)
        {
            var newCoord = GetNewCoordination(Coordinates.NewCoord(Actor.Location.X, Actor.Location.Y), Key);

            _currentMsg = _moveUp;
            var tile = CheckMovement(newCoord, Maps) as ArenaTile;

            if (tile.Passable)
            {
                MoveActorToLocation(newCoord);
                Response.Msg = "You move";
            }
            else
            {
                Response.Msg = string.Format("You hit a {0}", tile.Name);
            }
        }
Esempio n. 12
0
    /// <summary>
    /// spausdina duomenis faile
    /// </summary>
    /// <param name="Map"></param>
    private void PrintDataFile(MapsContainer Map)
    {
        string path = Server.MapPath("App_Data/Duomenys.txt");

        using (StreamWriter writer = new StreamWriter(path))
        {
            writer.WriteLine("Salų kiekis: {0,10}", Map.Count);
            for (int i = 0; i < Map.Count; i++)
            {
                writer.WriteLine("n ir m reikšmės: {0,5}{1,5}", Map.GetMap(i).ySize, Map.GetMap(i).xSize);
                for (int j = 1; j < Map.GetMap(i).ySize - 1; j++)
                {
                    writer.Write("Stačiakampio duomenys: ");
                    for (int k = 1; k < Map.GetMap(i).xSize - 1; k++)
                    {
                        writer.Write(Map.GetMap(i).Map[k, j]);
                    }
                    writer.WriteLine();
                }
            }
        }
    }
Esempio n. 13
0
 public ConsoleMapWindow(WindowType type, MapsContainer container)
     : base(type)
 {
     ArenaContainer = container;
     _buffer        = new ConsoleMapBuffer();
 }
Esempio n. 14
0
        public static InputResponse ProcessArenaInput(this Actor Actor, ConsoleKey Key, MapsContainer Maps)
        {
            _currentActor = Actor;
            InputResponse response = new InputResponse();

            response.MsgWindowType = WindowType.TopMsg;
            response.Actor         = _currentActor;
            response.Redraw        = true;
            MoveActor(Actor, Key, Maps, response);
            return(response);
        }
Esempio n. 15
0
 public void FixtureInitialize()
 {
     mapper = Mapper.Engine;
     MapsContainer.CreateAutomapperMaps();
 }
Esempio n. 16
0
 public void FixtureInitialize()
 {
     fixture = new Fixture();
     MapsContainer.CreateAutomapperMaps();
     mapper = Mapper.Engine;
 }
Esempio n. 17
0
        //TODO: implement builder pattern

        private IConsoleWindowContainer CreateTestWindows()
        {
            Console.SetWindowSize(230, 60);
            ConsoleWindowContainer WindowContainer = new ConsoleWindowContainer();

            List <ConsoleWindowBase> windows = new List <ConsoleWindowBase>();

            ConsoleTextWindow topWindow = new ConsoleTextWindow(WindowType.TopMsg);

            topWindow.Location     = Coordinates.NewCoord(0, 0);
            topWindow.DrawBorder   = true;
            topWindow.BorderSymbol = '*';
            topWindow.Height       = 5;
            topWindow.Enabled      = true;
            topWindow.Width        = Console.WindowWidth;


            ConsoleTextField field1 = new ConsoleTextField();

            field1.Location = new Coordinates(1, 1);
            field1.Color    = System.ConsoleColor.Cyan;
            field1.Msg      = "TEST";

            topWindow.FieldList.Add(field1);


            ConsoleTextWindow bottomWindow = new ConsoleTextWindow(WindowType.BottomWindow);

            bottomWindow.Location     = Coordinates.NewCoord(0, 41);
            bottomWindow.DrawBorder   = true;
            bottomWindow.BorderSymbol = '*';
            bottomWindow.Height       = 5;
            bottomWindow.Enabled      = true;
            bottomWindow.Width        = Console.WindowWidth;

            ConsoleTextField field2 = new ConsoleTextField();

            field2.Location = new Coordinates(1, 1);
            field2.Color    = System.ConsoleColor.Cyan;


            bottomWindow.FieldList.Add(field2);



            var Player    = new ActorsBuilder().BuildPlayer();
            var ActorMaps = new ActorsMap();

            ActorMaps.Map.Add(Player);



            MapsContainer    container = new MapsContainer(new MapBuilder().SimpleSquareMap(80, 30), ActorMaps);
            ConsoleMapWindow mapWindow = new ConsoleMapWindow(WindowType.Arena, container);

            mapWindow.Active   = true;
            mapWindow.Enabled  = true;
            mapWindow.Location = new Coordinates(20, 8);

            windows.Add(mapWindow);
            windows.Add(topWindow);
            windows.Add(bottomWindow);

            WindowContainer.WindowList = windows;

            return(WindowContainer);
        }