Ejemplo n.º 1
0
    private void GenerateBatch()
    {
        int length = 2;

        length = (int)Mathf.Min(length, query.Count);

        List <ChunkTexture> chunkList = new List <ChunkTexture>();

        for (int i = 0; i < length; i++)
        {
            DictionaryEntry entry = query.Dequeue();

            ChunkTexture chunk     = (ChunkTexture)entry.Key;
            Rect         pixelsBox = (Rect)entry.Value;

            chunk.FillTexturePlanet(pixelsBox);
            chunk.UpdateColliders(pixelsBox);

            if (!chunkList.Contains(chunk))
            {
                chunkList.Add(chunk);
            }
        }

        foreach (ChunkTexture chunk in chunkList)
        {
            chunk.chunkTexture.Apply();
        }
    }
Ejemplo n.º 2
0
    public void ApplyRadial(Vector3 point, float radius)
    {
        point = Camera.main.ScreenToWorldPoint(point);
        Rect dmgBox = new Rect(point.x - radius, point.y - radius, radius * 2, radius * 2f);

        Rect chunkRange          = MathTests.GetOverlappingBox(planetFrame, dmgBox);
        Rect chunkRangeUnits     = MathTests.BoxChunkUnits(chunkRange);
        Rect chunkRangeUnitsDisc = MathTests.BoxToGrid(chunkRangeUnits);

        for (float y = chunkRangeUnitsDisc.y; y < chunkRangeUnitsDisc.y + chunkRangeUnitsDisc.height; y++)
        {
            for (float x = chunkRangeUnitsDisc.x; x < chunkRangeUnitsDisc.x + chunkRangeUnitsDisc.width; x++)
            {
                ChunkTexture chunk = chunks[((int)y + radiusChunks) * radiusChunks * 2 + ((int)x + radiusChunks)];

                Rect chunkBox   = new Rect(x, y, 1f, 1f);
                Rect overlapBox = MathTests.GetOverlappingBox(chunkRangeUnits, chunkBox);

                Rect pixelsBox = GetPixelsBox(chunkBox, overlapBox);

                chunk.ApplyRadial(point, radius, pixelsBox);
                chunk.UpdateColliders(pixelsBox);
            }
        }
    }