Exemplo n.º 1
0
 public override bool Target(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     if (target != null &&
         target.ownedByPlayer != user.ownedByPlayer &&
         user.isAlive &&
         BattleBoard.GetBlockDistanceBetweenDice(user, target) <= range)
     {
         return(true);
     }
     else
     {
         if (target != null)
         {
             String failString = "";
             if (user.isAlive == false)
             {
                 failString = " as " + user.name + " is dead.";
             }
             else if (BattleBoard.GetBlockDistanceBetweenDice(user, target) > range)
             {
                 failString = " as target is out of range.";
             }
             usageDescription = name + " failed" + failString;
         }
         return(false);
     }
 }
Exemplo n.º 2
0
        public bool Move(Vector2 targetBoardLocation)
        {
            if (BattleBoard.GetBoardTile((int)targetBoardLocation.X, (int)targetBoardLocation.Y) == null)
            {
                return(false);
            }
            if (BattleBoard.GetBoardTile((int)targetBoardLocation.X, (int)targetBoardLocation.Y).occupyingDiceman != null)
            {
                return(false);
            }
            if (BoardLocation.X != -1 && BoardLocation.Y != -1)
            {
                BattleBoard.board[BoardLocX, BoardLocY].occupyingDiceman = null;
            }
            else
            {
                isOnBoard = true;
            }
            Vector2 tempLoc = BoardLocation;

            BoardLocation = targetBoardLocation;
            if (BattleBoard.GetBoardTile(BoardLocX, BoardLocY) != null)
            {
                BattleBoard.board[BoardLocX, BoardLocY].occupyingDiceman = this;
            }
            else
            {
                BoardLocation = tempLoc;
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[2])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     if (target.isAlive)
     {
         float  damageDealt         = user.strength * damage;
         String damageDealtDescript = target.DamageDice(damageDealt);
         if (target.isAlive)
         {
             BattleBoard.AddEffect(new AbilityInput(
                                       user,
                                       new Stunned(0, Constant.e_stunDuration, 0, Constant.e_stunSpeed, Constant.e_stunIcon),
                                       target,
                                       Vector2.Zero));
             usageDescription = damageDealtDescript + " and is STUNNED.";
         }
         else
         {
             usageDescription = damageDealtDescript + ".";
         }
     }
     else
     {
         usageDescription = "Target is already dead.";
     }
 }
Exemplo n.º 4
0
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[2])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     for (int i = -range; i <= range; i++)
     {
         for (int j = -range; j <= range; j++)
         {
             if (BattleBoard.GetBoardTile(user.BoardLocX + i, user.BoardLocY + j) != null)
             {
                 target = BattleBoard.GetBoardTile(user.BoardLocX + i, user.BoardLocY + j).occupyingDiceman;
                 if (target != null && target.isAlive && target.ownedByPlayer != user.ownedByPlayer)
                 {
                     float damageDealt = user.strength * damage;
                     usageDescription = target.DamageDice(damageDealt);
                     user.Move(firedBoardLocation);
                     usageDescription += " and \n" + user.ownedByPlayer.playerName + "'s " + user.name + " vaulted away.";
                     return;
                 }
             }
         }
     }
     usageDescription = name + " failed as no enemies \nwere in range.";
 }
Exemplo n.º 5
0
        public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
        {
            foreach (Effect debuff in user.activeEffects)
            {
                if (!debuff.AllowedDiceAbilities()[2])
                {
                    usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
                    return;
                }
            }
            int            hitsCount = Constant.a_multishotHits;
            List <Diceman> diceHit   = new List <Diceman>();

            if (target.isAlive && BattleBoard.GetBlockDistanceBetweenDice(user, target) <= range)
            {
                float damageDealt = user.strength * damage;
                usageDescription = target.DamageDice(damageDealt);
                hitsCount--;
                diceHit.Add(target);
            }
            for (int i = -range; i <= range; i++)
            {
                for (int j = -range; j <= range; j++)
                {
                    if (BattleBoard.GetBoardTile(user.BoardLocX + i, user.BoardLocY + j) != null && hitsCount > 0)
                    {
                        target = BattleBoard.GetBoardTile(user.BoardLocX + i, user.BoardLocY + j).occupyingDiceman;
                        foreach (Diceman dice in diceHit)
                        {
                            if (dice == target)
                            {
                                target = null;
                            }
                        }
                        if (target != null && target.isAlive && target.ownedByPlayer != user.ownedByPlayer &&
                            BattleBoard.GetBlockDistanceBetweenDice(user, target) <= range)
                        {
                            float damageDealt = user.strength * damage;
                            if (hitsCount == Constant.a_multishotHits)
                            {
                                usageDescription = "";
                            }
                            usageDescription += target.DamageDice(damageDealt);
                            hitsCount--;
                        }
                    }
                }
            }
            if (hitsCount == Constant.a_multishotHits)
            {
                usageDescription = name + " failed as no enemies \nwere in range.";
            }
            else
            {
                usageDescription += ".";
            }
        }
Exemplo n.º 6
0
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[2])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     if (target.isAlive)
     {
         usageDescription = target.ownedByPlayer.playerName + "'s " + target.name + " is now \n" + Constant.e_poisonName + ".";
         BattleBoard.AddEffect(new AbilityInput(
                                   user,
                                   new Poisoned(0, Constant.e_poisonDuration, Constant.a_poisonDamage, Constant.e_poisonSpeed, Constant.e_poisonIcon),
                                   target,
                                   Vector2.Zero));
     }
 }
