コード例 #1
0
        public Texture(LevelGenInfo info, int textureIndex)
        {
            colors = info.colors;
            type   = info.textureType;

            if (type == TextureType.ColorGrid)
            {
                colorGridIndices = new int[info.colorGridX, info.colorGridY];
                for (int x = 0; x < info.colorGridX; x++)
                {
                    for (int y = 0; y < info.colorGridY; y++)
                    {
                        colorGridIndices[x, y] = Util.randInt(0, info.colors.Count);
                    }
                }
                bmp = new Bitmap((int)Constants.textureSize.x, (int)Constants.textureSize.y);
                g   = Graphics.FromImage(bmp);
            }

            int textureGroupIndex = getTextureGroupIndex(type);

            if (textureGroupIndex != -1)
            {
                string filename = Constants.dataDir + "textureGroup" + textureGroupIndex.ToString() + "/tex" + textureIndex.ToString() + ".png";
                //bmp = new Bitmap(Bitmap.FromFile(filename), new Size((int)Constants.textureSize.x, (int)Constants.textureSize.y));
                bmp = new Bitmap(Bitmap.FromFile(filename));
            }
        }
コード例 #2
0
ファイル: GameState.cs プロジェクト: techmatt/GL2019
        public GameLevel(int levelIndex)
        {
            int          expansion = 0;
            LevelGenInfo info      = null;

            while (info == null)
            {
                info     = new LevelGenInfo(levelIndex, expansion);
                alphabet = new AlphabetState(info);

                if (alphabet.glyphs.Count != Constants.totalGlyphCount)
                {
                    info = null;
                    expansion++;
                }
            }

            var glyphsUsed = new HashSet <int>();

            for (int i = 0; i < Constants.beamCount; i++)
            {
                beams.Add(new Beam(info, info.beamNoteCounts[i], glyphsUsed));
            }

            pulseSpeed = 0.1;

            resetPulse();
        }
コード例 #3
0
ファイル: GameState.cs プロジェクト: techmatt/GL2019
        public Note(LevelGenInfo info)
        {
            double noteLength = Util.uniform(info.minNoteLength, info.maxNoteLength);

            start      = Util.uniform(0.0, 1.0 - noteLength);
            end        = start + noteLength;
            glyphIndex = Util.randInt(0, Constants.totalGlyphCount);
        }
コード例 #4
0
ファイル: GameState.cs プロジェクト: techmatt/GL2019
        public Beam(LevelGenInfo info, int noteCount, HashSet <int> glyphsUsed)
        {
            int maxNoteAddAttempts = 100;

            for (int i = 0; i < maxNoteAddAttempts && notes.Count < noteCount; i++)
            {
                Note newNote = new Note(info);
                if (canAddNote(newNote, glyphsUsed))
                {
                    notes.Add(newNote);
                    glyphsUsed.Add(newNote.glyphIndex);
                }
            }
        }
コード例 #5
0
ファイル: GameState.cs プロジェクト: techmatt/GL2019
        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);
                }
            }
        }
コード例 #6
0
ファイル: GameState.cs プロジェクト: techmatt/GL2019
 public GlyphState(LevelGenInfo info, int textureIndex)
 {
     texture = new Texture(info, textureIndex);
     residualScanStrength = 0.0;
 }