private void ActionSuperJumpUp(BackgroundAccess Foreground)
        {
            // jump up 8 to 12
            if (this.VelocityY < 0.0f)
            {
                this._State = PlayerState.FallMoving;
            }
            else
            {
                this._State = PlayerState.SuperJumpUp;
            }

            if (this.Frame < 8 || this.Frame > 12)
            {
                this.Frame     = 8;
                this.VelocityY = SpaceAndTime.LengthFrom2DTo3D(50);
                this.VelocityX = 0.0f;
            }
            else if (this.Frame != 12)
            {
                this.Frame++;
            }

            this.ApplyNormalGravity();
        }
Ejemplo n.º 2
0
        public void GenerateVerticies()
        {
            float HalfWidth  = SpaceAndTime.LengthFrom2DTo3D(this.Width) * 0.5f;
            float HalfHeight = SpaceAndTime.LengthFrom2DTo3D(this.Height) * 0.5f;

            //Bottom right
            this.Verticies[0].X  = HalfWidth;
            this.Verticies[0].Y  = HalfHeight;
            this.Verticies[0].Z  = 0f;
            this.Verticies[0].Tu = 0.0f;
            this.Verticies[0].Tv = 0.0f;

            //Bottom left
            this.Verticies[1].X  = -HalfWidth;
            this.Verticies[1].Y  = HalfHeight;
            this.Verticies[1].Z  = 0f;
            this.Verticies[1].Tu = 1.0f;
            this.Verticies[1].Tv = 0.0f;

            //Top right
            this.Verticies[2].X  = HalfWidth;
            this.Verticies[2].Y  = -HalfHeight;
            this.Verticies[2].Z  = 0f;
            this.Verticies[2].Tu = 0.0f;
            this.Verticies[2].Tv = 1.0f;

            //Top left
            this.Verticies[3].X  = -HalfWidth;
            this.Verticies[3].Y  = -HalfHeight;
            this.Verticies[3].Z  = 0f;
            this.Verticies[3].Tu = 1.0f;
            this.Verticies[3].Tv = 1.0f;
        }
        private void ActionParachute(BackgroundAccess Foreground)
        {
            //parachute 17
            this._State = PlayerState.Parachute;
            this.Frame  = 17;

            if (this.IsOnGround == true)
            {
                this._State = PlayerState.Land;
            }

            //Set velocity from gravity
            this.VelocityY -= SpaceAndTime.LengthFrom2DTo3D(2);
            if (this.VelocityY < SpaceAndTime.LengthFrom2DTo3D(8))
            {
                this.VelocityY = -SpaceAndTime.LengthFrom2DTo3D(8);
            }

            if (this.FaceLeft == true)
            {
                this.VelocityX = SpaceAndTime.LengthFrom2DTo3D(16);
            }
            else
            {
                this.VelocityX = -SpaceAndTime.LengthFrom2DTo3D(16);
            }
        }
        private void ActionSuperJumpMoving(BackgroundAccess Foreground)
        {
            // 13 to 16
            if (this.VelocityY < 0.0f)
            {
                this._State = PlayerState.FallMoving;
            }
            else
            {
                this._State = PlayerState.SuperJumpMoving;
            }

            if (this.Frame < 13 || this.Frame > 16)
            {
                this.Frame     = 13;
                this.VelocityY = SpaceAndTime.LengthFrom2DTo3D(50);
                if (this.FaceLeft)
                {
                    this.VelocityX = SpaceAndTime.LengthFrom2DTo3D(16);
                }
                else
                {
                    this.VelocityX = -SpaceAndTime.LengthFrom2DTo3D(16);
                }
            }
            else if (this.Frame != 16)
            {
                this.Frame++;
            }

            this.ApplyNormalGravity();
        }
 private void ApplyNormalGravity()
 {
     //Apply normal gravity only if another gravity has not been applied
     if (this.VelocityY > -SpaceAndTime.LengthFrom2DTo3D(36))
     {
         this.VelocityY -= SpaceAndTime.LengthFrom2DTo3D(9);
     }
 }
 private void ActionDrown()
 {
     //Make player drown if they are not already drowning
     this.RotationX += 2.0f;
     if (this._State != PlayerState.Drown)
     {
         this._DeathCount++;
         this._State    = PlayerState.Drown;
         this.VelocityY = -SpaceAndTime.LengthFrom2DTo3D(1);
         this.VelocityX = 0.0f;
     }
 }
