Esempio n. 1
0
        protected void TriggerEventFrame(float dt)
        {
            for (int i = pendingEventFrames.Count - 1; i >= 0; i--)
            {
                BaseEvent ef = pendingEventFrames[i];
                if (ef.ShowTrigger().ShowTriggerType() != TriggerType.Frame)
                {
                    continue;
                }
                TimelineTrigger timelineTrigger = (TimelineTrigger)ef.ShowTrigger();
                float           activeAt        = timelineTrigger.ShowScaledFrameInSeconds();
                activeAt = activeAt / config.AttackSpeed();
                if (offsetByEvent.ContainsKey(ef))
                {
                    activeAt += offsetByEvent[ef];
                }

                float timelineElapsed = elapsed;
                if (timelineTrigger.relative)
                {
                    timelineElapsed = phaseElapsed;
                }
                if (timelineElapsed < activeAt)
                {
                    continue;
                }

                pendingEventFrames.RemoveAt(i);
                processedEventFrames.Add(ef);
                Trigger(ef, GetEventFrameArgsFor(ef));
            }
        }
Esempio n. 2
0
        public Rotation(BaseEvent be, Character caster, Environment environment)
        {
            this.be          = be;
            this.caster      = caster;
            this.environment = environment;
            ra = (RotationAction)be.ShowAction();
            Entity entity = caster.GameObject().GetComponent <EntityReference>().Entity;

            movementComponent = entity.GetComponent <MovementComponent>();
            TimelineTrigger timelineTrigger = (TimelineTrigger)be.ShowTrigger();

            duration            = ra.ShowDurationInSeconds(timelineTrigger.ShowScaleTime());
            interpolationMethod = ra.ShowInterpolation();
            interpolator        = EasingFunctions.GetEasingFunction(interpolationMethod);
            movingDirection     = ra.ShowMovingDirection();
            mode = ra.mode.ShowRotationMode();
            switch (mode)
            {
            case RotationAction.RotationMode.Delta:
                deltaRotationMode = (RotationAction.DeltaRotationMode)ra.mode;
                break;

            case RotationAction.RotationMode.Destination:
                destinationRotationMode = (RotationAction.DestinationRotationMode)ra.mode;
                break;
            }
        }
Esempio n. 3
0
        public Jump(BaseEvent eventFrame, Character character, Skill parentSkill,
                    Environment environment, bool jumpOverDistance = true)
        {
            this.character        = character;
            this.parentSkill      = parentSkill;
            this.environment      = environment;
            this.jumpOverDistance = jumpOverDistance;

            characterCollider = character.GameObject().GetComponent <BoxCollider>();

            BaseEvent be = eventFrame;

            jumpAction = (JumpAction)be.action;
            if (be.trigger.ShowTriggerType() == TriggerType.Frame)
            {
                TimelineTrigger tt = (TimelineTrigger)be.trigger;
                if (tt.ShowScaledFrameInSeconds() == 0)
                {
                    DoJump();
                }
            }
            else
            {
                DoJump();
            }
        }
Esempio n. 4
0
        public void SkipToTime(float time)
        {
            float deltaElapsed = time - elapsed;

            if (deltaElapsed > 0)
            {
                elapsed += deltaElapsed;
            }

            float deltaPhaseElapsed = time - phaseElapsed;

            if (deltaPhaseElapsed > 0)
            {
                phaseElapsed += deltaPhaseElapsed;
            }

            for (int i = pendingEventFrames.Count - 1; i >= 0; i--)
            {
                BaseEvent ef = pendingEventFrames[i];
                if (ef.ShowTrigger().ShowTriggerType() != TriggerType.Frame)
                {
                    continue;
                }
                TimelineTrigger timelineTrigger = (TimelineTrigger)ef.ShowTrigger();
                float           activeAt        = timelineTrigger.ShowScaledFrameInSeconds();
                activeAt = activeAt / config.AttackSpeed();
                if (offsetByEvent.ContainsKey(ef))
                {
                    activeAt += offsetByEvent[ef];
                }

                float timelineElapsed = elapsed;
                if (timelineTrigger.relative)
                {
                    timelineElapsed = phaseElapsed;
                }
                if (timelineElapsed < activeAt)
                {
                    continue;
                }

                pendingEventFrames.RemoveAt(i);
                processedEventFrames.Add(ef);
            }

            foreach (Loopable loopable in loopableElements)
            {
                if (loopable is AnimationPlayback)
                {
                    ((AnimationPlayback)loopable).JumpToTime(time);
                }
            }
        }
