Esempio n. 1
0
        public void TickCollisions(TickCollisionsEvent _)
        {
            // TODO: Do this via collision detection instead.
            // TODO: Clean this up.
            // Keeps sword rested on the ground.
            if (this.stateMachine_.IsOnGround)
            {
                var bladeFromGroundY = -(this.playerRigidbody_.CenterY -
                                         this.playerRigidbody_.BottomY);
                bladeFromGroundY -= MathF.Abs(
                    TrigMath.LenDegY(this.handDis_, this.handDeg_));

                var minAngle = MathF.Acos(bladeFromGroundY / this.bladeLength_) /
                               MathF.PI *
                               180;

                var diffToGround = TrigMath.DifferenceInDegrees(this.swordDeg_, 270);
                if (FloatMath.Abs(diffToGround) <= minAngle)
                {
                    this.swordDeg_ = 270 + FloatMath.Sign(diffToGround) * minAngle;

                    if (FloatMath.Abs(this.swordDevVel_) > 2)
                    {
                        this.swordDevVel_ *= -.5f;
                    }
                    else
                    {
                        this.swordDevVel_ = 0;
                    }
                }
            }
        }
Esempio n. 2
0
        private void TickCollisions_(TickCollisionsEvent _)
        {
            var initXSpd      = FloatMath.Abs(this.playerRigidbody_.XVelocity);
            var collidedTypes = this.collider_.TickCollisions();

            if ((collidedTypes & LevelTileTypes.LEFT_WALL) != 0 ||
                (collidedTypes & LevelTileTypes.RIGHT_WALL) != 0)
            {
                if (initXSpd > 1)
                {
                    this.playerSounds_.PlayBumpWallSound();
                }
            }

            // If falling while meant to be on the ground, then switch to falling state.
            if (this.stateMachine_.IsOnGround && this.rigidbody_.YVelocity > 0)
            {
                this.stateMachine_.State    = PlayerState.INITIALLY_FALLING_OFF_LEDGE;
                this.initiallyFallingTimer_ = 3;
            }

            if (this.stateMachine_.State == PlayerState.WALL_SLIDING &&
                this.rigidbody_.YVelocity > 0)
            {
                this.playerRigidbody_.YAcceleration =
                    PlayerConstants.WALL_SLIDING_GRAVITY;
            }
            else
            {
                this.playerRigidbody_.YAcceleration = PlayerConstants.GRAVITY;
            }
        }
 public void TickCollisions(TickCollisionsEvent _)
 => this.CurrentItem.TickCollisions(_);
Esempio n. 4
0
 public void TickCollisions(TickCollisionsEvent _)
 {
     // TODO: Collisions?
 }