Exemplo n.º 1
0
 public void LoadContent()
 {
     playerSprite = game.getSprite("nonFireMissle");
     ani = new SpriteStripAnimationHandler(new Sprite(game.Content, "missile_strip_strip4"),4,45);
 }
Exemplo n.º 2
0
 public void LoadContent()
 {
     playerSprite = game.getSprite(spriteNumber);
     ani = game.getSpriteAnimation(spriteNumber);
 }
Exemplo n.º 3
0
        public override void Update(GameTime gameTime, float worldSpeed)
        {
            keyInput.Update(gameTime);
            if (game.isInCreatorMode)
            {
                if (keyInput.keyboardState.IsKeyDown(Keys.LeftShift) && keyInput.keyboardState.IsKeyDown(Keys.X))
                {
                    body.Position = ConvertUnits.ToSimUnits(Constants.player1SpawnLocation);
                }

            }

            if (ignoreInput > 0)
            {
                ignoreInput--;
                //Ignore input for a couple of frams to allow redirection
                //return;
            }
            if (game.deathAnimation)
            {
                playerSprite = game.getSprite("fire1");
                return;

            }
            if (keyInput.IsNewKeyPressed(Keys.Tab))
            {
                game.isPausePressed = true;
            }
            if (keyInput.IsKeyPressed(Keys.Up) || keyInput.IsKeyPressed(Keys.W))
            {
                game.isUpMenuSelect = 1;
            }
            if (keyInput.IsKeyPressed(Keys.Down) || keyInput.IsKeyPressed(Keys.S))
            {
                game.isUpMenuSelect = 2;
            }
            ani.Update();
            doAnimation = false;
            shiftPosition = new Vector2(0, 0);

            float direction = inputState.GetJoyDirection();
            float x = (float)Math.Sin(direction);
            float y = (float)Math.Cos(direction) - 1;
            if(inputState.IsNewButtonPressed(Buttons.LeftShoulder))
            {
                game.magValue= game.magValue*-1;
            }

            //if (body.LinearVelocity.X < 3 && body.LinearVelocity.X > -3)
            //body.ApplyLinearImpulse(new Vector2(inputState.getXDirection() * 2f, 0));// inputState.getYDirection() * 300f));

            float xDirection = inputState.getXDirection();
            xDirection += keyInput.HorizontalMovement();
            float yDirection = inputState.getYDirection();
            yDirection -= keyInput.VerticalMovement();
            float runningValue = 1.5f;
            if (isOnJumpAnimation)
                xDirection = 0;
            distance = (float)(distance + gameTime.ElapsedGameTime.TotalMilliseconds * 0.002f * Math.Abs(body.LinearVelocity.X));
            if (distance > 0.9f)
            {
                distance = 0;
                run = !run;
            }
            float waterValue = 0.85f;
            if (game.inWater)
            {
                waterValue = 0.35f;
                if (body.LinearVelocity.Y > 4f)// && !game.oldWater)
                {
                    body.LinearVelocity = new Vector2(body.LinearVelocity.X, 4f);
                }
                game.inWater = false;
                if (game.ran.Next(100) % 13 == 0)
                {
                    TempBlock bubble = new TempBlock(game, game.Arena, ConvertUnits.ToDisplayUnits(body.Position) - Constants.player1SpawnLocation + new Vector2(0, -35), 1, "bubbleSpriteSheet");
                    game.addEntity(bubble);
                }
            }

            //Ignores input if it's in creator mode
            if (game.isInCreatorMode && !game.testLevel)
            {
                body.IgnoreGravity = true;
                body.LinearVelocity = new Vector2(0, 0);
                return;
            }

            if (inputState.IsButtonPressed(Buttons.RightShoulder) || keyInput.IsKeyPressed(Keys.Z) || keyInput.IsKeyPressed(Keys.L))
                runningValue = 2.5f;

            if ((xDirection > 0 && body.LinearVelocity.X < 0) || (xDirection < 0 && body.LinearVelocity.X > 0))
            {
                body.LinearVelocity = new Vector2(body.LinearVelocity.X * 0.88f, body.LinearVelocity.Y);

            }

            if (onGround)
            {
                if ((Math.Abs(body.LinearVelocity.X) < 10 * runningValue))
                {
                    body.ApplyLinearImpulse(new Vector2(xDirection * 0.45f * runningValue*waterValue, 0));// inputState.getYDirection() * 300f));
                }
                if (xDirection == 0)
                    fixture.Friction = 80;
                else
                    fixture.Friction = 0;
            }
            else
            {

                body.ApplyLinearImpulse(new Vector2(xDirection * 0.95f * runningValue*waterValue, 0));// inputState.getYDirection() * 300f));
                //motor.MotorSpeed = inputState.getXDirection()*10;
                if (inputState.getXDirection() == 0)
                    fixture.Friction = 10;
                else
                    fixture.Friction = 0;

            }

            if ((inputState.isAPressed() || keyInput.IsNewKeyPressed(Keys.Space)) && onGround && !game.isNextToSign)// && body.LinearVelocity.Y > -50)
            {
                body.IgnoreGravity = true;
                float oldYvalue = body.LinearVelocity.Y;
                if (oldYvalue > 0)
                    oldYvalue = 0;
                body.LinearVelocity = new Vector2(body.LinearVelocity.X, 0);
                modes = Modes.AIRUP;
                body.ApplyLinearImpulse(new Vector2(0, -30f+oldYvalue*waterValue));
                if (isOnWall)
                {
                    if (jumpDirection)
                    {
                        body.ApplyLinearImpulse(new Vector2(-7.75f * runningValue*waterValue, 0f));
                    }
                    else
                    {
                        body.ApplyLinearImpulse(new Vector2(7.75f * runningValue*waterValue, 0f));
                    }

                }
                body.IgnoreGravity = false;
                onGround = false;
                maxSpeedInAir = body.LinearVelocity;
                game.sounds["Rage//Wave//jump"].Play();
                //modes = Modes.AIRUP;
            }

            if ((inputState.IsNewButtonReleased(Buttons.A) || keyInput.IsNewKeyReleased(Keys.Space)) && body.LinearVelocity.Y < -1)
            {
                body.LinearVelocity = new Vector2(body.LinearVelocity.X, body.LinearVelocity.Y / 2f);

            }
            if (modes != Modes.WALL)
            {
                if (body.LinearVelocity.X > 0)
                {
                    faceRight = true;
                }
                if (body.LinearVelocity.X < 0)
                {
                    faceRight = false;
                }
            }

            if (body.LinearVelocity.Y < -1)
            {
                //playerSprite = game.getSprite("SpaceAir");
            }
            else
            {
                //playerSprite = game.getSprite("Space");
            }

            mikeStandingStill = false;

            if (onGround)//modes == Modes.GROUND)
            {
                //TODO: add running

                XboxInput xbi = (XboxInput)inputState;
                if (Math.Abs(body.LinearVelocity.X) > 0.00005 || Math.Abs(xbi.getXDirection()) > 0)
                {
                    if (run)
                        playerSprite = game.getSprite("MikeRun1");
                    else
                        playerSprite = game.getSprite("MikeRun2");
                    if (Math.Abs(body.LinearVelocity.X) < 5)
                    {
                        ani = game.getSpriteAnimation("sprite15_strip4");
                        ani.addSound(game.sounds["Rage//Wave//running"]);
                        ani.changeSoundRate(8);
                        int frameRate = 120 * (int)(5f / Math.Abs(body.LinearVelocity.X));
                        ani.changeFrameRate(frameRate);
                    }
                    else
                    {
                        ani = game.getSpriteAnimation("sprite16_strip6");
                        ani.addSound(game.sounds["Rage//Wave//running"]);
                        ani.changeSoundRate(6);
                        int frameRate = 60 * (int)(15f / Math.Abs(body.LinearVelocity.X));
                        ani.changeFrameRate(frameRate);
                    }
                    doAnimation = true;
                    isOnWall = false;
                    isOnJumpAnimation = false;
                }
                if (body.LinearVelocity.X == 0)
                {
                    playerSprite = game.getSprite("MikeStand");
                    mikeStandingStill = true;
                    ani = game.getSpriteAnimation("player_strip12");
                    doAnimation = true;
                    isOnWall = false;
                    isOnJumpAnimation = false;
                }
                if (xbi.IsButtonPressed(Buttons.LeftShoulder))
                {

                    body.LinearVelocity = new Vector2(body.LinearVelocity.X * 0.95f, body.LinearVelocity.Y);
                }

                // modes = Modes.WAITING;
            }
            if (Math.Abs(body.LinearVelocity.Y) >= 0.0001f)
            {

                if (yDirection > 0)
                    body.ApplyLinearImpulse(new Vector2(0, yDirection * 1.05f*waterValue));
                else
                    body.ApplyLinearImpulse(new Vector2(0, yDirection * 0.12f*waterValue));

                if (!isOnWall)
                {
                    if (body.LinearVelocity.Y > 0.05f)
                    {
                        ani = game.getSpriteAnimation("sprite17");
                    }
                    if (body.LinearVelocity.Y < -0.05f)
                    {
                        ani = game.getSpriteAnimation("sprite17-2");
                    }
                    wallJumpCount = 0;
                }
                else
                {
                    ani = game.getSpriteAnimation("sprite18_strip4");
                    //ani = game.getSpriteAnimation("SpriteWallSlide");
                    if (isFirstAni)
                    {
                        ani.setStatePub(0);
                        isFirstAni = false;
                    }

                    wallJumpCount++;
                    faceRight = jumpDirection;
                    if (ani.getCycles() >= 2)
                    {
                        isOnWall = false;
                        isOnJumpAnimation = false;
                        faceRight = !jumpDirection;
                    }

                }
            }
            if (modes == Modes.WALL)
            {
                isOnJumpAnimation = true;
                playerSprite = game.getSprite("MikeWall");
                fixture.Friction = 80;
                //ani = game.getSpriteAnimation("sprite14_strip9");
                ani = game.getSpriteAnimation("SpriteWallSlide");
                if(!determineIfBothCornersIntersect())
                    ani = game.getSpriteAnimation("sprite17");
                doAnimation = true;
                shiftPosition = new Vector2(8, 0);
                isOnWall = true;
                jumpDirection = isWallOnRight;// faceRight;
                faceRight = jumpDirection;
                isFirstAni = true;
            }
            if (body.LinearVelocity.X > 25)
            {
                body.LinearVelocity = new Vector2(25, body.LinearVelocity.Y);

            }
        }
