示例#1
0
        public MagicSpell(string Name, IMagicUser Owner, MagicUserContext GlobalContext, Dictionary <string, MagicElement> DicMagicElement)
        {
            this.Name = Name;

            ListMagicSpell                  = new List <BaseAutomaticSkill>();
            ListMagicCore                   = new List <MagicCore>();
            this.GlobalContext              = GlobalContext;
            this.GlobalContext.ActiveUser   = Owner;
            this.GlobalContext.ActiveTarget = Owner;

            FileStream   FS = new FileStream("Content/Spells/" + Name + ".pes", FileMode.Open, FileAccess.Read);
            BinaryReader BR = new BinaryReader(FS, Encoding.UTF8);

            int ListMagicCoreCount = BR.ReadInt32();

            for (int C = 0; C < ListMagicCoreCount; ++C)
            {
                string    NewMagicCoreName = BR.ReadString();
                MagicCore NewMagicCore     = (MagicCore)DicMagicElement[NewMagicCoreName].Copy();
                NewMagicCore.Load(BR, DicMagicElement);
                ListMagicCore.Add(NewMagicCore);
            }

            FS.Close();
            BR.Close();
        }
示例#2
0
        public Fireball(MagicUserParams MagicParams, ProjectileParams Params, IMagicUser Parent)
            : base(MagicParams, 500)
        {
            this.Params = Params;
            this.Parent = Parent;

            Damage = 5;
            Speed = new Vector2(-(float)Math.Cos(Params.SharedParams.OwnerAngle) * 6, (float)Math.Sin(Params.SharedParams.OwnerAngle) * 6);

            Rectangle CollisionBox = new Rectangle(0, 0, 50, 32);

            float MinX = Params.SharedParams.OwnerPosition.X - CollisionBox.Width / 2f;
            float MinY = Params.SharedParams.OwnerPosition.Y - CollisionBox.Height / 2f;
            float MaxX = MinX + CollisionBox.Width;
            float MaxY = MinY + CollisionBox.Height;

            Polygon NewPolygon = new Polygon();
            NewPolygon.ArrayVertex = new Vector2[4];
            NewPolygon.ArrayVertex[0] = new Vector2(MinX, MinY);
            NewPolygon.ArrayVertex[1] = new Vector2(MinX, MaxY);
            NewPolygon.ArrayVertex[2] = new Vector2(MaxX, MaxY);
            NewPolygon.ArrayVertex[3] = new Vector2(MaxX, MinY);

            NewPolygon.ComputePerpendicularAxis();
            NewPolygon.ComputerCenter();

            Collision.ListCollisionPolygon = new List<Polygon>(1) { NewPolygon };
            MagicParams.SetMagicUser(Parent);
        }
示例#3
0
    public override void Trigger(IMagicUser sender, int skillId)
    {
        var offset = ActionRpgKitController.Instance.SkillDatabase.GetMagicSkillById(skillId).CastingTime;

        StopCoroutine("EffectCountdown");
        StartCoroutine(EffectCountdown(offset));
    }
示例#4
0
 public MagicSpell(IMagicUser Owner, IMagicUser Target)
 {
     ListMagicSpell             = new List <BaseAutomaticSkill>();
     ListMagicCore              = new List <MagicCore>();
     GlobalContext              = new MagicUserContext();
     GlobalContext.ActiveUser   = Owner;
     GlobalContext.ActiveTarget = Target;
 }
示例#5
0
 public InvisibleFireball(float Damage, ExplosionOptions ExplosionAttributes, RobotAnimation Owner, Vector2 Position, float Angle,
                          MagicUserParams MagicParams, IMagicUser Parent)
     : base(Damage, ExplosionAttributes, Owner, Position, Angle)
 {
     this.MagicParams = MagicParams;
     this.Parent      = Parent;
     MagicParams.SetMagicUser(Parent);
 }
示例#6
0
 private void MagicSkillLearned(IMagicUser sender, int skillId)
 {
     if (skillId > -1)
     {
         BaseSkill skill = SkillDatabase.GetMagicSkillById(skillId);
         AddSkillPanel(skill);
     }
 }
示例#7
0
    public void MagicSkillLearned(IMagicUser sender, int skillId)
    {
        var skill    = ActionRpgKitController.Instance.SkillDatabase.GetMagicSkillById(skillId);
        var headline = string.Format("You learned a new Skill \"{0}\"", skill.Skill.Name);
        var content  = string.Format("{0}\n\nTo use the Skill, assign the necessary Items to the Slots on the right and trigger them in the right order.\nGo to the Character Menu to see the Item combination.", skill.Skill.Description);

        StoryViewer.Instance.PushMessage(new MessageStruct(headline, content, portrait: NewSkillSprite));
    }
示例#8
0
    public void TriggerMagicEffect(IMagicUser sender, int skillId)
    {
        if (magicEffects[skillId] != null)
        {
            magicEffects[skillId].Trigger(sender, skillId);
        }

        if (magicSounds[skillId] != null)
        {
            AudioControl.Instance.PlaySound(magicSounds[skillId]);
        }
    }
