Пример #1
0
        private SubUnitType type; //tracks the type of SubUnit represented

        #endregion Fields

        #region Constructors

        public SubUnit( GameGrid g )
        {
            grid = g;
            Location = new Point(0,0);
            type = SubUnitType.blank;
            countdown = -1;
        }
Пример #2
0
        private SubUnit[] subunits; //the subunits

        #endregion Fields

        #region Constructors

        public Unit( GameGrid g )
        {
            rnd = new System.Random();
            grid = g;

            //create SubUnits
            subunits = new SubUnit[4];
            for (int i=0; i<subunits.Length; i++)
                subunits[i] = new SubUnit( grid );
        }
Пример #3
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();
        }
Пример #4
0
        //draws a grid to the drawing surface
        private void DrawGrid( GameGrid g, DrawingSurface s)
        {
            int index;

            for( int i=0; i<g.Size.Width; i++ )
            {
                for (int j=0; j<g.Size.Height; j++)
                {
                    index = GetIlIndex(g.GetSpace(i,j));
                    if (index >= 0)
                        s.Surface.DrawImage(ilUnits.Images[index], i*20, j*20, 20, 20);
                    if (g.GetOrbCount(i,j)>-1)
                        s.Surface.DrawString(""+g.GetOrbCount(i,j), font, new SolidBrush(Color.Black),(i*20)+11, (j*20)+11, strfmt);
                }
            }
        }