private void Initialize() { this.Write(Commands.LS7366_CLEAR | Commands.LS7366_MDR0); this.Write(Commands.LS7366_CLEAR | Commands.LS7366_MDR1); this.Write(Commands.LS7366_CLEAR | Commands.LS7366_STR); this.Write(Commands.LS7366_CLEAR | Commands.LS7366_CNTR); this.Write(Commands.LS7366_LOAD | Commands.LS7366_OTR); this.Mode = CountMode.Quad1; this.Write(Commands.LS7366_WRITE | Commands.LS7366_MDR1, MDR1Modes.LS7366_MDR1_4BYTE | MDR1Modes.LS7366_MDR1_ENCNT); }
/// <summary> /// Initialize a new <see cref="QuadratureEncoder"/> /// </summary> public QuadratureEncoder(QuadratureEncoderChannel channel, CountMode mode) { //Do not use HardwareProvider to keep the feature independant : //no HardwareProvider.HwProvider.GetQuadratureEncoderChannelCount(); //no HardwareProvider.HwProvider.GetQuadratureEncoderPinsForChannel(...); //-> if a solution doesn't need this feature, no stub is required _channel = channel; _mode = mode; GetQuadratureEncoderPinsForChannel(channel, out _pin_A, out _pin_B); Initialize(); _dispatcher = new NativeEventDispatcher("Community_QuadratureEncoder_Driver", 0); _dispatcher.OnInterrupt += Dispatcher_OnInterrupt; }
public Counter(Properties props) { if (props.from > props.to) { var cc = props.to; props.to = props.from; props.from = cc; } this.from = props.from; this.to = props.to; this.countMode = props.countMode; this.current = props.current.MinMax(from, to); }
/// <summary> /// Initializes the Timer /// </summary> /// <param name="host">MonoBehaviour to run the Timer on</param> /// <param name="duration">Duration of the Timer in seconds</param> /// <param name="countDirection">Defines whether the Timer counts up or down</param> /// <param name="onTimerUpdate">Callback for the timer Update</param> /// <param name="onTimeElapsed">Callback for when the Timer finishes</param> /// <param name="loop">If true, the Timer restarts itself automatically</param> private void Init(float duration, CountMode countDirection, Action <float> onTimerUpdate, Action onTimeElapsed, bool loop) { Duration = duration; _elapsedTime = 0.0f; Loop = loop; Mode = UpdateMode.SCALED_TIME; CountDirection = countDirection; // register Callbacks if (onTimeElapsed != null) { OnTimeElapsed += onTimeElapsed; } if (onTimerUpdate != null) { OnTimerUpdate += onTimerUpdate; } }
/// <summary> /// Creates a Timer with the given Time as duration and registers a callback for when it updates and when it finishes /// </summary> /// <param name="host">MonoBehaviour to run the Timer on</param> /// <param name="duration">Duration of the Timer in seconds</param> /// <param name="countDirection">Defines whether the Timer counts up or down</param> /// <param name="onTimerUpdate">Callback for the timer Update</param> /// <param name="onTimeElapsed">Callback for when the Timer finishes</param> /// <param name="loop">If true, the Timer restarts itself automatically</param> public Timer(float duration, CountMode countDirection, Action <float> onTimerUpdate, Action onTimeElapsed, bool loop = false) { Init(duration, countDirection, onTimerUpdate, onTimeElapsed, loop); }
/// <summary> /// Creates a Timer with the given Time as duration /// </summary> /// <param name="host">MonoBehaviour to run the Timer on</param> /// <param name="duration">Duration of the Timer in seconds</param> /// <param name="countDirection">Defines whether the Timer counts up or down</param> /// <param name="loop">If true, the Timer restarts itself automatically</param> public Timer(float duration, CountMode countDirection, bool loop = false) { Init(duration, countDirection, null, null, loop); }
void BuildChildren() { if (ChildPrefab.Length < 1 || Paths == null || Paths.Length < 1 || Paths[0] == null) { return; } int MaxChildCount = 0; int CurChildIndex = 0; switch (mode) { case Mode.Count: if (ChildIndex == null || ChildIndex.Length != Count) { ChildIndex = new int[Count]; for (int i = 0; i < Count; i++) { ChildIndex[i] = CurChildIndex; CurChildIndex++; if (CurChildIndex >= ChildPrefab.Length) { CurChildIndex = 0; } } } foreach (CinemachineSmoothPath path in Paths) { if (path == null) { continue; } AdjustChildCount(); MaxChildCount = path.Looped ? this.transform.childCount : (this.transform.childCount <= 1 ? 1 : this.transform.childCount - 1); switch (countMode) { case CountMode.Average: break; case CountMode.Sum: switch (m_PositionUnits) { case CinemachinePathBase.PositionUnits.PathUnits: Step = (path.m_Waypoints.Length - 1) * 1f / MaxChildCount; break; default: case CinemachinePathBase.PositionUnits.Distance: Step = path.PathLength * 1f / MaxChildCount; break; case CinemachinePathBase.PositionUnits.Normalized: Step = 1f / MaxChildCount; break; } break; } } break; case Mode.Step: Count = 0; Clamp(); m_PositionUnits = CinemachinePathBase.PositionUnits.Distance; countMode = CountMode.Sum; foreach (CinemachineSmoothPath path in Paths) { if (path == null) { continue; } for (float i = 0; i <= path.PathLength; i += Step) { if (i <= path.PathLength - (path.Looped ? Step : 0)) { Count++; } } } if (ChildIndex == null || ChildIndex.Length != Count) { ChildIndex = new int[Count]; for (int i = 0; i < Count; i++) { ChildIndex[i] = CurChildIndex; CurChildIndex++; if (CurChildIndex >= ChildPrefab.Length) { CurChildIndex = 0; } } } AdjustChildCount(); break; } UpdateChildren(); }
public TemplateAsset(XElement asset) { CountMode = new CountMode(this); ID = int.Parse(asset.Attribute("ID").Value); Name = asset.Element("N").Value; Text = new Description(asset.Element("T")); RarityType = asset.Attribute("RT").Value; Rarity = new Description(asset.Element("R")); ItemType = asset.Element("IT").Value; EffectTargets = asset.Element("ET")?.Elements().Select(s => new EffectTarget(s)).ToList() ?? new List <EffectTarget>(); ReleaseVersion = asset.Attribute("RV")?.Value; IsPausable = asset.Attribute("IP")?.Value; if (asset.Attribute("IR") != null) { IsRollable = true; } if (asset.Element("FN") != null) { FestivalName = new Description(asset.Element("FN")); } if (asset.Element("A")?.HasElements == true) { Allocation = new Allocation(asset.Element("A")); } if (asset.Element("AR") != null) { AssociatedRegions = new Description(asset.Element("AR")); } if (asset.Element("UT") != null) { UpgradeText = new Description(asset.Element("UT")); } if (asset.Element("Mo")?.HasElements == true) { Modules = new Modules(asset.Element("Mo")); } if (asset.Element("M")?.HasElements == true) { Maintenance = new Maintenance(asset.Element("M")); } if (asset.Element("FB")?.HasElements == true) { FactoryBase = new FactoryBase(asset.Element("FB")); } if (asset.Element("UC")?.HasElements == true) { UpgradeCosts = asset.Element("UC").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("GU")?.HasElements == true) { GenericUpgrades = asset.Element("GU").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("BC")?.HasElements == true) { BuildCosts = asset.Element("BC").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("IS")?.HasElements == true) { ItemSets = asset.Element("IS").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("PU")?.HasElements ?? false) { PopulationUpgrades = asset.Element("PU").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("EA")?.HasElements ?? false) { ExpeditionAttributes = asset.Element("EA").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("DU")?.HasElements ?? false) { AttackableUpgrades = asset.Element("DU").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("AU")?.HasElements ?? false) { AttackerUpgrades = asset.Element("AU").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("IAU")?.HasElements ?? false) { ItemActionUpgrades = asset.Element("IAU").Elements().Select(s => new Upgrade(s)).ToList(); } TradePrice = asset.Element("TP")?.Value; HiringFee = asset.Element("HF")?.Value; if (asset.Element("I") != null) { Info = new Description(asset.Element("I")); } if (asset.Element("S") != null) { Sources = asset.Element("S").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("ME") != null) { MonumentEvents = asset.Element("ME").Elements().Select(s => int.Parse(s.Value)).ToList(); } if (asset.Element("MT") != null) { MonumentThresholds = asset.Element("MT").Elements().Select(s => int.Parse(s.Value)).ToList(); } if (asset.Element("MR") != null) { MonumentRewards = asset.Element("MR").Elements().Select(s => int.Parse(s.Value)).ToList(); } if (asset.Element("SP") != null) { SetParts = asset.Element("SP").Elements().Select(s => s.Value).ToList(); } if (asset.Element("DBU")?.HasElements ?? false) { DivingBellUpgrades = asset.Element("DBU").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("CIU")?.HasElements ?? false) { CraftableItemUpgrades = asset.Element("CIU").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("IWUI")?.HasElements ?? false) { ItemWithUI = asset.Element("IWUI").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("ISE")?.HasElements ?? false) { ItemStartExpedition = asset.Element("ISE").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("B")?.HasElements ?? false) { Building = asset.Element("B").Elements().Select(s => new Upgrade(s)).ToList(); } if (asset.Element("ISS")?.HasElements ?? false) { ItemSocketSet = asset.Element("ISS").Elements().Select(s => new Upgrade(s)).ToList(); } HasEffectTargetInfo = EffectTargets.Count > 0; }