Exemplo n.º 1
0
    /// <summary>
    /// 在连续一片格子范围内,获取门
    /// </summary>
    /// <param name="Start">起始格子位置</param>
    /// <param name="End">结束点格子位置</param>
    /// <returns>返回墙列表</returns>
    public static void GetWallList(ref List <IggWall> WallList, Int2 Start, Int2 End)
    {
        if (WallList == null)
        {
            WallList = new List <IggWall>();
        }
        WallList.Clear();

        if (Start.Layer != End.Layer)
        {
            return;
        }

        if (Start.Unit >= End.Unit)
        {
            for (int i = Start.Unit; i >= End.Unit; i--)
            {
                AddWall(ref WallList, Start.Layer, i);
            }
        }
        else
        {
            for (int i = Start.Unit; i <= End.Unit; i++)
            {
                AddWall(ref WallList, Start.Layer, i);
            }
        }
    }
        public async Task Fill_empty_wall_list_with_fake_data()
        {
            var usersGet  = SubstituresForVkApi.UsersGet();
            var groupsGet = SubstituresForVkApi.GroupsGet();
            var wallList  = new WallList();

            var filler = new AvailableWallsFiller(usersGet, groupsGet);
            var info   = await filler.FillAsync(wallList);

            Assert.That(info.Succeed, Is.True);
            Assert.That(wallList.Items.Count, Is.EqualTo(3));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Iterate over all wall XML files and load them
        /// </summary>
        public void LoadWalls()
        {
            DirectoryInfo di = new DirectoryInfo(Path.Combine("XML Data", "Walls"));

            FileInfo[] fiArr = di.GetFiles("*.xml");
            foreach (FileInfo fileInfo in fiArr)
            {
                Int32 id = Convert.ToInt32(Path.GetFileNameWithoutExtension(fileInfo.Name));
                WallList.Add(id, this.WallsLoadXml(fileInfo.FullName));
                Segments.Add(id, new List <LineSegment>(WallList[id].NumWalls));
            }
        }
Exemplo n.º 4
0
    private void SetRoom(int positionX, int positionY, int width, int height) //在地圖上畫出房間
    {
        for (int i = positionX; i < positionX + width; i++)
        {
            for (int j = positionY; j < positionY + height; j++)
            {
                PositionList.Add(new Vector2Int(i, j));

                if (i == Position.x || i == Position.x + Width - 1 || j == Position.y || j == Position.y + Height - 1)
                {
                    WallList.Add(new Vector2Int(i, j));
                }
            }
        }
    }
Exemplo n.º 5
0
    protected override void SetSpace()
    {
        for (int i = Position.x; i < Position.x + Width; i++)
        {
            for (int j = Position.y; j < Position.y + Height; j++)
            {
                PositionList.Add(new Vector2Int(i, j));

                if (i == Position.x || i == Position.x + Width - 1 || j == Position.y || j == Position.y + Height - 1)
                {
                    WallList.Add(new Vector2Int(i, j));
                }
            }
        }

        Vector2Int        treasurePosition = new Vector2Int();
        List <Vector2Int> tempList         = new List <Vector2Int>(PositionList);

        for (int i = 0; i < _treasureAmount; i++)
        {
            treasurePosition = tempList[Random.Range(0, tempList.Count)];
            tempList.Remove(treasurePosition);
            if (!WallList.Contains(treasurePosition))
            {
                TreasureDic.Add(treasurePosition, new Treasure(RoomData.GetRandomTreasureID()));
            }
            else
            {
                i--;
            }
        }

        Vector2Int moneyPosition = new Vector2Int();

        for (int i = 0; i < _moneyAmount; i++)
        {
            moneyPosition = tempList[Random.Range(0, tempList.Count)];
            tempList.Remove(moneyPosition);
            if (!WallList.Contains(moneyPosition))
            {
                MoneyDic.Add(moneyPosition, Random.Range(DungeonData.MinMoney, DungeonData.MaxMoney + 1));
            }
            else
            {
                i--;
            }
        }
    }
Exemplo n.º 6
0
    private void DFS(Vector2Int walker)
    {
        Vector2Int        direction = new Vector2Int();
        Vector2Int        newWalker = new Vector2Int();
        List <Vector2Int> tempList  = new List <Vector2Int>();

        while (_spaceQueue.Count > 0)
        {
            tempList = new List <Vector2Int>(_directions);
            while (tempList.Count > 0)
            {
                direction = tempList[Random.Range(0, tempList.Count)];
                newWalker = walker + direction * 2;
                if (newWalker.x >= Position.x && newWalker.x < Position.x + Width && newWalker.y >= Position.y && newWalker.y < Position.y + Height &&
                    !PositionList.Contains(newWalker))
                {
                    PositionList.Add(walker + direction);
                    PositionList.Add(walker + direction * 2);
                    _spaceQueue.Enqueue(walker + direction * 2);

                    if (walker.x == Position.x || walker.x == Position.x + Width - 1 || walker.y == Position.y || walker.y == Position.y + Height - 1)
                    {
                        WallList.Add(walker);
                    }

                    break;
                }
                else
                {
                    tempList.Remove(direction);
                }
            }

            if (tempList.Count > 0)
            {
                DFS(newWalker);
            }
            else //如果所有的方向都沒有路
            {
                if (TreasureDic.Count < _treasureAmount)
                {
                    TreasureDic.Add(walker, new Treasure(RoomData.GetRandomTreasureID()));
                }

                DFS(_spaceQueue.Dequeue());
            }
        }
    }
        public AvailableWallsViewModel(IEventAggregator eventAggregator, AvailableWallsFiller filler, SharedWallContext sharedWallContext)
        {
            _eventAggregator   = eventAggregator;
            _filler            = filler;
            _sharedWallContext = sharedWallContext;
            WallList           = new WallList();

            WallList.ItemClicked += onWallItemClicked;
            _eventAggregator.GetEvent <WallSelectorEvents.FillWallRequest>().Subscribe(fillWallList);
            _eventAggregator.GetEvent <MainBottomEvents.Refresh>().Subscribe(fillWallList);

            _eventAggregator.GetEvent <AuthBarEvents.AuthorizationCompleted>()
            .Subscribe(authorized => IsAuthorized = authorized);
            _eventAggregator.GetEvent <AuthBarEvents.LogOutCompleted>()
            .Subscribe(() => IsAuthorized = false);
        }
Exemplo n.º 8
0
    protected override void SetSpace()
    {
        for (int i = Position.x; i < Position.x + Width; i++)
        {
            for (int j = Position.y; j < Position.y + Height; j++)
            {
                PositionList.Add(new Vector2Int(i, j));

                if (i == Position.x || i == Position.x + Width - 1 || j == Position.y || j == Position.y + Height - 1)
                {
                    WallList.Add(new Vector2Int(i, j));
                }
            }
        }
        TreasureDic.Add(new Vector2Int(Position.x + Width / 2, Position.y + Height / 2), new Treasure(RoomData.GetRandomTreasureID()));
    }
Exemplo n.º 9
0
    /// <summary>
    /// 获取格子的墙体,并添加到列表中
    /// </summary>
    /// <param name="Start">起始格子位置</param>
    /// <param name="End">结束点格子位置</param>
    /// <returns>返回墙列表</returns>
    private static void AddWall(ref List <IggWall> WallList, int Layer, int Unit)
    {
        if (WallList == null)
        {
            WallList = new List <IggWall>();
        }
        MapGrid m = GetMG(Layer, Unit);

        if (m != null)
        {
            IggWall w = m.GetWall();
            if (w != null && WallList.Contains(w) == false)
            {
                WallList.Add(w);
            }
        }
    }
        public async Task Fill_empty_wall_list_with_corrupted_users_data()
        {
            var usersGet = Substitute.For <IUsersGet>();

            usersGet.GetAsync(QueryParameters.No()).ReturnsForAnyArgs(new UsersGetResponse {
                Content = null
            });

            var groupsGet = SubstituresForVkApi.GroupsGet();
            var wallList  = new WallList();

            var filler = new AvailableWallsFiller(usersGet, groupsGet);
            var info   = await filler.FillAsync(wallList);

            Assert.That(info.Succeed, Is.False);
            Assert.That(info.ErrorMessage, Is.Not.Null);
        }
Exemplo n.º 11
0
        private void WallList_Loaded(object sender, RoutedEventArgs e)
        {
            var sb = WallList.GetListViewScrollViewer();

            sb.ViewChanging += (s, args) =>
            {
                if (args.FinalView.VerticalOffset > 100)
                {
                    ChromeFrame.SetIsVisible(this, ChromeFrame.VisibilityStates.IntermediateFull);
                }
                else
                {
                    ChromeFrame.SetIsVisible(this, ChromeFrame.VisibilityStates.Intermediate);
                }
            };

            WallList.Loaded -= WallList_Loaded;
        }
Exemplo n.º 12
0
        private void WallList_Loaded(object sender, RoutedEventArgs e)
        {
            wallScrollViewer = WallList.GetListViewScrollViewer();
            wallScrollViewer.ViewChanging += (s, args) =>
            {
                if (args.FinalView.VerticalOffset > 150)
                {
                    ChromeFrame.SetIsVisible(this, ChromeFrame.VisibilityStates.IntermediateFull);
                }
                else
                {
                    ChromeFrame.SetIsVisible(this, ChromeFrame.VisibilityStates.Intermediate);
                }
            };

            //wallScrollViewer.ChangeView(null, vm.WallScrollOffset, null, true);
            WallList.Loaded -= WallList_Loaded;
        }
Exemplo n.º 13
0
    protected override void SetSpace()
    {
        PositionList.Add(Position);
        _spaceQueue.Enqueue(Position);
        DFS(Position);

        List <Vector2Int> tempList      = new List <Vector2Int>(PositionList);
        Vector2Int        moneyPosition = new Vector2Int();

        for (int i = 0; i < _moneyAmount; i++)
        {
            moneyPosition = tempList[Random.Range(0, tempList.Count)];
            tempList.Remove(moneyPosition);
            if (!WallList.Contains(moneyPosition))
            {
                MoneyDic.Add(moneyPosition, Random.Range(DungeonData.MinMoney, DungeonData.MaxMoney + 1));
            }
            else
            {
                i--;
            }
        }
    }
Exemplo n.º 14
0
        public bool IsWall(Coord coord)
        {
            bool res = WallList.Contains(coord);

            return(res);
        }