Пример #1
0
        public void recordGlyphScan(GameManager manager, int scannedGlyphIndex, Color scannerColor)
        {
            foreach (Beam b in beams)
            {
                b.recordGlyphScan(manager, pulseLocation, scannedGlyphIndex);
            }
            GlyphState g = alphabet.glyphs[scannedGlyphIndex];

            g.residualScanStrength = Constants.residualScanMax;
            g.scannerColor         = scannerColor;
        }
Пример #2
0
        public void renderDecoder(GameState state, int renderWidth, int renderHeight)
        {
            gViewport.Clear(Color.Black);
            gViewport.DrawImage(database.images.decoderBkg.bmp, 0, 0);

            int glyphIndex = 0;

            for (int gridY = 0; gridY < Constants.decoderGridSize.y; gridY++)
            {
                for (int gridX = 0; gridX < Constants.decoderGridSize.x; gridX++)
                {
                    if (glyphIndex >= Constants.totalGlyphCount)
                    {
                        continue;
                    }

                    GlyphState g    = state.level.alphabet.glyphs[glyphIndex];
                    Bitmap     bmpA = database.images.glyphImages[glyphIndex].bmp;
                    Bitmap     bmpB = g.texture.bmp;

                    //Constants.decoderGridStart +
                    Vec2 gridStartPos = Constants.decoderGridStart + new Vec2(gridX * Constants.decoderGridSpacing.x, gridY * Constants.decoderGridSpacing.y);
                    drawImage(bmpA, gridStartPos, new Vec2(Constants.glyphDim, Constants.glyphDim));
                    drawImage(bmpB, gridStartPos + Constants.decoderTextureOffset, Constants.textureSize);

                    if (g.residualScanStrength > 0.0)
                    {
                        double strength  = g.residualScanStrength / Constants.residualScanMax;
                        Color  c         = Color.FromArgb((int)(strength * 255.0), g.scannerColor);
                        Pen    borderPen = new Pen(c, 10.0f);
                        drawRectangle(borderPen, gridStartPos + Constants.decoderTextureOffset, Constants.textureSize);
                    }

                    glyphIndex++;
                }
            }

            renderWidth  = targetBox.Width;
            renderHeight = targetBox.Height;
            resizeScreen(renderWidth, renderHeight);
            gScreen.CompositingMode   = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
            gScreen.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            gScreen.DrawImage(bmpViewport, new Rectangle(0, 0, renderWidth, renderHeight));
            targetBox.Image = bmpScreen;
        }
Пример #3
0
        public AlphabetState(LevelGenInfo info)
        {
            if (info.textureType == TextureType.ColorGrid)
            {
                int maxAttemptCount = 100;
                for (int i = 0; i < Constants.totalGlyphCount; i++)
                {
                    for (int attempt = 0; attempt < maxAttemptCount; attempt++)
                    {
                        GlyphState newGlyph = new GlyphState(info, -1);
                        bool       isValid  = true;
                        foreach (GlyphState g in glyphs)
                        {
                            if (Texture.texturesEquivalent(g.texture, newGlyph.texture))
                            {
                                isValid = false;
                            }
                        }
                        if (isValid)
                        {
                            glyphs.Add(newGlyph);
                            break;
                        }
                    }
                }
            }
            else
            {
                var textureIndices = new List <int>();
                for (int i = 0; i < Constants.totalGlyphCount; i++)
                {
                    textureIndices.Add(i);
                }
                textureIndices = textureIndices.Shuffle();

                for (int i = 0; i < Constants.totalGlyphCount; i++)
                {
                    GlyphState newGlyph = new GlyphState(info, textureIndices[i]);
                    glyphs.Add(newGlyph);
                }
            }
        }