当前位置: 首页>>代码示例>>C#>>正文


C# FastList.ToArray方法代码示例

本文整理汇总了C#中FastList.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# FastList.ToArray方法的具体用法?C# FastList.ToArray怎么用?C# FastList.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FastList的用法示例。


在下文中一共展示了FastList.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveProps

 public static void RemoveProps()
 {
     var prefabs = Resources.FindObjectsOfTypeAll<BuildingInfo>();
     foreach (var buildingInfo in prefabs)
     {
         var fastList = new FastList<BuildingInfo.Prop>();
         if (buildingInfo == null)
         {
             continue;
         }
         if (buildingInfo.m_props != null)
         {
             var props = buildingInfo.m_props;
             foreach (var prop in props.Where(prop => prop != null))
             {
                 if (prop.m_finalProp != null)
                 {
                     if (
                         (!OptionsHolder.Options.removeSmoke || !prop.m_finalProp.name.Contains("Smoke") && !prop.m_finalProp.name.Contains("smoke")) &&
                         (!OptionsHolder.Options.removeSteam || !prop.m_finalProp.name.Contains("Steam") && !prop.m_finalProp.name.Contains("steam")) &&
                         (!OptionsHolder.Options.removeClownHeads || !prop.m_finalProp.name.Contains("Clown") && !prop.m_finalProp.name.Contains("clown")) &&
                         (!OptionsHolder.Options.removeIceCones || !prop.m_finalProp.name.Contains("Cream") && !prop.m_finalProp.name.Contains("cream")) &&
                         (!OptionsHolder.Options.removeDoughnutSquirrels || !prop.m_finalProp.name.Contains("Squirrel") && !prop.m_finalProp.name.Contains("squirrel")) &&
                         (!OptionsHolder.Options.removeRandom3dBillboards || prop.m_finalProp.name != "Billboard_3D_variation") &&
                         (!OptionsHolder.Options.removeFlatBillboards || prop.m_finalProp.name != "Hologram Ad Game Arcade") &&
                         (!OptionsHolder.Options.removeNeonChirpy || !BillboardCategories.Contains(prop.m_finalProp.editorCategory)) &&
                         (!OptionsHolder.Options.removeOctopodes || !prop.m_finalProp.name.Contains("Octopus") && !prop.m_finalProp.name.Contains("octopus")) &&
                         (!OptionsHolder.Options.removeWallFlags || prop.m_finalProp.name != "flag_pole_wall") &&
                         (!OptionsHolder.Options.removeSolarPanels || !prop.m_finalProp.name.Contains("Solar panel"))
                         )
                     {
                         fastList.Add(prop);
                     }
                 }
                 else
                 {
                     fastList.Add(prop);
                 }
             }
         }
         buildingInfo.m_props = fastList.ToArray();
     }
 }
开发者ID:earalov,项目名称:Skylines-PropRemover,代码行数:43,代码来源:PropRemover.cs

