예제 #1
0
        private CombatLocation getLocation(Player player, String coordsAsString)
        {
            int i = 0;
            int j = 0;

            try
            {
                String[] coords = coordsAsString.Split(',');
                if (coords.Length != 2)
                {
                    return(null);
                }

                i = Convert.ToInt16(coords[0]);
                j = Convert.ToInt16(coords[1]);
            }
            catch (Exception ex)
            {
                return(null);
            }

            CombatLocation endLocation = new CombatLocation(player.Location.board, i, j, player.Location.direction);

            return(endLocation);
        }
예제 #2
0
        public void startLevel(Party party, int level)
        {
            this.level = level;

            // TO DO:  Need to do this in XML
            // Set the main player location and add them to the board
            Player         mainPlayer = party.getMainPlayer();
            CombatLocation location   = new CombatLocation(this.board, 9, 9, AnimationKey.NorthEast);

            mainPlayer.Location = location;
            board.addGameEntity(mainPlayer);

            Player soldier = party.getHumanByReferenceName("soldier");

            location         = new CombatLocation(this.board, 9, 2, AnimationKey.NorthEast);
            soldier.Location = location;
            board.addGameEntity(soldier);

            this.turnBased.startLevel(level);
            this.screen.startLevel(level);

            try
            {
                combatTheme = lhg.Content.Load <Song>("Audio/combat theme_1");
                MediaPlayer.Play(combatTheme);
                MediaPlayer.IsRepeating = true;
            }
            catch
            {
            }
        }
예제 #3
0
        public List <Hex> getHexPath(Player player, Point point)
        {
            List <Hex> hexPath = null;

            CombatLocation startLocation = player.Location;
            HexBoard       hexBoard      = startLocation.board.MyHexBoard;
            Hex            startHex      = hexBoard.getHex(startLocation.i, startLocation.j);
            Hex            endHex        = hexBoard.FindHexMouseClick(point);

            if (startHex != null && endHex != null)
            {
                hexPath = startLocation.board.findPath(startHex, endHex);
            }

            return(hexPath);
        }
예제 #4
0
        public int movePlayer(Player player, Point mousePoint, AnimationCallback callback)
        {
            Hex endHex = player.MyBoard.findHexAt(mousePoint);

            if (endHex != null)
            {
                // Make sure the hex that the user clicked on is an allowable move

                //if (hexBoard.BoardState.isCellSelected(endHex))
                {
                    CombatLocation endLocation = new CombatLocation(player.Location.board, endHex.I, endHex.J, player.Location.direction);
                    return(movePlayer(player, endLocation, callback));
                }
            }

            return(0);
        }
예제 #5
0
        public int movePlayer(Player player, CombatLocation endLocation, int numCellsToMove, AnimationCallback callback)
        {
            CombatLocation startLocation = player.Location;
            Hex            startHex      = hexBoard.getHex(startLocation.i, startLocation.j);

            if (startHex != null)
            {
                Hex endHex = hexBoard.getHex(endLocation.i, endLocation.j);
                if (endHex != null)
                {
                    // Only move the player the number of action points they have
                    return(movePlayer(player, startHex, endHex, numCellsToMove, callback));
                }
            }

            return(0);
        }
예제 #6
0
        public int movePlayer(Player player, CombatLocation endLocation, AnimationCallback callback)
        {
            int numHexesMoved = 0;

            CombatLocation startLocation = player.Location;
            HexBoard       hexBoard      = startLocation.board.MyHexBoard;
            Hex            startHex      = hexBoard.getHex(startLocation.i, startLocation.j);

            if (startHex != null)
            {
                Hex endHex = hexBoard.getHex(endLocation.i, endLocation.j);
                if (endHex != null)
                {
                    // Get the hexes that are along the way to the path the user clicked on.
                    List <Hex> hexPath = startLocation.board.findPath(startHex, endHex);
                    movePlayer(player, hexPath, callback);
                    numHexesMoved = hexPath.Count;
                }
            }

            return(numHexesMoved);
        }
예제 #7
0
        private void handleMove(LHGConsole console, String[] arguments)
        {
            // move player 1 2,3
            if (arguments.Length < 4)
            {
                console.WriteLine("Error: Invalid number of arguments for move command!");
            }
            else
            {
                if (arguments[1].Equals("player"))
                {
                    Player player = getPlayer(arguments[2]);
                    if (player == null)
                    {
                        console.WriteLine("Error: Unable to find player '" + arguments[2] + "'!");
                    }

                    CombatLocation endLocation = getLocation(player, arguments[3]);
                    //this.combatSystem.movePlayer( player, endLocation );
                }
            }
        }
예제 #8
0
        public int movePlayer(Player player, int i, int j, AnimationCallback callback)
        {
            CombatLocation endLocation = new CombatLocation(player.Location.board, i, j, player.Location.direction);

            return(movePlayer(player, endLocation, callback));
        }
예제 #9
0
 public Hex getHexNextTo(CombatLocation location)
 {
     return(getHexNextTo(location.getHex(), location.direction));
 }