游戏开发论坛

 找回密码
 立即注册
搜索
查看: 8037|回复: 15

用c#开发的地图编辑器!

[复制链接]

68

主题

710

帖子

719

积分

高级会员

Rank: 4

积分
719
QQ
发表于 2004-11-29 10:54:00 | 显示全部楼层 |阅读模式
用c#开发的地图编辑器!
是个bug版本!功能很不完善!
谢谢支持!
------------------------注意!!!
需要安装 .NET Framework运行库!!!!
地址:http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&displaylang=zh-cn
这是下载页面!!不是文件链接!!
只是个月前学习c#的副产品
bug不少!谢谢支持!

sf_20041129105444.rar

210.77 KB, 下载次数:

1万

主题

1万

帖子

2万

积分

管理员

中级会员

Rank: 9Rank: 9Rank: 9

积分
20686
发表于 2004-11-29 10:57:00 | 显示全部楼层

Re:用c#开发的地图编辑器!

支持一下!:)

41

主题

340

帖子

345

积分

中级会员

Rank: 3Rank: 3

积分
345
发表于 2004-11-29 16:37:00 | 显示全部楼层

Re:用c#开发的地图编辑器!

俺喜欢C#,当然要支持了!

3

主题

8

帖子

8

积分

新手上路

Rank: 1

积分
8
发表于 2004-11-29 18:49:00 | 显示全部楼层

Re:用c#开发的地图编辑器!

我刚开始学习,用C#做编辑器挺快捷的

9

主题

48

帖子

52

积分

注册会员

Rank: 2

积分
52
QQ
发表于 2004-11-29 22:31:00 | 显示全部楼层

Re:用c#开发的地图编辑器!

偶也支持一下。

2

主题

32

帖子

32

积分

注册会员

Rank: 2

积分
32
QQ
发表于 2005-1-1 08:37:00 | 显示全部楼层

Re:用c#开发的地图编辑器!

