public void TestManaReserveUsage() { AttackContext.Owner = CreateDummyRobot(); MagicUser ActiveUser = new MagicUser(); MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams Params = new MagicUserParams(ActiveSpell.GlobalContext); ActiveUser.ManaReserves = 1000; ActiveUser.CurrentMana = 100; InvisibleMagicCoreFireball FireballCore1 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore1.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); ActiveSpell.ListMagicCore.Add(FireballCore1); ActiveSpell = new MagicSpell(ActiveSpell, ActiveUser); BaseAutomaticSkill NewSkill = ActiveSpell.ComputeSpell()[0]; for (int i = 0; i < 10; i++) { NewSkill.AddSkillEffectsToTarget(string.Empty); } Assert.AreEqual(0, ActiveUser.ChanneledMana); Assert.AreEqual(990, ActiveUser.ManaReserves); Assert.AreEqual(100, ActiveUser.CurrentMana); }
public void TestFireballChannelingActivation() { AttackContext.Owner = CreateDummyRobot(); MagicUser ActiveUser = new MagicUser(); MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams Params = new MagicUserParams(ActiveSpell.GlobalContext); ActiveUser.ManaReserves = 1000; ActiveUser.CurrentMana = 100; InvisibleMagicCoreFireball FireballCore1 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore1.ListLinkedMagicElement.Add(new ChannelExternalManaSource(Params)); ActiveSpell.ListMagicCore.Add(FireballCore1); ActiveSpell = new MagicSpell(ActiveSpell, ActiveUser); BaseAutomaticSkill NewSkill = ActiveSpell.ComputeSpell()[0]; CreateFireballEffectTripleThunder Fireball = (CreateFireballEffectTripleThunder)NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0]; for (int i = 0; i < 9; i++) { NewSkill.AddSkillEffectsToTarget(string.Empty); Assert.AreEqual(i + 1, Fireball.ChanneledMana); } NewSkill.AddSkillEffectsToTarget(string.Empty); Assert.AreEqual(1, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0]).NumberOfExecutions); Assert.AreEqual(0, ActiveUser.ChanneledMana); Assert.AreEqual(100, ActiveUser.CurrentMana); }
public void TestExplodingFireballPositionWithOffset() { AttackContext.Owner = CreateDummyRobot(); MagicUser ActiveUser = new MagicUser(); MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams Params = new MagicUserParams(ActiveSpell.GlobalContext); ActiveUser.ManaReserves = 1000; ActiveUser.CurrentMana = 100; InvisibleMagicCoreFireball FireballCore1 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore1.ListLinkedMagicElement.Add(new ChannelExternalManaSource(Params)); FireballCore1.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); InvisibleMagicCoreFireball FireballCore2 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore2.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); FireballCore2.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); FireballCore2.ListLinkedMagicElement.Add(new MagicCoreOffset(Params, AttackParams, -15, 0)); InvisibleMagicCoreFireball FireballCore3 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore3.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); FireballCore3.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); FireballCore3.ListLinkedMagicElement.Add(new MagicCoreOffset(Params, AttackParams, 55, 0)); FireballCore1.ListLinkedMagicElement.Add(FireballCore2); FireballCore1.ListLinkedMagicElement.Add(FireballCore3); ActiveSpell.ListMagicCore.Add(FireballCore1); ActiveSpell = new MagicSpell(ActiveSpell, ActiveUser); BaseAutomaticSkill NewSkill = ActiveSpell.ComputeSpell()[0]; CreateFireballEffectTripleThunder Fireball1 = (CreateFireballEffectTripleThunder)NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0]; Fireball1.ChanneledMana = 2000; NewSkill.AddSkillEffectsToTarget(string.Empty); Constants.TotalGameTime = 10; NewSkill.AddSkillEffectsToTarget(string.Empty); DummyMap.ListLayer[0].ListAttackCollisionBox[0].ListCollisionPolygon[0].Center = new Vector2(10, 10); //Channel enough Mana for 2 fireballs for (int i = 0; i < 50; i++) { DummyMap.ListLayer[0].ListAttackCollisionBox[0].Update(new GameTime(new TimeSpan(), new TimeSpan(0, 0, 0, 0, 16))); } Constants.TotalGameTime = 20; DummyMap.ListLayer[0].ListAttackCollisionBox[0].Update(new GameTime(new TimeSpan(), new TimeSpan(0, 0, 0, 50, 0))); Assert.AreEqual(0, DummyMap.ListLayer[0].ListAttackCollisionBox[0].ListCollisionPolygon[0].Center.X); Assert.AreEqual(70, DummyMap.ListLayer[0].ListAttackCollisionBox[1].ListCollisionPolygon[0].Center.X); }
private Attack GetAnimationStartSandbox(MagicSpell ActiveSpell, Vector2 AnimationOrigin, out List <Projectile> ListOutputProjectile) { MagicProjectileSandboxStartAnimation AnimationStartSandbox = new MagicProjectileSandboxStartAnimation(); GlobalContext.OwnerSandbox = AnimationStartSandbox; SharedParams.OwnerPosition = AnimationOrigin; SharedParams.OwnerAngle = 0; List <BaseAutomaticSkill> ListAttackAttribute = ActiveSpell.ComputeSpell(); Attack SpellAttack = new Attack("Dummy Attack"); SpellAttack.ArrayAttackAttributes = ListAttackAttribute.ToArray(); ListOutputProjectile = AnimationStartSandbox.SimulateAttack(SpellAttack); foreach (Projectile ActiveProjectile in ListOutputProjectile) { float MinX = float.MaxValue; float MinY = float.MaxValue; float MaxX = float.MinValue; float MaxY = float.MinValue; for (int P = ActiveProjectile.Collision.ListCollisionPolygon.Count - 1; P >= 0; --P) { for (int V = ActiveProjectile.Collision.ListCollisionPolygon[P].ArrayVertex.Length - 1; V >= 0; --V) { if (ActiveProjectile.Collision.ListCollisionPolygon[P].ArrayVertex[V].X < MinX) { MinX = ActiveProjectile.Collision.ListCollisionPolygon[P].ArrayVertex[V].X; } if (ActiveProjectile.Collision.ListCollisionPolygon[P].ArrayVertex[V].X > MaxX) { MaxX = ActiveProjectile.Collision.ListCollisionPolygon[P].ArrayVertex[V].X; } if (ActiveProjectile.Collision.ListCollisionPolygon[P].ArrayVertex[V].Y < MinY) { MinY = ActiveProjectile.Collision.ListCollisionPolygon[P].ArrayVertex[V].Y; } if (ActiveProjectile.Collision.ListCollisionPolygon[P].ArrayVertex[V].Y > MaxY) { MaxY = ActiveProjectile.Collision.ListCollisionPolygon[P].ArrayVertex[V].Y; } } } //Offset almost completely outside screen ActiveProjectile.Offset(new Vector2(Constants.Width + MaxX - 1, 0)); ActiveProjectile.IsAlive = true; } return(SpellAttack); }
public void TestMagicSanbox() { List <MagicSpell> ListMagicSpell = new List <MagicSpell>(); UnitMagic ActiveUser = new UnitMagic("Dummy Magic", ListMagicSpell); Character DummyCharacter = new Character(); DummyCharacter.Name = "Dummy Pilot"; DummyCharacter.Level = 1; DummyCharacter.ArrayLevelMEL = new int[1] { 100 }; DummyCharacter.ArrayLevelRNG = new int[1] { 100 }; DummyCharacter.ArrayLevelDEF = new int[1] { 100 }; DummyCharacter.ArrayLevelSKL = new int[1] { 100 }; DummyCharacter.ArrayLevelEVA = new int[1] { 100 }; DummyCharacter.ArrayLevelHIT = new int[1] { 200 }; DummyCharacter.ArrayLevelMaxSP = new int[1] { 50 }; ActiveUser.ArrayCharacterActive = new Character[1] { DummyCharacter }; ActiveUser.ChanneledMana = 1000; MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams MagicParams = new MagicUserParams(ActiveSpell.GlobalContext); ProjectileContext GlobalContext = new ProjectileContext(); ProjectileParams MagicProjectileParams = new ProjectileParams(GlobalContext); GlobalContext.OwnerSandbox = Sandbox; MagicSpell FireballSpell = new MagicSpell(ActiveUser); ListMagicSpell.Add(FireballSpell); MagicCoreFireball FireballCore1 = new MagicCoreFireball(MagicParams, MagicProjectileParams); FireballSpell.ListMagicCore.Add(FireballCore1); ActiveUser.Init(); FireballSpell.ComputeSpell()[0].AddSkillEffectsToTarget(""); Assert.AreEqual(1, Sandbox.ListProjectile.Count); }
public void TestExplodingFireballActivation() { AttackContext.Owner = CreateDummyRobot(); MagicUser ActiveUser = new MagicUser(); MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams Params = new MagicUserParams(ActiveSpell.GlobalContext); ActiveUser.ManaReserves = 1000; ActiveUser.CurrentMana = 100; InvisibleMagicCoreFireball FireballCore1 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore1.ListLinkedMagicElement.Add(new ChannelExternalManaSource(Params)); FireballCore1.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); InvisibleMagicCoreFireball FireballCore2 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore2.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); FireballCore2.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); InvisibleMagicCoreFireball FireballCore3 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore3.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); FireballCore3.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); FireballCore1.ListLinkedMagicElement.Add(FireballCore2); FireballCore1.ListLinkedMagicElement.Add(FireballCore3); ActiveSpell.ListMagicCore.Add(FireballCore1); ActiveSpell = new MagicSpell(ActiveSpell, ActiveUser); BaseAutomaticSkill NewSkill = ActiveSpell.ComputeSpell()[0]; CreateFireballEffectTripleThunder FireballEffect = (CreateFireballEffectTripleThunder)NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0]; FireballEffect.ChanneledMana = 2000; NewSkill.AddSkillEffectsToTarget(string.Empty); Assert.AreEqual(0, DummyMap.ListLayer[0].ListAttackCollisionBox.Count); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0]).NumberOfExecutions); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0].ListLinkedMagicElement[2]).NumberOfExecutions); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0].ListLinkedMagicElement[3]).NumberOfExecutions); Constants.TotalGameTime = 10; NewSkill.AddSkillEffectsToTarget(string.Empty); Assert.AreEqual(1, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0]).NumberOfExecutions); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0].ListLinkedMagicElement[2]).NumberOfExecutions); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0].ListLinkedMagicElement[3]).NumberOfExecutions); Assert.AreEqual(1, DummyMap.ListLayer[0].ListAttackCollisionBox.Count); Assert.AreEqual(2, DummyMap.ListLayer[0].ListAttackCollisionBox[0].ListActiveSkill.Count); InvisibleFireball Fireball1 = (InvisibleFireball)DummyMap.ListLayer[0].ListAttackCollisionBox[0]; IMagicUser FireballParent = Fireball1.Parent; //Channel enough Mana for 2 fireballs for (int i = 0; i < 50; i++) { DummyMap.ListLayer[0].ListAttackCollisionBox[0].Update(new GameTime(new TimeSpan(), new TimeSpan(0, 0, 0, 0, 16))); Assert.AreEqual(2000 - i * 2, FireballParent.CurrentMana); } Constants.TotalGameTime = 20; Assert.AreEqual(true, DummyMap.ListLayer[0].ListAttackCollisionBox.Contains(Fireball1)); DummyMap.ListLayer[0].ListAttackCollisionBox[0].Update(new GameTime(new TimeSpan(), new TimeSpan(0, 0, 0, 50, 0))); Assert.AreEqual(false, DummyMap.ListLayer[0].ListAttackCollisionBox.Contains(Fireball1)); Assert.AreEqual(2, DummyMap.ListLayer[0].ListAttackCollisionBox.Count); }