public void SetAnimationDirection(AnimatorUtils.animationDirection direction)
 {
     if (characterAnimation != null && !dying)
     {
         //bool changeDirection = changeDirection(direction);
         if (direction == AnimatorUtils.animationDirection.left)
         {
             characterAnimation.On_Front_Back(true);
             characterAnimation.On_Left_Right(true);
         }
         else if (direction == AnimatorUtils.animationDirection.right)
         {
             characterAnimation.On_Front_Back(false);
             characterAnimation.On_Left_Right(false);
         }
         else if (direction == AnimatorUtils.animationDirection.up)
         {
             characterAnimation.On_Front_Back(false);
             characterAnimation.On_Left_Right(true);
         }
         else if (direction == AnimatorUtils.animationDirection.down)
         {
             characterAnimation.On_Front_Back(true);
             characterAnimation.On_Left_Right(false);
         }
         lastDirection = direction;
     }
 }
        public void ExecutePush(Tile tile, AnimatorUtils.animationDirection direction)
        {
            interupted  = false;
            pushing     = true;
            pathCounter = 0;

            SetAnimationDirection(direction);
            SetAnimation(AnimatorUtils.animationType.damage);

            path.Add(tile);
            tileManager.MoveBoardEntity(tile.Position, this, false);
            ChangeTarget();
        }
        public bool ChangeDirection(AnimatorUtils.animationDirection direction)
        {
            HashSet <AnimatorUtils.animationDirection> noRotate = new HashSet <AnimatorUtils.animationDirection>
            {
                AnimatorUtils.animationDirection.right, AnimatorUtils.animationDirection.down
            };

            if (lastDirection == direction)
            {
                return(true);
            }
            if (lastDirection != null)
            {
                if (noRotate.Contains((AnimatorUtils.animationDirection)lastDirection) && noRotate.Contains(direction))
                {
                    return(true);
                }
            }

            return(false);
        }
        private void ChangeTarget()
        {
            // we gotta check to see if we just walked into a taunt, we will have to do this for stun as well

            /*if (GetTauntTiles().Count != 0)
             * {
             *  HashSet<Tile> tauntTiles = GetTauntTiles();
             *  for(int a = 0; a < path.Count; a++)
             *  {
             *      if (tauntTiles.Contains(path[a]))
             *      {
             *          path.RemoveRange(a, path.Count - a);
             *          interupted = true;
             *      }
             *  }
             * }
             */

            if (path.Count > 0)
            {
                AnimatorUtils.animationDirection dir = AnimatorUtils.GetAttackDirectionCode(GetTile().Position, path[0].Position);
                if (!pushing)
                {
                    SetAnimationDirection(dir);
                }
                target = path[0];
                path.RemoveAt(0);
                pathCounter++;
                if (charging)
                {
                    Position targetTile = position + direction;
                    Tile     t          = tileManager.GetTile(targetTile);
                    if (t != null && t.BoardEntity != null && t.BoardEntity.Team != Team)
                    {
                        chargeCounter++;
                        Tile newTile = tileManager.GetTile(targetTile + direction);
                        AnimatorUtils.animationDirection pushDir = AnimatorUtils.GetAttackDirectionCode(newTile.Position, position);
                        ((CharacterBoardEntity)t.BoardEntity).ExecutePush(newTile, pushDir);
                    }
                }
            }
            else
            {
                bool display = team == Team.Player;
                if (!charging)
                {
                    stats.SubtractMovementPoints(pathCounter, display);
                }
                if (interuptClearMovement)
                {
                    stats.SetMutableStat(AttributeStats.StatType.Movement, 0);
                    stats.SetMutableStat(AttributeStats.StatType.AP, 0);
                    interuptClearMovement = false;
                }
                // all done moving
                target                  = null;
                PathOnClick.pause       = false;
                OutlineOnHover.disabled = false;
                if (characterAnimation != null)
                {
                    SetAnimation(AnimatorUtils.animationType.idle);
                }
                if (moveDoneCallback != null)
                {
                    Action <bool> tempMoveDoneCallback = moveDoneCallback;
                    moveDoneCallback = null;
                    tempMoveDoneCallback(interupted);
                }

                if (charging)
                {
                    Position targetTile = position + direction;
                    Tile     t          = tileManager.GetTile(targetTile);
                    if (t != null && t.BoardEntity != null && t.BoardEntity.Team != Team)
                    {
                        chargeCallback(chargeCounter, Core.Instance.convert(t.BoardEntity));
                    }
                    else
                    {
                        chargeCallback(chargeCounter, null);
                    }
                    charging = false;
                }
            }
        }