Exemplo n.º 1
0
        public Level(String Player1Name, String Player2Name)
        {
            Player1 = new Character(Player1Name, true);
            Player2 = new Character(Player2Name, false);
            //Player2 = new Character(Player2Name, false, constants.ROBOT_BEHAVIOR.ATTACKING);

            Player1.MySprite.GlobPos = new Vector2(0,
                (int)(constants.GROUND_HEIGHT - (constants.SPRITE_SIZE * constants.SPRITE_SCALE)));
            Player2.MySprite.GlobPos = new Vector2(constants.SCREEN_WIDTH - (int)(constants.SPRITE_WIDTH * constants.SPRITE_SCALE),
                (int)(constants.GROUND_HEIGHT - (constants.SPRITE_SIZE * constants.SPRITE_SCALE)));

            bgRect = new Rectangle(0, 0, constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT);
            roundIndicators = new SimpleSprite[constants.NUM_ROUNDS];
        }
Exemplo n.º 2
0
        public bool shouldBlock(Character otherPlayer)
        {
            int player2XPos = (int)otherPlayer.MySprite.GlobPos.X;

            if (otherPlayer.isAttacking())
            {
                if (isOnLeft && (player2XPos - mySprite.GlobPos.X <= constants.blockDistance))
                    return true;
                else if (!isOnLeft && (mySprite.GlobPos.X - player2XPos <= constants.blockDistance))
                    return true;
            }

            return false;
        }
Exemplo n.º 3
0
        private void playerWin(Character player)
        {
            player.MyWins += 1;

            for (int i = 0; i < roundIndicators.Length; i++)
            {
                if (i < (roundIndicators.Length / 2))
                {
                    if (i < Player1.MyWins)
                        roundIndicators[i].ClipTangle = new Rectangle(40, 0, 40, 40);
                }
                else
                {
                    if ((i - (roundIndicators.Length / 2)) < Player2.MyWins)
                        roundIndicators[i].ClipTangle = new Rectangle(40, 0, 40, 40);
                }
                roundIndicators[i].refreshClipping();
            }

            if (player.MyWins == (constants.NUM_ROUNDS / 2))
            {
                wintext = player.MySprite.charName.ToUpper() + " IS CHAMPION. HOORAY!";
                currentState = constants.LEVELSTATE.GAMEWIN;
            }
            else
            {
                wintext = player.MySprite.charName.ToUpper() + " WINS";
                currentState = constants.LEVELSTATE.ROUNDWIN;
            }

            winTextPos.X = (constants.SCREEN_WIDTH / 2) - (mainFont.MeasureString(wintext).X / 2);
            winTextPos.Y = (constants.SCREEN_HEIGHT / 2) - (mainFont.MeasureString(wintext).Y / 2);
        }
Exemplo n.º 4
0
 private void checkDamage(Character attacker, Character victim)
 {
     if (attacker.MyHitbox.Intersects(victim.MyHitbox))
     {
         if (attacker.isActiveFrame())
         {
             if (!victim.isBlocking())
             {
                 victim.doDamage(attacker.MySprite.damageValues[(int)attacker.MySprite.CurrentAnim]);
                 if (attacker.IsOnLeft)
                 {
                     attacker.incPos(-(attacker.MySprite.pushBack[(int)attacker.MySprite.CurrentAnim]), 0);
                     victim.incPos(attacker.MySprite.pushBack[(int)attacker.MySprite.CurrentAnim], 0);
                 }
                 else
                 {
                     attacker.incPos(attacker.MySprite.pushBack[(int)attacker.MySprite.CurrentAnim], 0);
                     victim.incPos(-attacker.MySprite.pushBack[(int)attacker.MySprite.CurrentAnim], 0);
                 }
             }
             else
             {
                 if (attacker.IsOnLeft)
                 {
                     attacker.incPos(-(attacker.MySprite.blockedPushback[(int)attacker.MySprite.CurrentAnim]), 0);
                     victim.incPos(attacker.MySprite.blockedPushback[(int)attacker.MySprite.CurrentAnim], 0);
                 }
                 else
                 {
                     attacker.incPos(attacker.MySprite.blockedPushback[(int)attacker.MySprite.CurrentAnim], 0);
                     victim.incPos(-attacker.MySprite.blockedPushback[(int)attacker.MySprite.CurrentAnim], 0);
                 }
             }
         }
     }
 }