Exemple #1
0
    private IEnumerator StartAnimationImpl(List <Vector2AnimationData> datas)
    {
        if (isWaitingForStart)
        {
            yield break;
        }
        if (IsStarted)
        {
            isWaitingForStart = true;
        }
        yield return(new WaitUntil(() => false == IsStarted));

        isWaitingForStart = false;

        if (!IsStarted)
        {
            //this.Datas = datas;
            Datas.Clear();
            foreach (var data in datas)
            {
                Datas.Add(new BosVector2AnimationInfo {
                    Data = data, Direction = BosAnimationDirection.Forward
                });
            }
            timer = 0f;
            easeFuncs.Clear();
            events.Clear();
            for (int i = 0; i < Datas.Count; i++)
            {
                easeFuncs.Add(AnimUtils.GetEaseFunc(Datas[i].Data.EaseType));
                List <AnimationEventInfo <Vector2> > dataEvents = new List <AnimationEventInfo <Vector2> >();
                if (Datas[i].Data.Events != null)
                {
                    foreach (AnimationEvent <Vector2> evt in Datas[i].Data.Events)
                    {
                        dataEvents.Add(new AnimationEventInfo <Vector2> {
                            Event       = evt,
                            IsCompleted = false
                        });
                    }
                }
                events.Add(dataEvents);
            }
            isStartedStatus.Clear();
            for (int i = 0; i < Datas.Count; i++)
            {
                isStartedStatus.Add(true);
            }
            Datas.ForEach(d => d.Data.OnStart?.Invoke(d.Data.StartValue, d.Data.Target));
        }
    }