Beispiel #1
0
        public Vector3Int GetFreePosAnyLvl()
        {
            var emptySlots = new List <Vector3Int>();

            for (var i = 0; i < IndexMas[1].Length; i++)
            {
                for (var j = 0; j < IndexMas[1][i].Length; j++)
                {
                    for (int z = 1; z < ChunkManager.MaxGroundsLvls; z++)
                    {
                        if (IndexMas[1][i][j] != -1 ||
                            !ChunkUtil.IsGround(ChunkNumber,
                                                ChunkUtil.GetDovvner(new Vector3Int(i, j, z))))
                        {
                            continue;
                        }
                        emptySlots.Add(new Vector3Int(i, j, z));
                    }
                }
            }
            if (emptySlots.Count == 0)
            {
                return(new Vector3Int(0, 0, 0));
            }

            var range = Random.Range(0, emptySlots.Count);

            return(emptySlots[range]);
        }
Beispiel #2
0
 public static bool IsInvalidPoint(int chunkNumber, Vector3Int point)
 {
     return((point.z + 1 < ChunkManager.MaxGroundsLvls &&
             ChunkUtil.IsAnyEntity(chunkNumber, ChunkUtil.GetUpper(point))) ||
            ChunkUtil.IsGround(chunkNumber, point) ||
            ChunkUtil.IsEntity(chunkNumber, point));
 }