嗯`~我顶~~

2

主题

32

帖子

32

积分

注册会员

Rank: 2

积分
32
QQ
发表于 2005-1-1 08:41:00 | 显示全部楼层

Re:用c#开发的地图编辑器!

好厉害的啊~~

0

主题

7

帖子

7

积分

新手上路

Rank: 1

积分
7
发表于 2005-1-15 02:55:00 | 显示全部楼层

Re:用c#开发的地图编辑器!

虽然不专业
但是很好啊

0

主题

2

帖子

8

积分

新手上路

Rank: 1

积分
8
发表于 2005-1-27 14:37:00 | 显示全部楼层

Re:用c#开发的地图编辑器!

呵呵~谢谢楼主。
学习笔记
<Form1>核心代码:
private void button1_Click(object sender, EventArgs e)
{
      this.RECT.X = 0;
      this.RECT.Y = 0x100;
}
private void button5_Click(object sender, EventArgs e)
{
      for (int num1 = 0; num1 < 12; num1++)
      {
            for (int num2 = 0; num2 < 20; num2++)
            {
                  this.mymap.mymapX[num1, num2].picRect.X = 0;
                  this.mymap.mymapX[num1, num2].picRect.Y = 0x100;
            }
      }
      this.flashWin();
}
private void button6_Click(object sender, EventArgs e)
{
      this.flashWin();
}
public void flashWin()
{
      for (int num1 = 0; num1 < 12; num1++)
      {
            for (int num2 = 0; num2 < 20; num2++)
            {
                  this.mygrap.DrawImage(this.picBit, (int) ((num2 - 1) * 0x20), (int) ((num1 - 1) * 0x20), this.mymap.mymapX[num1, num2].picRect, this.myunit);
            }
      }
}
private void Form1_Load(object sender, EventArgs e)
{
      this.mygrap = this.panel1.CreateGraphics();
      this.tuKuanTu = this.pictureBox2.CreateGraphics();
      this.panel1.MouseMove += new MouseEventHandler(this.panel1_MouseMove);
      this.panel1.MouseLeave += new EventHandler(this.panel1_MouseLeave);
      this.panel1.MouseDown += new MouseEventHandler(this.panel1_MouseDown);
      this.pictureBox2.MouseDown += new MouseEventHandler(this.pictureBox2_MouseDown);
      this.pictureBox2.MouseMove += new MouseEventHandler(this.pictureBox2_MouseMove);
      this.bita.MakeTransparent(Color.Aqua);
      this.panel1.BackgroundImage = Image.FromFile("pic/\u7eff\u5730.bmp");
      this.timer1.Enabled = false;
}
private void hScrollBar2_Scroll(object sender, ScrollEventArgs e)
{
      if (this.hScrollBar2.Value == 3)
      {
            MessageBox.Show("ASDf");
      }
}
private void menuItem10_Click(object sender, EventArgs e)
{
      MessageBox.Show("\u53ea\u80fd\u4fdd\u5b58\u5230\u7a0b\u5e8f\u7684\u6267\u884c\u6587\u4ef6.exe\u76ee\u5f55\u5185");
      this.saveFileDialog1.AddExtension = true;
      this.saveFileDialog1.ShowDialog();
}
private void menuItem18_Click(object sender, EventArgs e)
{
      this.Cursor = new Cursor("cur/\u666e\u901a.cur");
}
private void menuItem19_Click(object sender, EventArgs e)
{
      this.Cursor = new Cursor("cur/\u5927\u753b\u7b14.cur");
}
private void menuItem20_Click(object sender, EventArgs e)
{
      this.openFileDialog1.ShowDialog();
}
private void menuItem3_Click(object sender, EventArgs e)
{
      base.Close();
}
private void menuItem6_Click(object sender, EventArgs e)
{
      this.mapShuxing.ShowDialog();
}
private void menuItem8_Click(object sender, EventArgs e)
{
      this.timer1.Enabled = false;
      this.panel1.Refresh();
}
private void menuItem9_Click(object sender, EventArgs e)
{
      this.timer1.Enabled = true;
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
      StreamReader reader1 = new StreamReader(this.openFileDialog1.FileName);
      this.mymap.mapName = reader1.ReadLine();
      this.mymap.PointX = reader1.ReadLine();
      this.mymap.Pointy = reader1.ReadLine();
      this.mymap.exInfo = reader1.ReadLine();
      for (int num1 = 0; num1 < 12; num1++)
      {
            for (int num2 = 0; num2 < 20; num2++)
            {
                  this.mymap.mymapX[num1, num2].picRect.X = Convert.ToInt32(reader1.ReadLine(), 10);
                  this.mymap.mymapX[num1, num2].picRect.Y = Convert.ToInt32(reader1.ReadLine(), 10);
                  this.mymap.mymapX[num1, num2].suf = reader1.ReadLine();
                  this.mymap.mymapX[num1, num2].zudang = reader1.ReadLine();
            }
      }
      reader1.Close();
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
      int num1 = 0;
      int num2 = 0;
      int num3 = 0;
      int num4 = 0;
      for (int num5 = 0; num5 < 20; num5++)
      {
            if ((e.X > (num1 * num5)) && (e.X < (0x20 * num5)))
            {
                  num3 = num5;
                  this.label6.Text = num5.ToString();
                  num1 += 0x20;
                  break;
            }
      }
      for (int num6 = 0; num6 < 12; num6++)
      {
            if ((e.Y > (num2 * num6)) && (e.Y < (0x20 * num6)))
            {
                  num4 = num6;
                  this.label7.Text = num6.ToString();
                  num2 += 0x20;
                  break;
            }
      }
      if (e.Button == MouseButtons.Left)
      {
            this.mymap.mymapX[num4, num3].picRect.X = this.RECT.X;
            this.mymap.mymapX[num4, num3].picRect.Y = this.RECT.Y;
            this.mygrap.DrawImage(this.picBit, (int) ((num3 - 1) * 0x20), (int) ((num4 - 1) * 0x20), this.RECT, this.myunit);
      }
      if (e.Button == MouseButtons.Right)
      {
            this.mymap.mymapX[num4, num3].picRect.X = 0;
            this.mymap.mymapX[num4, num3].picRect.Y = 0x100;
            this.mygrap.DrawImage(this.picBit, (int) ((num3 - 1) * 0x20), (int) ((num4 - 1) * 0x20), this.mymap.mymapX[num4, num3].picRect, this.myunit);
      }
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
      this.label6.Text = e.X.ToString();
      this.label7.Text = e.Y.ToString();
      int num1 = 0;
      int num2 = 0;
      int num3 = 0;
      int num4 = 0;
      for (int num5 = 0; num5 < 20; num5++)
      {
            if ((e.X > (num1 * num5)) && (e.X < (0x20 * num5)))
            {
                  num3 = num5;
                  this.label6.Text = num5.ToString();
                  num1 += 0x20;
                  break;
            }
      }
      for (int num6 = 0; num6 < 12; num6++)
      {
            if ((e.Y > (num2 * num6)) && (e.Y < (0x20 * num6)))
            {
                  num4 = num6;
                  this.label7.Text = num6.ToString();
                  num2 += 0x20;
                  break;
            }
      }
      int num7 = num3;
      this.label8.Text = num7.ToString();
}
private void pictureBox2_MouseDown(object sender, MouseEventArgs e)
{
      if ((e.X < 0x20) && (e.Y < 0x20))
      {
            this.RECT.X = this.aa.X;
            this.RECT.Y = this.aa.Y;
      }
      else if ((e.X < 0x40) && (e.Y < 0x20))
      {
            this.RECT.X = 0x20 + this.aa.X;
            this.RECT.Y = this.aa.Y;
      }
      else if ((e.X < 0x80) && (e.Y < 0x20))
      {
            this.RECT.X = 0x40 + this.aa.X;
            this.RECT.Y = this.aa.Y;
      }
      else if ((e.X < 0x20) && (e.Y < 0x40))
      {
            this.RECT.X = this.aa.X;
            this.RECT.Y = 0x20 + this.aa.Y;
      }
      else if ((e.X < 0x40) && (e.Y < 0x40))
      {
            this.RECT.X = 0x20 + this.aa.X;
            this.RECT.Y = 0x20 + this.aa.Y;
      }
      else if ((e.X < 0x80) && (e.Y < 0x40))
      {
            this.RECT.X = 0x40 + this.aa.X;
            this.RECT.Y = 0x20 + this.aa.Y;
      }
      else if ((e.X < 0x20) && (e.Y < 0x60))
      {
            this.RECT.X = this.aa.X;
            this.RECT.Y = 0x40 + this.aa.Y;
      }
      else if ((e.X < 0x40) && (e.Y < 0x60))
      {
            this.RECT.X = 0x20 + this.aa.X;
            this.RECT.Y = 0x40 + this.aa.Y;
      }
      else if ((e.X < 0x80) && (e.Y < 0x60))
      {
            this.RECT.X = 0x40 + this.aa.X;
            this.RECT.Y = 0x40 + this.aa.Y;
      }
      else if ((e.X < 0x20) && (e.Y < 0x80))
      {
            this.RECT.X = this.aa.X;
            this.RECT.Y = 0x60 + this.aa.Y;
      }
      else if ((e.X < 0x40) && (e.Y < 0x80))
      {
            this.RECT.X = 0x20 + this.aa.X;
            this.RECT.Y = 0x60 + this.aa.Y;
      }
      else if ((e.X < 0x80) && (e.Y < 0x80))
      {
            this.RECT.X = 0x40 + this.aa.X;
            this.RECT.Y = 0x60 + this.aa.Y;
      }
}
private void pictureBox2_MouseMove(object sender, MouseEventArgs e)
{
      if ((e.X < 0x20) && (e.Y < 0x20))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0, 0);
      }
      else if ((e.X < 0x40) && (e.Y < 0x20))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0x20, 0);
      }
      else if ((e.X < 0x80) && (e.Y < 0x20))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0x40, 0);
      }
      else if ((e.X < 0x20) && (e.Y < 0x40))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0, 0x20);
      }
      else if ((e.X < 0x40) && (e.Y < 0x40))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0x20, 0x20);
      }
      else if ((e.X < 0x80) && (e.Y < 0x40))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0x40, 0x20);
      }
      else if ((e.X < 0x20) && (e.Y < 0x60))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0, 0x40);
      }
      else if ((e.X < 0x40) && (e.Y < 0x60))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0x20, 0x40);
      }
      else if ((e.X < 0x80) && (e.Y < 0x60))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0x40, 0x40);
      }
      else if ((e.X < 0x20) && (e.Y < 0x80))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0, 0x60);
      }
      else if ((e.X < 0x40) && (e.Y < 0x80))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0x20, 0x60);
      }
      else if ((e.X < 0x80) && (e.Y < 0x80))
      {
            this.tuKuanTu.DrawImage(this.picBit, 0, 0, this.aa, this.myunit);
            this.tuKuanTu.DrawImageUnscaled(this.bita, 0x40, 0x60);
      }
}
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
{
      this.mymap.mapName = this.mapShuxing.textBox3.Text;
      StreamWriter writer1 = new StreamWriter(this.saveFileDialog1.FileName);
      writer1.WriteLine(this.mymap.mapName);
      writer1.WriteLine(this.mymap.PointX);
      writer1.WriteLine(this.mymap.Pointy);
      writer1.WriteLine(this.mymap.exInfo);
      for (int num1 = 0; num1 < 12; num1++)
      {
            for (int num2 = 0; num2 < 20; num2++)
            {
                  writer1.WriteLine(this.mymap.mymapX[num1, num2].picRect.X);
                  writer1.WriteLine(this.mymap.mymapX[num1, num2].picRect.Y);
                  writer1.WriteLine(this.mymap.mymapX[num1, num2].suf);
                  writer1.WriteLine(this.mymap.mymapX[num1, num2].zudang);
            }
      }
      writer1.Close();
}
private void timer1_Tick(object sender, EventArgs e)
{
      Pen pen1 = new Pen(Color.Black, 1f);
      int num1 = 0x20;
      for (int num2 = 0; num2 < 20; num2++)
      {
            this.mygrap.DrawLine(pen1, num1, 0, num1, 0x198);
            num1 += 0x20;
      }
      int num3 = 0x20;
      for (int num4 = 0; num4 < 0x13; num4++)
      {
            this.mygrap.DrawLine(pen1, 0, num3, 0x278, num3);
            num3 += 0x20;
      }
      pen1.Dispose();
}
private void timer2_Tick(object sender, EventArgs e)
{
      this.flashWin();
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
      string text1;
      if ((text1 = e.Node.Text) != null)
      {
            text1 = string.IsInterned(text1);
            if (text1 != "\u5730\u9762")
            {
                  if (text1 == "\u7070\u571f\u5730")
                  {
                        this.aa.X = 0xc0;
                        this.aa.Y = 0;
                        gricap.showBmp(this.picBit, 0, 0, this.tuKuanTu, this.aa);
                  }
                  else if (text1 == "\u7eff\u5730")
                  {
                        this.aa.X = 0x60;
                        this.aa.Y = 0x100;
                        gricap.showBmp(this.picBit, 0, 0, this.tuKuanTu, this.aa);
                  }
                  else if (text1 == "\u77f3\u5934\u5730")
                  {
                        this.aa.X = 0xc0;
                        this.aa.Y = 0x80;
                        gricap.showBmp(this.picBit, 0, 0, this.tuKuanTu, this.aa);
                  }
                  else if (text1 == "\u7816\u5757\u5730")
                  {
                        this.aa.X = 480;
                        this.aa.Y = 0;
                        gricap.showBmp(this.picBit, 0, 0, this.tuKuanTu, this.aa);
                  }
                  else if (text1 == "\u5927\u77f3\u5934\u5730")
                  {
                        this.aa.X = 480;
                        this.aa.Y = 0x100;
                        gricap.showBmp(this.picBit, 0, 0, this.tuKuanTu, this.aa);
                  }
            }
            else
            {
                  this.picBit = (Bitmap) Image.FromFile("pic/dimian.png");
                  this.aa.X = 0x60;
                  this.aa.Y = 0x100;
                  gricap.showBmp(this.picBit, 0, 0, this.tuKuanTu, this.aa);
            }
      }
}
好累,<Form1>差不多就是这样子了。

68

主题

710

帖子

719

积分

高级会员

Rank: 4

积分
719
QQ
 楼主| 发表于 2005-1-28 20:45:00 | 显示全部楼层

Re:用c#开发的地图编辑器!

代码 很乱 不要 看
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-25 08:39

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表