Exemplo n.º 7
0
        public override bool Target(Diceman user, Diceman target, Vector2 firedBoardLocation)
        {
            if (BattleBoard.GetBoardTile(firedBoardLocation) != null &&
                BattleBoard.GetBoardTile(firedBoardLocation).occupyingDiceman == null &&
                user.isAlive)
            {
                return(true);
            }
            String failString = "";

            if (user.isAlive == false)
            {
                failString = " as " + user.name + " is dead.";
            }
            else if (BattleBoard.GetBoardTile(firedBoardLocation).occupyingDiceman != null)
            {
                failString = " as position is occupied.";
            }
            usageDescription = name + " failed" + failString;
            return(false);
        }
Exemplo n.º 8
0
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[2])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     if (target.isAlive)
     {
         Vector2        moveToLoc      = Vector2.Zero;
         List <Vector2> locsNearTarget = new List <Vector2>();
         for (int i = -1; i <= 1; i++)
         {
             for (int j = -1; j <= 1; j++)
             {
                 if (!(i == 0 && j == 0))
                 {
                     locsNearTarget.Add(new Vector2(target.BoardLocX + i, target.BoardLocY + j));
                 }
             }
         }
         float minDist = BattleBoard.GetRealDistanceBetweenTileLocations(new Vector2(0, 0), new Vector2(BattleBoard.board.GetLength(0), BattleBoard.board.GetLength(1)));
         for (int i = 0; i < locsNearTarget.Count; i++)
         {
             if (BattleBoard.GetRealDistanceBetweenTileLocations(user.BoardLocation, locsNearTarget[i]) < minDist)
             {
                 minDist   = BattleBoard.GetRealDistanceBetweenTileLocations(user.BoardLocation, locsNearTarget[i]);
                 moveToLoc = locsNearTarget[i];
             }
         }
         locsNearTarget.Remove(moveToLoc);
         while (user.BoardLocation != moveToLoc && !user.Move(moveToLoc))
         {
             if (locsNearTarget.Count != 0)
             {
                 minDist = BattleBoard.board.Length;
                 for (int i = 0; i < locsNearTarget.Count; i++)
                 {
                     if (BattleBoard.GetRealDistanceBetweenTileLocations(user.BoardLocation, locsNearTarget[i]) < minDist)
                     {
                         minDist   = BattleBoard.GetRealDistanceBetweenTileLocations(user.BoardLocation, locsNearTarget[i]);
                         moveToLoc = locsNearTarget[i];
                     }
                 }
                 locsNearTarget.Remove(moveToLoc);
             }
             else
             {
                 usageDescription = Constant.a_chargeTargetSurrounded;
                 return;
             }
         }
         float damageDealt = user.strength * damage;
         usageDescription  = user.ownedByPlayer.playerName + "'s " + user.name + " charged and\n";
         usageDescription += target.DamageDice(damageDealt);
         usageDescription += ".";
     }
     else
     {
         usageDescription = "Target is already dead.";
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
            InputManager.Update(gameTime);
            switch (currentGameState)
            {
            case GameState.MainMenu:
                if (InputManager.keyboardState.IsKeyDown(Keys.H))
                {
                    host             = new GameHost();
                    client           = new GameClient("localhost", new Player("Host"));
                    currentGameState = GameState.MultiplayerLobby;
                }
                else if (InputManager.keyboardState.IsKeyDown(Keys.J))
                {
                    client           = new GameClient("", new Player("Client"));
                    currentGameState = GameState.MultiplayerLobby;
                }
                break;

            case GameState.MultiplayerLobby:
                if (client.IsGameJoined && InputManager.keyboardState.IsKeyDown(Keys.S))
                {
                    if (host != null)
                    {
                        client.SendGameStartMsg();
                    }
                }
                if (client.isGameStarted)
                {
                    opponentPlayer = client.OpponentPlayer;
                    loggedInPlayer = client.LoggedInPlayer;
                    board          = new BattleBoard(
                        boardTileTextures,
                        mainUIFont,
                        new Vector2(320, -192),
                        Constant.o_boardSize,
                        loggedInPlayer,
                        opponentPlayer,
                        client,
                        new Vector2(this.Window.ClientBounds.Width, this.Window.ClientBounds.Height));
                    client.SendDiceConfiguration(new Diceman.Class[]
                    {
                        Diceman.Class.Bruiser,
                        Diceman.Class.Bruiser,
                        Diceman.Class.Bruiser,
                        Diceman.Class.Ranger,
                        Diceman.Class.Ranger
                    });
                    currentGameState = GameState.Playing;
                }
                break;

            case GameState.Playing:
                if (client.IsGameJoined)
                {
                    board.Update(gameTime);
                }
                else
                {
                    if (host != null)
                    {
                        host.StopServer();
                        host = null;
                    }
                    client           = null;
                    board            = null;
                    opponentPlayer   = null;
                    loggedInPlayer   = new Player(loggedInPlayer.playerName);
                    currentGameState = GameState.MainMenu;
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                break;
            }
            base.Update(gameTime);
        }