最简单的C#小游戏编程
只求最简单的C#小游戏编程。。。各位高手帮忙写个吧。。。最短,最简单哈。。。谢谢大家了。。。andfeifei@126.com...
只求最简单的C#小游戏编程。。。各位高手帮忙写个吧。。。最短,最简单哈。。。谢谢大家了。。。
andfeifei@126.com 展开
andfeifei@126.com 展开
展开全部
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Player
{
public string Name;
Card[] cards = new Card[5];
public void InitFiveCards()//五张牌
{
Random md = new Random();
int m = md.Next(1, 14);
for (int i = 0; i < 5; i++)
{
Card card = new Card();
card.Point = md.Next(1, 14);
card.Color = md.Next(0, 4);
cards[i] = card;
}
}
public void display()
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine(cards[i].CardDisplayString());
}
}
public void chosecard() //取牌
{
int n;
Random md = new Random();
int m = md.Next(1, 14);
n = Convert.ToInt32(Console.ReadLine());
Card cd = new Card();
switch (n)
{
case 0:
Table.tablecard = n;
Console.WriteLine("新取的牌");
break;
case 1:
n = m;
Console.WriteLine("上个玩家丢的牌");
break;
}
}
public void throwcard()//丢牌
{
Card[] cards = new Card[5];
Random md = new Random();
int m = md.Next(1, 14);
for (int i = 0; i < 5; i++)
{
Card card = new Card();
card.Point = md.Next(1, 14);
card.Color = md.Next(0, 4);
cards[i] = card;
switch (i)
{
case 0:
card = cards[1];
break;
case 1:
card = cards[2];
break;
case 2:
break;
case 3:
card = cards[3];
break;
case 4:
card = cards[4];
break;
}
}
Console.WriteLine("chose the card:{0}");
}
public void Changeplayer()
{
int m;
}
public bool isWin()
{
for (int i = 1; i < 5;i++ )
{
if (cards[i].Color != cards[0].Color)
{
return false;
}
}
return true;
}
}
class Table
{
public static int tablecard;
public void cunchu()
{
Console.WriteLine(tablecard);
}
}
class Card
{
public int Point;
public int Color;
public string CardDisplayString()
{
string sColor = "";
switch (Color)
{
case 0:
sColor = "红心";
break;
case 1:
sColor = "方块";
break;
case 2:
sColor = "黑桃";
break;
case 3:
sColor = "草花";
break;
}
return string.Format("花色:{0} Point:{1}", sColor, Point);
}
class Program
{
static void Main(string[] args)
{
//1.输入玩家数量
int py;
Console.WriteLine("请输入玩家的数量");
py = int.Parse(Console.ReadLine());
Player[] pys = new Player[py];
//2.输入玩家姓名
for (int m = 0; m < py; m++)
{
pys[m] = new Player();
Console.WriteLine("请输入第{0}玩家名字", m + 1);
pys[m].Name = Console.ReadLine();
pys[m].InitFiveCards();
}
//3.开始游戏
bool isExit = false;
while (!isExit)
{
for (int m = 0; m < py; m++)
{
pys[m].display();
pys[m].chosecard();
pys[m].throwcard();
if (pys[m].isWin())
{
Console.WriteLine("The player name :{0}" + "游戏结束");
isExit = true;
break;
}
}
}
Console.ReadLine();
}
}
}
}
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Player
{
public string Name;
Card[] cards = new Card[5];
public void InitFiveCards()//五张牌
{
Random md = new Random();
int m = md.Next(1, 14);
for (int i = 0; i < 5; i++)
{
Card card = new Card();
card.Point = md.Next(1, 14);
card.Color = md.Next(0, 4);
cards[i] = card;
}
}
public void display()
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine(cards[i].CardDisplayString());
}
}
public void chosecard() //取牌
{
int n;
Random md = new Random();
int m = md.Next(1, 14);
n = Convert.ToInt32(Console.ReadLine());
Card cd = new Card();
switch (n)
{
case 0:
Table.tablecard = n;
Console.WriteLine("新取的牌");
break;
case 1:
n = m;
Console.WriteLine("上个玩家丢的牌");
break;
}
}
public void throwcard()//丢牌
{
Card[] cards = new Card[5];
Random md = new Random();
int m = md.Next(1, 14);
for (int i = 0; i < 5; i++)
{
Card card = new Card();
card.Point = md.Next(1, 14);
card.Color = md.Next(0, 4);
cards[i] = card;
switch (i)
{
case 0:
card = cards[1];
break;
case 1:
card = cards[2];
break;
case 2:
break;
case 3:
card = cards[3];
break;
case 4:
card = cards[4];
break;
}
}
Console.WriteLine("chose the card:{0}");
}
public void Changeplayer()
{
int m;
}
public bool isWin()
{
for (int i = 1; i < 5;i++ )
{
if (cards[i].Color != cards[0].Color)
{
return false;
}
}
return true;
}
}
class Table
{
public static int tablecard;
public void cunchu()
{
Console.WriteLine(tablecard);
}
}
class Card
{
public int Point;
public int Color;
public string CardDisplayString()
{
string sColor = "";
switch (Color)
{
case 0:
sColor = "红心";
break;
case 1:
sColor = "方块";
break;
case 2:
sColor = "黑桃";
break;
case 3:
sColor = "草花";
break;
}
return string.Format("花色:{0} Point:{1}", sColor, Point);
}
class Program
{
static void Main(string[] args)
{
//1.输入玩家数量
int py;
Console.WriteLine("请输入玩家的数量");
py = int.Parse(Console.ReadLine());
Player[] pys = new Player[py];
//2.输入玩家姓名
for (int m = 0; m < py; m++)
{
pys[m] = new Player();
Console.WriteLine("请输入第{0}玩家名字", m + 1);
pys[m].Name = Console.ReadLine();
pys[m].InitFiveCards();
}
//3.开始游戏
bool isExit = false;
while (!isExit)
{
for (int m = 0; m < py; m++)
{
pys[m].display();
pys[m].chosecard();
pys[m].throwcard();
if (pys[m].isWin())
{
Console.WriteLine("The player name :{0}" + "游戏结束");
isExit = true;
break;
}
}
}
Console.ReadLine();
}
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给个邮箱,我给你发
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询