示例2: OnSaveData

        public void OnSaveData()
        {
            Debug.Log("Saving Mod Data.");
            var data = new FastList<byte>();

            GenerateUniqueId();

            Debug.Log("UniqueID: " + UniqueId);
            var uniqueIdBytes = BitConverter.GetBytes(UniqueId);

            foreach (var uniqueIdByte in uniqueIdBytes)
            {
                data.Add(uniqueIdByte);
            }

            var dataToSave = data.ToArray();
            SerializableData.SaveData(DataId, dataToSave);

            var filepath = Path.Combine(Application.dataPath, "trafficManagerSave_" + UniqueId + ".xml");
            Debug.Log("Save Location: " + filepath);
            var configuration = new Configuration();

            for (var i = 0; i < 32768; i++)
            {
                if (TrafficPriority.PrioritySegments.ContainsKey(i))
                {
                    if (TrafficPriority.PrioritySegments[i].Node1 != 0)
                    {
                        configuration.PrioritySegments.Add(new[] { TrafficPriority.PrioritySegments[i].Node1, i, (int)TrafficPriority.PrioritySegments[i].Instance1.Type });
                    }
                    if (TrafficPriority.PrioritySegments[i].Node2 != 0)
                    {
                        configuration.PrioritySegments.Add(new[] { TrafficPriority.PrioritySegments[i].Node2, i, (int)TrafficPriority.PrioritySegments[i].Instance2.Type });
                    }
                }

                if (CustomRoadAI.NodeDictionary.ContainsKey((ushort) i))
                {
                    var nodeDict = CustomRoadAI.NodeDictionary[(ushort)i];

                    configuration.NodeDictionary.Add(new[] {nodeDict.NodeId, Convert.ToInt32(nodeDict.ManualTrafficLights), Convert.ToInt32(nodeDict.TimedTrafficLights), Convert.ToInt32(nodeDict.TimedTrafficLightsActive)});
                }

                if (TrafficLightsManual.ManualSegments.ContainsKey(i))
                {
                    if (TrafficLightsManual.ManualSegments[i].Node1 != 0)
                    {
                        var manualSegment = TrafficLightsManual.ManualSegments[i].Instance1;

                        configuration.ManualSegments.Add(new[]
                        {
                            manualSegment.Node,
                            manualSegment.Segment,
                            (int)manualSegment.CurrentMode,
                            (int)manualSegment.LightLeft,
                            (int)manualSegment.LightMain,
                            (int)manualSegment.LightRight,
                            (int)manualSegment.LightPedestrian,
                            (int)manualSegment.LastChange,
                            (int)manualSegment.LastChangeFrame,
                            Convert.ToInt32(manualSegment.PedestrianEnabled)
                        });
                    }
                    if (TrafficLightsManual.ManualSegments[i].Node2 != 0)
                    {
                        var manualSegment = TrafficLightsManual.ManualSegments[i].Instance2;

                        configuration.ManualSegments.Add(new[]
                        {
                            manualSegment.Node,
                            manualSegment.Segment,
                            (int)manualSegment.CurrentMode,
                            (int)manualSegment.LightLeft,
                            (int)manualSegment.LightMain,
                            (int)manualSegment.LightRight,
                            (int)manualSegment.LightPedestrian,
                            (int)manualSegment.LastChange,
                            (int)manualSegment.LastChangeFrame,
                            Convert.ToInt32(manualSegment.PedestrianEnabled)
                        });
                    }
                }

                if (!TrafficLightsTimed.TimedScripts.ContainsKey((ushort) i)) continue;

                var timedNode = TrafficLightsTimed.GetTimedLight((ushort) i);

                configuration.TimedNodes.Add(new[] { timedNode.NodeId, timedNode.CurrentStep, timedNode.NumSteps(), Convert.ToInt32(timedNode.IsStarted())});

                var nodeGroup = new ushort[timedNode.NodeGroup.Count];

                for (var j = 0; j < timedNode.NodeGroup.Count; j++)
                {
                    nodeGroup[j] = timedNode.NodeGroup[j];
                }

                configuration.TimedNodeGroups.Add(nodeGroup);

                for (var j = 0; j < timedNode.NumSteps(); j++)
                {
//.........这里部分代码省略.........
开发者ID:seiggy,项目名称:Skylines-Traffic-Manager,代码行数:101,代码来源:SerializableDataExtension.cs

示例3: SetupTurningLaneProps

        private static void SetupTurningLaneProps(NetInfo.Lane lane)
        {
            var isLeftDriving = Singleton<SimulationManager>.instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True;

            if (lane.m_laneProps == null)
            {
                return;
            }

            if (lane.m_laneProps.m_props == null)
            {
                return;
            }

            var fwd = lane.m_laneProps.m_props.FirstOrDefault(p => p.m_flagsRequired == NetLane.Flags.Forward);
            var left = lane.m_laneProps.m_props.FirstOrDefault(p => p.m_flagsRequired == NetLane.Flags.Left);
            var right = lane.m_laneProps.m_props.FirstOrDefault(p => p.m_flagsRequired == NetLane.Flags.Right);

            if (fwd == null)
            {
                return;
            }

            if (left == null)
            {
                return;
            }

            if (right == null)
            {
                return;
            }


            // Existing props
            //var r0 = NetLane.Flags.Forward; 
            //var r1 = NetLane.Flags.ForwardRight;
            //var r2 = NetLane.Flags.Left;
            //var r3 = NetLane.Flags.LeftForward;
            //var r4 = NetLane.Flags.LeftForwardRight;
            //var r5 = NetLane.Flags.LeftRight;
            //var r6 = NetLane.Flags.Right;

            //var f0 = NetLane.Flags.LeftRight;
            //var f1 = NetLane.Flags.Left;
            //var f2 = NetLane.Flags.ForwardRight;
            //var f3 = NetLane.Flags.Right;
            //var f4 = NetLane.Flags.None;
            //var f5 = NetLane.Flags.Forward;
            //var f6 = NetLane.Flags.LeftForward;


            var newProps = new FastList<NetLaneProps.Prop>();

            //newProps.Add(fwd); // Do we want "Forward" on a turning lane?
            newProps.Add(left);
            newProps.Add(right);

            var fl = left.ShallowClone();
            fl.m_flagsRequired = NetLane.Flags.LeftForward;
            fl.m_flagsForbidden = NetLane.Flags.Right;
            newProps.Add(fl);

            var fr = right.ShallowClone();
            fr.m_flagsRequired = NetLane.Flags.ForwardRight;
            fr.m_flagsForbidden = NetLane.Flags.Left;
            newProps.Add(fr);

            var flr = isLeftDriving ? right.ShallowClone() : left.ShallowClone();
            flr.m_flagsRequired = NetLane.Flags.LeftForwardRight;
            flr.m_flagsForbidden = NetLane.Flags.None;
            newProps.Add(flr);

            var lr = isLeftDriving ? right.ShallowClone() : left.ShallowClone();
            lr.m_flagsRequired = NetLane.Flags.LeftRight;
            lr.m_flagsForbidden = NetLane.Flags.Forward;
            newProps.Add(lr);

            lane.m_laneProps = ScriptableObject.CreateInstance<NetLaneProps>();
            lane.m_laneProps.name = "TurningLane";
            lane.m_laneProps.m_props = newProps.ToArray();
        }
开发者ID:Katalyst6,项目名称:CSL.TransitAddonMod,代码行数:82,代码来源:RoadHelper.LaneSetup.cs

示例4: ReadTrack

        public void ReadTrack()
        {
            var newTrack = new Track(1);
            _score.AddTrack(newTrack);

            var flags = Data.ReadByte();
            newTrack.Name = ReadStringByteLength(40);
            newTrack.IsPercussion = (flags & 0x01) != 0;

            var stringCount = ReadInt32();
            var tuning = new FastList<int>();
            for (int i = 0; i < 7; i++)
            {
                var stringTuning = ReadInt32();
                if (stringCount > i)
                {
                    tuning.Add(stringTuning);
                }
            }
            newTrack.Tuning = tuning.ToArray();

            var port = ReadInt32();
            var index = ReadInt32() - 1;
            var effectChannel = ReadInt32() - 1;
            Data.Skip(4); // Fretcount
            if (index >= 0 && index < _playbackInfos.Count)
            {
                var info = _playbackInfos[index];
                info.Port = port;
                info.IsSolo = (flags & 0x10) != 0;
                info.IsMute = (flags & 0x20) != 0;
                info.SecondaryChannel = effectChannel;

                newTrack.PlaybackInfo = info;
            }

            newTrack.Capo = ReadInt32();
            newTrack.Color = ReadColor();

            if (_versionNumber >= 500)
            {
                // flags for
                //  0x01 -> show tablature
                //  0x02 -> show standard notation
                Data.ReadByte();
                // flags for
                //  0x02 -> auto let ring
                //  0x04 -> auto brush
                Data.ReadByte();

                // unknown
                Data.Skip(43);
            }

            // unknown
            if (_versionNumber >= 510)
            {
                Data.Skip(4);
                ReadStringIntByte();
                ReadStringIntByte();
            }
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:62,代码来源:Gp3To5Importer.cs

示例5: LoadSf2


//.........这里部分代码省略.........
                Generator[] globalGens = null;
                int i;
                if (p.Zones[0].Generators.Length == 0 ||
                    p.Zones[0].Generators[p.Zones[0].Generators.Length - 1].GeneratorType != GeneratorEnum.Instrument)
                {
                    globalGens = p.Zones[0].Generators;
                    i = 1;
                }
                else
                {
                    i = 0;
                }

                var regionList = new FastList<Sf2Region>();
                while (i < p.Zones.Length)
                {
                    byte presetLoKey = 0;
                    byte presetHiKey = 127;
                    byte presetLoVel = 0;
                    byte presetHiVel = 127;

                    if (p.Zones[i].Generators[0].GeneratorType == GeneratorEnum.KeyRange)
                    {
                        if (TypeUtils.IsLittleEndian)
                        {
                            presetLoKey = TypeUtils.ToUInt8(p.Zones[i].Generators[0].AmountInt16 & 0xFF);
                            presetHiKey = TypeUtils.ToUInt8((p.Zones[i].Generators[0].AmountInt16 >> 8) & 0xFF);
                        }
                        else
                        {
                            presetHiKey = TypeUtils.ToUInt8(p.Zones[i].Generators[0].AmountInt16 & 0xFF);
                            presetLoKey = TypeUtils.ToUInt8((p.Zones[i].Generators[0].AmountInt16 >> 8) & 0xFF);
                        }
                        if (p.Zones[i].Generators.Length > 1 && p.Zones[i].Generators[1].GeneratorType == GeneratorEnum.VelocityRange)
                        {
                            if (TypeUtils.IsLittleEndian)
                            {
                                presetLoVel = TypeUtils.ToUInt8(p.Zones[i].Generators[1].AmountInt16 & 0xFF);
                                presetHiVel = TypeUtils.ToUInt8((p.Zones[i].Generators[1].AmountInt16 >> 8) & 0xFF);
                            }
                            else
                            {
                                presetHiVel = TypeUtils.ToUInt8(p.Zones[i].Generators[1].AmountInt16 & 0xFF);
                                presetLoVel = TypeUtils.ToUInt8((p.Zones[i].Generators[1].AmountInt16 >> 8) & 0xFF);
                            }
                        }
                    }
                    else if (p.Zones[i].Generators[0].GeneratorType == GeneratorEnum.VelocityRange)
                    {
                        if (TypeUtils.IsLittleEndian)
                        {
                            presetLoVel = TypeUtils.ToUInt8(p.Zones[i].Generators[0].AmountInt16 & 0xFF);
                            presetHiVel = TypeUtils.ToUInt8((p.Zones[i].Generators[0].AmountInt16 >> 8) & 0xFF);
                        }
                        else
                        {
                            presetHiVel = TypeUtils.ToUInt8(p.Zones[i].Generators[0].AmountInt16 & 0xFF);
                            presetLoVel = TypeUtils.ToUInt8((p.Zones[i].Generators[0].AmountInt16 >> 8) & 0xFF);
                        }
                    }
                    if (p.Zones[i].Generators[p.Zones[i].Generators.Length - 1].GeneratorType == GeneratorEnum.Instrument)
                    {
                        var insts = sfinsts[p.Zones[i].Generators[p.Zones[i].Generators.Length - 1].AmountInt16];
                        foreach (var inst in insts)
                        {
                            byte instLoKey;
                            byte instHiKey;
                            byte instLoVel;
                            byte instHiVel;
                            if (TypeUtils.IsLittleEndian)
                            {
                                instLoKey = TypeUtils.ToUInt8(inst.Generators[(int)GeneratorEnum.KeyRange] & 0xFF);
                                instHiKey = TypeUtils.ToUInt8((inst.Generators[(int)GeneratorEnum.KeyRange] >> 8) & 0xFF);
                                instLoVel = TypeUtils.ToUInt8(inst.Generators[(int)GeneratorEnum.VelocityRange] & 0xFF);
                                instHiVel = TypeUtils.ToUInt8((inst.Generators[(int)GeneratorEnum.VelocityRange] >> 8) & 0xFF);
                            }
                            else
                            {
                                instHiKey = TypeUtils.ToUInt8(inst.Generators[(int)GeneratorEnum.KeyRange] & 0xFF);
                                instLoKey = TypeUtils.ToUInt8((inst.Generators[(int)GeneratorEnum.KeyRange] >> 8) & 0xFF);
                                instHiVel = TypeUtils.ToUInt8(inst.Generators[(int)GeneratorEnum.VelocityRange] & 0xFF);
                                instLoVel = TypeUtils.ToUInt8((inst.Generators[(int)GeneratorEnum.VelocityRange] >> 8) & 0xFF);
                            }
                            if ((instLoKey <= presetHiKey && presetLoKey <= instHiKey) && (instLoVel <= presetHiVel && presetLoVel <= instHiVel))
                            {
                                var r = new Sf2Region();
                                Std.ArrayCopy(inst.Generators, 0, r.Generators, 0, r.Generators.Length);
                                ReadSf2Region(r, globalGens, p.Zones[i].Generators, true);
                                regionList.Add(r);
                            }
                        }
                    }
                    i++;
                }
                var mp = new MultiPatch(p.Name);
                mp.LoadSf2(regionList.ToArray(), _assets);
                _assets.PatchAssets.Add(new PatchAsset(mp.Name, mp));
                AssignPatchToBank(mp, p.BankNumber, p.PatchNumber, p.PatchNumber);
            }
        }
开发者ID:eriser,项目名称:alphaSynth,代码行数:101,代码来源:PatchBank.cs

示例6: OnSaveData

        public void OnSaveData()
        {
            FastList<byte> data = new FastList<byte>();
            //            Debug.Log("OnSaveData() 1");
            GenerateUniqueID();

            byte[] uniqueIdBytes = BitConverter.GetBytes(uniqueID);
            foreach (byte uniqueIdByte in uniqueIdBytes) {
                data.Add(uniqueIdByte);
            }
            //            Debug.Log("OnSaveData() 2");

            byte[] dataToSave = data.ToArray();
            SerializableData.SaveData(dataID, dataToSave);

            //            Debug.Log("OnSaveData() 3");
            var filepath = Path.Combine(Application.dataPath, "trafficManagerSave_" + uniqueID + ".xml");
            //            Debug.Log("OnSaveData()");

            var configuration = new Configuration();
            //            Debug.Log("OnSaveData() 4");

            configuration.laneFlags = "";
            configuration.nodeCrosswalk = "";
            configuration.nodeTrafficLights = "";

            for (var i = 0; i < 32768; i++) {
                if (TrafficPriority.prioritySegments.ContainsKey(i)) {
                    if (TrafficPriority.prioritySegments[i].node_1 != 0) {
                        configuration.prioritySegments.Add(new int[3] {
                            TrafficPriority.prioritySegments[i].node_1,
                            i,
                            (int)TrafficPriority.prioritySegments[i].instance_1.type
                        });
                    }
                    //Debug.Log("OnSaveData() 5");

                    if (TrafficPriority.prioritySegments[i].node_2 != 0) {
                        configuration.prioritySegments.Add(new int[3] {
                            TrafficPriority.prioritySegments[i].node_2,
                            i,
                            (int)TrafficPriority.prioritySegments[i].instance_2.type
                        });
                    }
                }
                //Debug.Log("OnSaveData() 6");

                if (CustomRoadAI.nodeDictionary.ContainsKey((ushort)i)) {
                    var nodeDict = CustomRoadAI.nodeDictionary[(ushort)i];

                    configuration.nodeDictionary.Add(new int[4] {
                        nodeDict.NodeId,
                        Convert.ToInt32(nodeDict._manualTrafficLights),
                        Convert.ToInt32(nodeDict._timedTrafficLights),
                        Convert.ToInt32(nodeDict.TimedTrafficLightsActive)
                    });
                }
            //                Debug.Log("OnSaveData() 7");

                if (TrafficLightsManual.ManualSegments.ContainsKey(i)) {
                    if (TrafficLightsManual.ManualSegments[i].node_1 != 0) {
                        var manualSegment = TrafficLightsManual.ManualSegments[i].instance_1;

                        configuration.manualSegments.Add(new int[10] {
                            (int)manualSegment.node,
                            manualSegment.segment,
                            (int)manualSegment.currentMode,
                            (int)manualSegment.lightLeft,
                            (int)manualSegment.lightMain,
                            (int)manualSegment.lightRight,
                            (int)manualSegment.lightPedestrian,
                            (int)manualSegment.lastChange,
                            (int)manualSegment.lastChangeFrame,
                            Convert.ToInt32(manualSegment.pedestrianEnabled)
                        });
                    }
                    //Debug.Log("OnSaveData() 8");

                    if (TrafficLightsManual.ManualSegments[i].node_2 != 0) {
                        var manualSegment = TrafficLightsManual.ManualSegments[i].instance_2;
                        //Debug.Log("OnSaveData() 9");

                        configuration.manualSegments.Add(new int[10] {
                            (int)manualSegment.node,
                            manualSegment.segment,
                            (int)manualSegment.currentMode,
                            (int)manualSegment.lightLeft,
                            (int)manualSegment.lightMain,
                            (int)manualSegment.lightRight,
                            (int)manualSegment.lightPedestrian,
                            (int)manualSegment.lastChange,
                            (int)manualSegment.lastChangeFrame,
                            Convert.ToInt32(manualSegment.pedestrianEnabled)
                        });
                    }
                }
            //                Debug.Log("OnSaveData() 10");

                if (TrafficLightsTimed.timedScripts.ContainsKey((ushort)i)) {
                    var timedNode = TrafficLightsTimed.GetTimedLight((ushort)i);
//.........这里部分代码省略.........
开发者ID:akira-ishizaki,项目名称:TrafficManager_ImprovedAI,代码行数:101,代码来源:SerializableDataExtension.cs

示例7: XMLStringToActiveRewards

 public static IReward[] XMLStringToActiveRewards(string xml)
 {
     FastList<IReward> rewards = new FastList<IReward> ();
     XmlDocument doc = new XmlDocument ();
     doc.LoadXml (xml);
     foreach (XmlNode rewardNode in doc.SelectNodes("boost")) {
         XmlAttributeCollection atts = rewardNode.Attributes;
         Boost b = new Boost();
         b.ValueID = Data.StringToValueID(atts ["name"].Value);
         b.Value = float.Parse(atts ["value"].Value);
         if (atts ["endDate"] != null) {
             b.EndDate = DateTime.Parse (atts ["endDate"].Value);
         }
         b.Activate ();
         rewards.Add (b);
     }
     return rewards.ToArray ();
 }
开发者ID:CWMlolzlz,项目名称:Challenges,代码行数:18,代码来源:DataManager.cs

示例8: OnSaveData

        public void OnSaveData()
        {
            if (Debugger.Enabled)
            {
                Debugger.Log("Building Themes: SerializableDataExtension.OnSaveData was called.");
                Debugger.Log("ON_SAVE_DATA");
            }

            var data = new FastList<byte>();

            GenerateUniqueId();

            var uniqueIdBytes = BitConverter.GetBytes(UniqueId);
            foreach (var uniqueIdByte in uniqueIdBytes)
            {
                data.Add(uniqueIdByte);
            }

            var dataToSave = data.ToArray();
            SerializableData.SaveData(DataId, dataToSave);

            var filepath = BuildSaveFilePath();

            var configuration = new DistrictsConfiguration();

            var themesManager = Singleton<BuildingThemesManager>.instance;
            for (byte i = 0; i < 128; i++)
            {
                if (!themesManager.IsThemeManagementEnabled(i)) continue;

                var themes = themesManager.GetDistrictThemes(i, false);
                if (themes == null)
                {
                    continue; ;
                }
                var themesNames = new string[themes.Count];
                var j = 0;
                foreach (var theme in themes)
                {
                    themesNames[j] = theme.name;
                    j++;
                }
                configuration.Districts.Add(new DistrictsConfiguration.District()
                {
                    id = i,
                    blacklistMode = themesManager.IsBlacklistModeEnabled(i),
                    themes = themesNames
                });
                if (Debugger.Enabled)
                {
                    Debugger.LogFormat("Building Themes: Saving: {0} themes enabled for district {1}", themes.Count, i);
                }
            }

            if (configuration.Districts.Count > 0) DistrictsConfiguration.Serialize(filepath, configuration);

            if (Debugger.Enabled)
            {
                Debugger.LogFormat("Building Themes: Serialization done.");
                Debugger.AppendThemeList();
            }
        }
开发者ID:fadster,项目名称:BuildingThemes,代码行数:62,代码来源:SerializableDataExtension.cs

示例9: FormatDetails

 public void FormatDetails()
 {
     FastList<UIComponent> comps = new FastList<UIComponent> ();
     comps.Add (m_challengeName);
     comps.Add (m_challengeDesc);
     comps.Add (m_challengeBreakdown);
     if (!m_challengeReward.text.Equals ("")) {
         comps.Add(m_challengeReward);
     }
     if (!m_challengePenalty.text.Equals ("")) {
         comps.Add (m_challengePenalty);
     }
     comps.Add (m_challengeDeadline);
     AutoSpace (comps.ToArray ());
 }
开发者ID:CWMlolzlz,项目名称:Challenges,代码行数:15,代码来源:ChallengeManagerPanel.cs

示例10: UserInterface

        public UserInterface()
        {
            instance = this;

            UIView view = GameObject.FindObjectOfType<UIView> ();

            if (view == null)
                return;

            UIComponent bulldozerBar = UIView.Find ("BulldozerBar");

            if (bulldozerBar == null)
                return;

            try {
                XmlSerializer serializer = new XmlSerializer (typeof(XmlData));
                using (StreamReader reader = new StreamReader("V10Bulldoze.xml")) {
                    data = (XmlData)serializer.Deserialize (reader);
                    reader.Close ();
                }
            } catch (FileNotFoundException) {
                // No options file yet
                data = new XmlData ();
                data.needSave = true;
            } catch (Exception e) {
                Debug.Log ("V10Bulldoze: " + e.GetType ().Name + " while reading xml file: " + e.Message + "\n" + e.StackTrace + "\n\n");
                if (e.InnerException != null)
                    Debug.Log ("Caused by: " + e.InnerException.GetType ().Name + ": " + e.InnerException.Message + "\n" + e.InnerException.StackTrace);
                return;
            }

            //1.X -> 1.3
            if (data.version < 1.3d) {
                // Everything has already been setted to its default value, so let's just adjust the version and save.
                data.version = 1.3d;
                data.needSave = true;
            }

            abandonedButton = new GameObject ("V10Bulldoze abandoned button");
            burnedButton = new GameObject ("V10Bulldoze burned button");
            audioButton = new GameObject ("V10Bulldoze audio button");

            Transform parent = bulldozerBar.transform;
            abandonedButton.transform.parent = parent;
            burnedButton.transform.parent = parent;
            audioButton.transform.parent = parent;

            Shader shader = Shader.Find ("UI/Default UI Shader");
            if (shader == null) {
                Debug.Log ("V10Bulldoze: Can't find default UI shader.");
                shader = new Shader ();
                shader.name = "V10Bulldoze dummy shader";
            }

            UITextureAtlas atlas = ScriptableObject.CreateInstance<UITextureAtlas> ();
            atlas.name = "V10Bulldoze Atlas";
            atlas.material = new Material (shader);
            atlas.material.mainTexture = new Texture2D (0, 0, TextureFormat.DXT5, false);

            FastList<Texture2D> list = new FastList<Texture2D> ();
            list.EnsureCapacity (18);

            UIButton button = abandonedButton.AddComponent<UIButton> ();
            button.relativePosition = new Vector3 (7.0f, -57.0f);
            initButton ("AbandonedButton", button, list, data.abandoned, "Demolish Abandoned", view);
            button.atlas = atlas;

            button = burnedButton.AddComponent<UIButton> ();
            button.relativePosition = new Vector3 ((float)(7 + buttonSize + 7), -57.0f);
            initButton ("BurnedButton", button, list, data.burned, "Demolish Burned", view);
            button.atlas = atlas;

            button = audioButton.AddComponent<UIButton> ();
            button.relativePosition = new Vector3 ((float)(7 + buttonSize + 7 + buttonSize + 7), -57.0f);
            initButton ("AudioButton", button, list, !data.disableEffect, "Mute Bulldozing", view);
            button.atlas = atlas;

            atlas.AddTextures (list.ToArray ());
        }
开发者ID:aoighost,项目名称:V10Bulldoze,代码行数:79,代码来源:UserInterface.cs

示例11: MergeTracks

        public MidiTrack MergeTracks()
        {
            var eventCount = 0;
            var notesPlayed = 0;
            var programsUsed = new FastList<byte>();
            var drumProgramsUsed = new FastList<byte>();
            var channelsUsed = new FastList<byte>();
            for (int x = 0; x < Tracks.Length; x++)
            {
                eventCount += Tracks[x].MidiEvents.Length;
                notesPlayed += Tracks[x].NoteOnCount;

                for (int i = 0; i < Tracks[x].Instruments.Length; i++)
                {
                    var p = Tracks[x].Instruments[i];
                    if (programsUsed.IndexOf(p) == -1)
                        programsUsed.Add(p);
                }
                for (int i = 0; i < Tracks[x].DrumInstruments.Length; i++)
                {
                    var p = Tracks[x].DrumInstruments[i];
                    if (drumProgramsUsed.IndexOf(p) == -1)
                        drumProgramsUsed.Add(p);
                }

                for (int i = 0; i < Tracks[x].ActiveChannels.Length; i++)
                {
                    var p = Tracks[x].ActiveChannels[i];
                    if (channelsUsed.IndexOf(p) == -1)
                        channelsUsed.Add(p);
                }
            }

            var track = new MidiTrack(programsUsed.ToArray(),
                                                drumProgramsUsed.ToArray(),
                                                channelsUsed.ToArray(),
                                                new MidiEvent[eventCount]);
            track.NoteOnCount = notesPlayed;
            return track;
        }
开发者ID:eriser,项目名称:alphaSynth,代码行数:40,代码来源:MidiFile.cs

示例12: ReadSystemCommonMessage

 private static MidiEvent ReadSystemCommonMessage(IReadable input, int delta, byte status)
 {
     switch ((SystemCommonTypeEnum)status)
     {
         case SystemCommonTypeEnum.SystemExclusive2:
         case SystemCommonTypeEnum.SystemExclusive:
             {
                 var maker = input.ReadInt16BE();
                 if (maker == 0x0)
                 {
                     maker = input.ReadInt16BE();
                 }
                 else if (maker == 0xF7)
                     return null;
                 var data = new FastList<byte>();
                 var b = input.ReadByte();
                 while (b != 0xF7)
                 {
                     data.Add((byte)b);
                     b = input.ReadByte();
                 }
                 return new SystemExclusiveEvent(delta, status, maker, data.ToArray());
             }
         case SystemCommonTypeEnum.MtcQuarterFrame:
             return new SystemCommonEvent(delta, status, (byte)input.ReadByte(), 0);
         case SystemCommonTypeEnum.SongPosition:
             return new SystemCommonEvent(delta, status, (byte)input.ReadByte(), (byte)input.ReadByte());
         case SystemCommonTypeEnum.SongSelect:
             return new SystemCommonEvent(delta, status, (byte)input.ReadByte(), 0);
         case SystemCommonTypeEnum.TuneRequest:
             return new SystemCommonEvent(delta, status, 0, 0);
         default:
             throw new Exception("The system common message was invalid or unsupported : " + status);
     }
 }
开发者ID:eriser,项目名称:alphaSynth,代码行数:35,代码来源:MidiFile.cs

示例13: ReadTrack

        private MidiTrack ReadTrack(IReadable input)
        {
            var instList = new FastList<Byte>();
            var drumList = new FastList<Byte>();
            var channelList = new FastList<Byte>();
            var eventList = new FastList<MidiEvent>();
            var noteOnCount = 0;
            var totalTime = 0;
            while (input.Read8BitChars(4) != "MTrk")
            {
                var length = input.ReadInt32BE();
                while (length > 0)
                {
                    length--;
                    input.ReadByte();
                }
            }

            var endPosition = input.ReadInt32BE() + input.Position;
            var prevStatus = 0;
            while (input.Position < endPosition)
            {
                var delta = ReadVariableLength(input);
                totalTime += delta;
                var status = input.ReadByte();
                if (status >= 0x80 && status <= 0xEF)
                {//voice message
                    prevStatus = status;
                    eventList.Add(ReadVoiceMessage(input, delta, (byte)status, (byte)input.ReadByte()));
                    noteOnCount = TrackVoiceStats(eventList[eventList.Count - 1], instList, drumList, channelList, noteOnCount);
                }
                else if (status >= 0xF0 && status <= 0xF7)
                {//system common message
                    prevStatus = 0;
                    eventList.Add(ReadSystemCommonMessage(input, delta, (byte)status));
                }
                else if (status >= 0xF8 && status <= 0xFF)
                {//realtime message
                    eventList.Add(ReadRealTimeMessage(input, delta, (byte)status));
                }
                else
                {//data bytes
                    if (prevStatus == 0)
                    {//if no running status continue to next status byte
                        while ((status & 0x80) != 0x80)
                        {
                            status = input.ReadByte();
                        }
                        if (status >= 0x80 && status <= 0xEF)
                        {//voice message
                            prevStatus = status;
                            eventList.Add(ReadVoiceMessage(input, delta, (byte)status, (byte)input.ReadByte()));
                            noteOnCount = TrackVoiceStats(eventList[eventList.Count - 1], instList, drumList, channelList, noteOnCount);
                        }
                        else if (status >= 0xF0 && status <= 0xF7)
                        {//system common message
                            eventList.Add(ReadSystemCommonMessage(input, delta, (byte)status));
                        }
                        else if (status >= 0xF8 && status <= 0xFF)
                        {//realtime message
                            eventList.Add(ReadRealTimeMessage(input, delta, (byte)status));
                        }
                    }
                    else
                    {//otherwise apply running status
                        eventList.Add(ReadVoiceMessage(input, delta, (byte)prevStatus, (byte)status));
                        noteOnCount = TrackVoiceStats(eventList[eventList.Count - 1], instList, drumList, channelList, noteOnCount);
                    }
                }
            }

            if (input.Position != endPosition)
                throw new Exception("The track length was invalid for the current MTrk chunk.");
            if (channelList.IndexOf(MidiHelper.DrumChannel) != -1)
            {
                if (drumList.IndexOf(0) == -1)
                    drumList.Add(0);
            }
            else
            {
                if (instList.IndexOf(0) == -1)
                    instList.Add(0);
            }
            var track = new MidiTrack(instList.ToArray(),
                drumList.ToArray(),
                channelList.ToArray(),
                eventList.ToArray());
            track.NoteOnCount = noteOnCount;
            track.EndTime = totalTime;
            return track;
        }
开发者ID:eriser,项目名称:alphaSynth,代码行数:91,代码来源:MidiFile.cs

示例14: SetTracks

        public void SetTracks(dynamic tracksData, bool render = true)
        {
            FastList<int> tracks = new FastList<int>();

            // decode string
            if (JsTypeOf(tracksData) == [email protected])
            {
                try
                {
                    tracksData = JSON.parse((string)tracksData);
                }
                catch
                {
                    tracksData = new[] { 0 };
                }
            }

            // decode array
            if (JsTypeOf(tracksData) == JsTypes.number)
            {
                tracks.Add((int)tracksData);
            }
            else if (tracksData.length)
            {
                for (var i = 0; i < tracksData.length; i++)
                {
                    int value;
                    if (JsTypeOf(tracksData[i]) == JsTypes.number)
                    {
                        value = (int)tracksData[i];
                    }
                    else
                    {
                        value = Std.ParseInt(tracksData[i].ToString());
                    }

                    if (value >= 0)
                    {
                        tracks.Add(value);
                    }
                }
            }
            TrackIndexes = tracks.ToArray();

            if (render)
            {
                Render();
            }
        }
开发者ID:eriser,项目名称:alphaTab,代码行数:49,代码来源:JsApiBase.cs

示例15: ChallengeNodeToChallenge

        public static Challenge ChallengeNodeToChallenge(XmlNode challengeNode, bool loadStates)
        {
            XmlAttributeCollection challengeAtts = challengeNode.Attributes;
            FastList<IGoal> goalsToAdd = new FastList<IGoal> ();
            FastList<IReward> rewardsToAdd = new FastList<IReward> ();
            FastList<IReward> penaltiesToAdd = new FastList<IReward> ();

            int years = -1, months = -1;
            foreach (XmlNode node in challengeNode.ChildNodes) {
                //Debug.PrintMessage(node.Name);
                if (node.Name == "goal") {
                    string name = node.Attributes ["name"].Value;
                    float passValue = float.Parse (node.Attributes ["passValue"].Value);
                    float failValue = float.Parse (node.Attributes ["failValue"].Value);
                    NumericalGoal goal = new NumericalGoal (StringToValueID (name), GoalTypeExtension.FromComparison (failValue, passValue), failValue, passValue);
                    if (node.Attributes ["passOnce"] != null) {
                        goal.PassOnce = bool.Parse (node.Attributes ["passOnce"].Value);
                    }
                    if (node.Attributes ["failOnce"] != null) {
                        goal.FailOnce = bool.Parse (node.Attributes ["failOnce"].Value);
                    }
                    if (loadStates && node.Attributes["hasAlreadyFailed"] != null) {
                        goal.HasAlreadyFailed = bool.Parse(node.Attributes ["hasAlreadyFailed"].Value);
                    }
                    if (loadStates && node.Attributes["hasAlreadyPassed"] != null) {
                        goal.HasAlreadyPassed = bool.Parse(node.Attributes ["hasAlreadyPassed"].Value);
                    }
                    goalsToAdd.Add (goal);
                } else if (node.Name == "deadline") {
                    if (node.Attributes ["years"] != null)
                        years = int.Parse (node.Attributes ["years"].Value);
                    if (node.Attributes ["months"] != null)
                        months = int.Parse (node.Attributes ["months"].Value);

                } else if (node.Name == "reward") {
                    foreach (XmlNode rewardNode in node.ChildNodes) {
                        if (rewardNode.Name == "boost") {
                            Boost newBoost = new Boost ();
                            newBoost.ValueID = Data.StringToValueID(rewardNode.Attributes ["name"].Value);
                            newBoost.Value = float.Parse (rewardNode.Attributes ["value"].Value);

                            if (rewardNode.Attributes ["years"] != null){
                                newBoost.Years = int.Parse (rewardNode.Attributes ["years"].Value);
                            }
                            if (rewardNode.Attributes ["months"] != null){
                                newBoost.Months = int.Parse (rewardNode.Attributes ["months"].Value);
                            }
                            rewardsToAdd.Add (newBoost);
                        } else if (rewardNode.Name == "payment") {
                            rewardsToAdd.Add(new Payment (int.Parse (rewardNode.Attributes ["amount"].Value)));
                        }
                    }
                } else if (node.Name == "penalty") {
                    foreach (XmlNode rewardNode in node.ChildNodes) {
                        if (rewardNode.Name == "payment") {
                            penaltiesToAdd.Add(new Payment (int.Parse(rewardNode.Attributes ["amount"].Value)));
                        }
                    }
                }
            }
            Challenge newChallenge = new Challenge (challengeAtts ["name"].Value, challengeAtts ["desc"].Value, goalsToAdd.ToArray (), rewardsToAdd.ToArray(), penaltiesToAdd.ToArray());
            //Debug.PrintMessage(challengeNode.OuterXml);
            if (challengeAtts ["requires"] != null) {
                newChallenge.PassTolerance = int.Parse (challengeAtts ["requires"].Value);
            }
            if (challengeAtts ["failTolerance"] != null) {
                newChallenge.FailTolerance = int.Parse (challengeAtts ["failTolerance"].Value);
            }
            if (loadStates && challengeAtts ["startDate"] != null) {
                newChallenge.MapStartTime = DateTime.Parse (challengeAtts ["startDate"].Value);
            }
            if (years >= 0) {
                newChallenge.Years = years;
            }
            if (months >= 0) {
                newChallenge.Months = months;
            }
            return newChallenge;
        }
开发者ID:CWMlolzlz,项目名称:Challenges,代码行数:79,代码来源:DataManager.cs


注:本文中的FastList.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。