private void UpdateGame() { //Deal with gesture starting and stopping and hand grabbing if (grabAction.GetAxis(SteamVR_Input_Sources.LeftHand) >= 0.1f) { if (!leftHand.GetGrabbing()) { leftHand.ToggleGrabbing(); gestureManager.BeginGesture(this, true, true); } } else { if (leftHand.GetGrabbing()) { leftHand.ToggleGrabbing(); spellHandler.CastSpell(gestureManager.EndGesture(), gestureManager.CurrentHand()); } } if (grabAction.GetAxis(SteamVR_Input_Sources.RightHand) >= 0.1f) { if (!rightHand.GetGrabbing()) { rightHand.ToggleGrabbing(); gestureManager.BeginGesture(this, false, true); } } else { if (rightHand.GetGrabbing()) { rightHand.ToggleGrabbing(); spellHandler.CastSpell(gestureManager.EndGesture(), gestureManager.CurrentHand()); } } gestureManager.Update(this, Time.deltaTime, true); //Deal with player movement CalcMovement(); //Remove the shield material if the shield is gone if (healthComp.ShieldBroke()) { leftHand.GetComponentInChildren <SkinnedMeshRenderer>().material = baseMaterial; rightHand.GetComponentInChildren <SkinnedMeshRenderer>().material = baseMaterial; } leftHand.SetGems(healthComp.GetHealth() / (float)startingHP); rightHand.SetGems(healthComp.GetHealth() / (float)startingHP); }
public void CastSpell_FocusSpellCastAndTicksOnce_AllEventsRemoved() { var caster = NewFakePlayer(); var target = NewFakePlayer(); var spell = NewFakeSpell(); spell.fakeIsFocus = true; spell.fakeTarget = "Realm"; spell.Duration = 20; spell.fakeFrequency = 20; spell.fakeSpellType = "DamageShield"; spell.fakePulse = 1; var spellHandler = new SpellHandler(caster, spell, NewSpellLine()); var gameEventMgrSpy = GameEventMgrSpy.LoadAndReturn(); Assert.IsTrue(spellHandler.CastSpell(target)); target.fakeRegion.fakeElapsedTime = 2; spellHandler.StartSpell(target); //tick caster.OnPlayerMove(); var eventNumberOnCaster = gameEventMgrSpy.GameObjectEventCollection[caster].Count; var eventNumberOnTarget = gameEventMgrSpy.GameObjectEventCollection[target].Count; Assert.AreEqual(0, eventNumberOnCaster, "Caster has not the right amount of event subscriptions"); Assert.AreEqual(0, eventNumberOnTarget, "Target has not the right amount of event subscriptions"); }
public void CastSpell_OnNPCTarget_True() { var caster = NewFakePlayer(); var target = NewFakeNPC(); var spell = NewFakeSpell(); var spellHandler = new SpellHandler(caster, spell, null); bool isCastSpellSuccessful = spellHandler.CastSpell(target); Assert.IsTrue(isCastSpellSuccessful); }
public async Task RoaCommand(CommandContext context) { if (context.Channel.Name == "bot-commands") { SpellHandler sob = (SpellHandler)ModuleHandler.modules["runes of arcane"]; string user = context.Member.Nickname == null ? context.Member.Username : context.Member.Nickname; int cutoff = context.Message.Content.IndexOf(' ') + 1; string target = cutoff == 0 ? user : context.Message.Content.Substring(cutoff); await context.RespondAsync(sob.CastSpell(user, target)); } }
public void CastSpell_OnNPCTarget_CastStartingEventFired() { var caster = NewFakePlayer(); var target = NewFakeNPC(); var spell = NewFakeSpell(); var spellHandler = new SpellHandler(caster, spell, null); spellHandler.CastSpell(target); var actual = caster.lastNotifiedEvent; var expected = GameLivingEvent.CastStarting; Assert.AreEqual(expected, actual); Assert.AreEqual((caster.lastNotifiedEventArgs as CastingEventArgs).SpellHandler, spellHandler); }
public void CastSpell_FocusSpell_FiveEventsOnCasterAndOneEventOnTarget() { var caster = NewFakePlayer(); var target = NewFakePlayer(); var spell = NewFakeSpell(); spell.fakeIsFocus = true; spell.fakeTarget = "Realm"; spell.Duration = 20; var spellHandler = new SpellHandler(caster, spell, NewSpellLine()); var gameEventMgrSpy = GameEventMgrSpy.LoadAndReturn(); UtilChanceIsHundredPercent.Enable(); spellHandler.CastSpell(target); var eventNumberOnCaster = gameEventMgrSpy.GameObjectEventCollection[caster].Count; var eventNumberOnTarget = gameEventMgrSpy.GameObjectEventCollection[target].Count; Assert.AreEqual(5, eventNumberOnCaster, "Caster has not the right amount of event subscriptions"); Assert.AreEqual(1, eventNumberOnTarget, "Target has not the right amount of event subscriptions"); }
public void CastSpell_FocusSpellAndCasterMoves_AllEventsRemoved() { var caster = NewFakePlayer(); var target = NewFakeNPC(); var spell = NewFakeSpell(); spell.fakeIsFocus = true; spell.fakeTarget = "realm"; spell.Duration = 20; var spellHandler = new SpellHandler(caster, spell, NewSpellLine()); var gameEventMgrSpy = GameEventMgrSpy.LoadAndReturn(); FakeServer.LoadAndReturn().FakeServerRules.fakeIsAllowedToAttack = false; UtilChanceIsHundredPercent.Enable(); spellHandler.CastSpell(target); caster.OnPlayerMove(); var eventNumberOnCaster = gameEventMgrSpy.GameObjectEventCollection[caster].Count; var eventNumberOnTarget = gameEventMgrSpy.GameObjectEventCollection[target].Count; Assert.AreEqual(0, eventNumberOnCaster, "Caster has not the right amount of event subscriptions"); Assert.AreEqual(0, eventNumberOnTarget, "Target has not the right amount of event subscriptions"); }
/// <summary> /// Action /// </summary> /// <param name="living"></param> public override void Execute(GameLiving living) { if (CheckPreconditions(living, DEAD | SITTING | MEZZED | STUNNED)) { return; } GamePlayer player = living as GamePlayer; if (player != null) { /*BlissfulIgnoranceEffect BlissfulIgnorance = (BlissfulIgnoranceEffect)player.EffectList.GetOfType(typeof(BlissfulIgnoranceEffect)); * if (BlissfulIgnorance != null) * BlissfulIgnorance.Cancel(false); * * new BlissfulIgnoranceEffect().Start(player);*/ Hashtable table_spells = new Hashtable(); foreach (Spell spell in SkillBase.GetSpellList("Savagery")) { if (spell.Group == 0 || spell.Target.ToLower() != "self") { continue; } if (spell.Level <= player.GetSpellLine("Savagery").Level) { if (!table_spells.ContainsKey(spell.Group)) { table_spells.Add(spell.Group, spell); } else { Spell oldspell = (Spell)table_spells[spell.Group]; if (spell.Level > oldspell.Level) { table_spells[spell.Group] = spell; } } } } foreach (object obj in table_spells.Values) { if (obj == null || !(obj is Spell)) { continue; } Spell spell = obj as Spell; try { DBSpell db = new DBSpell(); db.ClientEffect = spell.ClientEffect; db.Icon = spell.Icon; db.Name = spell.Name; db.Description = spell.Description; db.Duration = spell.Duration / 1000; db.Power = 0; db.Value = spell.Value; db.Message1 = ""; db.Message2 = ""; db.Message3 = ""; db.Message4 = ""; db.Type = spell.SpellType; db.Target = "Self"; db.MoveCast = true; db.Uninterruptible = true; SpellHandler handler = new SpellHandler(player, new Spell(db, 0), SkillBase.GetSpellLine("Savagery")); if (handler != null) { handler.CastSpell(); } } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("RR5 Savage : use spell, ", e); } } } } DisableSkill(living); }
/// <summary> /// Action /// </summary> /// <param name="living"></param> public override void Execute(GameLiving living) { if (CheckPreconditions(living, DEAD | SITTING | MEZZED | STUNNED)) { return; } if (living is GamePlayer player) { Hashtable tableSpells = new Hashtable(); foreach (Spell spell in SkillBase.GetSpellList("Savagery")) { if (spell.Group == 0 || spell.Target.ToLower() != "self") { continue; } if (spell.Level <= player.GetSpellLine("Savagery").Level) { if (!tableSpells.ContainsKey(spell.Group)) { tableSpells.Add(spell.Group, spell); } else { Spell oldspell = (Spell)tableSpells[spell.Group]; if (spell.Level > oldspell.Level) { tableSpells[spell.Group] = spell; } } } } foreach (object obj in tableSpells.Values) { if (!(obj is Spell spell)) { continue; } try { DBSpell db = new DBSpell { ClientEffect = spell.ClientEffect, Icon = spell.Icon, Name = spell.Name, Description = spell.Description, Duration = spell.Duration / 1000, Power = 0, Value = spell.Value, Message1 = string.Empty, Message2 = string.Empty, Message3 = string.Empty, Message4 = string.Empty, Type = spell.SpellType, Target = "Self", MoveCast = true, Uninterruptible = true }; SpellHandler handler = new SpellHandler(player, new Spell(db, 0), SkillBase.GetSpellLine("Savagery")); handler.CastSpell(); } catch (Exception e) { if (Log.IsErrorEnabled) { Log.Error("RR5 Savage : use spell, ", e); } } } } DisableSkill(living); }