Esempio n. 1
0
        public void CheckCollision(FT_Character checkingPlayer, int counter)
        {
            for (int i = 0; i < characters.Length; i++)
            {
                if (counter != i)
                {
                    if (characters[i] != null && !characters[i].dead && !characters[i].dying)
                    {
                        if (checkingPlayer.collides(characters[i]))
                        {
                            if (checkingPlayer.position.X < characters[i].position.X)
                            {
                                checkingPlayer.velocity.X = -1.5f;
                                characters[i].velocity.X = 1.5f;
                            }
                            else
                            {
                                checkingPlayer.velocity.X = 1.5f;
                                characters[i].velocity.X = -1.5f;
                            }

                            soundBank.PlayCue("Collision");
                            characters[i].CurrentAction = FT_Character.Action.Knockback;
                            checkingPlayer.CurrentAction = FT_Character.Action.Knockback;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public bool collides(FT_Character player)
 {
     Rectangle firewallRectangle = new Rectangle((int)(position.X - size.X / 2), (int)(position.Y - size.Y / 2), (int)size.X, (int)size.Y);
     Rectangle playerRectangle = new Rectangle((int)player.position.X, (int)(player.position.Y + (64 - size.Y)), (int)player.collisionSize.X, (int)player.collisionSize.Y);
     if (firewallRectangle.Intersects(playerRectangle))
         return true;
     return false;
 }
Esempio n. 3
0
 public bool collides(FT_Character player)
 {
     Rectangle fireballRectangle = new Rectangle((int)position.X, (int)(position.Y), (int)size.X, (int)size.Y);
     Rectangle playerRectangle = new Rectangle((int)player.position.X, (int)(player.position.Y + (64 - size.Y)), (int)player.collisionSize.X, (int)player.collisionSize.Y);
     if (fireballRectangle.Intersects(playerRectangle) && active == true)
     {
         active = false;
         return true;
     }
     return false;
 }
Esempio n. 4
0
 public void CheckFireCollision(FT_Character checkingPlayer)
 {
     if (leftFire.collides(checkingPlayer) || rightFire.collides(checkingPlayer))
     {
         checkingPlayer.dying = true;
         checkingPlayer.CurrentAction = FT_Character.Action.Slide;
     }
     else
     {
         foreach (Fireball fb in fireballsReleased)
         {
             if (fb.bounces > 2)
             {
                 fb.active = false;
             }
             else if (fb.collides(checkingPlayer))
             {
                 fb.active = false;
                 checkingPlayer.dying = true;
                 checkingPlayer.CurrentAction = FT_Character.Action.Slide;
             }
         }
     }
 }
Esempio n. 5
0
        private void SoloPlayerInput(FT_Character player, GamePadState padState, Keys shoot, Keys left, Keys right, Keys specialAttack, float elapsedTime)
        {
            if (currentKeyboardState.IsKeyDown(shoot) || padState.IsButtonDown(Buttons.A))
            {
                player.CurrentAction = FT_Character.Action.Freeze;
                if (!isShot && numberOfShots > 0)
                {
                    isShot = true;
                    numberOfShots--;
                    if (player.isMovingLeft)
                    {
                        fireballVelocity = new Vector2(-5.0f, 2.5f);
                    }
                    else
                    {
                        fireballVelocity = new Vector2(5.0f, 2.5f);
                    }

                    fireballsReleased.Add(new Fireball(fireball, player.position + new Vector2(0.0f, 64.0f), fireballVelocity, 0.5f));
                }
            }
            else if (currentKeyboardState.IsKeyDown(specialAttack) || padState.IsButtonDown(Buttons.B))
            {
                player.CurrentAction = FT_Character.Action.Freeze;
                if (!isShot && numberOfShots >= 3)
                {
                    isShot = true;
                    numberOfShots -= 3;
                    fireballVelocity = new Vector2(5.0f, 0.0f);
                    fireballsReleased.Add(new Fireball(fireball, new Vector2(0.0f, Fireball.groundLevel), fireballVelocity, 1.0f));
                }
            }
            else if (currentKeyboardState.IsKeyDown(left) || padState.IsButtonDown(Buttons.DPadLeft))
            {
                player.CurrentAction = FT_Character.Action.RunLeft;
            }
            else if (currentKeyboardState.IsKeyDown(right) || padState.IsButtonDown(Buttons.DPadRight))
            {
                player.CurrentAction = FT_Character.Action.RunRight;
            }
            else
            {
                player.CurrentAction = FT_Character.Action.Freeze;
            }

            if (isShot)
            {
                shootTimer -= elapsedTime;
                if (shootTimer <= 0.0f)
                {
                    isShot = false;
                    shootTimer = 1500.0f;
                }
            }
            if (numberOfShots < 5)
            {
                fireballTimer += elapsedTime;
                if (fireballTimer > 3000.0f)
                {
                    fireballTimer = 0.0f;
                    numberOfShots++;
                }
            }
        }
Esempio n. 6
0
        private void PlayerInput(FT_Character player, GamePadState padState, Keys duck, Keys jump, Keys left, Keys right, float elapsedTime)
        {
            if (player.dying)
            {
                player.CurrentAction = FT_Character.Action.Slide;
            }
            else
            {
                if (player.CurrentAction == FT_Character.Action.Knockback)
                {
                    //  do nothing until knockback effect is over.
                }
                else
                {
                    player.CurrentAction = FT_Character.Action.Freeze;

                    if (currentKeyboardState.IsKeyDown(left) || padState.IsButtonDown(Buttons.DPadLeft))
                    {
                        player.CurrentAction = FT_Character.Action.RunLeft;
                    }
                    if (currentKeyboardState.IsKeyDown(right) || padState.IsButtonDown(Buttons.DPadRight))
                    {
                        player.CurrentAction = FT_Character.Action.RunRight;
                    }
                    if (currentKeyboardState.IsKeyDown(duck) || padState.IsButtonDown(Buttons.X))
                    {
                        player.CurrentAction = FT_Character.Action.Duck;
                    }
                    if (currentKeyboardState.IsKeyDown(jump) || padState.IsButtonDown(Buttons.A))
                    {
                        player.CurrentAction = FT_Character.Action.Jump;
                        if (player.onGround)
                        {
                            soundBank.PlayCue("Jump");
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        public void LoadContent(ContentManager Content, Vector2 center)
        {
            soloPosition = center + new Vector2(100, -270);
            elevatedHeight = 50.0f;
            fireball = Content.Load<Texture2D>("FireballTactics/Fireball");
            fireballMeter = Content.Load<Texture2D>("FireballTactics/FireballMeter");
            fireballsReleased = new List<Fireball>();
            firewall = Content.Load<Texture2D>("FireballTactics/Firewall");

            leftFire = new Firewall(firewall, new Vector2(96.0f, (center.Y * 2) - (72.0f + elevatedHeight)), 3.0f, 0, true);
            rightFire = new Firewall(firewall, new Vector2((center.X * 2) - 96.0f, (center.Y * 2) - (72.0f + elevatedHeight)), 3.0f, 2, true);

            numberOfShots = 5;
            isShot = false;
            shootTimer = 1500.0f;
            fireballRectangle = new Rectangle(0, 0, 64, 64);

            characters = new FT_Character[4];
            deathFlames = new Firewall[4];
            audioEngine = new AudioEngine(@"Content\Character\LumberjackBustle.xgs");

            waveBank = new WaveBank(audioEngine, @"Content\Character\Wave Bank.xwb");
            soundBank = new SoundBank(audioEngine, @"Content\Character\Sound Bank.xsb");

            players[0].sprite = Content.Load<Texture2D>(@"Character\BlueKnightSpriteSheet");
            players[1].sprite = Content.Load<Texture2D>(@"Character\PinkKnightSpriteSheet");
            players[2].sprite = Content.Load<Texture2D>(@"Character\BlackKnightSpriteSheet");
            players[3].sprite = Content.Load<Texture2D>(@"Character\GreenKnightSpriteSheet");
            // whoever's the loser will be on top.
            for (int i = 1; i < 4; i++)
            {
                if (players[i] != null)
                {
                    if (players[i].Score < players[id1].Score)
                    {
                        id1 = i;
                    }
                }
            }

            int bottomCount = 0;
            for (int i = 0; i < 4; i++)
            {
                if (i == id1)
                {
                    characters[i] = new FT_Character();
                    characters[i].Initialize(players[i].sprite,
                                          soloPosition,
                                          Vector2.Zero);
                    characters[i].team = 0;
                    deathFlames[i] = new Firewall(firewall, new Vector2(96.0f, (center.Y * 2) - (72.0f + elevatedHeight)), 1.5f, 0, false);
                }
                else
                {
                    characters[i] = new FT_Character();
                    characters[i].Initialize(players[i].sprite,
                                          new Vector2(center.X - 100 + bottomCount * 100, FT_Character.groundLevel),
                                          Vector2.Zero);
                    characters[i].team = 1;
                    deathFlames[i] = new Firewall(firewall, new Vector2(96.0f, (center.Y * 2) - (72.0f + elevatedHeight)), 1.5f, 0, false);
                    bottomCount++;
                }
            }
        }
Esempio n. 8
0
 public bool collides(FT_Character otherPlayer)
 {
     if (currentAction != Action.Knockback)
     {
         Rectangle playerRectangle = new Rectangle((int)position.X, (int)(position.Y + (64 - size.Y)), (int)collisionSize.X, (int)collisionSize.Y);
         Rectangle otherPlayerRectangle = new Rectangle((int)otherPlayer.position.X, (int)(otherPlayer.position.Y + (64 - otherPlayer.size.Y)), (int)otherPlayer.collisionSize.X, (int)otherPlayer.collisionSize.Y);
         if (playerRectangle.Intersects(otherPlayerRectangle))
             return true;
     }
     return false;
 }