Ejemplo n.º 7
0
        private void Initialize(float NewX, float NewY, float NewZ, int NewWidth, int NewHeight, int NewSheetWidth, int NewSheetHeight)
        {
            this.Width       = NewWidth;
            this.Height      = NewHeight;
            this.SheetWidth  = NewSheetWidth;
            this.SheetHeight = NewSheetHeight;
            this.Frame       = 0;

            this.X = NewX;
            this.Y = NewY;
            this.Z = NewZ;

            this.AnimCount = ((int)(this.SheetWidth / this.Width)) * ((int)(this.SheetHeight / this.Height));

            //Since these are drawn in 3d coordinates
            // the verticies are specified in counter-clockwise order
            // TODO: IS VERTICIES SPELLED WRONG?
            this.Verticies = new Direct3D.CustomVertex.PositionTextured[4];

            float HalfWidth  = SpaceAndTime.LengthFrom2DTo3D(this.Width) * 0.5f;
            float HalfHeight = SpaceAndTime.LengthFrom2DTo3D(this.Height) * 0.5f;

            //Bottom right
            this.Verticies[0].X  = HalfWidth;
            this.Verticies[0].Y  = HalfHeight;
            this.Verticies[0].Z  = 0f;
            this.Verticies[0].Tu = 0.0f;
            this.Verticies[0].Tv = 0.0f;

            //Bottom left
            this.Verticies[1].X  = -HalfWidth;
            this.Verticies[1].Y  = HalfHeight;
            this.Verticies[1].Z  = 0f;
            this.Verticies[1].Tu = 1.0f;
            this.Verticies[1].Tv = 0.0f;

            //Top right
            this.Verticies[2].X  = HalfWidth;
            this.Verticies[2].Y  = -HalfHeight;
            this.Verticies[2].Z  = 0f;
            this.Verticies[2].Tu = 0.0f;
            this.Verticies[2].Tv = 1.0f;

            //Top left
            this.Verticies[3].X  = -HalfWidth;
            this.Verticies[3].Y  = -HalfHeight;
            this.Verticies[3].Z  = 0f;
            this.Verticies[3].Tu = 1.0f;
            this.Verticies[3].Tv = 1.0f;

            //Set sprite unique id
            this.UniqueSpriteIdentifier = ServerManager.UniqueIdentifier.GetNewUniqueId();
        }
        private void ActionHurt(BackgroundAccess Foreground)
        {
            //hurt 7

            float BigMovement = SpaceAndTime.LengthFrom2DTo3D(30);

            if (this.Frame != 7)
            {
                this.Frame = 7;

                //First cancel all movement
                this.VelocityX = 0;
                this.VelocityY = 0;

                //Now get the new movement
                switch (this._HurtSide)
                {
                case (CollisionRectAccess.HitSide.TopRight):
                    this.VelocityX = BigMovement;
                    this.VelocityY = -BigMovement;
                    break;

                case (CollisionRectAccess.HitSide.TopLeft):
                    this.VelocityX = -BigMovement;
                    this.VelocityY = -BigMovement;
                    break;

                case (CollisionRectAccess.HitSide.BottomRight):
                    this.VelocityX = BigMovement;
                    this.VelocityY = BigMovement;
                    break;

                case (CollisionRectAccess.HitSide.BottomLeft):
                    this.VelocityX = -BigMovement;
                    this.VelocityY = BigMovement;
                    break;
                }
            }
            else if (this.VelocityX == 0 || this.IsOnGround)
            {
                this._HurtSide = CollisionRectAccess.HitSide.None;
                this._State    = PlayerState.RollBack;
            }

            this.ApplyNormalGravity();
        }
        private void ActionRollForward(BackgroundAccess Foreground)
        {
            //roll 5 to 8

            this._State = PlayerState.RollForward;

            if (this.Frame < 5 || this.Frame > 8)
            {
                this.Frame = 5;
            }
            else if (this.Frame == 8)
            {
                if (this.FaceLeft == true)
                {
                    this._State = PlayerState.StandLeft;
                }
                else
                {
                    this._State = PlayerState.StandRight;
                }
            }
            else
            {
                this.Frame++;
            }

            if (this.FaceLeft == true)
            {
                this.VelocityX = SpaceAndTime.LengthFrom2DTo3D(16);
            }
            else
            {
                this.VelocityX = -SpaceAndTime.LengthFrom2DTo3D(16);
            }

            this.ApplyNormalGravity();
        }
        private void ActionFallMoving(BackgroundAccess Foreground)
        {
            //Fall 12
            if (this.IsOnGround == true)
            {
                this._State = PlayerState.Land;
            }
            else
            {
                this._State = PlayerState.FallMoving;
                this.Frame  = 12;
            }

            if (this.FaceLeft)
            {
                this.VelocityX = SpaceAndTime.LengthFrom2DTo3D(16);
            }
            else
            {
                this.VelocityX = -SpaceAndTime.LengthFrom2DTo3D(16);
            }

            this.ApplyNormalGravity();
        }
        private void ActionRunLeft(BackgroundAccess Foreground)
        {
            //walk 32 to 37

            this._State   = PlayerState.RunLeft;
            this.FaceLeft = true;

            if (this.Frame == 34 || this.Frame == 37)
            {
                Sounds.PlayStep();
            }

            //Reset to first frame if this animation has not started
            if (this.Frame < 32 || this.Frame >= 37)
            {
                this.Frame = 32;
            }
            else
            {
                this.Frame++;                 //Move to next frame
            }
            this.VelocityX = SpaceAndTime.LengthFrom2DTo3D(16);
            this.ApplyNormalGravity();
        }
        private void ActionJumpUp(BackgroundAccess Foreground)
        {
            // jump up 8 to 12
            if (this.FaceLeft == true)
            {
                this._State = PlayerState.JumpLeftUp;
            }
            else
            {
                this._State = PlayerState.JumpRightUp;
            }

            if (this.Frame < 8 || this.Frame > 12)
            {
                this.Frame     = 8;
                this.VelocityY = SpaceAndTime.LengthFrom2DTo3D(32);
            }
            else if (this.Frame != 12)
            {
                this.Frame++;
            }

            this.ApplyNormalGravity();
        }
