Ejemplo n.º 1
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--;
            }
        }
    }
Ejemplo n.º 2
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);
            }
        }
    }
Ejemplo n.º 3
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--;
            }
        }
    }
Ejemplo n.º 4
0
        public bool IsWall(Coord coord)
        {
            bool res = WallList.Contains(coord);

            return(res);
        }