一. 飞行棋分析:
- 游戏规则:
1. 两个人轮流掷骰子红人和绿人
2. 投掷出2,4,6点出门,投掷出6点可以在出门后再次投掷行走
3. 地图长度共100步
4. 地图中除过普通地板之外,另设六种特殊功能地板
1. 踩到香蕉皮,退6步
2. 踩到时空,前进6步
3. 踩到陷阱,暂停一回合
4. 踩到星星,可以再投掷一次
5. 踩到移魂大法,可以做出选择与对方互换位置
6. 踩到手枪,可以击退对方3步
7. 踩到大炮,可以直接将对方轰炸回家(需要重新出门)
5. 如果踩到对方,则对方直接回到起点, 游戏策划
-
地图面积30*13
-
每个格子30像素
-
地面的代号=0,普通地板=1,香蕉皮=2,时空=3,陷阱=4,星星=5,大挪移=6,手枪=7
红人=8,绿人=9using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace 飞行棋3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//游戏界面
Panel map = new Panel();// 这个数组是所有地板的的一个数组,游戏逻辑全部取决与数字组。/记录横(30)和竖(13)行的格子(30*13=390个图片数组)
int[] mapList = new int[390];//这个数组是所有的图片放置在数组,根据maplist决定每个元素的内容(30*13=390个图片数组)
PictureBox[] mapImg = new PictureBox[390];//图片的宽高
const int size = 30;//创建飞行棋走的路数组,并定义它的长度为100(老师解释:这个数组 用来 记录 所有 路 的索引位置)
int[] road = new int[100];//用来放数字
RichTextBox msg = new RichTextBox();//用来放筛子
PictureBox dice = new PictureBox();//红盒子的家
Panel redplayHome = new Panel();//绿盒子的家
Panel greenplayHome = new Panel();//红盒子
PictureBox redPlayer = new PictureBox();
//绿盒子
PictureBox greenPlayer = new PictureBox();
private void Form1_Load(object sender, EventArgs e)
{
//固定窗口位置
this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
this.BackColor = Color.FloralWhite;
this.Width = 1200;
this.Height = 600;
this.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - this.Width / 2;
this.Top = Screen.PrimaryScreen.WorkingArea.Height / 2 - this.Height / 2;//游戏界面 //Panel map = new Panel(); /*map.Width = mapList.GetLength(0) *size; map.Height = mapList.GetLength(1) * size;*/ //图片和格子数相乘等于整个地图的宽高(也可以给具体的数字) map.Width = 30 * size; map.Height = 13 * size; map.Location = new Point(20, 150); map.BorderStyle = BorderStyle.FixedSingle; this.Controls.Add(map); //调用这个盒子,使创建的地板以数组图片的形式显示在map地图中(在调用里面创建图片已经添加到map) InitialGame(); //框架加载时调用路的数组位置,并全部创建好数的位置 //CreateRoed(); //数组记录的地图划分 mapList, mapList中的路用1代替 //CreateMap(); // Panel redplayHome = new Panel(); redplayHome.Size = new Size(100, 100); redplayHome.BackgroundImage = Image.FromFile("../../img/select_circle.png"); redplayHome.Location = new Point(50, map.Top - 120); redplayHome.BackgroundImageLayout = ImageLayout.Stretch; this.Controls.Add(redplayHome); //Panel greenplayHome = new Panel(); greenplayHome.Size = new Size(100, 100); greenplayHome.BackgroundImage = Image.FromFile("../../img/select_circle.png"); greenplayHome.Location = new Point(170, map.Top - 120); greenplayHome.BackgroundImageLayout = ImageLayout.Stretch; this.Controls.Add(greenplayHome); //PictureBox redPlayer = new PictureBox(); redPlayer.Size = new Size(80, 80); redPlayer.Image = Image.FromFile("../../img/red.png"); redPlayer.Location = new Point(10, 10); redPlayer.SizeMode = PictureBoxSizeMode.StretchImage; redplayHome.Controls.Add(redPlayer); //PictureBox greenPlayer = new PictureBox(); greenPlayer.Size = new Size(80, 80); greenPlayer.Image = Image.FromFile("../../img/green.png"); greenPlayer.Location = new Point(10, 10); greenPlayer.SizeMode = PictureBoxSizeMode.StretchImage; greenplayHome.Controls.Add(greenPlayer); //红方和绿方 Label h = new Label(); h.Text = "红方"; h.AutoSize = true; //h. h.Location = new Point(redPlayer.Width / 2 - 11, redPlayer.Height / 2 - h.Height / 2); redPlayer.Controls.Add(h); Label L = new Label(); L.Text = "绿方"; L.AutoSize = true; // L. L.Location = new Point(greenPlayer.Width / 2 - 11, greenPlayer.Height / 2 - L.Height / 2); greenPlayer.Controls.Add(L); msg.Size = new Size(260, 600); msg.Location = new Point(map.Right + 20, 50); msg.ReadOnly = true; this.Controls.Add(msg); dice.Size = new Size(100, 100); dice.Image = Image.FromFile("../../img/roll.png"); dice.Location = new Point(msg.Left - 150, 50); dice.SizeMode = PictureBoxSizeMode.StretchImage; this.Controls.Add(dice); dice.MouseClick += Dice_MouseClick; string startmsg = "请两个人先轮流掷骰子,点大的先行一步,红方先手"; ResultTell(startmsg);
}
Random sj = new Random();
/* private void Dice_MouseClick(object sender, MouseEventArgs e)
{
int j = sj.Next(1, 7);
int i = sj.Next(1, 7);
if (i > j)
{
ResultTell(“红方先投掷出” + i + “点” + “,则” + i + “>” + j + “红方先出”);
}
else if (j < i)
{
ResultTell(“绿方先投掷出” + i + “点” + “,则” + i + “<” + j + “绿方先出”);
}
else if (j == i)
{
ResultTell(i + “=” + i + “两个i一样从新投掷出”);
}
}*/
void ResultTell(string str)
{
MessageBox.Show(str);
msg.AppendText(str + “\r\n”);//把比较的文字添加到msg里面
}//一、
//@@@_看情况制筛子(下面是制筛子的所有代码):
//1、表示双方制出筛子的点数
int[