Esempio n. 1
0
 public Score(DuelScreen screen)
 {
     score = 0;
     increase = 0;
     multiplier = 0;
     turnAmount = 0;
     this.screen = screen;
     totalTurns = 0;
     timer = 0f;
 }
Esempio n. 2
0
        public GunWindow(DuelScreen screen)
        {
            this.screen = screen;
            state = State.STATE_NONE;
            timmer = 0;
            hammerAngle = 0;
            triggerAngle = 0;
            gunImage = Game1.IMAGE_GUN;
            hammerImage = Game1.IMAGE_HAMMER;
            triggerImage = Game1.IMAGE_TRIGGER;
            spriteEffect = SpriteEffects.None;

            if (screen.player == PlayerIndex.Two)
            {
                gunImage = Game1.IMAGE_GUN2;
                hammerImage = Game1.IMAGE_HAMMER2;
                triggerImage = Game1.IMAGE_TRIGGER2;
                spriteEffect = SpriteEffects.FlipHorizontally;
                HAMMER_PIVOT_X = 8;
                HAMMER_PIVOT_Y = 32;
                TRIGGER_PIVOT_X = 11;
                TRIGGER_PIVOT_Y = 6;
            }
        }
Esempio n. 3
0
        public void update(GameTime time, DuelScreen game)
        {
            float force = 1.2f;
            float rForce;
            float fAngle;
            float pfAngle;
            float aAccel;
            float targetAngle = angle;

            Vector2 newPosition = new Vector2 (position.X, position.Y);
            newPosition += game.movementVector;

            if(thrown)
            {
                throwVelocity.Y += g;
                thrownPosition += throwVelocity;

                if (DuelScreen.distance(position, thrownPosition) < CATCH_DISTANCE && throwVelocity.Y > 0 && grab && game.bullets > 0)
                {
                    thrown = false;
                    if (player == PlayerIndex.One)
                    {
                        Game1.SOUND_WHIRL.Play(0.5f, 0, -1);
                    }
                    else
                    {
                        Game1.SOUND_WHIRL.Play(0.5f, 0, 1);
                    }

                    if(!game.won)
                        game.P1Score.scoreThrow(time);
                }
            }

            if (grab && !thrown)
            {
                //adjust angle of the gun if I just grabbed it
                if (justGrabbed)
                {
                    justGrabbed = false;
                    if (Math.Abs(MathHelper.WrapAngle(angle) - MathHelper.WrapAngle(myArm.getArmAngle())) < Math.Abs(MathHelper.WrapAngle(angle) - MathHelper.WrapAngle(myArm.getArmAngle() + (MathHelper.Pi / 2f))))
                    {
                        targetAngle = MathHelper.WrapAngle(myArm.getArmAngle());
                        aVelocity = 0f;
                        flatAngle = true;
                    }
                    else
                    {
                        targetAngle = MathHelper.WrapAngle(myArm.getArmAngle() + (MathHelper.Pi / 2f));
                        aVelocity = 0f;
                        flatAngle = false;
                    }
                }
                else
                {
                    // keep gun lined up with hand
                    if (flatAngle)
                    {
                        targetAngle = angle = MathHelper.WrapAngle(myArm.getArmAngle());
                        aVelocity = 0f;

                    }
                    else
                    {
                        targetAngle = angle = MathHelper.WrapAngle(myArm.getArmAngle() + (MathHelper.Pi / 2f));
                        aVelocity = 0f;
                    }
                }

                if (DuelScreen.distance(newPosition, myArm.joints[Arm.shoulder]) < Arm.ARM_LENGTH * 2f)
                {
                    position += game.movementVector;
                }
                else
                {
                    game.movementVector = Vector2.Zero;
                }

                if (Math.Abs(angle - targetAngle) > 0.01)
                {
                    angle -= (angle - targetAngle) / 10f;
                }
                else
                {
                    angle = targetAngle;
                }

            }
            else
            {
                if (DuelScreen.distance(newPosition, myArm.joints[Arm.shoulder]) < Arm.ARM_LENGTH * 2f)
                {
                    position += game.movementVector;
                }
                else
                {
                    game.movementVector = Vector2.Zero;
                }

                if ((game.movementVector.X != 0 || game.movementVector.Y != 0) && !thrown)
                {
                    //force due to movement
                    fAngle = (float)Math.Atan2(game.movementVector.Y, game.movementVector.X);
                    pfAngle = angle - fAngle;
                    rForce = (float)Math.Sin(pfAngle) * force;
                    aAccel = rForce * (float)time.ElapsedGameTime.TotalSeconds;
                    aVelocity += aAccel;
                }
                else
                {
                    fAngle = (float)Math.Atan2(1, 0.0);
                    pfAngle = MathHelper.WrapAngle(angle) /*+ MathHelper.Pi*/ - fAngle;
                    rForce = (float)Math.Sin(pfAngle) * g;
                    aAccel = rForce * (float)time.ElapsedGameTime.TotalSeconds;
                    aVelocity += aAccel;

                    float pos = (aVelocity > 0 ? 1.0f : -1.0f);
                    aAccel = 0.001f * pos;

                    if (Math.Abs(aVelocity) > 0.001f)
                        aVelocity -= 1 * aAccel;
                    else
                        aVelocity = 0;
                }

                angle += aVelocity;
                angle = MathHelper.WrapAngle(angle);
            }

            if (!thrown && DuelScreen.distance(position, new Vector2(HOLSTER_X, HOLSTER_Y)) < CATCH_DISTANCE)
            {
                if (grab)
                {
                    targetAngle = MathHelper.WrapAngle(myArm.getArmAngle());
                    flatAngle = true;
                    justGrabbed = false;
                    if (holstered)
                    {
                        holstered = false;
                        if (player == PlayerIndex.One)
                        {
                            Game1.SOUND_HOLSTER1.Play(1, 0, -1);
                            Game1.SOUND_WHIRL.Play(0.5f, 0, -1);
                        }
                        else
                        {
                            Game1.SOUND_HOLSTER1.Play(1, 0, 1);
                            Game1.SOUND_WHIRL.Play(0.5f, 0, 1);
                        }
                    }
                }
                else if (!holstered)
                {
                    holstered = true;
                    if (player == PlayerIndex.One)
                        Game1.SOUND_HOLSTER2.Play(1, 0, -1);
                    else
                        Game1.SOUND_HOLSTER2.Play(1, 0, 1);
                }
            }

            if (holstered || DuelScreen.distance(position, new Vector2(HOLSTER_X, HOLSTER_Y)) < CATCH_DISTANCE)
            {
                angle = HOLSTER_ANGLE;
            }
        }
