public override cSprite copy() { cSpriteBubble s = new cSpriteBubble(); s.copy(this); return(s); }
/// <summary> /// A factory method to return one of the various kinds of sprites randomly forned. /// </summary> /// <param name="spritetypeindex">An index for the type of sprite. To select the type of /// sprite, use cGame and select a type that begins with ST_. </param> /// <returns></returns> public cSprite randomSprite(int spritetypeindex) { cPolygon newpoly; cSpriteBubble newbubble; cPolyPolygon newpolypoly; cSpriteSphere psphere; if (spritetypeindex == cGame.ST_ASSORTED) { spritetypeindex = (int)Framework.randomOb.random((uint)cGame.ST_ASSORTED); } //Select a random index less than cGame.ST_ASSORTED /* This next block should be a switch, but the compiler won't let me use the cGame constants * in a switch. */ if (spritetypeindex == cGame.ST_SIMPLEPOLYGONS) { newpoly = new cPolygon(Framework.randomOb.random(3, 5)); newpoly.randomize( //cSprite.MF_RADIUS | cPolygon.MF_COLOR); return(newpoly); } else if (spritetypeindex == cGame.ST_FANCYPOLYGONS) { newpoly = new cPolygon(); newpoly.randomize( //cSprite.MF_RADIUS | cPolygon.MF_COLOR | cPolygon.MF_LINEWIDTH | cPolygon.MF_DOTS | cPolygon.MF_VERTCOUNT); return(newpoly); } else if (spritetypeindex == cGame.ST_ASTEROIDPOLYGONS) { newpoly = new cPolygon(); newpoly.setRandomAsteroidPolygon(5, 20, Framework.randomOb.randomReal(0.0f, 0.4f)); newpoly.randomize( //cSprite.MF_RADIUS cPolygon.MF_COLOR); return(newpoly); } else if (spritetypeindex == cGame.ST_BUBBLES) { newbubble = new cSpriteBubble(); newbubble.randomize( //cSprite.MF_RADIUS | cPolygon.MF_COLOR | cPolygon.MF_LINEWIDTH); return(newbubble); } else if (spritetypeindex == cGame.ST_SPHERES) { psphere = new cSpriteSphere(); psphere.randomize(cPolygon.MF_COLOR); Color fill = psphere.FillColor; return(psphere); } else if (spritetypeindex == cGame.ST_POLYPOLYGONS) { newpolypoly = new cPolyPolygon(); newpolypoly.randomize( //cSprite.MF_RADIUS | cPolygon.MF_COLOR | cPolygon.MF_LINEWIDTH | cPolygon.MF_DOTS | cPolygon.MF_VERTCOUNT); return(newpolypoly); } else if (spritetypeindex == cGame.ST_TRIPLEPOLYPOLYGONS) { newpolypoly = new cPolyPolygon(); newpolypoly.randomize(cPolygon.MF_VERTCOUNT); newpolypoly.TipShape = new cPolyPolygon(); newpolypoly.randomize( //cSprite.MF_RADIUS | cPolygon.MF_COLOR | cPolygon.MF_LINEWIDTH | cPolygon.MF_DOTS | cPolygon.MF_VERTCOUNT); return(newpolypoly); } return(new cSprite()); //Default in the cGame.ST_SPRITETYPENOTUSED case }