Exemplo n.º 4
0
        public void LoadContent()
        {
            if (loadFromCT)
            {
                if (game.cutScene > Constants.TOTAL_NUMBER_OF_WORLDS)
                    game.cutScene = 1;

                itemSprite = new Sprite(game.Content, "CutScene" + game.cutScene + "\\" + spriteNumber);
                ani = game.getSpriteAnimation("Error");
            }
            else
            {
                itemSprite = game.getSprite(spriteNumber);
                ani = game.getSpriteAnimation(spriteNumber);
            }
        }
Exemplo n.º 5
0
 public void LoadContent()
 {
     playerSprite = game.getSprite("MikeRun1");
     ani = game.getSpriteAnimation("player_strip12");
 }
Exemplo n.º 6
0
        public void LoadContent()
        {
            playerSprite = game.getSprite(spriteNumber);
            ani = game.getSpriteAnimation(spriteNumber);
            //game.stopWatchLagTimer.Start();
            //XNA Framework HiDef profile supports a maximum Texture2D size of 4096
            //if ((spriteNumber.Equals("bigBlock") || spriteNumber.Equals("groundWall"))&& width < 4096 && height < 4096)
            //{
            if (spriteNumber.Equals("bigBlock"))
            {
                if (game.currentWorld == 2)
                {
                    playerSprite = game.getSprite("blockWorld2");
                    //ani = game.getSpriteAnimation("blockWorld2");
                }
                else
                {
                    playerSprite = game.getSprite("blockWorld1");
                    //ani = game.getSpriteAnimation("blockWorld1");
                }

            }

            #if WINDOWS
            if ((spriteNumber.Equals("bigBlock"))&& width < 4096 && height < 4096 && Constants.BLOCK_EFFECT)
            {
                Color[] cData = new Color[(int)((int)width * (int)height)];
                game.stopWatchLagTimer.Start();
                dynamicPattern = game.getCachedDirt(new Rectangle((int)body.Position.X, (int)body.Position.Y, (int)width, (int)height));
                game.stopWatchLagTimer.Stop();
                if (dynamicPattern == null)
                {

                    Color[] template;

                    template = new Color[255 * 255];
                    //int demi = 95;
                    //game.getSprite("dirtyBlock2").index.GetData<Color>(template);

                    int demi = 255;
                    game.getSprite("pixGroundTemp").index.GetData<Color>(template);

                    //template = new Color[125 * 125];
                    //int demi = 125;
                    //game.getSprite("groundBad").index.GetData<Color>(template);

                    if (game.currentWorld == 2)
                    {
                        template = new Color[64 * 64];
                        game.getSprite("WaterGBlock").index.GetData<Color>(template);
                        demi = 64;

                    }

                    int counter = 0;
                    int maxCounter = template.Length;
                    for (int x = 0; x < width; x++)
                    {
                        for (int y = 0; y < height; y++)
                        {
                            int xMod = (int)origPos.X-(int)width/2+ x;// % 95;
                            int yMod = (int)origPos.Y - (int)height / 2 + y; //y % 95;
                            //xMod = xMod / (int)width;
                            //yMod = yMod / (int)height;
                            xMod = xMod % demi;
                            yMod = yMod % demi;

                            if (xMod < 0)
                            {
                                xMod = xMod+demi;
                            }
                            if (yMod < 0)
                            {
                                yMod =yMod+demi;
                            }
                            Color tempColor=template[xMod + yMod * demi];
                            if ((int)(x + y * (int)width) < cData.Length)
                            {
                                cData[(int)(x + y * (int)width)] = tempColor;

                            }
                            counter++;
                            if (counter == maxCounter)
                                counter = 0;//new Color(121, 98, 45);
                        }
                    }

                    GraphicsDevice gd= game.drawingTool.getGraphicsDevice();
                    this.dynamicPattern = new Texture2D(gd, (int)width, (int)height);
                    gd.Clear(Color.Black);
                    dynamicPattern.SetData<Color>(cData);
                    game.addCachedDirt(new Rectangle((int)body.Position.X, (int)body.Position.Y, (int)width, (int)height), dynamicPattern);
                }
                heightDiff = playerSprite.index.Height - height;
                widthDiff = playerSprite.index.Width - width;
                //origin = new Vector2(width / 2, height / 2);
            }
            #endif
        }
Exemplo n.º 7
0
 public void LoadContent()
 {
     itemSprite = game.getSprite(spriteName);
     ani = game.getSpriteAnimation(spriteName);
 }
Exemplo n.º 8
0
 public void LoadContent()
 {
     playerSprite = game.getSprite(spriteNumber);
     ani = new SpriteStripAnimationHandler(new Sprite(game.Content, "bubbleSpriteSheet"), 4, 240);
 }
Exemplo n.º 9
0
 public void LoadContent()
 {
     playerSprite = game.getSprite(spriteNumber);
     ani = game.getSpriteAnimation(spriteNumber);
     blackSprite = game.getSprite("black");
     blackCircleSprite = game.getSprite("blackCircle");
     redCircleSprite = game.getSprite("redCircle");
     redSprite = game.getSprite("red");
 }