Ejemplo n.º 1
0
        static void Activate()
        {
            if (isActive)
            {
                return;
            }

            isActive = true;
            timer.Start();
        }
Ejemplo n.º 2
0
        public void DropUnconscious(long duration = -1, bool toFront = true)
        {
            var          cat = AniCatalog.Unconscious;
            ScriptAniJob job = toFront ? cat.DropFront : cat.DropBack;

            if (job != null)
            {
                ModelInst.StartAniJob(job);
            }

            _Uncon = toFront ? Unconsciousness.Front : Unconsciousness.Back;

            var strm = BaseInst.GetScriptVobStream();

            strm.Write((byte)ScriptVobMessageIDs.Uncon);
            strm.Write((byte)_Uncon);
            BaseInst.SendScriptVobStream(strm);

            if (duration >= 0)
            {
                if (unconTimer == null)
                {
                    unconTimer = new GUCTimer(LiftUnconsciousness);
                }

                unconTimer.SetInterval(duration);
                unconTimer.Start();
            }

            OnUnconChange?.Invoke(this);
        }
Ejemplo n.º 3
0
        static void StartStand(HordeStand stand)
        {
            ActiveStand = stand;

            if (IsPlaying)
            {
                if (!string.IsNullOrWhiteSpace(stand.SFXStart))
                {
                    SoundHandler.PlaySound3D(new SoundDefinition(stand.SFXStart), stand.Position, 2500, 1.0f);
                }

                if (!string.IsNullOrWhiteSpace(stand.SFXStart))
                {
                    StandSFXLoop = SoundHandler.PlaySound3D(new SoundDefinition(stand.SFXLoop), stand.Position, 2500, 0.5f, true);
                }

                if (stand.Messages != null && stand.Messages.Length > 0)
                {
                    messageIndex = 0;
                    NextMessage();
                    if (stand.Messages.Length > 1 && stand.Duration > 0)
                    {
                        messageTimer.SetInterval(stand.Duration * TimeSpan.TicksPerSecond / (stand.Messages.Length - 1));
                        messageTimer.Start();
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void StartInactivityTimer()
 {
     if (chatInactivityTimer.Started)
     {
         chatInactivityTimer.Restart();
     }
     else
     {
         chatInactivityTimer.Start();
     }
 }
Ejemplo n.º 5
0
        static void StartStand(StandInst inst)
        {
            Log.Logger.Log("Start stand");
            ActiveStandInst = inst;
            standEnemyCount = 0;

            inst.Agent = CreateAgent(2 * inst.Stand.Range);
            if (inst.Boss != null)
            {
                inst.Agent.aiClients.Add(inst.Boss);
                inst.Boss.CanGetHit -= BossProtection;
                inst.Boss.OnDeath   += boss => EndStand();
            }
            else
            {
                gameTimer.SetInterval(inst.Stand.Duration * TimeSpan.TicksPerSecond);
                gameTimer.SetCallback(EndStand);
                gameTimer.Start();
            }
            FillUpStandEnemies();

            SetPhase(HordePhase.Stand);
        }
Ejemplo n.º 6
0
        void StartStand(HordeScenario.Stand stand)
        {
            if (!HordeMode.IsActive)
            {
                return;
            }

            ActiveStand = stand;

            if (!string.IsNullOrWhiteSpace(stand.SFXStart))
            {
                var def = new SoundDefinition(stand.SFXStart);
                if (stand.GlobalSFX)
                {
                    SoundHandler.PlaySound(def, 1.0f);
                }
                else
                {
                    SoundHandler.PlaySound3D(def, stand.Position, 5000 + stand.Range, 1.0f);
                }
            }

            if (!string.IsNullOrWhiteSpace(stand.SFXLoop))
            {
                var def = new SoundDefinition(stand.SFXLoop);
                if (stand.GlobalSFX)
                {
                    SoundHandler.PlaySound(def, 1.0f);
                }
                else
                {
                    SoundHandler.PlaySound3D(def, stand.Position, 5000 + stand.Range, 0.5f, true);
                }
            }

            if (stand.Messages != null && stand.Messages.Length > 0)
            {
                messageIndex = 0;
                NextMessage();
                if (stand.Messages.Length > 1 && stand.Duration > 0)
                {
                    messageTimer.SetInterval(stand.Duration / (stand.Messages.Length - 1));
                    messageTimer.SetCallback(NextMessage);
                    messageTimer.Start();
                }
            }
        }
Ejemplo n.º 7
0
        public static void ReadRequest(ArenaClient requester, PacketReader stream)
        {
            if (requester.Character == null || requester.IsDueling || requester.Character.IsDead || requester.GMJoined)
            {
                return;
            }

            if (!requester.Character.World.TryGetVob(stream.ReadUShort(), out NPCInst target))
            {
                return;
            }

            if (target.Client == null || target.IsDead)
            {
                return;
            }

            var targetClient = (ArenaClient)target.Client;

            if (targetClient.IsDueling || targetClient.GMJoined)
            {
                return;
            }

            int index;

            if ((index = targetClient.DuelRequests.FindIndex(r => r.Item1 == requester)) >= 0) // other player has already sent a request
            {
                targetClient.DuelRequests[index].Item2.Stop();
                targetClient.DuelRequests.RemoveAt(index);
                DuelStart(requester, targetClient);
            }
            else if ((index = requester.DuelRequests.FindIndex(r => r.Item1 == targetClient)) >= 0) // already sent a request
            {
                requester.DuelRequests[index].Item2.Restart();
            }
            else // add new request
            {
                var timer = new GUCTimer(DuelRequestDuration, () => requester.DuelRequests.RemoveAll(r => r.Item1 == targetClient));
                timer.Start();
                requester.DuelRequests.Add(targetClient, timer);

                SendRequest(requester, targetClient);
            }
        }
Ejemplo n.º 8
0
        public override void Close()
        {
            if (!shown)
            {
                return;
            }

            long diff = GameTime.Ticks - openTime;

            if (diff > MinOpenDuration)
            {
                DoClose();
            }
            else
            {
                closeTimer.Stop();
                closeTimer.SetInterval(MinOpenDuration - diff);
                closeTimer.Start();
            }
        }
Ejemplo n.º 9
0
        void StartStand(StandInst inst)
        {
            Log.Logger.Log("Start stand");
            ActiveStand = inst;

            inst.Agent = CreateAgent(2 * inst.Stand.Range);
            if (inst.Boss != null)
            {
                inst.Agent.Add(inst.Boss);
                inst.Boss.AllowHitTarget.Remove(BossProtection);
                inst.Boss.OnDeath += boss => EndStand();
            }

            standSpawnTimer.SetInterval(inst.Stand.EnemySpawnInterval);
            standSpawnTimer.SetCallback(StandSpawn);
            standSpawnTimer.Start();
            StandSpawn();

            SetPhase(GamePhase.Fight + 1 + inst.Index);
            standTimer.SetInterval(inst.Stand.Duration);
            standTimer.SetCallback(EndStand);
        }
Ejemplo n.º 10
0
        protected override void Start(GameScenario scenario)
        {
            if (!(scenario is TDMScenario))
            {
                throw new ArgumentException("Scenario is no TDMScenario!");
            }

            base.Start(scenario);

            TDMScenario tdmScen = (TDMScenario)scenario;

            foreach (var teamDef in tdmScen.Teams)
            {
                teams.Add(new TDMTeamInst()
                {
                    Definition = teamDef
                });
            }

            respawnTimer.SetCallback(RespawnWave);
            respawnTimer.Start();
            NPCInst.sOnHit += OnHit;
        }
Ejemplo n.º 11
0
        public void Toggle(ArenaClient client, bool open)
        {
            if (open)
            {
                if (!clients.ContainsKey(client))
                {
                    GUCTimer timer = new GUCTimer(UpdateInterval, () => SendUpdate(client));
                    clients.Add(client, timer);
                    timer.Start();

                    if (clients.Count == 1)
                    {
                        packetTimer.Start();
                        WriteUpdate();
                    }

                    SendUpdate(client);
                }
            }
            else
            {
                Remove(client);
            }
        }
Ejemplo n.º 12
0
 public void StartRainTimer()
 {
     rainTimer.Start();
 }
Ejemplo n.º 13
0
        protected override void Fight()
        {
            foreach (var bar in spawnBarriers)
            {
                bar.Despawn();
            }
            spawnBarriers.Clear();

            if (Scenario.SpawnBarriers != null)
            {
                foreach (var bar in Scenario.SpawnBarriers)
                {
                    if (bar.AddAfterEvent)
                    {
                        CreateBarrier(bar);
                    }
                }
            }

            foreach (var group in Scenario.Enemies)
            {
                var agent = CreateAgent();
                foreach (var pair in group.npcs)
                {
                    int maxCount = (int)Math.Ceiling(pair.CountScale * players.Count);
                    for (int i = 0; i < maxCount; i++)
                    {
                        agent.Add(SpawnNPC(pair.Enemy, group.Position, group.Range));
                    }
                }
            }

            foreach (var group in Scenario.AmbientNPCs)
            {
                foreach (var pair in group.npcs)
                {
                    for (int i = 0; i < pair.CountScale; i++)
                    {
                        var      npc    = SpawnNPC(pair.Enemy, group.Position, new Angles(0, group.Yaw, 0), group.Range, 0, false);
                        ItemInst weapon = npc.GetEquipmentBySlot(NPCSlots.TwoHanded);
                        if (weapon == null)
                        {
                            weapon = npc.GetEquipmentBySlot(NPCSlots.OneHanded1);
                        }
                        if (weapon != null)
                        {
                            npc.DoDrawWeapon(weapon);
                        }
                        AmbientNPCs.Add(npc);
                    }
                }
            }

            standTimer.SetInterval(TimeSpan.TicksPerSecond);
            standTimer.SetCallback(CheckStandDistance);
            standTimer.Start();

            base.Fight();

            NPCInst.sOnHit += OnHit;
        }
Ejemplo n.º 14
0
 public void StartTimer()
 {
     HideBarrier();
     _Timer.Start();
 }
Ejemplo n.º 15
0
 public static void Init()
 {
     timer = new GUCTimer(RegenerationInterval, RegeneratePlayers);
     timer.Start();
 }