Beispiel #1
0
        public void ApplyEffectOnTarget_WhenAbilityIsUsedOnOpponent()
        {
            //Arrange
            var casterMock   = new Mock <IHero>();
            var opponentMock = new Mock <IHero>();
            var debuff       = new Debuff("Curse", 2, HeroClass.Cleric, EffectType.Debuff, 2, 10);

            debuff.Caster = casterMock.Object;
            var opponentAppliedEffects = new List <IEffect>();

            opponentMock.Setup(x => x.AppliedEffects).Returns(opponentAppliedEffects);
            casterMock.Setup(x => x.Opponent).Returns(opponentMock.Object);
            //Act
            debuff.Apply();
            //Assert
            Assert.AreEqual(debuff, opponentMock.Object.AppliedEffects.FirstOrDefault());
        }
Beispiel #2
0
    protected virtual void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "HitBox" && collision.transform == MyTarget)
        {
            Character c = collision.GetComponentInParent <Character>();
            speed = 0;
            c.TakeDamage(damage, Source);

            if (debuff != null)
            {
                Debuff clone = debuff.Clone();
                clone.Apply(c);
            }

            GetComponent <Animator>().SetTrigger("impact");
            myRigidBody.velocity = Vector2.zero;
            MyTarget             = null;
        }
    }