Beispiel #1
0
 public JellyfishAttack(Enemy parent, AttackValueRadius tentacle, LayerMask targetLayer) : base(parent)
 {
     this.tentacle       = new AttackSet(tentacle, new CircleAreaAttack(tentacle.CD, tentacle.DetectRadius, targetLayer));
     this.tentacle.value = tentacle;
     this.targetLayer    = targetLayer;
     jf = (Jellyfish)Parent;
     jf.OnTentacleAnimFined += TentacleAnimationFin;
 }
 public CannibalFlowerAttack(Enemy parent, AttackValueRadius needle, AttackValueRadius bite, LayerMask targetLayer, List <Collider2D> needles) : base(parent)
 {
     this.targetLayer = targetLayer;
     this.needles.AddRange(needles);
     attacks.Add(this.needle = new AttackSet(needle, new CircleAreaAttack(needle.CD, needle.DetectRadius, targetLayer, this.NeedleAttacking)));
     attacks.Add(this.bite   = new AttackSet(bite, new CircleAreaAttack(bite.CD, bite.DetectRadius, targetLayer)));
     cf = (CannibalFlower)Parent;
     cf.OnAnimationFinished += this.AnimFinished;
     GalaxySeeker.Physics2D.OverlapCircle(Parent.tf.position, Mathf.Infinity, targetLayer, ref target);
 }
 void AnimFinished(AnimationClip anim)
 {
     if (currentAttack == bite)
     {
         (currentAttack.action as CircleAreaAttack).CauseDamage(currentAttack.value.Damage);
     }
     if (anim.name == currentAttack.value.Clip.name)
     {
         currentAttack.action.AttackFinished( );
         cf.Anim.Play(cf.Anim.clip.name);
         currentAttack = null;
     }
 }
Beispiel #4
0
 //callback method for OnAnimationFinished
 //take different action due to animation end
 void AnimFinished(AnimationClip anim)
 {
     if (anim.name == bite.value.Clip.name)
     {
         target.TakeDamage(this.bite.value.Damage);
     }
     if (anim == currentAttack.value.Clip)
     {
         currentAttack.action.AttackFinished( );
     }
     else
     {
         return;
     }
     kcf.Anim.Play(kcf.Anim.clip.name);
     currentAttack = null;
 }
Beispiel #5
0
 //detect if targetLayer get collide with vines
 //if true cause damage to target due to attack damage
 void DetectTargetCollide(AttackSet attack, LayerMask targetLayer, List <Collider2D> colliders)
 {
     //get all collider which collide with vine in all vines
     foreach (Collider2D col in colliders)
     {
         List <Collider2D> cols   = new List <Collider2D> ( );
         ContactFilter2D   filter = new ContactFilter2D( );
         filter.SetLayerMask(targetLayer);
         col.OverlapCollider(filter, cols);
         foreach (Collider2D co in cols)
         {
             if (target)
             {
                 target.TakeDamage(attack.value.Damage);
             }
         }
     }
 }
Beispiel #6
0
        public void RollAttackSet(AttackSet atkSet, Character ch)
        {
            AttackSetResult res = new AttackSetResult();

            res.Character = ch;

            foreach (Attack at in atkSet.WeaponAttacks)
            {
                AttackRollResult ares = new AttackRollResult(at);
                res.Results.Add(ares);
            }
            foreach (Attack at in atkSet.NaturalAttacks)
            {
                AttackRollResult ares = new AttackRollResult(at);
                res.Results.Add(ares);
            }


            _Results.Insert(0, res);

            TrimList();

            RenderResults();
        }
Beispiel #7
0
 protected override void Start()
 {
     base.Start();
     gainStatSet = gameObject.AddComponent <GainStatSet>();
     attackSet   = gameObject.AddComponent <AttackSet>();
 }
Beispiel #8
0
 protected override void FixedTick( )
 {
     if (target)
     {
         bFacingRight = GalaxySeeker.Physics2D.IsRight(Parent.tf.position, targetTransform.position);
     }
     //Change render direction
     if (currentAttack == null)
     {
         Render.ChangeDirectionY(bFacingRight, Parent.tf, true);
     }
     //Update all attacks' state
     foreach (AttackSet attack in attacks)
     {
         attack.action.UpdateState(Parent.tf.position);
     }
     //if not attacking try to find an attack
     if (currentAttack == null)
     {
         //Choose use special attack or normal attack
         bool bUseSpecial = Eccentric.Math.ChosenDueToProbability(specialProbability, normalProbability);
         //Special attack
         if (bUseSpecial)
         {
             //add all the attack already to list
             List <AttackSet> actionToUse = new List <AttackSet> ( );
             foreach (AttackSet attack in specialAttacks)
             {
                 if (attack.action.IsCanAttack)
                 {
                     actionToUse.Add(attack);
                 }
             }
             // if there is only one set current attack to it
             // or choose it  with random with same probability
             if (actionToUse.Count == 1)
             {
                 currentAttack = actionToUse [0];
             }
             else if (actionToUse.Count == 0)
             {
                 return;
             }
             else
             {
                 currentAttack = actionToUse [Eccentric.Math.RandomNum(actionToUse.Count)];
             }
         }
         //Normal attack
         else
         {
             //NOTFIN
             if (bite.action.IsCanAttack)
             {
                 currentAttack = bite;
             }
             else
             {
                 List <AttackSet> actionAbleUse = new List <AttackSet> ( );
                 if (vine.action.IsCanAttack)
                 {
                     actionAbleUse.Add(vine);
                 }
                 if (needle.action.IsCanAttack)
                 {
                     actionAbleUse.Add(needle);
                 }
                 if (actionAbleUse.Count == 1)
                 {
                     currentAttack = actionAbleUse [0];
                 }
                 else if (actionAbleUse.Count == 0)
                 {
                     return;
                 }
                 else
                 {
                     currentAttack = actionAbleUse [Eccentric.Math.RandomNum(actionAbleUse.Count)];
                 }
             }
             if (currentAttack == null)
             {
                 return;
             }
         }
         //if attack is ready attack and play the attack animation
         if (currentAttack.action.IsCanAttack)
         {
             currentAttack.action.Attack( );
             kcf.Anim.Play(currentAttack.value.Clip.name);
         }
         else
         {
             currentAttack = null;
         }
     }
 }
Beispiel #9
0
 protected override void Start()
 {
     base.Start();
     heal      = gameObject.AddComponent <HealAreaEveryXSec>();
     attackSet = gameObject.AddComponent <AttackSet>();
 }