示例#9
0
    /// <summary>
    /// Run a countdown after a skill has been used.</summary>
    private IEnumerator MagicSkillCountdown(IMagicUser sender, int skillId)
    {
        float endTime = Character.MagicSkillEndTimes[Character.MagicSkills.IndexOf(skillId)];

        var skillData = ActionRpgKitController.Instance.SkillDatabase.GetMagicSkillById(skillId);

        Animator.SetFloat("MagicAnimation", skillData.AnimationIndex);
        Animator.SetTrigger("Magic");

        endTime = Time.time + skillData.CastingTime;

        while (Time.time < endTime)
        {
            yield return(null);
        }
        Character.UseMagicSkill(skillId);
    }
示例#10
0
        public MagicSpell(MagicSpell Other, IMagicUser Owner)
        {
            Name = Other.Name;

            ListMagicSpell             = new List <BaseAutomaticSkill>();
            ListMagicCore              = new List <MagicCore>();
            GlobalContext              = Other.GlobalContext;
            GlobalContext.ActiveUser   = Owner;
            GlobalContext.ActiveTarget = Owner;

            for (int C = 0; C < Other.ListMagicCore.Count; ++C)
            {
                MagicCore NewMagicCore = (MagicCore)Other.ListMagicCore[C].Copy();
                NewMagicCore.CopyElements(Other.ListMagicCore[C]);
                ListMagicCore.Add(NewMagicCore);
            }
        }
示例#11
0
        public override void Compute(MagicCoreAttributes Attributes, MagicUserContext GlobalContext)
        {
            IMagicUser OriginalUser   = GlobalContext.ActiveUser;
            IMagicUser OriginalTarget = GlobalContext.ActiveTarget;

            Attributes.TotalManaCost += RequiredMana;
            MagicEffect        SpellEffect = GetSpellEffect();
            BaseAutomaticSkill BaseSkill   = CreateSpell(SpellEffect, GlobalContext);

            GlobalContext.ActiveTarget = SpellEffect;

            //Linked magic cores are considered as following skills
            if (Attributes.CurrentSpell != null)
            {
                GlobalContext.ActiveUser = OriginalTarget;
                Attributes.CurrentSpell.ListFollowingSkill.Add(BaseSkill);
                BaseSkill.CurrentSkillLevel.ListActivation[1].ListRequirement.Add(new ManaChanneledRequirement(Attributes.TotalManaCost, MagicParams));
            }
            else
            {
                BaseSkill.CurrentSkillLevel.ListActivation[1].ListRequirement.Add(new ManaChanneledRequirement(Attributes.TotalManaCost, MagicParams));
                //Add a final effect that will empty the channeled mana on its own after every other effects are executed.
                BaseSkill.CurrentSkillLevel.ListActivation[1].ListEffect.Add(new EmptyChanneledManaEffect(MagicParams));
            }

            Attributes.CurrentSkill = BaseSkill;
            Attributes.CurrentSpell = SpellEffect;

            foreach (MagicElement ActiveListMagicElement in ListLinkedMagicElement)
            {
                ActiveListMagicElement.Compute(Attributes, GlobalContext);

                Attributes.CurrentSkill = BaseSkill;
                Attributes.CurrentSpell = SpellEffect;
            }

            BaseSkill.CurrentSkillLevel.ListActivation[1].ListEffectTargetReal.Add(new List <AutomaticSkillTargetType>()
            {
                new EffectActivationExecuteOnly()
            });

            GlobalContext.ActiveUser   = OriginalUser;
            GlobalContext.ActiveTarget = OriginalTarget;
        }
示例#12
0
 public virtual void MagicSkillTriggered(IMagicUser sender, int skillId)
 {
     StartCoroutine(MagicSkillCountdown(sender, skillId));
 }
示例#13
0
        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);
        }
 private void MagicSkillTriggered(IMagicUser sender, int skillId)
 {
     sender.UseMagicSkill(skillId);;
 }
示例#15
0
 public void MagicSkillTriggeredTest(IMagicUser sender, int skillId)
 {
     _magicSkillTriggered += 1;
 }
示例#16
0
 public void MagicSkillLearnedTest(IMagicUser sender, int skillId)
 {
     _magicSkillLearned += 1;
 }
示例#17
0
 public virtual void Trigger(IMagicUser sender, int skillId)
 {
 }
示例#18
0
 /// <summary>
 /// Start the Magic Regeneration when the Player has used Magic.</summary>
 /// <param name="attribute"></param>
 /// <param name="value"></param>
 public void MagicUsed(IMagicUser sender, int skillId)
 {
     StopCoroutine("RegenerateMagic");
     StartCoroutine(RegenerateMagic(Character.Stats.Magic.MaxValue));
 }
示例#19
0
 public void SetMagicTarget(IMagicUser ActiveUser)
 {
     GlobalContext.ActiveTarget = ActiveUser;
 }
示例#20
0
 public void SetMagicUser(IMagicUser ActiveUser)
 {
     GlobalContext.ActiveUser = ActiveUser;
 }