コード例 #1
0
    public List <PixelPosByte> GetAcceptableCellPositions(int count)
    {
        List <PixelPosByte> acceptableVariants = new List <PixelPosByte>();

        if (count == 0)
        {
            return(acceptableVariants);
        }
        for (byte i = 0; i < INNER_RESOLUTION; i++)
        {
            for (byte j = 0; j < INNER_RESOLUTION; j++)
            {
                if (map[i * INNER_RESOLUTION + j] == false)
                {
                    acceptableVariants.Add(new PixelPosByte(i, j));
                }
            }
        }
        if (acceptableVariants.Count == 0)
        {
            fullfillStatus = FullfillStatus.Full;
            return(new List <PixelPosByte>());
        }
        else
        {
            while (acceptableVariants.Count > count)
            {
                int i = Random.Range(0, acceptableVariants.Count);
                acceptableVariants.RemoveAt(i);
            }
            return(acceptableVariants);
        }
    }
コード例 #2
0
 public PlaneExtension(Plane i_myPlane, Structure i_mainStructure)
 {
     ResetMap();
     artificialStructuresCount = 0;
     myPlane = i_myPlane;
     if (i_mainStructure != null)
     {
         AddStructure(i_mainStructure);
     }
     else
     {
         fullfillStatus = FullfillStatus.Empty;
     }
 }
コード例 #3
0
    public void RecalculateSurface()
    {
        ResetMap();
        artificialStructuresCount = 0;
        fullfillStatus            = FullfillStatus.Empty;

        if (structures != null)
        {
            int a = 0;
            while (a < structures.Count)
            {
                Structure s = structures[a];
                if (s == null)
                {
                    structures.RemoveAt(a);
                    continue;
                }
                if (s.isArtificial)
                {
                    artificialStructuresCount++;
                }
                SurfaceRect sr = s.surfaceRect;
                if (sr.size != INNER_RESOLUTION)
                {
                    int i = 0, j = 0;
                    while (j < sr.size & sr.x + i < INNER_RESOLUTION)
                    {
                        while (i < sr.size & sr.z + j < INNER_RESOLUTION)
                        {
                            map.Set((sr.x + i) * INNER_RESOLUTION + sr.z + j, true);
                            i++;
                        }
                        i = 0; // обнуляй переменные !
                        j++;
                    }
                }
                else
                {
                    map.SetAll(true);
                    fullfillStatus = FullfillStatus.Full;
                    return;
                }
                a++;
            }
            if (structures.Count == 0)
            {
                structures = null;
                return;
            }
            else
            {
                foreach (bool b in map)
                {
                    if (b == false)
                    {
                        fullfillStatus = FullfillStatus.Unknown;
                        return;
                    }
                }
                fullfillStatus = FullfillStatus.Full;
            }
        }
    }