Esempio n. 1
0
        public static void InitialGame_2()
        {
            Heroine h = new Heroine(0, 400, 100, 100, "唐妮");
            //Boss
            Monster boss = FactoryM.createMonster(1500, 270, "Boss");

            Goods fire   = FactoryGoods.createGoods(750, 620, "Fire");
            Goods blood  = FactoryGoods.createGoods(900, 600, "Blood");
            Goods blood1 = FactoryGoods.createGoods(750, 530, "Blood");
            Goods gold   = FactoryGoods.createGoods(760, 460, "Gold");
            Goods gold_1 = FactoryGoods.createGoods(200, 320, "Gold");
            Goods gold_2 = FactoryGoods.createGoods(230, 320, "Gold");
            Goods gold_3 = FactoryGoods.createGoods(260, 320, "Gold");
            Goods gold_4 = FactoryGoods.createGoods(290, 320, "Gold");
            Goods Door   = FactoryGoods.createGoods(2750, 270, "Door");
            Goods torch  = FactoryGoods.createGoods(150, 270, "Torch");
            Goods torch1 = FactoryGoods.createGoods(500, 270, "Torch");
            Goods foods  = FactoryGoods.createGoods(500, 320, "Foods");

            //UI
            Life     life_UI  = new Life(50, 10, 20, 20);
            Listing  list_UI  = new Listing(600, 30);
            BossLife bossLife = new BossLife(700, 20, 20, 20);

            Hero_GetGoods gold_list = new Hero_GetGoods();

            //记录窗体信息
            //加载背景图片
            //BackGround backGround = new BackGround(0, 0, 20);


            SingleObject.GetSingle().AddGameObject(new BackGround(0, 0, 20));
            //SingleObject.GetSingle().AddGameObject(backGround);
            SingleObject.GetSingle().BG.BGImage = Properties.Resources.Caverns;
            SingleObject.GetSingle().BG.BGunder = Properties.Resources.Caverns1;
            //rec = new Rectangle(form.Location, form.Size);
            SingleObject.GetSingle().BG.SetCamera(rec);
            //加载测试游戏对象
            SingleObject.GetSingle().BG.TP = h;
            //加入物品
            SingleObject.GetSingle().BG.ListMonster.Add(boss);
            SingleObject.GetSingle().BG.ListGoods.Add(fire);
            SingleObject.GetSingle().BG.ListGoods.Add(blood);
            SingleObject.GetSingle().BG.ListGoods.Add(blood1);
            SingleObject.GetSingle().BG.ListGoods.Add(gold);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_1);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_2);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_3);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_4);
            SingleObject.GetSingle().BG.ListGoods.Add(torch);
            SingleObject.GetSingle().BG.ListGoods.Add(torch1);
            SingleObject.GetSingle().BG.ListGoods.Add(Door);
            SingleObject.GetSingle().BG.ListGoods.Add(foods);
            //加载UI界面
            SingleObject.GetSingle().AddGameObject(life_UI);
            SingleObject.GetSingle().AddGameObject(list_UI);
            SingleObject.GetSingle().AddGameObject(bossLife);
            //创建金币集对象
            SingleObject.GetSingle().BG.GoldList = gold_list;
        }
Esempio n. 2
0
 public void If_Finished()
 {
     if (SingleObject.GetSingle().BG.TP.finsh)
     {
         timer1.Stop();
         comm.Wait(500);
         GameOver gameOver = new GameOver();
         this.Hide();
         gameOver.ShowDialog(this);
         Start f = new Start();
         this.Hide();
         f.ShowDialog(this);
         this.Close();
     }
     if (SingleObject.GetSingle().BG.TP.Vector)
     {
         timer1.Stop();
         comm.Wait(500);
         Congraduation c = new Congraduation();
         this.Hide();
         c.ShowDialog(this);
         Start f = new Start();
         this.Hide();
         f.ShowDialog(this);
         this.Close();
     }
 }
Esempio n. 3
0
 //3.提供一个静态函数返回一个唯一对象
 public static SingleObject GetSingle()
 {
     if (_single == null)
     {
         _single = new SingleObject();
     }
     return(_single);
 }
Esempio n. 4
0
        private void Exit_Game()
        {
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream("MyFile.bin", FileMode.Create,
                                                  FileAccess.Write, FileShare.None);

            formatter.Serialize(stream, SingleObject.GetSingle());
            stream.Close();
            MessageBox.Show("保存成功");
            //using (FileStream fs = new FileStream(@"In.txt", FileMode.OpenOrCreate, FileAccess.Write))
            //{
            //    BinaryFormatter bf = new BinaryFormatter();
            //    bf.Serialize(fs, SingleObject._single);
            //}
        }
Esempio n. 5
0
 public void Init_Game()
 {
     if (load_game)
     {
         IFormatter formatter = new BinaryFormatter();
         Stream     stream    = new FileStream("MyFile.bin", FileMode.Open,
                                               FileAccess.Read, FileShare.Read);
         SingleObject.SetSingle((SingleObject)formatter.Deserialize(stream));
         stream.Close();
     }
     else
     {
         Level.InitialGame_1(this);
         //Level.InitialGame_2();
     }
 }
Esempio n. 6
0
 private void print_score()
 {
     label1.Text     = SingleObject.GetSingle().BG.TP.score.ToString();
     label1.Location = new Point((int)(this.Width / 2 + 170), (int)(this.Height / 2 + 21));
 }
Esempio n. 7
0
 public static void SetSingle(SingleObject single)
 {
     _single = single;
 }
