コード例 #1
0
ファイル: Form1.cs プロジェクト: Datmnguyen/CMPE2800
        /// <summary>
        /// Child function of async method that create random color in specific time
        /// </summary>
        /// <param name="time">input time</param>
        private void RandomColor(int time)
        {
            //delay inside method, use stopwatch to get exact timing
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            while (sw.ElapsedMilliseconds < time)
            {
                ;
            }

            //random number -> random color
            ShapeRock.BaseColor = RandomColorLib.RandColor();
        }
コード例 #2
0
ファイル: ShapeBase.cs プロジェクト: Datmnguyen/CMPE2800
        /// <summary>
        /// Virtual method between main & derived classes
        /// </summary>
        /// <param name="gr">current canvas</param>
        public virtual void virtualRender(Graphics gr)
        {
            //if shape is buller, technicolor it for fun
            if (_eItem == eItemType.Shot)
            {
                _itemColor = RandomColorLib.RandColor();
            }

            //fill the supply graphic board with supplied path and color
            gr.FillPath(new SolidBrush(_itemColor), GetPath());

            //draw the outline of shape, for testing purpose
            //gr.DrawPath(new Pen(Color.White), GetPath());
        }
コード例 #3
0
ファイル: ShapeThruster.cs プロジェクト: Datmnguyen/CMPE2800
        /// <summary>
        /// Override render method, draw shape when flag is true, else transparent it
        /// </summary>
        /// <param name="gr">current graphics canvas</param>
        public override void virtualRender(Graphics gr)
        {
            //rand color everytime render
            _itemColor = RandomColorLib.RandColor();

            //always draw but use transparent color if thruting is not ON
            if (IsThruster)
            {
                //make color like a flame
                _fOpacity = _rnd.Next(25, 200);
                gr.FillPath(new SolidBrush(_itemColor), GetPath());
            }

            //hide it by set the color to transparent
            else
            {
                gr.FillPath(new SolidBrush(Color.Transparent), GetPath());
            }
        }