Ejemplo n.º 13
0
        public BackgroundAccess(Direct3D.Device NewParentDevice)
        {
            float PlatformWidthInFloats = SpaceAndTime.LengthFrom2DTo3D(64.0f);
            float CurrColmn             = 2.0f;

            this.Platforms = new ArrayList();
            SpriteAccess TemplatePlatform = new SpriteAccess(NewParentDevice, GameConfig.Files.Platform, 2.0f - (-1 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -1.4f, SpaceAndTime.SpriteZLocation, 64, 64, 64, 64, Color.FromArgb(0x00, 0x00, 0xFF, 0x00), 0, 0);

            this.Platforms.Add(TemplatePlatform);
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (0 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -1.4f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (1 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -1.4f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (6 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -1.4f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (7 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -1.4f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (8 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -1.4f, SpaceAndTime.SpriteZLocation));

            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (-1 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -.1f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (1 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -.1f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (2.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -.1f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (3.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -.1f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (4.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -.1f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (6 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -.1f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (8 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), -.1f, SpaceAndTime.SpriteZLocation));

            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (-.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), 1.2f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (0.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), 1.2f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (1.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), 1.2f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (3.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), 1.2f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (5.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), 1.2f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (6.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), 1.2f, SpaceAndTime.SpriteZLocation));
            this.Platforms.Add(new SpriteAccess(TemplatePlatform, 2.0f - (7.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), 1.2f, SpaceAndTime.SpriteZLocation));

            //Set location of platforms
            foreach (SpriteAccess CurrPlatform in this.Platforms)
            {
                CurrPlatform.Location = GameConfig.Locations.Platforms;
            }

            //polls
            float        CurrPollY  = 0.46f;
            SpriteAccess PollTop    = new SpriteAccess(NewParentDevice, GameConfig.Files.PollTop, 2.0f - (0 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, 64, 64, 64, 64, Color.FromArgb(0x00, 0x00, 0xFF, 0x00), 0, 0);
            SpriteAccess PollCenter = new SpriteAccess(NewParentDevice, GameConfig.Files.PollCenter, 2.0f - (0 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, 64, 64, 64, 64, Color.FromArgb(0x00, 0x00, 0xFF, 0x00), 0, 0);
            SpriteAccess PollBottom = new SpriteAccess(NewParentDevice, GameConfig.Files.PollBottom, 2.0f - (0 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, 64, 64, 64, 64, Color.FromArgb(0x00, 0x00, 0xFF, 0x00), 0, 0);

            this.Polls = new ArrayList();
            this.Polls.Add(new PollAccess(PollTop, 2.0f - (0 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Top));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollCenter, 2.0f - (0 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Center));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollCenter, CurrColmn, CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Center));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollBottom, 2.0f - (0 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Bottom));

            CurrPollY = 0.46f;
            this.Polls.Add(new PollAccess(PollTop, 2.0f - (7 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Top));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollCenter, 2.0f - (7 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Center));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollCenter, 2.0f - (7 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Center));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollBottom, 2.0f - (7 * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Bottom));

            CurrPollY = 1.76f;
            this.Polls.Add(new PollAccess(PollTop, 2.0f - (2.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Top));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollCenter, 2.0f - (2.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Center));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollCenter, 2.0f - (2.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Center));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollBottom, 2.0f - (2.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Bottom));

            CurrPollY = 1.76f;
            this.Polls.Add(new PollAccess(PollTop, 2.0f - (4.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Top));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollCenter, 2.0f - (4.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Center));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollCenter, 2.0f - (4.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Center));

            CurrPollY -= PlatformWidthInFloats;
            this.Polls.Add(new PollAccess(PollBottom, 2.0f - (4.5f * SpaceAndTime.LengthFrom2DTo3D(64.0f)), CurrPollY, SpaceAndTime.SpriteZLocation, PollType.Bottom));

            //Set location of polls
            foreach (SpriteAccess CurrPoll in this.Polls)
            {
                CurrPoll.Location = GameConfig.Locations.Polls;
            }

            Direct3D.Device ParentDevice = NewParentDevice;
        }