Esempio n. 5
0
        public Dash(BaseEvent ef, Character caster, bool ignoreMinSpeedOnAir, Skill skill, Environment environment)
        {
            this.ef     = ef;
            this.caster = caster;
            this.ignoreMinSpeedOnAir = ignoreMinSpeedOnAir;
            this.skill = skill;
            mapGround  = environment.MapColliders().bottom;
            mapCeil    = environment.MapColliders().top;
            GameObject gameObject = caster.GameObject();

            casterTransform   = gameObject.transform;
            casterBoxCollider = gameObject.GetComponent <BoxCollider>();
            casterEntity      = gameObject.GetComponent <EntityReference>().Entity;
            movementComponent = casterEntity.GetComponent <MovementComponent>();
            da = (DashAction)ef.ShowAction();
            if (ef.ShowTrigger().ShowTriggerType() == TriggerType.Frame)
            {
                TimelineTrigger tt = (TimelineTrigger)ef.ShowTrigger();
                duration = da.ShowEndFrameInSeconds(tt.ShowScaleTime());
            }
            else
            {
                duration = da.ShowEndFrameInSeconds(1);
            }
            PerformDash(da, caster);
            isDashPerformed = true;
            CacheOriginalColliderData(ef, caster);
            ResizeCollider(ef);
            if (da.collision)
            {
                cubeShape = new CubeShape(GetCenterOfHitbox(), casterBoxCollider.size, new List <SsarTuple <Color, float> >(new [] { new SsarTuple <Color, float>(Color.cyan, duration), }));
                GizmosDrawer.Instance.AddRequest(new DrawRequest(cubeShape, duration));
            }

            if (da.collision)
            {
                collisionDetectionCoroutineHandle = Timing.RunCoroutine(DetectCollision(), Segment.FixedUpdate);
                centerOfHitBoxAtPreviousFrame     = GetCenterOfHitbox();
            }

            positionAtPreviousFrame = movementComponent.Position;
        }
        public DashTowardTarget(BaseEvent ef, Character caster, Environment environment)
        {
            this.ef          = ef;
            this.caster      = caster;
            this.environment = environment;

            dtta = (DashTowardTargetAction)ef.ShowAction();
            float scaletime = 1;

            if (ef.ShowTrigger() is TimelineTrigger)
            {
                TimelineTrigger tt = (TimelineTrigger)ef.ShowTrigger();
                scaletime = tt.ShowScaleTime();
            }
            duration = dtta.ShowDurationInSeconds(scaletime);
            List <Character> enemies = environment.FindNearbyCharacters(
                caster, Vector3.zero, 999,
                new[] {
                FindingFilter.ExcludeAllies, FindingFilter.ExcludeMe
            }
                );

            if (enemies.Count > 0)
            {
                enemy = enemies[0];
                Vector2 diff = enemy.Position() - caster.Position();

                if (!dtta.track)
                {
                    float distance        = Math.Abs(diff.x);
                    bool  isTargetFarAway = distance > dtta.distanceToKeep;
                    if (isTargetFarAway)
                    {
                        float distanceToDash = distance - dtta.distanceToKeep;
                        if (dtta.maxDistance >= 0)
                        {
                            distanceToDash = Mathf.Min(distanceToDash, dtta.maxDistance);
                        }
                        if (diff.x > 0)
                        {
                            caster.SetFacingDirectionToRight();
                            caster.SetMovingDirectionToRight();
                        }
                        else
                        {
                            caster.SetFacingDirectionToLeft();
                            caster.SetMovingDirectionToLeft();
                        }
                        dashRequest = (DashRequest)caster.Dash(distanceToDash, duration, 0, true, true, true, dtta.uniform);
                    }
                    else
                    {
                        isFinished = true;
                    }
                }
                else
                {
                    if (diff.x > 0)
                    {
                        caster.SetFacingDirectionToRight();
                        caster.SetMovingDirectionToRight();
                    }
                    else
                    {
                        caster.SetFacingDirectionToLeft();
                        caster.SetMovingDirectionToLeft();
                    }
                    dashRequest = (DashRequest)caster.Dash(dtta.distance, duration, 0, true, true, true, dtta.uniform);
                }
            }
            else
            {
                isFinished = true;
            }
        }
Esempio n. 7
0
 internal TimelineKeyTriggerCollection(TimelineTrigger timelineTrigger) : base(timelineTrigger)
 {
 }
Esempio n. 8
0
 // Start is called before the first frame update
 void Start()
 {
     trigger = GetComponentInChildren <TimelineTrigger>();
     autobus = GetComponent <Elektricka>();
 }