Example #1
0
        public void Check(IMovable user, ref Vector2 velocity, ref CollisionStatus status, LayerMask layerMask)
        {
            var bounds         = (Bounds2D)user.Hitbox.bounds;
            var shrinkedBounds = bounds;

            shrinkedBounds.Expand(user.Inset * -2);
            UPMDebug.DrawBounds2D(bounds, Color.magenta);
            UPMDebug.DrawBounds2D(shrinkedBounds, Color.yellow);
            foreach (var check in checks)
            {
                check.Check(user, ref velocity, ref status, layerMask, bounds, shrinkedBounds);
            }
        }
Example #2
0
        public override void Move(IMovable user, ref Vector2 velocity, ref CollisionStatus collisionStatus, StateMotorMachine machine, StateMotorConfig config1, LayerMask collisionMask)
        {
            var config = user.GetMotorConfig <GroundMotorConfig>();

            if (config == null)
            {
                UPMDebug.LogWarning("Expected GroundMotorConfig for GroundedState @ " + user);
                return;
            }

            ProcessInputs(user, config, ref velocity, ref collisionStatus);
            velocity.y += Gravity * config.GravityScale * Time.deltaTime;
            var max = user.MaxSpeed;

            velocity.x = Mathf.Clamp(velocity.x, -max, max);
            GroundedBehaviour.Check(user, ref velocity, ref collisionStatus, collisionMask);
        }
Example #3
0
        public override void Move(IMovable user, ref Vector2 velocity, ref CollisionStatus status)
        {
            var config = user.GetMotorConfig <StateMotorConfig>();

            if (config == null)
            {
                UPMDebug.LogWarning("Expected user " + user + " to have a StateMotorConfig but found none");
                return;
            }

            var m = config.StateMachine;

            if (m == null)
            {
                UPMDebug.LogError("Expected user " + user + " to have a state machine but found none");
                return;
            }

            m.Move(user, ref velocity, ref status, config, CollisionMask);
        }