Наследование: MonoBehaviour
        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);
              }
        }
Пример #2
0
		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()));
			}
		}
Пример #3
0
        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();
        }
Пример #4
0
        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;
        }
Пример #5
0
 public SimpleTimer GetSimpleTimer(string name)
 {
   var timer = new SimpleTimer(name);
   _simpleTimers.Add(timer);
   return timer;
 }
Пример #6
0
        /// <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);
        }
Пример #7
0
    public Timers(string name = null)
    {
      if (string.IsNullOrEmpty(name))
        Name = "Timers";
      else
        Name = name;

      TimersOverhead = new SimpleTimer("TimerOverhaed");
    }
Пример #8
0
 public NetTimerManager()
 {
     simpleTimer = new SimpleTimer(waitResponseTime);
     simpleTimer.tick += TickHandler;
 }
Пример #9
0
 /// <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;
 }
Пример #10
0
		/// <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());
		}
Пример #11
0
		/// <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()));
			}
		}
Пример #12
0
		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);
		}
 /// <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;
 }
Пример #14
0
    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();
        }
    }
Пример #15
0
	    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);
		}
Пример #16
0
 static EasyClient()
 {
     _timer = new SimpleTimer(_sch);
 }
Пример #17
0
		/// <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;
		}
Пример #18
0
        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);
        }
Пример #19
0
        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;
        }
Пример #20
0
        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();
        }
Пример #21
0
        public bool WaitUntilHandled(int timeoutAfterSeconds)
	    {
            SimpleTimer timer = new SimpleTimer(timeoutAfterSeconds);
            while (!HasHandledDialog && !timer.Elapsed)
            {
                Thread.Sleep(200);
            }

	        return HasHandledDialog;
	    }