/// <summary>
 /// Initializes a new instance of the <see cref="PerfTimer" /> class.
 /// </summary>
 /// <param name="categoryName">The name of the category.</param>
 private CriticalPerfTimer([NotNull] string categoryName)
     : base(categoryName, _counterData)
 {
     Timers = new Timers();
     // ReSharper disable PossibleNullReferenceException
     AddInfo("Count", "Total operations executed since the start of the process.", () => Timers.Count);
     AddInfo("Rate", "The number of operations per second.", () => Timers.Rate);
     AddInfo("Total Duration", "The total duration.", () => Timers.TotalDuration);
     AddInfo("Average Duration", "The average duration of each operation.", () => Timers.AverageDuration);
     AddInfo("Samples", "The number of samples.", () => Timers.SamplesCount);
     AddInfo("Samples Total", "The total duration of the samples.", () => Timers.TotalSampleDuration);
     AddInfo(
         "Samples Average",
         "The average duration of each operation in the samples.",
         () => Timers.AverageSampleDuration);
     AddInfo(
         "Warnings",
         "Total operations executed since the start of the process that have exceeded the warning duration threshold.",
         () => Timers.Warnings);
     AddInfo(
         "Criticals",
         "Total operations executed since the start of the process that have exceeded the critical duration threshold.",
         () => Timers.Criticals);
     // ReSharper restore PossibleNullReferenceException
 }
Example #2
0
		static void Main() {
			Timers timers = new Timers();
			Screen screen = new Screen();
			Keyboard keyboard = new Keyboard();
			Sound sound = new Sound();
			Chip8Emulator chip8 = new Chip8Emulator(timers, screen, keyboard, sound);
			Application.Run(new MainForm(chip8));
		}
