Esempio n. 1
0
        public Attack pickAttackForTarget(SoulAvenger.Character target)
        {
            //if the character doesn't have any attack in its queue. just return null
            if (attacks == null || attacks.Count <= 0)
            {
                return(null);
            }

            //get the attack with the highest DPA
            int MaxDPA = 0;

            Attack retAttack = null;

            foreach (Attack atk in attacks)
            {
                int DPA = atk.getDPA();

                if (!atk.canUseAttack())
                {
                    continue;
                }

                //if the new attack has a greater DPA or its equal and we may want(Randon.Range) use it
                if (DPA > MaxDPA || ((DPA == MaxDPA) && (Random.Range(0, 1) == 1)))
                {
                    MaxDPA    = DPA;
                    retAttack = atk;
                }
            }

            return(retAttack);
        }
Esempio n. 2
0
        //true if the character moves, false if is colliding so it has already reach the target
        public bool moveToTarget(SoulAvenger.Character target, float movementSpeed, bool keepInArena)
        {
            Vector3 current3dPos = getFeet().position;
            Vector3 target3dPos  = target.getFeet().position;
            Vector3 diff         = target3dPos - current3dPos;

            diff.z = 0;

            if (feetsAreColliding(target))
            {
                SoulAvenger.Character.FACING currentF = (diff.x > 0)?SoulAvenger.Character.FACING.RIGHT:SoulAvenger.Character.FACING.LEFT;
                currentFacing = currentF;
                return(false);
            }

            tk2dAnimatedSprite sprite = GetComponent <tk2dAnimatedSprite>();

            movementSpeed *= sprite.localTimeScale;
            Vector3 velocity = diff; velocity.Normalize(); velocity *= movementSpeed * Time.deltaTime;

            Vector3 newPos = current3dPos + velocity;

            tryToMove(newPos, keepInArena);
            return(true);
        }
Esempio n. 3
0
        public Vector3 getPosInTail(SoulAvenger.Character chara)
        {
            bool useLeft = leftCharacterTail.Contains(chara);

            List <SoulAvenger.Character> cTrail = useLeft?leftCharacterTail:rightCharacterTail;

            BoxCollider myFeetsCollider = getFeet().GetComponent <BoxCollider>();
            Vector3     pos             = myFeetsCollider.transform.localToWorldMatrix.MultiplyPoint(myFeetsCollider.center);

            pos.y = myFeetsCollider.transform.position.y;
            float xDimension = myFeetsCollider.size.x * 0.5f;

            for (int i = 0; i < cTrail.Count; i++)
            {
                SoulAvenger.Character c = cTrail[i];

                BoxCollider cFeetsCollider = c.getFeet().GetComponent <BoxCollider>();

                if (c != chara)
                {
                    xDimension += cFeetsCollider.size.x;
                }
                else
                {
                    xDimension += (cFeetsCollider.size.x * 0.5f + cFeetsCollider.center.x);
                    break;
                }
            }

            float sizeFactor = useLeft?-1.0f:1.0f;

            pos.x += xDimension * sizeFactor;

            return(pos);
        }
Esempio n. 4
0
        public bool feetsAreColliding(SoulAvenger.Character target)
        {
            BoxCollider myFeets     = this.getFeet().GetComponent <BoxCollider>();
            BoxCollider targetFeets = target.getFeet().GetComponent <BoxCollider>();

            return(SoulAvenger.CollisionDetection.Test2D(myFeets, targetFeets));
        }
Esempio n. 5
0
        public bool otherTailIsEmpty(SoulAvenger.Character chara)
        {
            List <SoulAvenger.Character> myTrail    = leftCharacterTail.Contains(chara)?leftCharacterTail:rightCharacterTail;
            List <SoulAvenger.Character> otherTrail = (myTrail == leftCharacterTail)?rightCharacterTail:leftCharacterTail;

            return(otherTrail.Count == 0);
        }
Esempio n. 6
0
        public void swapTail(SoulAvenger.Character chara)
        {
            List <SoulAvenger.Character> myTrail    = leftCharacterTail.Contains(chara)?leftCharacterTail:rightCharacterTail;
            List <SoulAvenger.Character> otherTrail = (myTrail == leftCharacterTail)?rightCharacterTail:leftCharacterTail;

            myTrail.Remove(chara);
            otherTrail.Add(chara);
        }
