public ModifierInstance(emodifierType modType) { ModType = modType; switch (modType) { case emodifierType.Slow: Timer = new SimpleTimer(2500); break; case emodifierType.Stunned: Timer = new SimpleTimer(Maths.RandomNr(500, 1500)); break; case emodifierType.Rooted: Timer = new SimpleTimer(3000); break; case emodifierType.ArmorHalved: Timer = new SimpleTimer(2500); break; case emodifierType.Poisoned: Timer = new SimpleTimer(5000); break; default: break; } }
protected IEnumerator ManageBuffer() { bool usingLiveAudio = false; while (true) { if (usingLiveAudio && useBakedAudio) { if (clip != null) { source.Stop(); source.clip = clip; source.Play(); usingLiveAudio = false; } else { useBakedAudio = false; // if there's no valid audio file to play, switch back to live Debug.Log("no valid audio clip has been assigned"); } } while (useBakedAudio) { yield return(null); } if (!usingLiveAudio) { source.Stop(); source.clip = Microphone.Start(selectedDevice, true, 10, maxFreq); while (Microphone.GetPosition(selectedDevice) <= 0) { yield return(Microphone.GetPosition(selectedDevice)); } source.Play(); } usingLiveAudio = true; SimpleTimer bufferTimer = new SimpleTimer(5f); while (!bufferTimer.isFinished && !useBakedAudio) { yield return(bufferTimer); } // stop playing audio and halt mic recording source.Stop(); Microphone.End(selectedDevice); // set new clip to new recording and wait for recording to being before playing source source.clip = Microphone.Start(selectedDevice, true, 10, maxFreq); while (Microphone.GetPosition(selectedDevice) <= 0) { yield return(Microphone.GetPosition(selectedDevice)); } source.Play(); } }
public SimpleTimer GetSimpleTimer(string name) { var timer = new SimpleTimer(name); _simpleTimers.Add(timer); return(timer); }
override public void Start() { ListenForUpdate(HandleUpdate); st = new SimpleTimer(); st.Start(); gameNodes = new FContainer(); Futile.atlasManager.LoadImage("car"); WEHTiled hurr = new WEHTiled("track"); gameNodes.AddChild(hurr.DrawLayer(0)); FContainer coll = hurr.DrawLayer(1); gameNodes.AddChild(coll); c = new Car(Futile.atlasManager.GetElementWithName("car"), coll); c.x = Futile.screen.width; c.y = -Futile.screen.height; c.rotation = 90; gameNodes.AddChild(c); lapCollider = new FSprite(Futile.whiteElement); lapCollider.scaleY = 5; lapCollider.SetPosition(1220, -832); lapCollider.alpha = 0; gameNodes.AddChild(lapCollider); RXWatcher.Watch(gameNodes); RXWatcher.Watch(lapCollider); this.AddChild(gameNodes); SetupUI(); }
// Use this for initialization void Start() { butt = GetComponent <Button>(); fillCanvas = coolDownSlider.GetComponent <Canvas>(); onCooldown = false; coolDownTimer = new SimpleTimer(); }
public void setNextTutorial(int currentOrder) { // get the next tutorial currentTutorial = getTutorialByOrder(currentOrder); if (!currentTutorial) { // finished all tutorials completedAllTutorials(); return; } explanationText.text = currentTutorial.explanation; if (currentTutorial.displayTutorialTimer > 0.0f) { st = new SimpleTimer(null, currentTutorial.displayTutorialTimer); StartCoroutine(st.DisplayTutorial()); } else { // not using the timer to control tutorial display displayTutorial = true; } }
// ctor private HealthListener() { _request = new Request(Utils.Config.BackEndSession.GetPhpSessionId(), Utils.Config.BackendUrl); _simpleTimer = Common.Utils.Hook.Loader <SimpleTimer> .Load(); _simpleTimer.syncHealthAction = () => Task.Run(() => _request.PostJson("/player/health/sync", CurrentHealth.ToJson())); }
private void ProcessQueue() { while (true) { MungEvent msg; if (_connection.State == ConnectionState.Connected) { while (_q.TryDequeue(out msg)) { try { SimpleTimer.DebugTime("event-send", () => { _connection.Send(msg); }); Debug.WriteLine("MUNG: sent: " + JsonConvert.SerializeObject(msg)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(string.Format("MUNG: Unable to send event: {0}", ex.Message)); } } } else { if (_connection.State == ConnectionState.Disconnected) { System.Diagnostics.Debug.WriteLine(string.Format("MUNG: Connecting to {0}", _connectionUrl)); _connection.Start(); //Console.WriteLine("Mung not connected"); Thread.Sleep(1000); } } Thread.Sleep(100); } }
protected Result DoNatTest(Simulator sim, Node node0, Node node1) { sim.Complete(true); // SimpleTimer.RunSteps(3600000); SimpleTimer.RunSteps(600000); long throughput = Throughput(node0.EdgeListenerList) + Throughput(node1.EdgeListenerList); DateTime start = DateTime.UtcNow; ManagedConnectionOverlord mco = new ManagedConnectionOverlord(node0); mco.Start(); node0.AddConnectionOverlord(mco); mco.Set(node1.Address); AreConnected connected = new AreConnected(node0, node1, null); connected.Start(); connected.Run(120); long time = (DateTime.UtcNow - start).Ticks / TimeSpan.TicksPerMillisecond; double avg_throughput = 0; if (time > 0) { throughput = Throughput(node0.EdgeListenerList) + Throughput(node1.EdgeListenerList) - throughput; avg_throughput = (1.0 * throughput) / time / 1000; } sim.Disconnect(); return(new Result(connected.TATypeAsString, time, avg_throughput)); }
public void TimesOutWhenTimeoutIsReached() { SimpleTimer timer = new SimpleTimer(new TimeSpan(100)); Assert.IsFalse(timer.IsTimeout()); Task.Delay(200).Wait(); Assert.IsTrue(timer.IsTimeout()); }
// The following are some helper functions /// <summary>This is an example of an public bool Complete(bool quiet) { DateTime start = DateTime.UtcNow; long ticks_end = start.AddHours(1).Ticks; bool success = false; while (DateTime.UtcNow.Ticks < ticks_end) { success = CheckRing(false); if (success) { break; } SimpleTimer.RunStep(); } if (!quiet) { if (success) { Console.WriteLine("It took {0} to complete the ring", DateTime.UtcNow - start); } else { PrintConnections(); PrintConnectionState(); Console.WriteLine("Unable to complete ring."); } } return(success); }
public static void Run(RelayOverlapSimulator sim, Address addr1, Address addr2) { Console.WriteLine("Beginning"); sim.Complete(false); SimpleTimer.RunSteps(1000000, false); StructuredNode node1 = (sim.Nodes[addr1] as NodeMapping).Node as StructuredNode; StructuredNode node2 = (sim.Nodes[addr2] as NodeMapping).Node as StructuredNode; sim.Complete(true); ManagedConnectionOverlord mco = new ManagedConnectionOverlord(node1); mco.Start(); node1.AddConnectionOverlord(mco); mco.Set(addr2); Connection con1 = node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2); while (con1 == null) { SimpleTimer.RunStep(); con1 = node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2); } Console.WriteLine(addr1 + "<=>" + addr2 + ":"); Console.WriteLine("\t" + node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2) + "\n"); sim.FindOverlap(node1, node2); node1.Disconnect(); node2.Disconnect(); SimpleTimer.RunSteps(100000); Console.WriteLine("End"); }
/// <summary>Runs all public benchmark methods (static and nonstatic) in the /// specified object ('set') and prints results to the console. Each method /// is run the number of times indicated by the Trials attribute of /// BenchmarkAttribute (if provided) or DefaultNumTrials.</summary> public void RunPublicBenchmarksInConsole(object subject, bool randomOrder, string prefix = null, bool clearOldResults = true) { #if CompactFramework // Console cursor cannot be controlled in the Compact Framework var t = new SimpleTimer(); RunPublicBenchmarks(subject, randomOrder, () => { // Also, console printing is slow; avoid spending too much time on it if (t.ClearAfter(10000) != 0) { PrintResults(Console.Out); t.Restart(); } }, prefix, clearOldResults); PrintResults(Console.Out); #else int end = Console.CursorTop; RunPublicBenchmarks(subject, randomOrder, () => { int start = Console.CursorTop; PrintResults(Console.Out); end = Console.CursorTop; Console.CursorTop = start; }, prefix, clearOldResults); Console.CursorTop = end; #endif }
// Static Members public static void Simulator(TunnelOverlapSimulator sim) { Address addr1 = null, addr2 = null; sim.AddDisconnectedPair(out addr1, out addr2, sim.NCEnable); sim.Complete(); SimpleTimer.RunSteps(1000000, false); StructuredNode node1 = (sim.Nodes[addr1] as NodeMapping).Node as StructuredNode; StructuredNode node2 = (sim.Nodes[addr2] as NodeMapping).Node as StructuredNode; node1.ManagedCO.AddAddress(addr2); SimpleTimer.RunSteps(100000, false); Console.WriteLine(addr1 + "<=>" + addr2 + ":"); Console.WriteLine("\t" + node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2) + "\n"); sim.PrintConnections(node1); Console.WriteLine(); sim.PrintConnections(node2); Console.WriteLine("\nPhase 2 -- Disconnect..."); sim.FindOverlap(node1, node2); sim.CloseOverlap(node1); sim.CloseOverlap(node2); SimpleTimer.RunSteps(100000, false); Console.WriteLine(addr1 + "<=>" + addr2 + ":"); Console.WriteLine("\t" + node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2) + "\n"); sim.PrintConnections(node1); Console.WriteLine(); sim.PrintConnections(node2); sim.Disconnect(); }
private static void waitUntilElementReadyStateIsComplete(IHTMLElement element) { //TODO: See if this method could be dropped, it seems to give // more trouble (uninitialized state of elements) // then benefits (I just introduced this method to be on // the save side) if (ElementTag.IsValidElement(element, Image.ElementTags)) { return; } // Wait if the readystate of an element is BETWEEN // Uninitialized and Complete. If it's uninitialized, // it's quite probable that it will never reach Complete. // Like for elements that could not load an image or ico // or some other bits not part of the HTML page. SimpleTimer timeoutTimer = new SimpleTimer(30); do { int readyState = ((IHTMLElement2)element).readyStateValue; if (readyState == 0 || readyState == 4) { return; } Thread.Sleep(Settings.SleepTime); } while (!timeoutTimer.Elapsed); throw new WatiNException("Element didn't reach readystate = complete within 30 seconds: " + element.outerText); }
private void ResetGame() { for (int i = 0; i < LoadedLevel.Count; i++) { Destroy(LoadedLevel[i]); } LoadedLevel.Clear(); //Can do other stuff here PlayerHolder.GetComponentInChildren <GhostSprites>().KillSwitchEngage(); ObjectRecycler.Singleton.RecycleAll(); SimpleTimer timer = PlayerCharacter.Singleton.GetComponent <SimpleTimer>(); timer.GetTimer(); PlayerCharacter.Singleton.GetFSM().Reboot(); PlayerHolder.GetComponentInChildren <MouseIndicator>().Show(); PlayerHolder.SetActive(false); OnQuitLevel.Invoke(currentLevelIndex); currentLevelIndex = -1; TimeManager.Instance.Resume(); }
public void SimpleTimerOneSecond() { var timer = new SimpleTimer(TimeSpan.FromSeconds(1)); Thread.Sleep(1200); Assert.IsTrue(timer.Elapsed); }
void AddTimer(float tick, Action callback) { var timer = new SimpleTimer(); timer.tick = tick; timer.onTickNotify = callback; }
private void NewTimer() { currentShowControlsDelay += showControlsDelayIncrement; currentShowControlsDelay = Mathf.Min(showControlsDelayMax, currentShowControlsDelay); playerTimer = new SimpleTimer(currentShowControlsDelay); playerTimer.TimerEndedEvent += PlayerTimeEvent; }
public static Connection StartConnection(string session, float timeoutSeconds) { return(new Connection { Session = session, timeoutTimer = SimpleTimer.StartNew(timeoutSeconds) }); }
protected virtual void Awake() { rigidbody2d = GetComponent <Rigidbody2D>(); // Timers bouncingTimer = gameObject.AddComponent <SimpleTimer>(); shieldRecoverTimer = gameObject.AddComponent <SimpleTimer>(); shieldRecoverRateTimer = gameObject.AddComponent <SimpleTimer>(); }
// Start is called before the first frame update protected void Awake() { if (sprites.IsAlmostSpecificCount()) { _spriteManager = new SpriteManager(referenceContainerSprite); _timer = new SimpleTimer(updateFrame); } }
protected static void RunUntilTaskFinished() { _finished = false; while (!_finished) { SimpleTimer.RunStep(); } }
public InputRepeater(Func <bool> inputSource) { InputValue = inputSource; DelayUntilRepeat = new SimpleTimer(GlobalInputProperties.DelayUntilRepeat); RepeatDelay = new SimpleTimer(GlobalInputProperties.RepeatDelay); DelayUntilRepeat.Reset(); RepeatDelay.Reset(); }
public static async Task AddReactionAsync(this SocketUserMessage self, IEmote emote, int lifeTime) { await self.AddReactionAsync(emote); SimpleTimer newTimer = new SimpleTimer(async() => { await self.RemoveReactionAsync(emote, Client.CurrentUser); }, MathService.TimeUnitToMilli(TimeUnit.Seconds, lifeTime), false); newTimer.Start(); }
protected void Awake() { _isWrong = percentSpeedSpecificLayer == null || containerLayers == null || percentSpeedSpecificLayer.Length < containerLayers.childCount; _timer = new SimpleTimer(timeForChangeDirection); _currentVelocity = velocityParallax; }
public void TimesOutWhenTimeoutIsReached() { SimpleTimer timer = new SimpleTimer(new TimeSpan(100)); Assert.IsFalse(timer.IsTimeout()); Thread.Sleep(200); Assert.IsTrue(timer.IsTimeout()); }
/// <summary> /// Class constructor. /// </summary> public CpsCalculator(TimeSpan windowTimeSpan) { _windowTimeSpan = windowTimeSpan; _window = new List <Period> { new Period() }; _timer = new SimpleTimer(Timer_Callback, 100); }
/// <summary> /// Class constructor. /// </summary> public CpsCalculator(ushort windowSeconds) { _windowTimeSpan = TimeSpan.FromSeconds(windowSeconds); _window = new List <Period> { new Period() }; _timer = new SimpleTimer(Timer_Callback, 100); }
public void TestTimeoutInvoke() { var test_bool = false; IDisposable disposeHandle = SimpleTimer.SetTimeout(() => test_bool = true, 100); Assert.IsFalse(test_bool); Thread.Sleep(150); Assert.IsTrue(test_bool); }
public GroupCertificateVerification(string revocation_url, string cacert_path) { _revocation_url = revocation_url; _timer = new SimpleTimer(UpdateRl, null, 0, UPDATE_PERIOD); _timer.Start(); _revoked_users = new Hashtable(); using(FileStream fs = File.Open(cacert_path, FileMode.Open)) { byte[] cert = new byte[fs.Length]; fs.Read(cert, 0, cert.Length); _ca_cert = new Certificate(cert); } }
public void WaitUntilExists(int waitDurationInSeconds) { SimpleTimer timeoutTimer = new SimpleTimer(waitDurationInSeconds); while (!Exists() && !timeoutTimer.Elapsed) { Thread.Sleep(200); } if (!Exists()) { throw new WatiNException(string.Format("Dialog not available within {0} seconds.", waitDurationInSeconds.ToString())); } }
internal PlayerCorpse(ZonePlayer zp, int xpLoss, bool zoneHasGraveyard) : base(zp, null) { _charId = zp.CharId; _hairColor = zp.HairColor; _beardColor = zp.BeardColor; _eyeColor1 = zp.EyeColor1; _hairStyle = zp.HairStyle; _luclinFace = zp.Face; _beard = zp.Beard; _xpLoss = xpLoss; // TODO: don't move items if PC had "become" an NPC? _lootItems = zp.InvMgr.AllPersonalItems().ToList<InventoryItem>(); _lootItems.AddRange(zp.InvMgr.CursorItems()); _lootItems.RemoveAll(ii => ii.Item.IsNoRent); if (IsEmpty()) _decayTimer.Start(DECAYMS_EMPTY_PC_CORPSE); else { if (zp.Level <= PC_CORPSE_LEVEL_LOW) _decayTimer = new SimpleTimer(DECAYMS_PC_CORPSE_LOW); else if (zp.Level <= PC_CORPSE_LEVEL_MID) _decayTimer = new SimpleTimer(DECAYMS_PC_CORPSE_MID); else _decayTimer = new SimpleTimer(DECAYMS_PC_CORPSE_HIGH); } if (zoneHasGraveyard) _graveyardTimer = new SimpleTimer(GRAVEYARD_TIMEOUT_MS); // TODO: get item tints and set for their corpse // TODO: soulbound items not switched to corpse, but put in normal slots on PC, not in a bag or what have you _allowedLooters.Add(zp.CharId); Save(); }
private object _looterIdSyncLock = new object(); // Clients could try to loot at the same time (frequently do, actually) #endregion Fields #region Constructors /// <summary>For use with NPC mobs.</summary> /// <param name="mob">Mob that died.</param> /// <param name="decayTime">Miliseconds until corpse decay.</param> /// <param name="lootItems">Items which will be part of the corpse's loot.</param> internal Corpse(Mob mob, List<InventoryItem> lootItems) : base(mob.ID, mob.Name.RemoveDigits() + "'s corpse" + mob.ID.ToString(), "", mob.X, mob.Y, mob.Z, mob.Heading) { if (lootItems != null) _lootItems.AddRange(lootItems); this.Platinum = mob.Platinum; this.Gold = mob.Gold; this.Silver = mob.Silver; this.Copper = mob.Copper; _changed = false; if (IsEmpty()) _decayTimer = new SimpleTimer(DECAYMS_EMPTY_NPC_CORPSE); else _decayTimer = new SimpleTimer(mob.Level > 54 ? DECAYMS_BOSS_NPC_CORPSE : DECAYMS_NPC_CORPSE); _gender = mob.Gender; _race = mob.Race; _bodyType = mob.BodyType; _size = mob.Size; _texture = mob.Texture; _helmTexture = mob.HelmTexture; }
/// <summary> /// Wait until the download progress window does not exist any more /// </summary> /// <param name="waitDurationInSeconds">duration in seconds to wait</param> public void WaitUntilDownloadCompleted(int waitDurationInSeconds) { SimpleTimer timeoutTimer = new SimpleTimer(waitDurationInSeconds); while (ExistsOrNull(DownloadProgressDialog) && !timeoutTimer.Elapsed) { // Logger.LogAction("WaitUntilDownloadCompleted"); Thread.Sleep(200); } if (ExistsOrNull(DownloadProgressDialog)) { throw new WatiNException(string.Format("Still downloading after {0} seconds.", waitDurationInSeconds.ToString())); } Logger.LogAction("Download complete at " + DateTime.Now.ToLongTimeString()); }
protected IEnumerator ManageBuffer() { bool usingLiveAudio = false; while (true) { if (usingLiveAudio && useBakedAudio) { if (clip != null) { source.Stop(); source.clip = clip; source.Play(); usingLiveAudio = false; } else { useBakedAudio = false; // if there's no valid audio file to play, switch back to live Debug.Log("no valid audio clip has been assigned"); } } while (useBakedAudio) yield return null; if (!usingLiveAudio) { source.Stop(); source.clip = Microphone.Start(selectedDevice, true, 10, maxFreq); while (Microphone.GetPosition(selectedDevice) <= 0) yield return Microphone.GetPosition(selectedDevice); source.Play(); } usingLiveAudio = true; SimpleTimer bufferTimer = new SimpleTimer(5f); while (!bufferTimer.isFinished && !useBakedAudio) yield return bufferTimer; // stop playing audio and halt mic recording source.Stop(); Microphone.End(selectedDevice); // set new clip to new recording and wait for recording to begin before playing source source.clip = Microphone.Start(selectedDevice, true, 10, maxFreq); while (Microphone.GetPosition(selectedDevice) <= 0) yield return Microphone.GetPosition(selectedDevice); source.Play(); } }
/// <summary> /// This method is called to initialise the start time for /// determining a time out. It's set to the current time. /// </summary> /// <returns></returns> public virtual SimpleTimer InitTimeout() { _timer = null; return Timer; }
public NpcMob(int entityId, Npc npcData, int gridId, float x, float y, float z, float heading) : base(entityId, npcData.Name, npcData.SurName, npcData.AC, (short)npcData.Attack, (short)npcData.STR, (short)npcData.STA, (short)npcData.DEX, (short)npcData.AGI, npcData.INT, npcData.WIS, npcData.CHA, npcData.Hp, npcData.Hp, npcData.Gender, (short)npcData.HpRegenRate, (short)npcData.ManaRegenRate, npcData.Race, npcData.NpcClass, npcData.NpcLevel, (BodyType)npcData.BodyType, 0, x, y, z, heading, npcData.Size, npcData.RunSpeed, 0) { _npcDbId = npcData.NpcID; _gridId = gridId; _seeInvis = npcData.SeeInvis; _seeInvisToUndead = npcData.SeeInvisUndead; _seeHide = npcData.SeeHide; _seeImprovedHide = npcData.SeeImprovedHide; _texture = npcData.Texture; _helmTexture = npcData.HelmTexture; _hairColor = (byte)npcData.HairColorLuclin; _beardColor = (byte)npcData.BeardColorLuclin; _eyeColor1 = (byte)npcData.EyeColorLuclin; _eyeColor2 = (byte)npcData.EyeColor2Luclin; _hairStyle = (byte)npcData.HairStyleLuclin; _luclinFace = (byte)npcData.Face; _beard = (byte)npcData.BeardLuclin; _aggroRange = npcData.AggroRadius; _assistRange = npcData.AggroRadius; _findable = npcData.Findable; _trackable = npcData.Trackable; _accuracy = npcData.Accuracy; _attackSpeed = npcData.AttackSpeed; _willAggroNPCs = npcData.NpcAggro; _meleeTexture1 = npcData.MeleeTexture1; _meleeTexture2 = npcData.MeleeTexture2; _minDmg = npcData.MinDamage; _maxDmg = npcData.MaxDamage; // TODO: timers... combat event, swarm, class attack, knight attack, assist, enraged, taunt _globalPositionUpdateTimer = new SimpleTimer(GLOBAL_POS_UPDATE_INTERVAL); // TODO: does this belong in mob? _hpUpdateTimer = new SimpleTimer(HP_UPDATE_INTERVAL); // Mana regen rate adjustments for lazy db updaters _manaRegen = Math.Max(_manaRegen, (short)0); if (GetCasterClass() != CasterClass.None && _manaRegen == 0) _manaRegen = (short)((this.Level / 10) + 4); // TODO: HP regen adjustments (Gives low end mobs no regen if set to 0 in db. Makes low end mobs more killable) _hpRegen = Math.Max(_hpRegen, (short)0); if (_hpRegen == 0) { } // min and max dmg adjustments if (_maxDmg == 0) { int acAdj = 12; if (this.Level >= 66) { if (_minDmg == 0) _minDmg = 200; if (_maxDmg == 0) _maxDmg = ((((99000) * (this.Level - 64)) / 400) * acAdj / 10); } else if (this.Level >= 60 && this.Level <= 65) { if (_minDmg == 0) _minDmg = (this.Level + (this.Level / 3)); if (_maxDmg == 0) _maxDmg = (this.Level * 3) * acAdj / 10; } else if (this.Level >= 51 && this.Level <= 59) { if (_minDmg == 0) _minDmg = (this.Level + (this.Level / 3)); if (_maxDmg == 0) _maxDmg = (this.Level * 3) * acAdj / 10; } else if (this.Level >= 40 && this.Level <= 50) { if (_minDmg == 0) _minDmg = this.Level; if (_maxDmg == 0) _maxDmg = (this.Level * 3) * acAdj / 10; } else if (this.Level >= 28 && this.Level <= 39) { if (_minDmg == 0) _minDmg = this.Level / 2; if (_maxDmg == 0) _maxDmg = ((this.Level * 2) + 2) * acAdj / 10; } else if (this.Level <= 27) { if (_minDmg == 0) _minDmg = 1; if (_maxDmg == 0) _maxDmg = (this.Level * 2) * acAdj / 10; } int clFact = GetClassLevelFactor(); _minDmg = (_minDmg * clFact) / 220; _maxDmg = (_maxDmg * clFact) / 220; } // TODO: calc max mana and then set mana // Adjust resists if needed _mr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.MR; _cr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.CR; _dr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.DR; _fr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.FR; _pr = npcData.MR < 1 ? (short)((this.Level * 11) / 10) : npcData.PR; // TODO: faction // TODO: spells // TODO: set guard spot? if (npcData.Loot != null) AddLoot(npcData); // Give npc some loot //_log.DebugFormat("{0} has {1} items - {2} of which are equipped...", npcData.Name, _lootItems.Count, _equipedItems.Count); //foreach (KeyValuePair<uint, LootItem> kvp in _equipedItems) { // _log.DebugFormat("slot {0} has itemId {1}", kvp.Key, kvp.Value.ItemID); //} if (npcData.NpcSpecialAttacks != null) ParseSpecialAttacks(npcData.NpcSpecialAttacks); StartAI(); }
private static void WaitUntilVisibleOrTimeOut(Window window) { // Wait untill window is visible so all properties // of the window class (like Style and StyleInHex) // will return valid values. SimpleTimer timer = new SimpleTimer(Settings.WaitForCompleteTimeOut); do { if (window.Visible) return; Thread.Sleep(50); } while (!timer.Elapsed); Logger.LogAction("Dialog with title '{0}' not visible after {1} seconds.", window.Title, Settings.WaitForCompleteTimeOut); }
public Timers(string name = null) { if (string.IsNullOrEmpty(name)) Name = "Timers"; else Name = name; TimersOverhead = new SimpleTimer("TimerOverhaed"); }
protected internal virtual void Init() { // TODO: load buffs, procs, shielders? // start various timers _ticTimer = new SimpleTimer(TIC_INTERVAL); _attackTimer = new SimpleTimer(0); _dwAttackTimer = new SimpleTimer(0); _rangedAttackTimer = new SimpleTimer(0); _stunTimer = new SimpleTimer(0); _manaUpdateTimer = new SimpleTimer(MANA_UPDATE_INTERVAL); // TODO: pets _hateMgr = new HateManager(this); }
/// <summary> /// Wait until the save/open/run dialog opens. /// This exists because some web servers are slower to start a file than others. /// </summary> /// <param name="waitDurationInSeconds">duration in seconds to wait</param> public void WaitUntilFileDownloadDialogIsHandled(int waitDurationInSeconds) { SimpleTimer timeoutTimer = new SimpleTimer(waitDurationInSeconds); while (!HasHandledFileDownloadDialog && !timeoutTimer.Elapsed) { // Logger.LogAction("WaitUntilFileDownloadDialogIsHandled"); Thread.Sleep(200); } if (!HasHandledFileDownloadDialog) { throw new WatiNException(string.Format("Has not shown dialog after {0} seconds.", waitDurationInSeconds.ToString())); } }
public bool WaitUntilHandled(int timeoutAfterSeconds) { SimpleTimer timer = new SimpleTimer(timeoutAfterSeconds); while (!HasHandledDialog && !timer.Elapsed) { Thread.Sleep(200); } return HasHandledDialog; }
/// <summary>Let's see if we can route for an IP. Default is do /// nothing!</summary> /// <param name="ip">The IP in question.</param> protected void HandleNewStaticIP(MemBlock ether_addr, MemBlock ip) { if(!_ipop_config.AllowStaticAddresses) { return; } lock(_sync) { if(_dhcp_config == null) { return; } } if(!_dhcp_server.IPInRange(ip)) { return; } DHCPServer dhcp_server = CheckOutDHCPServer(ether_addr); if(dhcp_server == null) { return; } ProtocolLog.WriteIf(IpopLog.DHCPLog, String.Format( "Static Address request for: {0}", Utils.MemBlockToString(ip, '.'))); WaitCallback wcb = null; wcb = delegate(object o) { byte[] res_ip = null; try { res_ip = dhcp_server.RequestLease(ip, true, Brunet.Address.ToString(), _ipop_config.AddressData.Hostname); } catch(Exception e) { ProtocolLog.WriteIf(IpopLog.DHCPLog, e.Message); } if(res_ip == null) { ProtocolLog.WriteIf(IpopLog.DHCPLog, String.Format( "Request for {0} failed!", Utils.MemBlockToString(ip, '.'))); } else { lock(_sync) { bool new_entry = true; if(_ether_to_ip.ContainsKey(ether_addr)) { if(_ether_to_ip[ether_addr].Equals(ip)) { new_entry = false; } } if(new_entry) { if(_static_mapping.ContainsKey(ether_addr)) { _static_mapping[ether_addr].Dispose(); } _static_mapping[ether_addr] = new SimpleTimer(wcb, null, _dhcp_config.LeaseTime * 1000 / 2, _dhcp_config.LeaseTime * 1000 / 2); } UpdateMapping(ether_addr, MemBlock.Reference(res_ip)); } } CheckInDHCPServer(dhcp_server); }; ThreadPool.QueueUserWorkItem(wcb); }
static EasyClient() { _timer = new SimpleTimer(_sch); }
private static void waitUntilElementReadyStateIsComplete(IHTMLElement element) { //TODO: See if this method could be dropped, it seems to give // more trouble (uninitialized state of elements) // then benefits (I just introduced this method to be on // the save side) if (ElementTag.IsValidElement(element, Image.ElementTags)) { return; } // Wait if the readystate of an element is BETWEEN // Uninitialized and Complete. If it's uninitialized, // it's quite probable that it will never reach Complete. // Like for elements that could not load an image or ico // or some other bits not part of the HTML page. SimpleTimer timeoutTimer = new SimpleTimer(30); do { int readyState = ((IHTMLElement2) element).readyStateValue; if (readyState == 0 || readyState == 4) { return; } Thread.Sleep(Settings.SleepTime); } while (!timeoutTimer.Elapsed); throw new WatiNException("Element didn't reach readystate = complete within 30 seconds: " + element.outerText); }
public SimpleTimer GetSimpleTimer(string name) { var timer = new SimpleTimer(name); _simpleTimers.Add(timer); return timer; }
/// <summary> /// Handles the dialogs to download (and save) a file /// Mainly used internally by WatiN. /// </summary> /// <param name="window">The window.</param> /// <returns></returns> public override bool HandleDialog(Window window) { // This if handles the File download dialog if (!HasHandledFileDownloadDialog && IsFileDownloadDialog(window)) { window.ToFront(); window.SetActivate(); DownloadProgressDialog = new Window(window.ParentHwnd); WinButton btn = GetButtonToPress(window); btn.Click(); hasHandledFileDownloadDialog = !Exists(window); if (HasHandledFileDownloadDialog) { Logger.LogAction("Download started at " + DateTime.Now.ToLongTimeString()); Logger.LogAction("Clicked " + _optionEnum.ToString()); } return true; } // This if handles the download progress dialog if (IsDownloadProgressDialog(window)) { DownloadProgressDialog = window; WinButton openOrRun= new WinButton(4377, new Hwnd(window.Hwnd)); if (openOrRun.Enabled) { WinButton close = new WinButton(2, new Hwnd(window.Hwnd)); close.Click(); SimpleTimer timer = new SimpleTimer(5); while (!timer.Elapsed && window.Exists()) { Thread.Sleep(200); } } return true; } // This if handles the File save as dialog if (IsFileSaveDialog(window)) { Logger.LogAction("Saving Download file as " + saveAsFilename); DownloadProgressDialog = new Window(window.ParentHwnd); HandleFileSaveDialog(window); return true; } // Window is not a dialog this handler can handle. return false; }
internal virtual void StartAI() { _thinkTimer = new SimpleTimer(THINK_INTERVAL, true); _walkTimer = new SimpleTimer(0); _moveTimer = new SimpleTimer(MOVE_INTERVAL); _scanTimer = new SimpleTimer(SCAN_INTERVAL); _aiTargetCheckTimer = new SimpleTimer(TARGET_CHECK_INTERVAL); // TODO: feign remember timer _deltaX = _deltaY = _deltaZ = 0.0F; _deltaHeading = 0; _hateMgr.Clear(); _runAnimSpeed = 0; this.IsAIControlled = true; _lastChange = DateTime.Now; }
/// <summary> /// This method is called to initialise the start time for /// determining a time out. It's set to the current time. /// </summary> /// <returns></returns> protected virtual SimpleTimer InitTimeout() { _timer = null; return Timer; }
public NetTimerManager() { simpleTimer = new SimpleTimer(waitResponseTime); simpleTimer.tick += TickHandler; }