Esempio n. 4
0
        public void update(GameTime time, DuelScreen game)
        {
            joints[hand] = gun.position;

            Vector2 diff = joints[elbow];
            diff -= joints[hand];
            double angle = Math.Atan2(diff.Y, diff.X);
            Vector2 tempElbow = new Vector2(ARM_LENGTH * (float)Math.Cos(angle), ARM_LENGTH * (float)Math.Sin(angle));
            tempElbow += joints[hand];
            diff = joints[shoulder] - tempElbow;
            if (Math.Abs(Math.Atan2(diff.Y, diff.X)) == ARM_LENGTH)
            {
                joints[elbow] = tempElbow;
            }
            else
            {
                diff = tempElbow - joints[shoulder];
                angle = Math.Atan2(diff.Y,diff.X);
                //check joint constraint
                double wristAngle = Math.Atan2(joints[hand].Y - joints[elbow].Y, joints[hand].X - joints[elbow].X);

                double aDiff = MathHelper.WrapAngle((float)wristAngle - (float)angle);

                if (aDiff > 0)
                    angle = wristAngle;
                joints[elbow].X = ARM_LENGTH * (float)Math.Cos(angle);
                joints[elbow].Y = ARM_LENGTH * (float)Math.Sin(angle);

                joints[elbow] += joints[shoulder];

                diff = joints[elbow] - tempElbow;
                joints[hand] -= diff;
            }
        }
Esempio n. 5
0
 internal void swapBullet(Bullet b, DuelScreen screen)
 {
     b.rotation = mirrorAngle(b.rotation);
     if (screen == p1Screen)
         ((DuelScreen)p2Screen).firedBullets.Add(b);
     else if (screen == p2Screen)
         ((DuelScreen)p1Screen).firedBullets.Add(b);
 }
Esempio n. 6
0
 internal void setMode(modes mode)
 {
     MediaPlayer.Stop();
     this.mode = mode;
     splashScreen = null;
     if (mode == modes.duel)
     {
         p1Screen = new DuelScreen(this, PlayerIndex.One);
         p2Screen = new DuelScreen(this, PlayerIndex.Two);
         MediaPlayer.Play(MUSIC_BG2);
     }
     else if (mode == modes.title)
     {
         mainScreen = new MenuScreen(this);
         MediaPlayer.Play(MUSIC_BG);
     }
 }
Esempio n. 7
0
 internal bool getEnemyGunState(DuelScreen screen)
 {
     if (screen == p1Screen)
         return !p2Screen.gun.holstered && !p2Screen.droppedGun;
     else
         return !p1Screen.gun.holstered && !p1Screen.droppedGun;
 }