當前位置: 首頁>>代碼示例>>C#>>正文


C# Chart.NoteCount方法代碼示例

本文整理匯總了C#中Chart.NoteCount方法的典型用法代碼示例。如果您正苦於以下問題:C# Chart.NoteCount方法的具體用法?C# Chart.NoteCount怎麽用?C# Chart.NoteCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Chart的用法示例。


在下文中一共展示了Chart.NoteCount方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Write

        public static void Write(Stream target, Chart chart)
        {
            // I don't know if these are needed, but they are
            // parameters for note count you would typically find
            // in such a chart, so we will include them

            BinaryWriter writer = new BinaryWriter(target);

            writer.Write((Int32)0);
            writer.Write((byte)0x10);    // notecount ID
            writer.Write((byte)0x00);    // player#
            writer.Write((Int16)chart.NoteCount(1));
            writer.Write((Int32)0);
            writer.Write((byte)0x10);    // notecount ID
            writer.Write((byte)0x01);    // player#
            writer.Write((Int16)chart.NoteCount(2));

            foreach (Entry entry in chart.Entries)
            {
                long num;
                long den;
                Int32 entryOffset = (Int32)(entry.LinearOffset);
                byte entryType = 0xFF;
                byte entryParameter = (byte)(entry.Parameter & 0xFF);
                Int16 entryValue = 0;

                switch (entry.Type)
                {
                    case EntryType.EndOfSong:
                        entryType = 0x06;
                        entryParameter = 0;
                        entryValue = 0;
                        break;
                    case EntryType.Judgement:
                        entryType = 0x08;
                        entryParameter = (byte)entry.Parameter;
                        entryValue = (Int16)entry.Value;
                        break;
                    case EntryType.Marker:
                        if (entry.Player < 1)
                        {
                            entryType = 0x07;
                            entryValue = (Int16)entry.Value;
                        }
                        else
                        {
                            entryType = (byte)(entry.Player - 1);
                            entryValue = 0;
                            entryParameter = (byte)entry.Column;
                        }
                        break;
                    case EntryType.Measure:
                        entryType = 0x0C;
                        entryParameter = (byte)(entry.Player - 1);
                        break;
                    case EntryType.Sample:
                        if (entry.Player > 0)
                        {
                            entryType = (byte)(entry.Player + 1);
                            entryValue = (Int16)entry.Value;
                            entryParameter = (byte)entry.Column;
                        }
                        break;
                    case EntryType.Tempo:
                        num = entry.Value.Numerator;
                        den = entry.Value.Denominator;
                        while ((num > 32767) || (den > 255))
                        {
                            num /= 2;
                            den /= 2;
                        }
                        entryValue = (Int16)num;
                        entryParameter = (byte)den;
                        entryType = 0x04;
                        break;
                    default:
                        continue;
                }
                if (entryType == 0xFF)
                    continue;

                writer.Write(entryOffset);
                writer.Write(entryType);
                writer.Write(entryParameter);
                writer.Write(entryValue);
            }
            writer.Write((Int32)0x7FFFFFFF);
            writer.Write((Int32)0);
        }
開發者ID:NoOnes2,項目名稱:scharfrichter,代碼行數:89,代碼來源:BeatmaniaIIDXPC.cs


注:本文中的Chart.NoteCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。