Example #3
0
 void Awake()
 {
     if (!IsExist())
     {
         //Сохраняем инстанс в каждой сцене
         if (Application.isPlaying)
             DontDestroyOnLoad(gameObject);
         _instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #4
0
        private static void timerStart()
        {
            var attackers = 0;
            var defenders = 0;

            var biz = BusinessManager.BizList[bizID];

            foreach (var p in NAPI.Pools.GetAllPlayers())
            {
                if (!Main.Players.ContainsKey(p) || !p.HasData("WARZONE") || p.GetData("WARZONE") != whereWarIsGoing)
                {
                    continue;
                }
                if (Main.Players[p].FractionID == biz.Mafia)
                {
                    defenders++;
                }
                else if (Main.Players[p].FractionID == attackersFracID)
                {
                    attackers++;
                }
            }
            foreach (var p in NAPI.Pools.GetAllPlayers())
            {
                if (!Main.Players.ContainsKey(p) || !p.HasData("WARZONE") || p.GetData("WARZONE") != whereWarIsGoing)
                {
                    continue;
                }
                if (Main.Players[p].FractionID == biz.Mafia || Main.Players[p].FractionID == attackersFracID)
                {
                    Trigger.ClientEvent(p, "sendCaptureInformation", attackers, defenders, 0, 0);
                    Trigger.ClientEvent(p, "captureHud", true);
                }
            }

            //warTimer = Main.StartT(1000, 1000, (o) => timerUpdate(), "MWUPDATE_TIMER");
            warTimer = Timers.Start(1000, () => timerUpdate());
            //Main.StopT(toStartWarTimer, "toStartWarTimer");
            warStarting = false;
            warIsGoing  = true;

            Manager.sendFractionMessage(biz.Mafia, $"Ахтунг! На нас напали! {Manager.getName(attackersFracID)} решили отхватить наш бизнес");
            Manager.sendFractionMessage(attackersFracID, "Стреляй! Отжимай! Вы начали войну за бизнес");
        }
Example #5
0
        private static void endCapture()
        {
            try
            {
                //Main.StopT(warTimer, "warTimer");
                Timers.Stop(warTimer);
                Main.ClientEventToAll("captureHud", false);
                var biz = BusinessManager.BizList[bizID];
                protectDate[biz.Mafia]       = DateTime.Now.AddMinutes(20);
                protectDate[attackersFracID] = DateTime.Now.AddMinutes(20);
                if (attackersSt <= defendersSt)
                {
                    Manager.sendFractionMessage(biz.Mafia, $"Обсосы сбежали! Вы дали им под хвост! Вы отстояли бизнес");
                    Manager.sendFractionMessage(attackersFracID, "Вы лохонулись! Враги были сильнее! Вы не смогли захватить бизнес");

                    foreach (var m in Manager.Members.Keys)
                    {
                        if (Main.Players[m].FractionID == biz.Mafia)
                        {
                            MoneySystem.Wallet.Change(m, 300);
                            GameLog.Money($"server", $"player({Main.Players[m].UUID})", 300, $"winBiz");
                        }
                    }
                }
                else if (attackersSt > defendersSt)
                {
                    Manager.sendFractionMessage(biz.Mafia, $"Вы прошляпили бизнес..");
                    Manager.sendFractionMessage(attackersFracID, "Шугнули их как детей! Вы захватили бизнес!");
                    biz.Mafia = attackersFracID;
                    foreach (var m in Manager.Members.Keys)
                    {
                        if (Main.Players[m].FractionID == attackersFracID)
                        {
                            MoneySystem.Wallet.Change(m, 300);
                            GameLog.Money($"server", $"player({Main.Players[m].UUID})", 300, $"winBiz");
                        }
                    }
                    biz.UpdateLabel();
                }
                warIsGoing = false;
                warBlips[whereWarIsGoing].Color = 40;
            }
            catch (Exception e) { Log.Write($"EndMafiaWar: " + e.Message, nLog.Type.Error); }
        }
Example #6
0
            protected override RunStatus Run(object context)
            {
                string dpsSpell = Settings.PullSpell;

                Target.Face();
                Utils.LagSleep();

                bool result = Spell.Cast(dpsSpell);

                Utils.LagSleep();
                Utils.WaitWhileCasting();

                if (dpsSpell == "Vampiric Touch")
                {
                    Timers.Reset("VampiricTouch");
                }

                return(result ? RunStatus.Success : RunStatus.Failure);
            }
        public override void Tick(RealmTime time)
        {
            base.Tick(time);
            CheckOutOfBounds();

            if (!_waitforplayers)
            {
                if (Enemies.Count == 0)
                {
                    if (_ready)
                    {
                        if (_waiting)
                        {
                            return;
                        }
                        _ready = false;
                        Wave++;
                        foreach (KeyValuePair <int, Player> i in Players)
                        {
                            i.Value.Client.SendPacket(new ArenaNextWavePacket
                            {
                                Type = Wave
                            });
                            i.Value.Client.SendPacket(new TextPacket
                            {
                                BubbleTime = 0,
                                Stars      = -1,
                                Name       = "Court Overseer",
                                Text       = "The next wave will start in 5 seconds"
                            });
                        }
                        _waiting = true;
                        Timers.Add(new WorldTimer(5000, (world, t) =>
                        {
                            _ready = false;
                            Spawn();
                            _waiting = false;
                        }));
                    }
                    _ready = true;
                }
            }
        }
Example #8
0
        /// <summary>
        /// The update loop that assumes timestep has been fixed
        /// </summary>
        /// <param name="gameTime"></param>
        protected override void Update(GameTime gameTime)
        {
            GlobalInput.Update();
            Timers.Update(gameTime);

            if (CurrentState == GameState.Menu)
            {
                if (GlobalInput.WasCommandEntered(InputCommand.Exit))
                {
                    Exit();
                }
                menu.Update(gameTime);
            }
            else if (CurrentState == GameState.Playing)
            {
                if (GlobalInput.WasCommandEntered(InputCommand.Pause) || !IsActive)
                {
                    CurrentState = GameState.Paused;
                }
                else
                {
                    SoundEffect.MasterVolume = 1;
                    scene.Update(gameTime);
                }
            }
            else if (CurrentState == GameState.Paused)
            {
                if (GlobalInput.WasCommandEntered(InputCommand.Pause))
                {
                    CurrentState = GameState.Playing;
                }
                else
                {
                    SoundEffect.MasterVolume = 0;
                    pauseMenu.Update(gameTime);
                }
            }
            else if (CurrentState == GameState.GameOver)
            {
                gameOverMenu.Update(gameTime);
                scene.Update(gameTime);
            }
        }
Example #9
0
    // timer <duration> [message]
    static void TimerStart(TimeSpan duration, string message, ITriggerMsg e, Timers timers)
    {
        // Return if invalid or negative duration.
        if (duration <= TimeSpan.Zero)
        {
            return;
        }

        int tmrNo = timers.Enqueue(duration, e, message);

        if (tmrNo >= 0)
        {
            e.Reply("Your timer has started. [{0}] {1}", tmrNo, duration.Str());
        }
        else
        {
            e.Reply("Max timer count reached. Please wait for some timers to finish or stop them manually.");
        }
    }
Example #10
0
 //if bomb hits this object
 public void hit()
 {
     string[] edges = { "edge1", "edge2" };
     if (HP < 1)
     {
         Buoyancy buoyancyComponent = transform.Find(edges[Random.Range(0, edges.Length - 1)]).GetComponent <Buoyancy>();
         buoyancyComponent.Volume = DESTROYED_OBJECT_VOLUME;
         if (gameObject.name == "AirCarrier")
         {
             Timers.timeout(20, () => { Game.Instance.gameOver("air carrier is destroyed"); });
         }
         return;
     }
     HP--;
     foreach (string edge in edges)
     {
         transform.Find(edge).GetComponent <Buoyancy>().Volume -= Mathf.Max(MIN_RANDOM_COEFFICIENT, Random.value) * buoyancy / maxHP;
     }
 }
Example #11
0
    public static void AddStatusAllAttachedBallsTemp(Transform t, BallStatus newStatus, Material mat, float duration)
    {
        AttachedBall ab;

        if (ab = t.GetComponent <AttachedBall>())
        {
            //we make copies so the delegate we create keeps its own state
            //Material oldMat = t.GetComponent<SpriteRenderer>().sharedMaterial;
            //Transform trans = t;
            ab.AddStatus(newStatus, mat);
            ab.StartCoroutine(Timers.Countdown(duration, () => {
                ab.RemoveStatus(newStatus, mat);
            }));
        }
        foreach (Transform child in t)
        {
            AddStatusAllAttachedBallsTemp(child, newStatus, mat, duration);
        }
    }
Example #12
0
                [Behavior] void Copying()
                {
                    this.Super(Active);
                    this.Trait(Cancellable);

                    this.OnActivate(() => Timers.Register("copy", TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(1), () => Try(Copy)));

                    this.OnDeactivate(async() =>
                    {
                        await Task.Delay(100); // give time for timer to fire
                        Timers.Unregister("copy");
                    });

                    this.OnReceive <Copied>(async x =>
                    {
                        events.Add("Received Copied");
                        await Task.Delay(100);
                    });
                }
Example #13
0
        protected override void Update(TimeSpan gameTime)
        {
            Timers.BeginTimer("Cube Behavior Update");

            currentAngle = (float)(clock.TotalTime.TotalSeconds) * this.Frequency;
            float sinAngle = (float)Math.Sin(currentAngle);
            float cosAngle = (float)Math.Cos(currentAngle);

            Vector3 aux;

            aux.X = initPosition.X + (sinAngle * this.Amplitude.X);
            aux.Y = initPosition.Y + (cosAngle * this.Amplitude.Y);
            aux.Z = initPosition.Z + (sinAngle * this.Amplitude.Z);

            this.Transform.Position = aux;

            Timers.EndTimer("Cube Behavior Update");
            Labels.Add("First cube position", this.Transform.Position);
        }
        private void LoadOuter()
        {
            this.ReflectionHelpers = new ReflectionHelpers();
            this.DataStore         = new DataStore();
            this.Promises          = new Promises();
            this.LoadHelpers       = new LoadHelpers();

            this.Timers             = new Timers();
            this.LogHelpers         = new LogHelpers();
            this.ModFeaturesHelpers = new ModFeaturesHelpers();
            this.PacketProtocolMngr = new PacketProtocolManager();

            this.BuffHelpers               = new BuffHelpers();
            this.NetHelpers                = new NetHelpers();
            this.ItemIdentityHelpers       = new ItemIdentityHelpers();
            this.NPCIdentityHelpers        = new NPCIdentityHelpers();
            this.ProjectileIdentityHelpers = new ProjectileIdentityHelpers();
            this.BuffIdentityHelpers       = new BuffIdentityHelpers();
            this.NPCBannerHelpers          = new NPCBannerHelpers();
            this.RecipeIdentityHelpers     = new RecipeIdentityHelpers();
            this.RecipeGroupHelpers        = new RecipeGroupHelpers();
            this.PlayerHooks               = new ExtendedPlayerHooks();
            this.WorldStateHelpers         = new WorldStateHelpers();
            this.ControlPanel              = new UIControlPanel();
            this.ModLock               = new ModLockService();
            this.EntityGroups          = new EntityGroups();
            this.PlayerMessages        = new PlayerMessages();
            this.Inbox                 = new InboxControl();
            this.GetModInfo            = new GetModInfo();
            this.GetModTags            = new GetModTags();
            this.MenuItemMngr          = new MenuItemManager();
            this.MenuContextMngr       = new MenuContextServiceManager();
            this.MusicHelpers          = new MusicHelpers();
            this.PlayerIdentityHelpers = new PlayerIdentityHelpers();
            this.CustomEntMngr         = new CustomEntityManager();
            this.CustomHotkeys         = new CustomHotkeys();
            this.XnaHelpers            = new XnaHelpers();
            this.ServerInfo            = new ServerInfo();
            //this.PlayerDataMngr = new PlayerDataManager();
            this.SupportInfo    = new SupportInfoDisplay();
            this.RecipeHack     = new RecipeHack();
            this.ModListHelpers = new ModListHelpers();
        }
Example #15
0
            protected override bool CanRun(object context)
            {
                const string spellName = "Flash Heal";

                if (!Utils.CombatCheckOk(spellName, false))
                {
                    return(false);
                }
                if (Self.IsHealthPercentAbove(Settings.RestHealPercent))
                {
                    return(false);
                }
                if (!Timers.Expired("HealingSpells", Settings.HealingSpellTimer))
                {
                    return(false);
                }

                return(Spell.CanCast(spellName));
            }
Example #16
0
            protected override bool CanRun(object context)
            {
                const string dpsSpell = "Nourish";

                if (Me.Silenced)
                {
                    return(false);
                }
                if (!Timers.Expired("Healing", 2000))
                {
                    return(false);
                }
                if (Me.GotTarget && !Utils.Adds && Me.HealthPercent > 25 && (Me.HealthPercent * 1.2) > CT.HealthPercent && !Target.IsElite)
                {
                    return(false);
                }
                if (Me.Level >= 10 && ClassHelpers.Druid.ClassSpec != ClassHelpers.Druid.ClassType.Balance)
                {
                    return(false);
                }
                if (ClassHelpers.Druid.Shapeshift.IsCatForm && Me.ManaPercent < (Settings.CatFormManaBalance * 3))
                {
                    return(false);
                }
                if (!CLC.ResultOK(Settings.NourishBalance))
                {
                    return(false);
                }
                if (Self.IsHealthPercentAbove(Settings.NourishBalanceHealth))
                {
                    return(false);
                }
                if (Self.Immobilised)
                {
                    return(false);
                }
                if (!Utils.CombatCheckOk(dpsSpell, false))
                {
                    return(false);
                }

                return(Spell.CanCast(dpsSpell));
            }
Example #17
0
            protected override bool CanRun(object context)
            {
                const string dpsSpell = "Regrowth";

                if (Me.Silenced)
                {
                    return(false);
                }
                if (!CLC.ResultOK(Settings.RegrowthFeralCat))
                {
                    return(false);
                }
                if (Self.IsHealthPercentAbove(Settings.RegrowthFeralCatHealth))
                {
                    return(false);
                }
                if (Self.Immobilised)
                {
                    return(false);
                }
                if (!Utils.CombatCheckOk(dpsSpell, false))
                {
                    return(false);
                }
                if (Self.IsBuffOnMe(dpsSpell))
                {
                    return(false);
                }
                if (Self.IsBuffOnMe(Druid_ID.SurvivalInstincts))
                {
                    return(false);
                }
                if (!Timers.Expired("FeralCatHealSpam", Settings.FeralCatHealSpam))
                {
                    return(false);
                }
                if (Me.CurrentMana < ClassHelpers.Druid.Shapeshift.ShapeshiftRountTripCost(dpsSpell, "Rejuvenation"))
                {
                    return(false);
                }

                return(Spell.CanCast(dpsSpell));
            }
Example #18
0
    protected override void Start()
    {
        base.Start();
        sprev            = possibleResults[Random.Range(0, possibleResults.Count)];
        timeInGame.text  = Timers.MINIGAME_STR() + " s";
        timeInPause.text = Timers.PAUSE_STR() + " s";

        foreach (Transform t in livesContainer.transform)
        {
            GameObject.Destroy(t.gameObject);
        }

        for (int i = 0; i < PersistentDataManager.RUN.Lives; i++)
        {
            Instantiate(lifePrefab, livesContainer);
        }

        StartCoroutine(SetRandom());
    }
Example #19
0
 private void timer_playerExitWorkVehicle(Client player, Vehicle vehicle)
 {
     NAPI.Task.Run(() =>
     {
         try
         {
             if (!player.HasData("WORK_CAR_EXIT_TIMER"))
             {
                 return;
             }
             if (NAPI.Data.GetEntityData(player, "IN_WORK_CAR"))
             {
                 //Main.StopT(NAPI.Data.GetEntityData(player, "WORK_CAR_EXIT_TIMER"), "WORK_CAR_EXIT_TIMER_truckers_2");
                 Timers.Stop(NAPI.Data.GetEntityData(player, "WORK_CAR_EXIT_TIMER"));
                 NAPI.Data.ResetEntityData(player, "WORK_CAR_EXIT_TIMER");
                 if (player.HasData("WayPointBiz"))
                 {
                     Business biz = player.GetData("WayPointBiz");
                     Trigger.ClientEvent(player, "createWaypoint", biz.UnloadPoint.X, biz.UnloadPoint.Y);
                 }
                 return;
             }
             if (NAPI.Data.GetEntityData(player, "CAR_EXIT_TIMER_COUNT") > 300)
             {
                 respawnCar(vehicle);
                 Trigger.ClientEvent(player, "SetOrderTruck", null);
                 player.ResetData("WayPointBiz");
                 Notify.Send(player, NotifyType.Info, NotifyPosition.BottomCenter, $"Вы закончили рабочий день", 3000);
                 NAPI.Data.SetEntityData(player, "ON_WORK", false);
                 NAPI.Data.SetEntityData(player, "WORK", null);
                 Timers.Stop(NAPI.Data.GetEntityData(player, "WORK_CAR_EXIT_TIMER"));
                 NAPI.Data.ResetEntityData(player, "WORK_CAR_EXIT_TIMER");
                 cancelOrder(player);
                 return;
             }
             NAPI.Data.SetEntityData(player, "CAR_EXIT_TIMER_COUNT", NAPI.Data.GetEntityData(player, "CAR_EXIT_TIMER_COUNT") + 1);
         } catch (Exception e)
         {
             Log.Write("Timer_PlayerExitWorkVehicle_Truckers: \n" + e.ToString(), nLog.Type.Error);
         }
     });
 }
Example #20
0
        private static void timerStartCapture(GangPoint region)
        {
            var attackers = 0;
            var defenders = 0;

            foreach (var p in NAPI.Pools.GetAllPlayers())
            {
                if (!Main.Players.ContainsKey(p) || !p.HasData("GANGPOINT") || p.GetData("GANGPOINT") != region.ID)
                {
                    continue;
                }
                if (Main.Players[p].FractionID == region.GangOwner)
                {
                    defenders++;
                }
                else if (Main.Players[p].FractionID == attackersFracID)
                {
                    attackers++;
                }
            }
            foreach (var p in NAPI.Pools.GetAllPlayers())
            {
                if (!Main.Players.ContainsKey(p) || !p.HasData("GANGPOINT") || p.GetData("GANGPOINT") != region.ID)
                {
                    continue;
                }
                if (Main.Players[p].FractionID == region.GangOwner || Main.Players[p].FractionID == attackersFracID)
                {
                    Trigger.ClientEvent(p, "sendCaptureInformation", attackers, defenders, 0, 0);
                    Trigger.ClientEvent(p, "captureHud", true);
                }
            }

            captureIsGoing  = true;
            captureStarting = false;
            //captureTimer = Main.StartT(1000, 1000, (o) => timerUpdate(region, region.ID), "CAPTUREUPDATE_TIMER");
            captureTimer = Timers.Start(1000, () => timerUpdate(region, region.ID));
            //Main.StopT(toStartCaptureTimer, "toStartCaptureTimer_gangcapture");

            Manager.sendFractionMessage(region.GangOwner, $"Ахтунг! На нас напали! {Manager.getName(attackersFracID)} решили отхватить нашу территорию");
            Manager.sendFractionMessage(attackersFracID, "Стреляй! Отжимай! Вы начали войну за территорию");
        }
Example #21
0
        ////////////////

        internal void TrialLicenseItemByDefinition(ItemDefinition itemDef, bool playSound)
        {
            var mymod = (LicensesMod)this.mod;

            if (this.TrialLicensedItem != null)
            {
                string itemName = ItemAttributeHelpers.GetQualifiedName(this.TrialLicensedItem.Type);

                Main.NewText(itemName + " trial cancelled.", Color.Yellow);

                if (!this.LicensedItems.Contains(itemDef))
                {
                    NihilismAPI.UnsetItemWhitelistEntry(this.TrialLicensedItem, true);
                }
            }

            this.TrialLicensedItems.Add(itemDef);
            this.TrialLicensedItem = itemDef;

            NihilismAPI.SetItemWhitelistEntry(itemDef, true);

            Timers.UnsetTimer("LicensesTrialPeriod");
            Timers.SetTimer("LicensesTrialPeriod", LicensesMod.Config.TrialLicenseDurationInTicks, () => {
                var myplayer = (LicensesPlayer)TmlHelpers.SafelyGetModPlayer(Main.LocalPlayer, mymod, "LicensesPlayer");

                if (!myplayer.LicensedItems.Contains(itemDef))
                {
                    string itemName = ItemAttributeHelpers.GetQualifiedName(itemDef.Type);

                    Main.NewText(itemName + " trial has expired.", Color.Yellow);
                    NihilismAPI.UnsetItemWhitelistEntry(itemDef, true);

                    myplayer.TrialLicensedItem = null;
                }
                return(false);
            });

            if (playSound)
            {
                Main.PlaySound(SoundID.Unlock, player.position);
            }
        }
Example #22
0
        protected void InitArena(RealmTime time)
        {
            if (IsEmpty())
            {
                if (ready)
                {
                    if (waiting)
                    {
                        return;
                    }

                    ready = false;

                    foreach (KeyValuePair <int, Player> i in Players)
                    {
                        if (i.Value.Client == null)
                        {
                            continue;
                        }

                        i.Value.Client.SendMessage(new IMMINENT_ARENA_WAVE
                        {
                            CurrentRuntime = time.ElapsedMsDelta,
                            Wave           = wave
                        });
                    }

                    waiting = true;

                    Timers.Add(new WorldTimer(5000, (world, t) =>
                    {
                        ready   = false;
                        waiting = false;
                        PopulateArena();
                    }));

                    wave++;
                }

                ready = true;
            }
        }
        private void CmdStopOnce(IPlayer player, string cmd, string[] args)
        {
            if (!player.IsAdmin)
            {
                return;
            }

            string timerName = args.Length == 0 ? "" : args[0];

            if (string.IsNullOrEmpty(timerName))
            {
                Puts($"The {Types.TimerOnce} timers has stopped");
            }
            else
            {
                Puts($"The {Types.TimerOnce} timer '{timerName}' has stopped");
            }

            Timers.StopTimer(Types.TimerOnce, args.Length == 0 ? "" : args[0]);
        }
Example #24
0
        public void Time_TimerTest()
        {
            var elapsed = TimeSpan.Zero;

            using (var p = Pipeline.Create())
            {
                // create a timer with the smallest possible increment
                var timer = Timers.Timer(p, TimeSpan.FromMilliseconds(1));

                timer.Do(t =>
                {
                    // verify that the timer ticks forward
                    Assert.IsTrue(t > elapsed);
                    elapsed = t;
                });

                p.RunAsync();
                p.WaitAll(TimeSpan.FromSeconds(1));
            }
        }
Example #25
0
    void bombTarget()
    {
        //My ballistics calculator
        float timeToCollision  = Mathf.Sqrt(altitude / GRAVITY);
        float attackPosition   = Mathf.Abs(timeToCollision * GetComponent <Rigidbody2D>().velocity.x) + BOMB_OFFSET;
        float distanceToAttack = Mathf.Abs(attackPosition - Mathf.Abs(deltaPosition));

        if (distanceToAttack < BOMB_THROW_ACCURACY)
        {
            planeBehaviour.throwBomb();
            setState(state = AIState.reachingTarget);
            Timers.timeout(2, () =>
            {
                targetPosition = BASE_POSITION;
                deltaPosition  = targetPosition - position;
                distance       = Mathf.Abs(deltaPosition);
                setState(state = AIState.landing);
            });
        }
    }
        ////////////////

        public TileDataManager()
        {
            this.OnTickGet = Timers.MainOnTickGet();
            Main.OnTick   += TileDataManager._Update;

            if (!Main.dedServ)
            {
                Overlays.Scene["TileDamageEffects"] = new TileEffectsOverlay();
                Overlays.Scene.Activate("TileDamageEffects");
            }

            LoadHooks.AddModUnloadHook(() => {
                Main.OnTick -= TileDataManager._Update;

                if (!Main.dedServ)
                {
                    Overlays.Scene["TileDamageEffects"].Deactivate();
                }
            });
        }
Example #27
0
        public void StartTimer()
        {
            for (;;)
            {
                foreach (var room in Timers.ToList())
                {
                    Timers[room.Key]--;
                    SendMessage(TimersData[room.Key], Timers[room.Key]);
                    if (Timers[room.Key] <= 0)
                    {
                        RemoveTimer(room.Key);
                        OnTimerEnd?.Invoke(room.Key);
                    }
                }

                Thread.Sleep(1000);
            }

            // ReSharper disable once FunctionNeverReturns
        }
Example #28
0
 public void onPlayerExitVehicleHandler(Client player, Vehicle vehicle)
 {
     try
     {
         if (NAPI.Data.GetEntityData(vehicle, "ACCESS") == "WORK" &&
         Main.Players[player].WorkID == 3 &&
         NAPI.Data.GetEntityData(player, "WORK") == vehicle)
         {
             Notify.Send(player, NotifyType.Warning, NotifyPosition.BottomCenter, $"Если Вы не сядете в транспорт через 5 минут, то рабочий день закончится", 3000);
             NAPI.Data.SetEntityData(player, "IN_WORK_CAR", false);
             if (player.HasData("WORK_CAR_EXIT_TIMER"))
                 //Main.StopT(NAPI.Data.GetEntityData(player, "WORK_CAR_EXIT_TIMER"), "WORK_CAR_EXIT_TIMER_taxi_1");
                 Timers.Stop(NAPI.Data.GetEntityData(player, "WORK_CAR_EXIT_TIMER"));
             NAPI.Data.SetEntityData(player, "CAR_EXIT_TIMER_COUNT", 0);
             //NAPI.Data.SetEntityData(player, "WORK_CAR_EXIT_TIMER", Main.StartT(1000, 1000, (o) => timer_playerExitWorkVehicle(player, vehicle), "TAXI_CAR_EXIT_TIMER"));
             NAPI.Data.SetEntityData(player, "WORK_CAR_EXIT_TIMER", Timers.StartTask(1000, () => timer_playerExitWorkVehicle(player, vehicle)));
         }
     }
     catch (Exception e) { Log.Write("PlayerExit: " + e.Message, nLog.Type.Error); }
 }
Example #29
0
 private static void healTimer(Client player)
 {
     NAPI.Task.Run(() =>
     {
         try
         {
             if (player.Health == 100)
             {
                 //Main.StopT(player.GetData("HEAL_TIMER"), "timer_10");
                 Timers.Stop(player.GetData("HEAL_TIMER"));
                 player.ResetData("HEAL_TIMER");
                 Trigger.ClientEvent(player, "stopScreenEffect", "PPFilter");
                 Notify.Send(player, NotifyType.Success, NotifyPosition.BottomCenter, $"Ваше лечение закончено", 3000);
                 return;
             }
             player.Health = player.Health + 1;
         }
         catch { }
     });
 }
Example #30
0
        public override void Update(GameTime gameTime)
        {
            if (_mapScripts == null)
            {
                return;
            }

            // TODO: Remove this hack when we have separate update and render loops.
            _30hzHack = !_30hzHack;
            if (_30hzHack)
            {
                return;
            }

            if (!Active)
            {
                return;
            }

            foreach (var coroutine in _activeCoroutines)
            {
                var result = coroutine.Execute(_executionContext);
                if (result is ActionResult.ActionFinished)
                {
                    _finishedCoroutines.Add(coroutine);
                }
            }

            foreach (var coroutine in _finishedCoroutines)
            {
                _activeCoroutines.Remove(coroutine);
            }

            _mapScripts.Execute(_executionContext);

            OnUpdateFinished?.Invoke(this, this);

            Timers.Update();

            Frame++;
        }
Example #31
0
        protected override void Init()
        {
            LoadMap($"wServer.realm.worlds.maps.arena{new Random().Next(1, 2)}.jm", MapType.Json);
            Wave            = 0;
            _waitforplayers = true;

            // setup spawn regions
            for (int x = 0; x < Map.Width; x++)
            {
                for (int y = 0; y < Map.Height; y++)
                {
                    if (Map[x, y].Region == TileRegion.Arena_Central_Spawn)
                    {
                        _centralSpawn.Add(new IntPoint(x, y));
                    }

                    if (Map[x, y].Region == TileRegion.Arena_Edge_Spawn)
                    {
                        _outerSpawn.Add(new IntPoint(x, y));
                    }
                }
            }

            Timers.Add(new WorldTimer(30000, (world, t) =>
            {
                _waitforplayers = false;
            }));

            foreach (Client i in Manager.Clients.Values)
            {
                i.SendPacket(new TextPacket
                {
                    BubbleTime = 0,
                    Stars      = -1,
                    Name       = "@ANNOUNCEMENT",
                    Text       = "A interdimensional portal to the Court Of Bereavement has opened! Type /court to join!"
                });
            }

            InformPlayers();
        }
Example #32
0
        void ModuleProgramInit()
        {
            wicoTravelMovement = new TravelMovement(this, _wicoControl);

            wicoThrusters    = new WicoThrusters(this);
            wicoGyros        = new WicoGyros(this, wicoBlockMaster);
            wicoGasTanks     = new GasTanks(this, wicoBlockMaster);
            wicoGasGens      = new GasGens(this);
            wicoConnectors   = new Connectors(this);
            wicoLandingGears = new LandingGears(this);
            wicoCameras      = new Cameras(this);
            wicoParachutes   = new Parachutes(this);
            wicoNavRotors    = new NavRotors(this);
            wicoAntennas     = new Antennas(this);
            wicoSensors      = new Sensors(this, wicoBlockMaster);
            wicoWheels       = new Wheels(this);

            wicoEngines = new HydrogenEngines(this);
            wicoPower   = new PowerProduction(this, wicoBlockMaster);
            wicoTimers  = new Timers(this, wicoBlockMaster);
            //            navRemote = new NavRemote(this);
            //            navCommon = new NavCommon(this);
            _wicoDisplays = new Displays(this, wicoBlockMaster, wicoElapsedTime);
            _cargoCheck   = new CargoCheck(this, wicoBlockMaster, _wicoDisplays);

            wicoBases = new WicoBases(this, wicoIGC, _wicoDisplays);

            wicoNavigation = new Navigation(this, _wicoControl, wicoBlockMaster, wicoIGC, wicoTravelMovement, wicoElapsedTime,
                                            wicoGyros, wicoWheels, wicoNavRotors, wicoThrusters, _wicoDisplays);

            spaceDock = new SpaceDock(this, _wicoControl, wicoBlockMaster, wicoThrusters, wicoConnectors
                                      , wicoAntennas, wicoGasTanks, wicoGyros, wicoPower, wicoTimers
                                      , wicoIGC, wicoBases, wicoNavigation, _cargoCheck, _wicoDisplays);

            _wicoControl.WantSlow(); // get updates so we can check for things like navigation commands in oldschool format

            /// DEBUG
            //            wicoIGC.SetDebug(true);
            //            _wicoControl.SetDebug(true);
            //            wicoElapsedTime.SetDebug(true);
        }
Example #33
0
    public void Spawn(List <GameObject> collection, float interval)
    {
        if (spawning)
        {
            GameObject ball = null;
            //Debug.Log ("Selecting ball");
            if (collection != null && collection.Count > 0)
            {
                ball = Util.GetRandomElement <GameObject>(collection);
            }

            if (ball != null)
            {
                //Debug.Log ("Spawning a " + ball.name);
                SpawnBall(ball);
            }
            //randomise the spawn a little bit
            float nextInterval = interval + Util.RandomSign() * Random.Range(0.1f, 0.2f) * interval;
            StartCoroutine(Timers.Countdown <List <GameObject>, float>(nextInterval, Spawn, collection, interval));
        }
    }
Example #34
0
 void timer_Elapsed(object sender, Timers.ElapsedEventArgs e)
 {
     Elapsed(this, e);
 }
Example #35
0
 public Camp(string name,
     float spawnTime,
     int respawnTimer,
     Vector3 position,
     List<Mob> mobs,
     Utility.Map.MapType mapType,
     GameObjectTeam team,
     Color colour,
     Timers timer,
     bool isRanged = false,
     int state = 0,
     int respawnTime = 0,
     int lastChangeOnState = 0)
 {
     Name = name;
     SpawnTime = spawnTime;
     RespawnTimer = respawnTimer;
     Position = position;
     MapPosition = Drawing.WorldToScreen(Position);
     MinimapPosition = Drawing.WorldToMinimap(Position);
     Mobs = mobs;
     MapType = mapType;
     Team = team;
     Colour = colour;
     IsRanged = isRanged;
     State = state;
     RespawnTime = respawnTime;
     LastChangeOnState = lastChangeOnState;
     Timer = timer;
 }
Example #36
0
 protected internal TimerEventArgs(Timers.Timer timer)
 {
     GondwanaTimer = timer;
 }
Example #37
0
        /*
         * Method handles adding new timer data to the appropriate List
         * objects and checklist
         */
        private void btnAddTimer_Click(object sender, EventArgs e)
        {
            if (txtTimerName.Text.CompareTo("") == 0) {
                MessageBox.Show("You must enter a timer name!",
                    "Timer Name Required");
            }
            if (!legitTime((int)numTimerHr.Value, (int)numTimerMin.Value,
                                (int)numTimerSec.Value, false)) {
                throw new DANTException("Not legit time from legitTime()\n");
            }

            Timers tmpTimer = new Timers();

            tmpTimer.name = txtTimerName.Text;
            tmpTimer.setInterval((int) numTimerHr.Value,
                                 (int) numTimerMin.Value,
                                 (int) numTimerSec.Value);
            tmpTimer.setOrigInterval(new TimeSpan((int) numTimerHr.Value,
                                      (int) numTimerMin.Value,
                                      (int) numTimerSec.Value));

            tmpTimer.setRunning(false);
            tmpTimer.soundBite = soundByteSelection();

            grayItemNameBoxNResetNumerics(false);

            //add it to the list
            activeTms.Add(tmpTimer);

            //add timer to the 'active' timers list in the checkboxlist
            addTimer(activeTms.IndexOf(tmpTimer));
            try {
                saveAlarmsTimers();
            } catch {
                if (fileIODebugging) {
                    Console.WriteLine("Error saving alarms/timers\n");
                }
                throw new DANTException("Error saving alarms/timers");
            }
        }
Example #38
0
        /*
         * Method creates a temporary timer to be utilized before
         * pushing it onto the active stack of timers
         */
        private Timers createTmpTimer(string[] fields)
        {
            if (fields[0] == null) { return null; }
            if (fields[0].CompareTo("T") != 0) { return null; }

            Timers tmp = new Timers();
            int[] ouah = null;

            tmp.name = fields[1];
            tmp.setRunning(false);
            ouah = convertSavedFields(fields);
            tmp.setInterval(ouah[0], ouah[1], ouah[2]);

            //in hindsight, these should both be set by TimeSpan, not one by
            //such and the other by 3 integers :P
            tmp.setOrigInterval(new TimeSpan(ouah[0], ouah[1], ouah[2]));

            return tmp;
        }
Example #39
0
            public Camp(string name,
                float spawnTime,
                int respawnTimer,
                Vector3 position,
                List<Mob> mobs,
                Utility.Map.MapType mapType,
                GameObjectTeam team,
                Color colour,
                Timers timer,
                bool isRanged = false,
                int state = 0,
                int respawnTime = 0,
                int lastChangeOnState = 0,
                bool shouldping = true,
                int lastPing = 0)
            {
                Name = name;
                SpawnTime = spawnTime;
                RespawnTimer = respawnTimer;
                Position = position;
                MapPosition = Drawing.WorldToScreen(Position);
                MinimapPosition = Drawing.WorldToMinimap(Position);
                Mobs = mobs;
                MapType = mapType;
                Team = team;
                Colour = colour;
                IsRanged = isRanged;
                State = state;
                RespawnTime = respawnTime;
                LastChangeOnState = lastChangeOnState;
                Timer = timer;
                ShouldPing = shouldping;
                LastPing = lastPing;

                #region Load Text

                TextMinimap = new Render.Text(0, 0, "", Program._menu.Item("timerfontminimap").GetValue<Slider>().Value, Program.White)
                {
                    VisibleCondition =
                        sender =>
                            Program.Timeronminimap && RespawnTime > Environment.TickCount && State == 7,
                    PositionUpdate = delegate
                    {
                        Vector2 v2 = Timer.MinimapPosition;
                        return v2;
                    },
                    TextUpdate = () => Timer.TextOnMinimap,
                    OutLined = false,
                    Centered = true
                };
                TextMinimap.Add();

                TextMap = new Render.Text(0, 0, "", Program._menu.Item("timerfontmap").GetValue<Slider>().Value, Program.White)
                {
                    VisibleCondition =
                        sender =>
                            Program.Timeronmap && RespawnTime > Environment.TickCount && State == 7 && Position.IsOnScreen(),
                    PositionUpdate = delegate
                    {
                        Vector2 v2 = Timer.Position;
                        return v2;
                    },
                    TextUpdate = () => Timer.TextOnMap,
                    OutLined = false,
                    Centered = true
                };
                TextMap.Add();

                #endregion

                //Drawing.OnEndScene += Drawing_OnEndScene;
            }
Example #40
0
        /*
         * Method attempts to load the alarms & timers config file, checking
         * for file corruption, incorrect permissions, and for file existance;
         * Method adds any found alarms or timers to the appropriate global
         * List objects and returns 'true' if no errors are found or throws
         * DANTException upon garbled data or no file found
         */
        private void loadAlarmsTimers()
        {
            String[] rawFile;
            int aCntr = 0, tCntr = 0;

            if (chkCfg()) { return; }

            rawFile = readCfg();
            if (rawFile == null) {
                throw new DANTException("Error reading cfg file");
            }

            foreach (String raw in rawFile) {
                String[] rawFields;
                //not sure how to fix this just yet; it might require
                //a change in the config file at this point, also
                Alarms tmpAlarm = new Alarms();
                Timers tmpTimer = new Timers();

                if (fileIODebugging) {
                    Console.WriteLine("raw: " + raw);
                }

                try {
                    rawFields = parseSavedFieldsLine(raw);
                } catch {
                    if (fileIODebugging) {
                        Console.WriteLine("Error parsing saved fields " +
                            "line\n");
                    }
                    rawFields = null;   //don't remember :|
                    throw new DANTException("Error parsing saved " +
                        "fields line\n");
                }

                if (rawFields == null) {
                    if (fileIODebugging) {
                        Console.WriteLine("null string");
                    }
                    continue;
                } else if (rawFields[0].CompareTo("A") == 0) {
                    tmpAlarm = createTmpAlarm(rawFields);
                    activeAls.Add(tmpAlarm);
                    addAlarm(aCntr++);
                } else if (rawFields[0].CompareTo("T") == 0) {
                    tmpTimer = createTmpTimer(rawFields);
                    activeTms.Add(tmpTimer);
                    addTimer(tCntr++);
                } else {
                    MessageBox.Show("Issue parsing config file!",
                        "Cannot Parse DANT.cfg", MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    throw new DANTException("Yet another issue trying to " +
                        "parse the config file!");
                }
            }
            return;
        }