Esempio n. 1
0
        private void PerformDash(DashAction da, Character caster)
        {
            switch (da.ShowRequirement())
            {
            case JumpAction.Requirement.Air:
                if (caster.IsOnGround())
                {
                    isThisJumpDisabled = true;
                }
                break;

            case JumpAction.Requirement.Ground:
                if (!caster.IsOnGround())
                {
                    isThisJumpDisabled = true;
                }
                break;
            }
            if (isThisJumpDisabled)
            {
                return;
            }

            float   distance  = Math.Abs(da.ShowDistance());
            Vector2 direction = da.ShowDirectionAsNormalizedVector();

            if (caster.FacingDirection() == Direction.Left)
            {
                direction = new Vector2(direction.x * -1, direction.y);
            }
            if (da.ShowDistance() < 0)
            {
                direction *= -1;
            }
            caster.SetMovingDirection(direction);

            if (da.ignoreObstacles || da.collision)
            {
                dashRequest = new FixedUpdateDashRequest(distance, duration, da.ShowBlendTime(), da.IsUniform());
                movementComponent.AddMovementRequest(dashRequest);
            }
            else
            {
                dashRequest = caster.Dash(
                    distance, duration, da.ShowBlendTime(), true, true, ignoreMinSpeedOnAir, da.IsUniform()
                    );
            }
        }
Esempio n. 2
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;
        }