0

我想开发一个棋盘游戏。我可以只使用 Windows 窗体应用程序创建它吗?我不想使用 XNA 。如果可以使用 windows 窗体应用程序创建,我如何将其转换为可执行文件。我不想将它作为控制台应用程序运行。我想将它创建为 Game 。

/*
It is a board game.
        15   14    13    12     11    10    9
        16   28    29    30     31    32    8
        17   27    42    43     44    33    7
        18   26    41    48     45    34    6  
        19   25    40    47     46    35    5
        20   24    39    38     37    36    4
        21   22    23     0      1     2    3

 It is my board structure . Player one starts at square 0 . If he puts one , he will   
 get into the game . Then he can move his coin up to 23.He can get into 24 , if he 
 already cut the other player coins . Cut in the sense , player 0 places his coin on a 
 square that contains another player coins.Then he can move his coin from 24 to 48 .    
 when the coin reaches 48 , it will be completed . If player 0 completes his 6 coins 
 first , he will be the winner .   
*/
namespace ConsoleApplication1
{
class Program
{
    public static int playerCount;
    public static int totalSquares = 49;
    public static int totalCoins = 6;
    public static bool errorFlag = false;
    public static bool flagrepeat = false;
    public static bool winner=false;

    static void Main()
    {
        if (ErrorTypes.errors==null)
        {
            ErrorTypes.addMessage();
        }
        getPlayers(); // To get the number of players

        startGame();// It will get the name of the player and 
        // will thorw exception if anything goes wrong and will
        // call the main function again.

    }  
/*
* If a coin reaches center square , then it completes
* A player wins if he completes all the six coins
*/
    public static void setWinner(player[] obj) 
    {
        for (int k = 0; k < Program.playerCount; k++)
        {
            if (obj[k].completedcoins == 6)
            {
                Console.WriteLine("Winner is player " + (k + 1));
                winner = true;
                break;
            }
        }
    }
    public static void play(player[] obj)
    {
        bool rollrepeat; // If a player puts one or five or six , he will get another          chance.
        board boards = new board(); // It contains 49 squares
        List<int> rollstore = new List<int>(10); // To store the rolls of a single  player. 
    // Eg is [6,5,6,2] . Coz no repeat for 2. so his turn ends . Now he has to move the   coin by selecting coin and //rollindex.
        List<int> temprollstore = new List<int>(10);
        int roll;
        bool final = false;
        int i = 0;
        Random rn = new Random(); // To generate roll
        bool flag = false, tempflag = false;

        int[] pos;
        while (true)
        {
            if (!gameover())
            {
                setWinner(obj);
                if (final == false)
                {
                    i = 0;
                    while (i < Program.playerCount)
                    {
    /*
    * to reset the flags so that another player can use it
    */
                        if (flag == true || flagrepeat == true)
                        {
                            flagrepeat = false;
                            flag = false;
                        }
    /*
    * 
    */
                        while (true)
                        {                  
            // This part of the does the job of storing the rolls and call the move   function
    // when the roll ends
          }        
                    }
                    print(obj);
                    Console.WriteLine("\n\nPress a Key To Go Next Round ");
                    Console.ReadKey();
                }
                else
                {
                    break;
                }
            }
        }
    }

请建议我创建板并将硬币放在广场上的方法。

4

2 回答 2

1

Windows Form Application您可以通过选择创建一个

文件-新建项目-Visual C# 或 Visual Basic - Windows 窗体应用程序

在那里,您可以根据需要开发您的游戏。

默认情况下,Visual Studio 在[Project's path]\Bin\Debug[Project's path]\Bin\Release根据您编译的构建配置创建项目的输出文件。这可以从项目的属性中更改。

在这些文件夹中,该.exe文件以及它需要正确执行的其他文件、资源或 dll 位于其中。

从那里你可以.exe双击运行你的,不需要视觉工作室。

您可以从此处了解有关 Visual Studio 输出文件的更多信息

希望这可以帮助

于 2013-09-22T13:09:17.283 回答
0

是的你可以。只需选择 File-New Project-Visual C# 或 Visual Basic-Forms Application。

然后当你完成编码时,只需编译为发布(在 Visual Studio 的顶部栏中选择发布,默认调试并编译),你的 .exe 文件将在你的(项目文件夹)/bin/release 中。

拿这个文件,你现在不需要 Visual Studio 来运行。

于 2013-09-22T12:57:44.117 回答