private void UpdatePowerRelay() { try { var relay = PowerSource.FindRelay(transform); if (relay != null && relay != _powerRelay) { if (_powerRelay != null) { _powerRelay.RemoveInboundPower(this); } _powerRelay = relay; _powerRelay.AddInboundPower(this); CancelInvoke("UpdatePowerRelay"); } else { _powerRelay = null; } if (_powerRelay != null) { _powerRelay.RemoveInboundPower(this); _powerRelay.AddInboundPower(this); CancelInvoke("UpdatePowerRelay"); } } catch (Exception e) { Log.Error(e.Message); } }
public ClassData(string name, PowerSource power_source, PrimaryAbility key_ability, HeroRoleType role) { Name = name; PowerSource = power_source; KeyAbility = key_ability; Role = role; }
private void UpdateBattery(PowerSource data) { //var charge = data.power < 1 ? 0f : data.maxPower; if (data == null) { return; } var percent = data.power / data.maxPower; if (_batteryFill != null) { if (data.power >= 0f) { var value = (percent >= 0.5f) ? Color.Lerp(this._colorHalf, this._colorFull, 2f * percent - 1f) : Color.Lerp(this._colorEmpty, this._colorHalf, 2f * percent); _batteryFill.color = value; _batteryFill.fillAmount = percent; } else { _batteryFill.color = _colorEmpty; _batteryFill.fillAmount = 0f; } } _batteryPercentageValue.text = ((data.power < 0f) ? Language.main.Get("ChargerSlotEmpty") : $"{Mathf.CeilToInt(percent * 100)}%"); }
public virtual void TestPower(Type type, ActionType actionType, AttackType attackType, string range, DamageTypes damageTypes, string effect, EffectTypes effectTypes, PowerFrequency frequency, PowerSource powerSource, string trigger) { Power power; power = Character.GetPowers().Where(x => (x.GetType() == type)).First(); Assert.NotNull(power, "Power not found"); Assert.AreEqual(actionType, power.Action); Assert.AreEqual(attackType, power.AttackTypeAndRange.AttackType); Assert.AreEqual(range, power.AttackTypeAndRange.Range); Assert.AreEqual(damageTypes, power.DamageTypes); Assert.AreEqual(effect != null, power.HasEffect); if (effect != null) { Assert.AreEqual(effect, power.Effect); } Assert.AreEqual(effectTypes, power.EffectTypes); Assert.AreEqual(frequency, power.Frequency); Assert.AreEqual(powerSource, power.PowerSource); Assert.AreEqual(trigger != null, power.HasTrigger); if (trigger != null) { Assert.AreEqual(trigger, power.Trigger); } }
public override void _Ready() { // onready equivalent doesn't exist in C# receiver = GetNode <PowerReceiver>("PowerReceiver"); source = GetNode <PowerSource>("PowerSource"); indicator = GetNode <Sprite>("Indicator"); }
private IEnumerator UpdatePowerRelay() { QuickLogger.Debug("In UpdatePowerRelay found at last!"); var i = 1; while (_connectedRelay == null) { QuickLogger.Debug($"Checking For Relay... Attempt {i}"); PowerRelay relay = PowerSource.FindRelay(this.transform); if (relay != null && relay != _connectedRelay) { _connectedRelay = relay; QuickLogger.Debug("PowerRelay found at last!"); } else { _connectedRelay = null; } i++; yield return(new WaitForSeconds(0.5f)); } }
private static void InitializeComponents() { var ground = new Ground(); var powerSource = new PowerSource { Voltage = 5 }; var resistor = new Resistor { Resistance = 220 }; var led = new LED { Current = 20, Voltage = 2 }; var powerToResistorConnection = new Connection(powerSource, resistor); resistor.InputConnection = powerToResistorConnection; var resistorToLedConnection = new Connection(resistor, led); resistor.OutputConnection = resistorToLedConnection; led.AnodeConnection = resistorToLedConnection; var ledToGroundConnection = new Connection(led, ground); led.CathodeConnection = ledToGroundConnection; _components.Add(ground); _components.Add(powerSource); _components.Add(resistor); _components.Add(led); }
private void AccumulatePowerSources(PowerRelay power) { List <IPowerInterface> inboundPowerSources = GetInboundPowerSources(power); foreach (IPowerInterface iSource in inboundPowerSources) { if (iSource == null) { continue; } PowerSource source = TryGetPowerSource(iSource); PowerRelay relay = TryGetPowerRelay(iSource); BatterySource battery = TryGetBatterySource(iSource); if (source != null) { AddPowerSourceEntry(source); continue; } else if (relay != null) { AccumulatePowerSources(relay); continue; } else if (battery != null) { AddGenericPowerEntry(battery); continue; } } }
private void AddPowerSourceEntry(PowerSource source) { if (source.gameObject.GetComponent <RegeneratePowerSource>()) { powerSources.Add(new RegenPowerSourceInfo(source)); } else if (source.gameObject.GetComponent <SolarPanel>()) { powerSources.Add(new SolarPanelPowerSourceInfo(source)); } else if (source.gameObject.GetComponent <ThermalPlant>()) { powerSources.Add(new ThermalPlantPowerSourceInfo(source)); } else if (source.gameObject.GetComponent <BaseBioReactor>()) { powerSources.Add(new BioreactorPowerSourceInfo(source)); } else if (source.gameObject.GetComponent <BaseNuclearReactor>()) { powerSources.Add(new NuclearReactorPowerSourceInfo(source)); } else { powerSources.Add(new PowerSourceInfo(source, TechType.None)); } }
/// <summary> /// functions used to draw power from PowerSource /// </summary> public virtual void PowerUp() // virtual for now(in case) { if (!IsPowered && PowerSource.HasDrawnPower(RequiredPower)) // if it's not powered, check if it can draw power { IsPowered = true; // if it can, draw power and power up } }
public void Activate() { spin = gameObject.FindChild("Blade Parent").EnsureComponent <TurbineSpin>(); powerSource = gameObject.EnsureComponent <PowerSource>(); powerSource.maxPower = QPatch.config.MaxPower; relay = gameObject.EnsureComponent <PowerRelay>(); relay.internalPowerSource = powerSource; relay.dontConnectToRelays = false; relay.maxOutboundDistance = 50; //relay.powerSystemPreviewPrefab = Resources.Load<GameObject>("Base/Ghosts/PowerSystemPreview.prefab"); if (relayPrefab != null) { PowerFX yourPowerFX = gameObject.AddComponent <PowerFX>(); yourPowerFX.vfxPrefab = relayPrefab.powerFX.vfxPrefab; yourPowerFX.attachPoint = gameObject.transform; relay.powerFX = yourPowerFX; } #if SUBNAUTICA Resources.UnloadAsset(powerRelay); #endif relay.UpdateConnection(); if (QPatch.config.TurbineMakesNoise) { SetupAudio(); } Logger.Log(Logger.Level.Debug, $"WindTurbine.Activate: end"); }
// Token: 0x06003119 RID: 12569 RVA: 0x0012E540 File Offset: 0x0012C740 private static void CreatePowerPreview(TechType constructableTechType, GameObject ghostModel) { GameObject gameObject = null; string poweredPrefabName = CraftData.GetPoweredPrefabName(constructableTechType); if (poweredPrefabName != string.Empty) { gameObject = PrefabDatabase.GetPrefabForFilename(poweredPrefabName); } if (gameObject != null) { PowerRelay component = gameObject.GetComponent <PowerRelay>(); Utils.Assert(component != null, "see log", null); if (component.powerFX != null && component.powerFX.attachPoint != null) { PowerFX powerFX = ghostModel.AddComponent <PowerFX>(); powerFX.attachPoint = new GameObject { transform = { parent = ghostModel.transform, localPosition = component.powerFX.attachPoint.localPosition } }.transform; } PowerRelay powerRelay = ghostModel.AddComponent <PowerRelay>(); powerRelay.maxOutboundDistance = component.maxOutboundDistance; powerRelay.dontConnectToRelays = component.dontConnectToRelays; if (component.internalPowerSource != null) { PowerSource powerSource = ghostModel.AddComponent <PowerSource>(); powerSource.maxPower = 0f; powerRelay.internalPowerSource = powerSource; } } }
protected override void Awake() { base.Awake(); _wires = GameObject.FindObjectsOfType <Wire>() as Wire[]; _powerSource = GameObject.FindObjectOfType <PowerSource>() as PowerSource; if (_powerSource == null) { Debug.LogError("One and only one power source must be in the scene"); } // scan the wires and powersource, generate graph(s) _wireGraph = GraphPath.Build(_wires); _electricCurrentGameObjectHolder = GameObject.Find("*ElectricCurrentHolder*"); if (_electricCurrentGameObjectHolder == null) { _electricCurrentGameObjectHolder = new GameObject("*ElectricCurrentHolder*"); } _dynamicObjectHolder = GameObject.Find("*DynamicObjectHolder*"); if (_dynamicObjectHolder == null) { _dynamicObjectHolder = new GameObject("*DynamicObjectHolder*"); } _backpackItemGameObjectHolder = GameObject.Find("*BackpackItemHolder"); if (_backpackItemGameObjectHolder == null) { _backpackItemGameObjectHolder = new GameObject("*BackpackItemHolder"); } _currentItemsInBackpack = SpawnBackpackDefaultItems(Application.loadedLevelName); _heroController = FindObjectOfType <HeroController>() as HeroController; }
public Electronics(string title, float price, PowerSource powerSource, string orderCode) { Title = title; Price = price; PowerSource = powerSource; OrderCode = orderCode; }
public static List <PowerSource> LoadPowerSources(string xmlfile) { List <PowerSource> powerSources = new List <PowerSource>(); XPathDocument doc = new XPathDocument(xmlfile); XPathNavigator nav = doc.CreateNavigator(); foreach (XPathNavigator n in nav.Select("/battle/powersources/powersource")) { PowerSource p = new PowerSource(); string name = n.GetAttribute("name", ""); string descr = n.GetAttribute("description", ""); p.Name = name; p.Description = descr; foreach (XPathNavigator n2 in n.Select("provides")) { p.Provide(n2.GetAttribute("value", "")); } foreach (XPathNavigator n3 in n.Select("requires")) { p.Require(n3.GetAttribute("value", "")); } powerSources.Add(p); } return(powerSources); }
public void PowerSourceCorrespondsToIsUpsPresentProperty(bool isUpsPresentState, PowerSource powerSourceState) { // BUG: It is strange that IsUpsPresent is exposed on PM, while ACOnline is exposed on the BatteryState property Assert.Equal<bool>( isUpsPresentState == PowerManager.IsUpsPresent, powerSourceState == PowerManager.PowerSource); }
// Adds a power supplier to the list of suppliers in range and checks for combined power. // NOTE: Make sure that Powered is set to true BEFORE calling this method, if applicable public void AddPowerSupplier(PowerSource supplier) { PowerSuppliersInRange.Add(supplier); if(!Powered && PowerSuppliersInRange.Count > 1) { RecheckPowerSuppliersForNewPower(); } }
public void DeviceTest() { var devices = MediaDevice.GetDevices().ToArray(); var device = devices.FirstOrDefault(this.deviceSelect); Assert.IsNotNull(device, "Device"); string description = device.Description; string friendlyName = device.FriendlyName; string manufacture = device.Manufacturer; device.Connect(); string firmwareVersion = device.FirmwareVersion; PowerSource powerSource = device.PowerSource; int powerLevel = device.PowerLevel; string model = device.Model; string serialNumber = device.SerialNumber; DeviceType deviceType = device.DeviceType; DeviceTransport transport = device.Transport; device.Disconnect(); Assert.AreEqual(this.deviceDescription, description, "Description"); Assert.AreEqual(this.deviceFriendlyName, friendlyName, "FriendlyName"); Assert.AreEqual(this.deviceManufacture, manufacture, "Manufacture"); Assert.AreEqual(this.deviceFirmwareVersion, firmwareVersion, "FirmwareVersion"); Assert.AreEqual(this.deviceModel, model, "Model"); Assert.AreEqual(this.deviceSerialNumber, serialNumber, "SerialNumber"); Assert.AreEqual(this.deviceDeviceType, deviceType, "DeviceType"); Assert.AreEqual(this.deviceTransport, transport, "Transport"); Assert.AreEqual(this.devicePowerSource, powerSource, "PowerSource"); Assert.IsTrue(powerLevel > 0, "PowerLevel"); }
public void Activate() { spin = gameObject.FindChild("Blade Parent").AddComponent <TurbineSpin>(); powerSource = gameObject.AddComponent <PowerSource>(); powerSource.maxPower = QPatch.config.MaxPower; relay = gameObject.AddComponent <PowerRelay>(); relay.internalPowerSource = powerSource; relay.dontConnectToRelays = false; relay.maxOutboundDistance = 50; PowerFX yourPowerFX = gameObject.AddComponent <PowerFX>(); PowerRelay powerRelay = CraftData.GetPrefabForTechType(TechType.SolarPanel).GetComponent <PowerRelay>(); yourPowerFX.vfxPrefab = powerRelay.powerFX.vfxPrefab; yourPowerFX.attachPoint = gameObject.transform; relay.powerFX = yourPowerFX; Resources.UnloadAsset(powerRelay); relay.UpdateConnection(); if (QPatch.config.TurbineMakesNoise) { SetupAudio(); } }
/// <summary> /// functions used to store power to PowerSource /// </summary> public virtual void PowerDown() // virtual for now(in case) { if (IsPowered && PowerSource.HasStoredPower(RequiredPower)) // if it's powered, check if power source is not full { IsPowered = false; // if it's not, give back power and turn off. } }
public virtual void Destroy() { PowerSource source = FindObjectOfType <PowerSource>(); source.Towers.Remove(this.gameObject); source.UpdatePower(); Destroy(this.gameObject); }
private void UpdateInputs() { if (Physics2D.OverlapPoint(inputTrans.position, LayerMask.GetMask("Wire"))) { source = Physics2D.OverlapPointAll(inputTrans.position, LayerMask.GetMask("Wire"))[0].GetComponent <PowerSource>(); sourceFound = true; } }
public override void _Ready() { _animationPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); _animationPlayer.Play("Work"); _powerSource = GetNode <PowerSource>("PowerSource"); _powerSource.Efficiency = 1.0f; }
public AbstractGadget(int size, bool isSmall) { this._size = size; this._isSmall = isSmall; _switches = new Switches(); _buttons = new Buttons(); _powersource = new PowerSource(); }
void PlacePowerSource() { //client sets powerSource reference separately powerSource = GameUnit.Instantiate <PowerSource>(); powerSource.name = "PowerSource Player" + player.playerNumber; powerSource.player = player; powerSource.transform.position = transform.position; powerSource.transform.rotation = transform.rotation; }
public void PowerUp() { if (!isPowered) { if (PowerSource.DrawPower(requiredPower)) { isPowered = true; } } }
private PowerSource TryGetPowerSource(IPowerInterface power) { PowerSource source = power as PowerSource; if (source == null && (power as Component) != null) { source = (power as Component).gameObject.GetComponent <PowerSource>(); } return(source); }
public void PowerDown() { if (isPowered) { if (PowerSource.StorePower(requiredPower)) { isPowered = false; } } }
public void TriggerEnter(Collider other) { if (!HasPower) { PowerSource newSource = other.gameObject.GetComponent <PowerSource>(); if (newSource != null) { EnablePowerSource(newSource); } } }
public static String GetSetPowerSourceValueIndexParam(PowerSource pwsrc) { switch (pwsrc) { case PowerSource.AC: return("-SETACVALUEINDEX"); case PowerSource.DC: return("-SETDCVALUEINDEX"); } return(""); }
public Motorcycle( string i_ModelName, string i_LicenseNumber, Wheel i_Wheel, int i_NumOfWheels, eVehicleStatus i_eStatus, PowerSource i_PowerSource, eLicencseType i_LicenseType, int i_EngineCapacity) : base(i_ModelName, i_LicenseNumber, i_Wheel, i_NumOfWheels, i_eStatus, i_PowerSource) { this.m_LicenseType = i_LicenseType; this.r_EngineCapacity = i_EngineCapacity; }
public int Count(PowerSource power_source) { int num = 0; foreach (HeroData hero in this.Heroes) { if (hero.Class == null || hero.Class.PowerSource != power_source) { continue; } num++; } return(num); }
private void UpdatePowerRelay() { PowerRelay relay = PowerSource.FindRelay(_mono.transform); if (relay != null && relay != _connectedRelay) { _connectedRelay = relay; QuickLogger.Debug("PowerRelay found at last!"); } else { _connectedRelay = null; } }
private void MakeLineRenderer(PowerSource powerSource, Equipment connectedEquipment) { GameObject g = new GameObject("PowerLine"); powerLines.Add (g); g.transform.parent = this.transform; LineRenderer r = g.AddComponent<LineRenderer>(); r.useWorldSpace = false; r.SetVertexCount(2); r.SetPosition(0, powerSource.transform.position); r.SetPosition(1, connectedEquipment.transform.position); r.material = lineMaterial; r.sortingLayerName = "Above"; r.SetColors(powerSource.wireColor, powerSource.wireColor); r.SetWidth(0.2f, 0.2f); }
/// <summary> /// Create a new <see cref="InternalModifierSource"/>. /// </summary> /// <param name="trainedSkill"> /// The skill the character is trained in. /// </param> /// <param name="primaryPowerSource"> /// The primary <see cref="Origin"/>'s power source. /// </param> /// <exception cref="ArgumentException"> /// <paramref name=" trainedSkill"/> is not a skill. /// </exception> public InternalModifierSource(ScoreType trainedSkill, PowerSource primaryPowerSource) : base("Character", "Character") { if (!ScoreTypeHelper.IsSkill(trainedSkill)) { throw new ArgumentException("Not a skill", "trainedSkill"); } TrainedSkill = trainedSkill; traits = new List<Trait>(); traits.Add(new Trait("Primary Origin Power Source", string.Format("+2 bonus to overcharge {0} Alpha powers", primaryPowerSource.ToString()))); powers = new List<Power>(); powers.Add(new BasicAttack()); powers.Add(new SecondWind()); }
// Update is called once per frame public void Update() { if (Input.GetMouseButtonDown(0)) { var worldClick = Camera.main.ScreenToWorldPoint(Input.mousePosition); Equipment q = Manager.instance.ship.GetBlock(worldClick); if (q is PowerSource) { start = (PowerSource)q; } } if (start != null && Input.GetMouseButtonUp(0)) { var worldClick = Camera.main.ScreenToWorldPoint(Input.mousePosition); Equipment q = Manager.instance.ship.GetBlock(worldClick); if (!(q is PowerSource)&& (q != null)) { start.ConnectedEquipments.Add(q); MakeLineRenderer(start, q); } start = null; } }
public void RemovePowerSupplier(PowerSource supplier) { PowerSuppliersInRange.Remove(supplier); }
ActionScene( Game game, Texture2D theTexture, Texture2D backgroundTexture, SpriteFont font, Vector2 gameoverPosition) : base(game) { this._audio = (AudioLibrary)Game.Services.GetService(typeof(AudioLibrary)); this._background = new ImageComponent(game, backgroundTexture, ImageComponent.DrawMode.Stretch); Components.Add(this._background); this._actionTexture = theTexture; this._spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); this._meteors = new MeteorsManager(Game, ref this._actionTexture); Components.Add(this._meteors); this._scoreFont = font; this._gameoverPosition = gameoverPosition; this._scorePlayer1 = new Score(game, font, Color.Blue) { Position = new Vector2(10, 10) }; Components.Add(this._scorePlayer1); this._rumblePad = new SimpleRumblePad(game); Components.Add(this._rumblePad); this._powerSource = new PowerSource(game, ref this._actionTexture); Components.Add(this._powerSource); #if DEBUG this._positionDebugText = new TextComponent(game, this._scoreFont, new Vector2(), Color.Red); Components.Add(this._positionDebugText); #endif }
public void PowerSourceCorrespondsToAcOnlineProperty(bool acOnlineState, PowerSource powerSourceState) { Assert.Equal<bool>( acOnlineState == PowerManager.GetCurrentBatteryState().ACOnline, powerSourceState == PowerManager.PowerSource); }
public override void TestPower(Type type, ActionType actionType, AttackType attackType, string range, DamageTypes damageTypes, string effect, EffectTypes effectTypes, PowerFrequency frequency, PowerSource powerSource, string trigger) { base.TestPower(type, actionType, attackType, range, damageTypes, effect, effectTypes, frequency, powerSource, trigger); }
public static String GetSetPowerSourceValueIndexParam(PowerSource pwsrc) { switch (pwsrc) { case PowerSource.AC: return "-SETACVALUEINDEX"; case PowerSource.DC: return "-SETDCVALUEINDEX"; } return ""; }
public static void SetMaximumPowerState(PowerProfile pwrprf, PowerSource pwsrc, int percentage) { if (pwrprf == null) { pwrprf = ActivePowerProfile; } //powercfg -setdcvalueindex [schemeguid] [subgroupguid] [settingguid] [setting] String args = String.Format("{0} {1} {2} {3} {4}", new String[] { GetSetPowerSourceValueIndexParam(pwsrc), pwrprf.Guid, SUBGROUP_GUID_PROCESSOR_POWER_MANAGEMENT, SETTING_GUID_MAXIMUM_PROCESSOR_STATE, Convert.ToString(percentage) }); ExecutePowerCfg(args); SetActiveScheme(pwrprf); }
/// <summary> /// Sending a 0 to the comport will toggle the DC power supply. /// Sending a 1 to the comport will toggle the usb power supply. /// Sending a 255 to the comport will give you current status of the device. /// The status of the device can be one of the four below: /// 0x0 = DC & USB off /// 0x1 = DC on /// 0x2 = USB on /// 0x3 = DC & USB on /// </summary> /// <param name="power">This parameter specifies the power state which can be on or off.</param> /// <param name="ps">This parameter specifies the power source.</param> internal static void Switch(PowerState power, PowerSource ps) { byte status; switch (GetStatus()) { case 0: // Both DC & USB off. if (power == PowerState.Off) { return; } else { switch ((int)ps) { case 2: status = Send(0); CheckStatus(status, 0); status = Send(1); CheckStatus(status, 1); break; default: byte b = Convert.ToByte((int)ps); status = Send(b); CheckStatus(status, b); break; } } break; case 1: // Only DC is on. if (power == PowerState.Off) { switch ((int)ps) { case 0: status = Send(0); CheckStatus(status, 0); break; default: break; } } else { switch ((int)ps) { case 0: break; default: status = Send(1); CheckStatus(status, 1); break; } } break; case 2: // Only USB is on. if (power == PowerState.Off) { switch ((int)ps) { case 1: status = Send(1); CheckStatus(status, 1); break; default: break; } } else { switch ((int)ps) { case 1: break; default: status = Send(0); CheckStatus(status, 0); break; } } break; case 3: // Both DC & USB on. if (power == PowerState.Off) { switch ((int)ps) { case 2: status = Send(0); CheckStatus(status, 0); status = Send(1); CheckStatus(status, 1); break; default: byte b = Convert.ToByte((int)ps); status = Send(b); CheckStatus(status, b); break; } } else { return; } break; } }
public static int GetMaximumPowerStatePercentage(PowerProfile pwrprf, PowerSource pwsrc) { if (pwrprf == null) { pwrprf = ActivePowerProfile; } String txt = Query(pwrprf.Guid, SUBGROUP_GUID_PROCESSOR_POWER_MANAGEMENT); string re1 = ".*?"; // Non-greedy match on filler string re2 = "(" + SETTING_GUID_MAXIMUM_PROCESSOR_STATE + ")"; // SQL GUID 1 string re3 = ".*?"; // Non-greedy match on filler string re4 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re5 = ".*?"; // Non-greedy match on filler string re6 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re7 = ".*?"; // Non-greedy match on filler string re8 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re9 = ".*?"; // Non-greedy match on filler string re10 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re11 = ".*?"; // Non-greedy match on filler string re12 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re13 = ".*?"; // Non-greedy match on filler string re14 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re15 = ".*?"; // Non-greedy match on filler string re16 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re17 = ".*?"; // Non-greedy match on filler string re18 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re19 = ".*?"; // Non-greedy match on filler string re20 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re21 = ".*?"; // Non-greedy match on filler string re22 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re23 = ".*?"; // Non-greedy match on filler string re24 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re25 = ".*?"; // Non-greedy match on filler string re26 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re27 = ".*?"; // Non-greedy match on filler string re28 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re29 = ".*?"; // Non-greedy match on filler string re30 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re31 = ".*?"; // Non-greedy match on filler string re32 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re33 = ".*?"; // Non-greedy match on filler string re34 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re35 = ".*?"; // Non-greedy match on filler string re36 = "((?:[a-z][a-z]+))"; // AC string re37 = ".*?"; // Non-greedy match on filler string re38 = "((?:[a-z][a-z]*[0-9]+[a-z0-9]*))"; // AC value string re39 = ".*?"; // Non-greedy match on filler string re40 = "(?:[a-z][a-z]+)"; // Uninteresting: word string re41 = ".*?"; // Non-greedy match on filler string re42 = "((?:[a-z][a-z]+))"; // DC string re43 = ".*?"; // Non-greedy match on filler string re44 = "((?:[a-z][a-z]*[0-9]+[a-z0-9]*))"; // DC Value Regex r = new Regex(re1 + re2 + re3 + re4 + re5 + re6 + re7 + re8 + re9 + re10 + re11 + re12 + re13 + re14 + re15 + re16 + re17 + re18 + re19 + re20 + re21 + re22 + re23 + re24 + re25 + re26 + re27 + re28 + re29 + re30 + re31 + re32 + re33 + re34 + re35 + re36 + re37 + re38 + re39 + re40 + re41 + re42 + re43 + re44, RegexOptions.IgnoreCase | RegexOptions.Singleline); Match m = r.Match(txt); if (m.Success) { String guidSettingsMaximumPowerState = m.Groups[1].ToString(); String acKey = m.Groups[2].ToString(); String acHexValue = m.Groups[3].ToString(); int acDecValue = Int32.Parse(acHexValue.Substring(1), NumberStyles.HexNumber); String dcKey = m.Groups[4].ToString(); String dcHexValue = m.Groups[5].ToString(); int dcDecValue = Int32.Parse(dcHexValue.Substring(1), NumberStyles.HexNumber); if (pwsrc == PowerSource.AC) { return acDecValue; } if (pwsrc == PowerSource.DC) { return dcDecValue; } } return -1; }
ActionScene(Game game, Texture2D theTexture, Texture2D backgroundTexture, SpriteFont font) : base(game) { _audio = (AudioLibrary)Game.Services.GetService(typeof(AudioLibrary)); _background = new ImageComponent(game, backgroundTexture, ImageComponent.DrawMode.Stretch); Components.Add(_background); _actionTexture = theTexture; _spriteBatch = (SpriteBatch) Game.Services.GetService(typeof (SpriteBatch)); _meteors = new MeteorsManager(Game, ref _actionTexture); Components.Add(_meteors); _scoreFont = font; _scorePlayer1 = new Score(game, font, _player1FontColor) {Position = new Vector2(10, 10)}; Components.Add(_scorePlayer1); _rumblePad = new SimpleRumblePad(game); Components.Add(_rumblePad); _powerSource = new PowerSource(game, ref _actionTexture); _powerSource.Initialize(); Components.Add(_powerSource); _wrench = new Wrench(game, game.Content.Load<Texture2D>("wrench")); _wrench.Initialize(); Components.Add(_wrench); #if DEBUG _positionDebugText=new TextComponent(game,_scoreFont,new Vector2(),Color.Red); Components.Add(_positionDebugText); #endif }
public void PowerSourceChangedEventWorks(PowerSource powerSourceToSet) { bool eventFired = false; PowerManager.PowerSourceChanged += new EventHandler( (object sender, EventArgs args) => { eventFired = true; }); // TODO: Fire Powermanager.PowerSourceChanged event. int secTimeout = 5; //wait 5 seconds for event to be fired. for (int i = 0; i < secTimeout * 10 && !eventFired; i++) { Thread.Sleep(100); } Assert.True(eventFired); }
public PowerManager() { _powerSource = PowerSource.AC; _powerScheme = PowerScheme.HighPerformance; _batteryLife = 100; }
/// <summary> /// Method should only be used on XP systems. /// </summary> public bool GetPowerStatus() { SystemPowerStatus status = new SystemPowerStatus(); bool result = GetSystemPowerStatus(status); if(result) { _powerSource = status.ACLineStatus == ACLineStatus.Online ? PowerSource.AC : PowerSource.Battery; _batteryLife = (int)(Math.Max((double)status.BatteryLifePercent * 0.3921, 100)); Debug.Report("Power Status: \n{0}", status); } else { Debug.ReportWarning("Failed to get power status"); } return result; }