Beispiel #1
0
        private StringFormat strfmt; //for drawing orb countdown text

        #endregion Fields

        #region Constructors

        public Orbz()
        {
            this.bRunning = false;
            this.bPaused = false;
            this.isDirty = true;
            this.bGameOver = false;
            this.bSound = true;

            //form generator component init.
            InitializeComponent();
            miStop.Checked = true;

            //add game components to the form
            this.gameArea = new GameGrid(new System.Drawing.Size(16, 24));
            this.srfGrid = new DrawingSurface();
            this.nextArea = new GameGrid(new System.Drawing.Size(5, 5));
            this.srfNext = new DrawingSurface();
            this.srfStatus = new DrawingSurface();
            this.nextUnit = new Unit(nextArea);
            this.activeUnit = new Unit(gameArea);
            this.font = new Font("Arial", 8, FontStyle.Bold);
            this.strfmt = new StringFormat();
            this.strfmt.Alignment = StringAlignment.Center;
            this.strfmt.LineAlignment = StringAlignment.Center;
            clock.Interval = GameState.ClockSpeed;
            this.MakeOrbImages();
            this.SuspendLayout();

            //configure game area
            this.Controls.Add(srfGrid);
            this.srfGrid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.srfGrid.Location = new System.Drawing.Point(8, 10);
            this.srfGrid.Size = new System.Drawing.Size(320, 480);
            this.srfGrid.Paint += new System.Windows.Forms.PaintEventHandler(this.SrfGrid_Paint);
            this.srfGrid.Initialize();
            this.gridBackGround = new LinearGradientBrush(srfGrid.ClientRectangle, Color.Gold, Color.Black, 53, false);

            //configure area to display next unit
            this.Controls.Add(srfNext);
            this.srfNext.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.srfNext.Location = new System.Drawing.Point(srfGrid.Location.X + 30 + srfGrid.Size.Width, 50);
            this.srfNext.Size = new System.Drawing.Size(100, 80);
            this.srfNext.Paint += new System.Windows.Forms.PaintEventHandler(this.SrfNext_Paint);
            this.srfNext.Initialize();
            this.nextBackGround = new SolidBrush(this.BackColor);

            //configure status area
            this.Controls.Add(srfStatus);
            this.srfStatus.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.srfStatus.Location = new System.Drawing.Point(336,264);
            this.srfStatus.Size = new System.Drawing.Size(148,224);
            this.srfStatus.Paint += new System.Windows.Forms.PaintEventHandler(this.SrfStatus_Paint);
            this.statusBackGround = new LinearGradientBrush(srfStatus.ClientRectangle, Color.DarkGoldenrod, Color.DimGray, 50, false);
            this.srfStatus.Initialize();

            this.ResumeLayout(true);

            //level up sound
            GameState.LevelUp += new GameEventHandler(Level_Up);
            Stream audio = Assembly.GetEntryAssembly().GetManifestResourceStream("Orbz.snd.bloop");
               			this.sndLevelUp = new byte[audio.Length];

            for (int i=0; i<audio.Length; i++)
                this.sndLevelUp[i] = (byte)audio.ReadByte();
        }
Beispiel #2
0
 //swap the active unit with the next unit
 private void SwapUnits()
 {
     Unit t = activeUnit;
     activeUnit = nextUnit;
     nextUnit = t;
     nextUnit.Grid = nextArea;
     nextUnit.Create();
     activeUnit.Grid = gameArea;
     activeUnit.Calibrate();
     srfNext.Invalidate();
     srfNext.Update();
 }
Beispiel #3
0
 //draws a unit to a drawing surface
 private void DrawUnit( Unit u, DrawingSurface d)
 {
     SubUnit s;
     for (int i=0; i<4; i++)
     {
         s = u.GetSubUnit(i);
         d.Surface.DrawImage(ilUnits.Images[GetIlIndex(s.Type)], s.Location.X*20, s.Location.Y*20, 20, 20 );
         if (s.OrbCount>-1)
             d.Surface.DrawString(""+s.OrbCount, font, new SolidBrush(Color.Black),(s.Location.X*20)+11, (s.Location.Y*20)+11, strfmt);
     }
 }