Beispiel #1
0
        private async Task PerformSpeicalEffect(CreatureView creatureView, VisualEffectParam visualEffectParam)
        {
            var specialEffectParams = visualEffectParam.specialEffectParams;

            for (int i = 0; i < specialEffectParams.Count; i++)
            {
                await Task.Delay((specialEffectParams[i].showTimePoint * visualEffectParam.totalTime).ToMillisecond());

                var effect = Instantiate(specialEffectParams[i].EffectTempalte, transform);
                effect.transform.position = creatureView.transform.position + specialEffectParams[i].offsetFromSelf;
            }
        }
Beispiel #2
0
        private async Task PerformMoveEffect(CreatureView creatureView, VisualEffectParam visualEffectParam)
        {
            var moveParams = visualEffectParam.movePramas;
            var originPos  = creatureView.transform.position;
            var waitTasks  = new List <Task>();

            for (int i = 0; i < moveParams.Count; i++)
            {
                waitTasks.Add(Task.Delay((moveParams[i].moveTimePoint * visualEffectParam.totalTime).ToMillisecond()));
            }
            for (int i = 0; i < moveParams.Count; i++)
            {
                await waitTasks[i];
                await creatureView.transform.DOMove(originPos + creatureView.transform.right.x *moveParams[i].moveOffset, moveParams[i].time).AsyncWaitForCompletion();
            }
        }
Beispiel #3
0
        public async Task Perform(CreatureView creatureView, VisualEffectParam visualEffectParam, TimePointHandler[] timePointCallbacks = null)
        {
            var task                     = Task.Delay(visualEffectParam.totalTime.ToMillisecond());
            var totalTime                = visualEffectParam.totalTime;
            var startTimePointTasks      = new List <Task>();
            var realEffectTimePointTasks = new List <Task>();
            var endTimePointTasks        = new List <Task>();
            var timePoints               = visualEffectParam.timePoints;

            if (timePoints != null)
            {
                for (int i = 0; i < timePoints.Count; i++)
                {
                    var timePoint = timePoints[i];
                    startTimePointTasks.Add(Task.Delay((timePoint.startEffectTimePoint * totalTime).ToMillisecond()));
                    realEffectTimePointTasks.Add(Task.Delay((timePoint.realEffectTimePoint * totalTime).ToMillisecond()));
                    endTimePointTasks.Add(Task.Delay((timePoint.endEffectTimePoint * totalTime).ToMillisecond()));
                }
            }

            if (visualEffectParam.specialEffectParams != null)
            {
                _ = PerformSpeicalEffect(creatureView, visualEffectParam);
            }

            if (visualEffectParam.movePramas != null)
            {
                _ = PerformMoveEffect(creatureView, visualEffectParam);
            }

            if (timePointCallbacks != null)
            {
                for (int i = 0; i < timePoints.Count; i++)
                {
                    await startTimePointTasks[i];
                    timePointCallbacks[i].start?.Invoke(timePoints[i].startEffectTimePoint, totalTime, visualEffectParam);
                    await realEffectTimePointTasks[i];
                    timePointCallbacks[i].realEffect?.Invoke(timePoints[i].realEffectTimePoint, totalTime, visualEffectParam);
                    await endTimePointTasks[i];
                    timePointCallbacks[i].end?.Invoke(timePoints[i].endEffectTimePoint, totalTime, visualEffectParam);
                }
            }

            await task;
        }