Esempio n. 8
0
 private void Form1_KeyUp(object sender, KeyEventArgs e)
 {
     SingleObject.GetSingle().BG.TP.key_upctrl(e);
     Door.new_level(e);
     If_Pause(e);
 }
Esempio n. 9
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     SingleObject.GetSingle().BG.TP.key_ctrl(e);
 }
Esempio n. 10
0
 private void Form1_Paint(object sender, PaintEventArgs e)
 {
     SingleObject.GetSingle().Draw(e.Graphics);
     If_Finished();
 }
Esempio n. 11
0
 private void Form1_Load(object sender, EventArgs e)
 {
     //测试
     SingleObject.GetSingle().test();
 }
Esempio n. 12
0
        public static void InitialGame_1(Form1 form)
        {
            Heroine h = new Heroine(0, 400, 100, 100, "唐妮");

            Monster fly_1 = FactoryM.createMonster(2000, 440, "fly");
            Monster fly_2 = FactoryM.createMonster(1500, 250, "fly");
            Monster walk  = FactoryM.createMonster(500, 520, "walk");
            Monster walk1 = FactoryM.createMonster(700, 340, "Walk");

            Goods fire   = FactoryGoods.createGoods(150, 550, "Fire");
            Goods blood  = FactoryGoods.createGoods(570, 350, "Blood");
            Goods gold_1 = FactoryGoods.createGoods(700, 520, "Gold");
            Goods gold_2 = FactoryGoods.createGoods(730, 520, "Gold");
            Goods gold_3 = FactoryGoods.createGoods(760, 520, "Gold");
            Goods gold_4 = FactoryGoods.createGoods(670, 520, "Gold");
            Goods gold_5 = FactoryGoods.createGoods(1510, 360, "Gold");
            Goods gold_6 = FactoryGoods.createGoods(1540, 350, "Gold");
            Goods gold_7 = FactoryGoods.createGoods(1570, 340, "Gold");
            Goods gold_8 = FactoryGoods.createGoods(1600, 330, "Gold");
            Goods Door   = FactoryGoods.createGoods(2795, 300, "Door");
            Goods torch  = FactoryGoods.createGoods(150, 450, "Torch");
            Goods torch1 = FactoryGoods.createGoods(500, 450, "Torch");
            Goods torch2 = FactoryGoods.createGoods(1500, 300, "Torch");
            Goods torch3 = FactoryGoods.createGoods(1900, 320, "Torch");
            Goods torch4 = FactoryGoods.createGoods(2250, 320, "Torch");
            Goods torch5 = FactoryGoods.createGoods(500, 450, "Torch");
            Goods torch6 = FactoryGoods.createGoods(1100, 300, "Torch");
            Goods foods  = FactoryGoods.createGoods(500, 350, "Foods");
            Goods foods1 = FactoryGoods.createGoods(1200, 520, "Foods");
            Goods foods2 = FactoryGoods.createGoods(2000, 350, "Foods");
            Goods foods3 = FactoryGoods.createGoods(800, 520, "Foods");
            Goods foods4 = FactoryGoods.createGoods(2500, 350, "Foods");

            Life    life_UI = new Life(50, 10, 20, 20);
            Listing list_UI = new Listing(600, 30);

            Hero_GetGoods gold_list = new Hero_GetGoods();

            //记录窗体信息
            //加载背景图片
            SingleObject.GetSingle().AddGameObject(new BackGround(0, 0, 20));
            SingleObject.GetSingle().BG.BGImage = Properties.Resources.background4;;
            SingleObject.GetSingle().BG.BGunder = Properties.Resources._5;

            rec = new Rectangle(form.Location, form.Size);
            SingleObject.GetSingle().BG.SetCamera(rec);

            //加载测试游戏对象
            SingleObject.GetSingle().BG.TP = h;
            //加入怪物
            SingleObject.GetSingle().BG.ListMonster.Add(fly_1);
            SingleObject.GetSingle().BG.ListMonster.Add(fly_2);
            SingleObject.GetSingle().BG.ListMonster.Add(walk);
            SingleObject.GetSingle().BG.ListMonster.Add(walk1);
            //加入物品
            SingleObject.GetSingle().BG.ListGoods.Add(fire);
            SingleObject.GetSingle().BG.ListGoods.Add(blood);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_1);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_2);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_3);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_4);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_5);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_6);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_7);
            SingleObject.GetSingle().BG.ListGoods.Add(gold_8);
            SingleObject.GetSingle().BG.ListGoods.Add(torch);
            SingleObject.GetSingle().BG.ListGoods.Add(torch1);
            SingleObject.GetSingle().BG.ListGoods.Add(torch2);
            SingleObject.GetSingle().BG.ListGoods.Add(torch3);
            SingleObject.GetSingle().BG.ListGoods.Add(torch4);
            SingleObject.GetSingle().BG.ListGoods.Add(torch5);
            SingleObject.GetSingle().BG.ListGoods.Add(torch6);
            SingleObject.GetSingle().BG.ListGoods.Add(Door);
            SingleObject.GetSingle().BG.ListGoods.Add(foods);
            SingleObject.GetSingle().BG.ListGoods.Add(foods1);
            SingleObject.GetSingle().BG.ListGoods.Add(foods2);
            SingleObject.GetSingle().BG.ListGoods.Add(foods3);
            SingleObject.GetSingle().BG.ListGoods.Add(foods4);
            //加载UI界面
            SingleObject.GetSingle().AddGameObject(life_UI);
            SingleObject.GetSingle().AddGameObject(list_UI);
            //创建金币集对象
            SingleObject.GetSingle().BG.GoldList = gold_list;
        }