private void HighlightAOE(BattleEntity self, Action action, Position target, Direction dir)
 {
     foreach (Position aoe in action.AoeTiles(self, target, dir, arena))
     {
         var aoeObj = GameObject.Instantiate(Resources.Load("aoe")) as GameObject;
         aoeObj.transform.position = new Vector3(tilesize * aoe.X, -tilesize * aoe.Y, 0);
         highlightAOE.Add(aoeObj);
     }
 }
        public bool PlayAction(Position target, Action action, Direction dir)
        {
            var entity = turns[currentTurn];
            if (entity.HP > 0 && !entity.ComingBack)
            {
                bool inRange = action.Range.InRange(arena, entity, target);
                if (action.Range2 != null && action.Range2.InRange(arena, entity, target))
                {
                    inRange = true;
                }

                if (inRange)
                {
                    if (action.ActionCost != null)
                    {
                        action.ActionCost.ApplyCost(entity, target);
                    }

                    foreach (GroundEffect effect in action.GroundEffects)
                    {
                        effect.apply(entity, target, dir, arena);
                    }

                    foreach (Position aoe in action.AoeTiles(entity, target, dir, arena))
                    {
                        foreach (BattleEntity pokemon in turns)
                        {
                            //todo ne pas toucher soi-même
                            if (aoe.Equals(pokemon.CurrentPos))
                            {
                                foreach (HitEffect effect in action.HitEffects)
                                {
                                    effect.apply(entity, pokemon, dir, arena);
                                }
                            }
                        }
                    }

                    actionId++;

                    if (action.NextTurn)
                    {
                        NextTurn();
                    }

                    foreach (int id in players)
                    {
                        var message = ToActionMessage(id, target, action, dir);
                        GlobalServer.Instance.SendMessage(id, message);
                    }

                    playIATurns();

                    return true;
                }
            }

            return false;
        }