private MulticlassConvertTransform(IHost host, ModelLoadContext ctx, IDataView input) : base(host, ctx, input, null) { Host.AssertValue(ctx); Host.AssertNonEmpty(Infos); _exes = new ColInfoEx[Infos.Length]; for (int i = 0; i < _exes.Length; i++) { byte b = ctx.Reader.ReadByte(); var kind = (DataKind)(b & 0x7F); Host.CheckDecode(Enum.IsDefined(typeof(DataKind), kind)); KeyCount range = null; if ((b & 0x80) != 0) { range = new KeyCount(); ulong count = ctx.Reader.ReadUInt64(); if (count != 0) { if (count < 0 || (ulong)(count - 1) > ulong.MaxValue) { throw Host.ExceptDecode("KeyType count too large"); } range.Count = count; } } PrimitiveDataViewType itemType; if (!TryCreateEx(Host, Infos[i], kind, range, out itemType, out _exes[i])) { throw Host.ExceptDecode("source is not of compatible type"); } } SetMetadata(); }
/// <summary> /// Describes how the transformer handles one column pair. /// </summary> /// <param name="name">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param> /// <param name="outputKind">The expected kind of the converted column.</param> /// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="name"/> will be used as source.</param> /// <param name="outputKeyCount">New key range, if we work with key type.</param> public ColumnInfo(string name, DataKind outputKind, string inputColumnName, KeyCount outputKeyCount = null) { Name = name; InputColumnName = inputColumnName ?? name; OutputKind = outputKind; OutputKeyCount = outputKeyCount; }
/// <summary> /// Describes how the transformer handles one column pair. /// </summary> /// <param name="input">Name of input column.</param> /// <param name="output">Name of output column.</param> /// <param name="outputKind">The expected kind of the converted column.</param> /// <param name="outputKeyCount">New key count, if we work with key type.</param> public ColumnInfo(string input, string output, DataKind outputKind, KeyCount outputKeyCount = null) { Input = input; Output = output; OutputKind = outputKind; OutputKeyCount = outputKeyCount; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player" || collision.tag == "Inmate") { KeyCount.incrementKeyCount(); Destroy(gameObject); } }
/// <summary> /// Creates a new chart instance. /// </summary> /// <param name="keyCount">The keycount of the chart.</param> public Chart(KeyCount keyCount) { KeyCount = keyCount; BPMs = new BeatObjectList <BPM>(); Objects = new BeatObjectList <BaseObject> [KeyCount.Value]; for (var i = 0; i < KeyCount.Value; i++) { Objects[i] = new BeatObjectList <BaseObject>(); } }
public void Test_OnKeyCountChanged() { var keyCount = new KeyCount(1); var calls = 0; keyCount.Changed += delegate { calls++; }; keyCount.Value = keyCount.Value; Assert.AreEqual(0, calls); keyCount.Value++; Assert.AreEqual(1, calls); }
public static void Reset() { Bpm = 0; Speed = 0; GameStarted = false; LargestRowIndex = 0; NoteProgress = 0; TotalNoteCount = 0; BeatProgress = 0; Score = 0; Combo = 0; Keys = KeyCount.FourK; }
public void AddPlayedGame(string gameTitle) { KeyCount gamePlayed = _userData.gamesPlayed.Find(r => r.name.Equals(gameTitle)); if (gamePlayed != null) { gamePlayed.count++; } else { _userData.gamesPlayed.Add(new KeyCount(gameTitle, 1)); } UpdateUserData(); }
public void UpdateKeyCountList(List <KeyCount> keyCountList, string name, int count) { KeyCount keyCount = keyCountList.Find(s => s.name.Equals(name)); if (keyCount != null) { keyCount.count += count; } else { keyCountList.Add(new KeyCount(name, count)); } UpdateUserData(); }
public void AddDevelopmentSkill(List <DevSkillsEnum> devtSkillsEnums) { foreach (DevSkillsEnum devSkillEnum in devtSkillsEnums) { string developmentSkill = DevSkills.EnumToString(devSkillEnum); KeyCount skillPlayed = _userData.skillsPlayed.Find(r => r.name.Equals(developmentSkill)); if (skillPlayed != null) { skillPlayed.count++; } else { _userData.skillsPlayed.Add(new KeyCount(developmentSkill, 1)); } } UpdateUserData(); }
private static bool TryCreateEx(IExceptionContext ectx, ColInfo info, DataKind kind, KeyCount range, out PrimitiveDataViewType itemType, out ColInfoEx ex) { ectx.AssertValue(info); ectx.Assert(Enum.IsDefined(typeof(DataKind), kind)); ex = null; var typeSrc = info.TypeSrc; if (range != null) { itemType = TypeParsingUtils.ConstructKeyType(SchemaHelper.DataKind2InternalDataKind(kind), range); } else if (!typeSrc.ItemType().IsKey()) { itemType = ColumnTypeHelper.PrimitiveFromKind(kind); } else if (!ColumnTypeHelper.IsValidDataKind(kind)) { itemType = ColumnTypeHelper.PrimitiveFromKind(kind); return(false); } else { var key = typeSrc.ItemType().AsKey(); ectx.Assert(ColumnTypeHelper.IsValidDataKind(key.RawKind())); ulong count = key.Count; // Technically, it's an error for the counts not to match, but we'll let the Conversions // code return false below. There's a possibility we'll change the standard conversions to // map out of bounds values to zero, in which case, this is the right thing to do. ulong max = (ulong)kind; if ((ulong)count > max) { count = max; } itemType = new KeyDataViewType(SchemaHelper.DataKind2ColumnType(kind).RawType, count); } // Ensure that the conversion is legal. We don't actually cache the delegate here. It will get // re-fetched by the utils code when needed. bool identity; Delegate del; if (!Conversions.DefaultInstance.TryGetStandardConversion(typeSrc.ItemType(), itemType, out del, out identity)) { if (typeSrc.ItemType().RawKind() == itemType.RawKind()) { switch (typeSrc.ItemType().RawKind()) { case DataKind.UInt32: // Key starts at 1. // Multiclass future issue uint plus = (itemType.IsKey() ? (uint)1 : (uint)0) - (typeSrc.IsKey() ? (uint)1 : (uint)0); identity = false; ValueMapper <uint, uint> map_ = (in uint src, ref uint dst) => { dst = src + plus; }; del = (Delegate)map_; if (del == null) { throw Contracts.ExceptNotSupp("Issue with casting"); } break; default: throw Contracts.Except("Not suppoted type {0}", typeSrc.ItemType().RawKind()); } } else if (typeSrc.ItemType().RawKind() == DataKind.Int64 && kind == DataKind.UInt64) { ulong plus = (itemType.IsKey() ? (ulong)1 : (ulong)0) - (typeSrc.IsKey() ? (ulong)1 : (ulong)0); identity = false; ValueMapper <long, ulong> map_ = (in long src, ref ulong dst) => { CheckRange(src, dst, ectx); dst = (ulong)src + plus; }; del = (Delegate)map_; if (del == null) { throw Contracts.ExceptNotSupp("Issue with casting"); } } else if (typeSrc.ItemType().RawKind() == DataKind.Single && kind == DataKind.UInt64) { ulong plus = (itemType.IsKey() ? (ulong)1 : (ulong)0) - (typeSrc.IsKey() ? (ulong)1 : (ulong)0); identity = false; ValueMapper <float, ulong> map_ = (in float src, ref ulong dst) => { CheckRange(src, dst, ectx); dst = (ulong)src + plus; }; del = (Delegate)map_; if (del == null) { throw Contracts.ExceptNotSupp("Issue with casting"); } } else if (typeSrc.ItemType().RawKind() == DataKind.Int64 && kind == DataKind.UInt32) { // Multiclass future issue uint plus = (itemType.IsKey() ? (uint)1 : (uint)0) - (typeSrc.IsKey() ? (uint)1 : (uint)0); identity = false; ValueMapper <long, uint> map_ = (in long src, ref uint dst) => { CheckRange(src, dst, ectx); dst = (uint)src + plus; }; del = (Delegate)map_; if (del == null) { throw Contracts.ExceptNotSupp("Issue with casting"); } } else if (typeSrc.ItemType().RawKind() == DataKind.Single && kind == DataKind.UInt32) { // Multiclass future issue uint plus = (itemType.IsKey() ? (uint)1 : (uint)0) - (typeSrc.IsKey() ? (uint)1 : (uint)0); identity = false; ValueMapper <float, uint> map_ = (in float src, ref uint dst) => { CheckRange(src, dst, ectx); dst = (uint)src + plus; }; del = (Delegate)map_; if (del == null) { throw Contracts.ExceptNotSupp("Issue with casting"); } } else if (typeSrc.ItemType().RawKind() == DataKind.Single && kind == DataKind.String) { // Multiclass future issue identity = false; ValueMapper <float, DvText> map_ = (in float src, ref DvText dst) => { dst = new DvText(string.Format("{0}", (int)src)); }; del = (Delegate)map_; if (del == null) { throw Contracts.ExceptNotSupp("Issue with casting"); } } else { return(false); } } DataViewType typeDst = itemType; if (typeSrc.IsVector()) { typeDst = new VectorDataViewType(itemType, typeSrc.AsVector().Dimensions.ToArray()); } // An output column is transposable iff the input column was transposable. VectorDataViewType slotType = null; if (info.SlotTypeSrc != null) { slotType = new VectorDataViewType(itemType, info.SlotTypeSrc.Dimensions.ToArray()); } ex = new ColInfoEx(kind, range != null, typeDst, slotType); return(true); }