• 大小: 2.29MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-14
  • 语言: C#
  • 标签: C#  怪兽游戏  

资源简介

S2 北大青鸟C#课程中的 Monster 完整案例。一个简单的Game 游戏,我使用简单工厂,代码 清晰,经调试暂无 bag ,总之感觉挺不错,界面 美观,功能齐全。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MyGame.Model;
using System.Threading;
using MyGame.DAL;


namespace MyGame
{

    public partial class levelForm : Form
    {
      
        public levelForm(string gt)
        {
            InitializeComponent();
            gameType = gt;
        }

        private string gameType;

        public string GameType
        {
            get { return gameType; }
            set { gameType = value; }
        }


        //怪兽集合
        Dictionary monsters = new Dictionary();
        //控件集合
        Dictionary UIMappings = new Dictionary();

        //创建一个GameManager 对象 gm 并创建关卡
        GameManager gm = new GameManager();
        PictureBox picHero = new PictureBox();
        PictureBox picMoster = null;
  
        #region 加载
        private void Form1_Load(object sender EventArgs e)
        {

            if (gameType.Equals(Common.GameModes.New.ToString()))
            {
                
                gm.Game = new Game();

                gm.Game.Hero = new Hero(“李小侠“ Image.FromFile(“../../image/hero.gif“) new Point(450 400) new Size(100 180) Image.FromFile(“../../image/heroDead.gif“));
            
                //使用简单工厂模式创建关卡
                gm.Game.CurrentLevel = LevelFactory.CreateLevel(1);                   
   
            }
            else
            {
                //接收加载过来的数据
                gm.Game = gm.Load();
                this.Refresh();
            }
            //付给当前的monsters
            monsters = gm.Game.CurrentLevel.Monsters;
            //调用初始化.
            InitUI();

            this.lblMessage.Text = ““;
            this.BackgroundImage = gm.Game.CurrentLevel.StagePic;
            //必杀技不可用
            this.cmsAttack.Items[“tsmiSuper“].Enabled = false;
        } 
        #endregion
        
        
        #region 初始化
        /// 
        /// 窗体中显示关卡中的怪物和玩家的状态控件
        /// 

        private void InitUI()
        {
           //默认窗体属性
            this.WindowState = FormWindowState.Maximized;
          //怪兽攻击
            this.btnMonster.Location = new Point(900160);              
            //保存
           // this.btnSave.Location = new Point(900400);
            //退出
            //this.btnExit.Location = new Point(900480);
            //死亡信息
            this.lblDeadMessage.Location = new Point(150450);
            this.lblDeadMessage.Text = ““;
            //攻击信息
            this.lblMessage.Location = new Point(300650);
            this.lblMessage.Width = 400;
            this.lblMessage.Height = 50;
            //攻击者头像
            this.picHead.Location = new Point(150 645);            
           this.picHead.Width = 90;
  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    1128448  2004-01-01 03:24  Game\bin\Debug\Game.exe

     文件      91648  2004-01-01 03:24  Game\bin\Debug\Game.pdb

     文件      14328  2004-01-01 03:24  Game\bin\Debug\Game.vshost.exe

     目录          0  2004-01-01 03:24  Game\bin\Debug

     目录          0  2004-01-01 03:15  Game\bin

     文件        745  2004-01-01 03:25  Game\Class\Common.cs

     文件        661  2004-01-01 00:10  Game\Class\Game.cs

     文件       8382  2004-01-01 02:48  Game\Class\GameManager.cs

     文件       5895  2004-01-01 05:57  Game\Class\Hero.cs

     文件       1221  2004-01-01 00:11  Game\Class\Level.cs

     文件       1736  2004-01-01 01:15  Game\Class\LevelFactory.cs

     文件       2765  2004-01-01 00:13  Game\Class\MonkeyMonster.cs

     文件       4874  2004-01-01 05:56  Game\Class\Monster.cs

     文件       2161  2004-01-01 00:13  Game\Class\TurtleMonster.cs

     文件       1018  2004-01-01 01:32  Game\Class\UIContainer.cs

     目录          0  2004-01-01 03:25  Game\Class

     文件      18791  2004-01-01 03:19  Game\Form1.cs

     文件       9574  2004-01-01 06:32  Game\Form1.Designer.cs

     文件       6011  2004-01-01 06:32  Game\Form1.resx

     文件        901  2004-01-01 00:26  Game\Game.sln

    ..A..H.     24576  2004-01-01 03:25  Game\Game.suo

     文件      10085  2004-01-01 04:43  Game\image\hero.gif

     文件       9789  2004-01-01 04:43  Game\image\heroDead.gif

     文件     507587  2004-01-01 04:43  Game\image\level1.jpg

     文件       8597  2004-01-01 04:43  Game\image\monkey.gif

     文件       8396  2004-01-01 04:43  Game\image\monkeyDead.gif

    ....SH.     25088  2004-01-01 04:43  Game\image\Thumbs.db

     文件       8756  2004-01-01 04:43  Game\image\turtle.gif

     文件       9160  2004-01-01 04:43  Game\image\turtleDead.gif

     目录          0  2004-01-01 04:43  Game\image

............此处省略30个文件信息

评论

共有 条评论