public ItemUsePreActionResult(ItemBasis item,MyCharacterController owner,params ObjectEntity[] targets)
     : base(owner)
 {
     //GameController.PlayingLogger.addLogFormat("Ts:{0}", targets.Length);
     Item = item;
     Targets = targets;
     Animations = new EffectAnimationEntity[] { };
     Options = new List<ExertionItemEffect.ExeritionOption>();
 }
 IEnumerator linearshot(EffectAnimationEntity entity, Vector2 start, Vector2 end, float duration,float scale,float speed)
 {
     //Debug.LogFormat("{0} to {1}",start,end);
     var line = BresenhamLOS.getLines(start, end);
     //line.Insert(0, start);
     //line.Add(end);
     Debug.Log(line.Count);
     //int idx = 0;
     foreach (Vector2 pos in line) {
         //GameController.PlayingLogger.addLogFormat("P[{0}]:{1}",idx++,pos);
         var e = singleshotEffect(GameObject.Instantiate(entity), pos, scale, speed, true);
         e.AutoDestroy = true;
         var animator = e.Animator;
         yield return new WaitUntil(() =>
         {
             if (animator == null) return true;
             return animator.GetCurrentAnimatorStateInfo(0).normalizedTime > (1f - duration);
         });
     }
     GameObject.Destroy(entity.gameObject);
 }
 public Coroutine destroyExitedAnimation(EffectAnimationEntity entity)
 {
     return GameControlProxy.Instance.StartCoroutine(destroyOnExitAnimation(entity));
 }
 public IEnumerator smoothDamp(EffectAnimationEntity entity, Vector2 start, Vector2 target, float smoothtime)
 {
     entity.WrapMode = WrapMode.Loop;
     entity.transform.position = start;
     entity.setActive(true);
     var vel = Vector2.zero;
     yield return new WaitUntil(() => {
         entity.transform.position = Vector2.SmoothDamp(entity.transform.position, target, ref vel, smoothtime);
         var dist = Vector2.Distance(entity.transform.position, target);
         if (dist <= 0.5f) entity.transform.position = target;
         //Debug.LogFormat("Distance:{0}", dist);
         return (Vector2)entity.transform.position == target;
     });
     entity.AnimationExit();
 }
 private IEnumerator destroyOnExitAnimation(EffectAnimationEntity entity)
 {
     yield return new WaitUntil(() => entity.IsAnimationExited);
     GameObject.Destroy(entity.gameObject);
 }
 public EffectAnimationEntity singleshotEffect(EffectAnimationEntity effect, Vector2 pos,float scale, float speed, bool immediately)
 {
     if (effect == null) {
         Debug.logger.LogError("shingleshotEffect", "Effect is Null!!!");
         return null;
     }
     Debug.LogFormat("Effect:{0}",effect.ToString());
     var entity = effect;//GameObject.Instantiate(effect);
     entity.transform.localScale *= scale;
     entity.transform.position = pos;
     entity.Speed = speed;
     entity.WrapMode = WrapMode.Once;
     entity.gameObject.SetActive(immediately);
     entity.End = pos;
     entity.CurrentAnimationType = EffectAnimationEntity.AnimationType.POINT;
     return entity;
 }
 public EffectAnimationEntity singleshotEffect(EffectAnimationEntity anime, float scale, float speed, bool immediately)
 {
     if (anime == null) return null;
     return singleshotEffect(anime,anime.transform.position,scale,speed,immediately);
 }
 public IEnumerator linearshotEffect(EffectAnimationEntity entity, Vector2 start, Vector2 end, float duration = 0, float scale = 1f,float speed=1f)
 {
     yield return linearshot(entity, start, end, duration, scale, speed);
 }
 public IEnumerator playAbilityAnimation(PlayerController player, EffectAnimationEntity entity)
 {
     if (entity != null) {
         entity.playSE();
         GameController.EffectAnimationController.singleshotEffect(entity, player.FrontPos, 1, 2, true);
     }
     yield return null;
 }
    public override IEnumerator PlayMainEffectAnimation()
    {
        GameController.SoundController.playSE(SoundNameList.Character_Attack);
        yield return new WaitForSeconds(0.01f);
        EffectAnimationEntity[] entities = new EffectAnimationEntity[Tokens.Length];
        int idx = 0;
        foreach (var token in Tokens) {
            entities[idx++] = GameController.EffectAnimationController.singleshotEffect(EffectAnimationNameList.NormalAttack1, token.Position);
        }
        foreach (var entity in entities) {
            yield return WaitAnimationExit(entity);
        }

        //yield return new WaitForSeconds(0.15f);
    }
 public IEnumerator playAbilityAnimation(PlayerController player,EffectAnimationEntity entity)
 {
     yield return GameController.EffectAnimationController.smoothDamp(entity, player.FrontPos, Target.Position, 0.2f);
 }
 public IEnumerator playAbilityAnimation(PlayerController player, EffectAnimationEntity entity)
 {
     GameController.EffectAnimationController.singleshotEffect(entity, Trap.Position, 1, 2, true);
     entity.playSE();
     yield return null;
 }