protected virtual void Fight() { if (this.SpawnWorld != null) { var oldWorld = this.SpawnWorld; this.SpawnWorld = null; // move to real world foreach (ArenaClient c in players) { if (c.IsCharacter) { InitialSpawnClient(c, false); } else { JoinAsSpectator(c); } } oldWorld.Delete(); } SetPhase(GamePhase.Fight); phaseTimer.SetInterval(Scenario.FightDuration); phaseTimer.SetCallback(FadeOut); phaseTimer.Restart(); }
void ShowBarrier() { long transition = Randomizer.GetInt(TransitionSecondsMin, TransitionSecondsMax) * TimeSpan.TicksPerSecond; SetNextWeight(GameTime.Ticks + transition, 1.0f); // barrier visible _Timer.SetInterval(VisibleTimeMin + (long)(Randomizer.GetDouble() * VisibleTimeMax)); _Timer.SetCallback(HideBarrier); }
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); }
public ChatMenu() { screenSize = GUCView.GetScreenSize(); chatHeigth = screenSize.Y / 5; chatWidth = screenSize.X - 350; chatBackground = new GUCVisual(0, 0, chatWidth, chatHeigth + 5); chatBackground.SetBackTexture("Dlg_Conversation.tga"); const int space = 20; int lines = chatHeigth / space; for (int i = 0; i < lines; i++) { chatBackground.CreateText("" + i, 20, 5 + i * space); chatBackground.Texts[i].Text = ""; } textBox = new GUCTextBox(70, chatHeigth + 5, chatWidth - 90, false); prefix = new GUCVisual(15, chatHeigth + 5, chatWidth, 20); prefix.CreateText("", 0, 0); chatInactivityTimer = new GUCTimer(); chatInactivityTimer.SetCallback(() => { if (!textBox.Enabled) { chatBackground.Hide(); } chatInactivityTimer.Stop(); }); chatInactivityTimer.SetInterval(6 * TimeSpan.TicksPerSecond); }
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(); } } } }
public ChatMenu(Chat chat) { _Chat = chat ?? throw new ArgumentNullException(nameof(chat)); _Chat.ChatMessageReceived += (sender, args) => ReceiveServerMessage(args.Mode, args.Message); screenSize = GUCView.GetScreenSize(); chatHeigth = screenSize.Y / 5; chatWidth = screenSize.X - 350; chatBackground = new GUCVisual(0, 0, chatWidth, chatHeigth + 5); chatBackground.SetBackTexture("Dlg_Conversation.tga"); const int space = 20; int lines = chatHeigth / space; for (int i = 0; i < lines; i++) { chatBackground.CreateText("" + i, 20, 5 + i * space); chatBackground.Texts[i].Text = ""; } textBox = new GUCTextBox(70, chatHeigth + 5, chatWidth - 90, false); prefix = new GUCVisual(15, chatHeigth + 5, chatWidth, 20); prefix.CreateText("", 0, 0); chatInactivityTimer = new GUCTimer(); chatInactivityTimer.SetCallback(() => { if (!textBox.Enabled) { chatBackground.Hide(); } chatInactivityTimer.Stop(); }); chatInactivityTimer.SetInterval(6 * TimeSpan.TicksPerSecond); }
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); }
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(); } } }
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(); } }
public static void StartHorde(HordeDef def) { if (def == null) { return; } Log.Logger.Log("horde init"); ArenaClient.ForEach(c => { var client = (ArenaClient)c; client.HordeScore = 0; client.HordeDeaths = 0; client.HordeKills = 0; client.HordeClass = null; }); players.ForEach(c => c.Spectate()); players.Clear(); if (activeWorld != null) { activeWorld.BaseWorld.ForEachVob(v => v.Despawn()); } var stream = ArenaClient.GetScriptMessageStream(); stream.Write((byte)ScriptMessages.HordeStart); stream.Write(def.Name); ArenaClient.ForEach(c => c.SendScriptMessage(stream, NetPriority.Low, NetReliability.ReliableOrdered)); activeDef = def; activeWorld = WorldInst.List.Find(w => w.Path == def.WorldPath); spawnBarriers.Clear(); foreach (var bar in activeDef.SpawnBarriers) { if (!bar.AddAfterEvent) { spawnBarriers.Add(CreateBarrier(bar)); } } ActiveStands.Clear(); for (int i = 0; i < activeDef.Stands.Length; i++) { var stand = activeDef.Stands[i]; StandInst inst = new StandInst() { Index = i, Stand = stand, }; if (stand.Boss != null) { inst.Boss = SpawnEnemy(stand.Boss, stand.Position); inst.Boss.CanGetHit += BossProtection; } inst.Barriers = new List <VobInst>(stand.Barriers.Length); foreach (var bar in stand.Barriers) { if (!bar.AddAfterEvent) { inst.Barriers.Add(CreateBarrier(bar)); } } ActiveStands.Add(inst); } foreach (var hi in activeDef.Items) { ItemInst item = new ItemInst(ItemDef.Get(hi.ItemDef)); item.Spawn(activeWorld, hi.Position, hi.Angles); } standEnemyCount = 0; ActiveStandInst = null; gameTimer.SetInterval(30 * TimeSpan.TicksPerSecond); gameTimer.SetCallback(Start); gameTimer.Stop(); SetPhase(HordePhase.WarmUp); }