Esempio n. 7
0
 public int getMyTailIndex(SoulAvenger.Character chara)
 {
     if (leftCharacterTail.Contains(chara))
     {
         return(leftCharacterTail.IndexOf(chara));
     }
     else if (rightCharacterTail.Contains(chara))
     {
         return(rightCharacterTail.IndexOf(chara));
     }
     return(-1);
 }
Esempio n. 8
0
 public void moveToTailTip(SoulAvenger.Character chara)
 {
     if (leftCharacterTail.Contains(chara))
     {
         leftCharacterTail.Remove(chara);
         leftCharacterTail.Insert(0, chara);
     }
     else if (rightCharacterTail.Contains(chara))
     {
         rightCharacterTail.Remove(chara);
         rightCharacterTail.Insert(0, chara);
     }
 }
Esempio n. 9
0
        public Vector3 getMyTailAxis(SoulAvenger.Character chara)
        {
            if (leftCharacterTail.Contains(chara))
            {
                return(Vector3.left);
            }
            else if (rightCharacterTail.Contains(chara))
            {
                return(Vector3.right);
            }

            return(Vector3.zero);
        }
Esempio n. 10
0
        public bool isFirstInTail(SoulAvenger.Character chara)
        {
            if (leftCharacterTail != null && leftCharacterTail.Contains(chara) && leftCharacterTail[0] == chara)
            {
                return(true);
            }

            if (rightCharacterTail != null && rightCharacterTail.Contains(chara) && rightCharacterTail[0] == chara)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 11
0
 public virtual void CancelMovementIfNeeded()
 {
     if (currentTarget != null)
     {
         currentTarget = null;
         if (currentAttack != null)
         {
             currentAttack.currentState = Attack.AttackStates.IDLE;
         }
         tk2dAnimatedSprite sprite = getSprite();
         if (sprite.CurrentClip.name.ToLower() != "idle")
         {
             changeAnimation("idle");
         }
     }
 }
Esempio n. 12
0
        public void pushToTail(SoulAvenger.Character c)
        {
            Vector3 CharPos = c.getFeet().position;
            Vector3 myPos   = this.getFeet().position;

            Vector3 diff = CharPos - myPos;

            if (diff.x <= 0.0f)
            {
                leftCharacterTail.Add(c);

                while (leftCharacterTail.Contains(null))
                {
                    leftCharacterTail.Remove(null);
                }

                leftCharacterTail.Sort(
                    delegate(SoulAvenger.Character c1, SoulAvenger.Character c2)
                {
                    float d1 = Vector3.Distance(this.getFeet().transform.position, c1.getFeet().transform.position);
                    float d2 = Vector3.Distance(this.getFeet().transform.position, c2.getFeet().transform.position);
                    return((d1 < d2)?-1:1);
                }
                    );
            }
            else
            {
                rightCharacterTail.Add(c);

                while (leftCharacterTail.Contains(null))
                {
                    leftCharacterTail.Remove(null);
                }

                rightCharacterTail.Sort(
                    delegate(SoulAvenger.Character c1, SoulAvenger.Character c2)
                {
                    float d1 = Vector3.Distance(this.getFeet().transform.position, c1.getFeet().transform.position);
                    float d2 = Vector3.Distance(this.getFeet().transform.position, c2.getFeet().transform.position);
                    return((d1 < d2)?-1:1);
                }
                    );
            }
        }
Esempio n. 13
0
        public float getMyTailDistance(SoulAvenger.Character chara)
        {
            Vector3 pos = getPosInTail(chara);

            return(Vector3.Distance(pos, chara.transform.position));
        }
Esempio n. 14
0
 public bool moveToTarget(SoulAvenger.Character target, float movementSpeed)
 {
     return(moveToTarget(target, movementSpeed, true));
 }
Esempio n. 15
0
 public void deleteFromTail(SoulAvenger.Character c)
 {
     leftCharacterTail.Remove(c);
     rightCharacterTail.Remove(c);
 }
Esempio n. 16
0
 public bool isInTail(SoulAvenger.Character c)
 {
     return(leftCharacterTail.Contains(c) || rightCharacterTail.Contains(c));
 }
Esempio n. 17
0
 public virtual void onAttackFrom(SoulAvenger.Character c, Attack attack)
 {
 }