Example #1
0
        /// <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();
        }
Example #2
0
        /// <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());
        }
Example #3
0
        /// <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());
            }
        }