예제 #1
0
        /* setTipShape puts a clone of pshape at each vertex of the
         *  pbasepoly(), and then it deletes pshape.  So don't use a pshape as argument that you need to save. */
        //cSprite overloads

        /* Overload the standard cSpriteComposite radius() method. */

        public override void mutate(int mutationflags, float mutationstrength)
        {
            if (BasePoly == null)
            {
                add(new cPolygon());
            }
            BasePoly.mutate(mutationflags, mutationstrength);
            cSprite ptipshapenew;

            if (TipShape != null)
            {
                ptipshapenew = TipShape.copy(); //Use this as a model
            }
            else
            {
                ptipshapenew = new cPolygon();
            }
            ptipshapenew.mutate(mutationflags, mutationstrength);
            //Make the tip shape have smaller radius than the basepoly.
            ptipshapenew.Radius = Framework.randomOb.mutate(ptipshapenew.Radius,
                                                            MIN_TIP_RADIUS_RATIO * BasePoly.Radius, MAX_TIP_RADIUS_RATIO * BasePoly.Radius,
                                                            mutationstrength);
            //Randomize the tip rotations.
            _tipangvelocity = Framework.randomOb.randomSign() * Framework.randomOb.mutate(_tipangvelocity, cPolyPolygon.MINTIPANGLEVELOCITY,
                                                                                          cPolyPolygon.MAXTIPANGLEVELOCITY, mutationstrength);
            //Make all the tips the same.
            TipShape = ptipshapenew; //This deletes ptipshapenew
            //More fixup
            _newgeometryflag = true; //Because you changed the relative positions of the tips.
        }
예제 #2
0
        public cCritterArmedPlayer(cGame pownergame = null)
            : base(pownergame)
        {
            _sensitive       = false;
            _collidepriority = cCollider.CP_PLAYER; /* Don't use the setCollidePriority mutator, as that
                                                     * forces a call to pgame()->buildCollider(); */
                                                    //	setDensity(cCritter.INFINITEDENSITY);
                                                    //So it can bull through.  But it's wiser to let the individual games do this.
            AttitudeToMotionLock = false;           /* We want the player's
                                                     * attitude to be controlled by the listner actions and not by bumping into things,
                                                     * or moving with gravity. */
            AimToAttitudeLock    = true;            /* Normally
                                                     * we want a player to shoot in the dirction of his attitude. */
            cPolygon ppolygon = new cPolygon(3);

            /* Now make it a thin isoceles triangle, with the apex at the 0th vertex.
             *          All that matters at first is the ratios of the numbers, as we will use
             *          seRadius to make the thing the right size. */
            ppolygon.setVertex(0, new cVector3(4.0f, 0.0f));
            ppolygon.setVertex(1, new cVector3(0.0f, 1.0f));
            ppolygon.setVertex(2, new cVector3(0.0f, -1.0f));
            ppolygon.Radius = cCritter.PLAYERRADIUS; //Make it to a good size.
            Sprite          = ppolygon;              /* Normally the _prismdz will get changed to PLAYERPRISMDZ
                                                      * by the cGame.setPlayer call */
            PrismDz         = cSprite.PLAYERPRISMDZ;
        }
예제 #3
0
        public override cSprite copy()
        {
            cPolygon p = new cPolygon();

            p.copy(this);
            return(p);
        }
예제 #4
0
        /* Useful for wrapping
         *  verts in a polygon class to pass to pgraphics->draw. */
        //Overloaded cSprite methods

        public override void copy(cSprite psprite) //Use this in copy constructor and operator=
        {
            /* Because our class has some CArray fields, we can't use the default overloaded
             * copy constructor and operator=.  So as to avoid having to maintain similar code
             * for these two different methods, we write a helper copy function that both
             * the copy constructor and the operator= can use. */
            base.copy(psprite); //does center(), _radius, _angle, _rotationspeed.
            if (!psprite.IsKindOf("cPolygon"))
            {
                return;                              //You're done if psprite isn't a cPolygon*.
            }
            cPolygon ppolygon = (cPolygon)(psprite); /* I know it is a cPolygon
                                                      * at this point, but I need to do a cast, so the compiler will let me
                                                      * call a bunch of cPolygon methods. */

            //Arrays
            _vectorvert.Copy(ppolygon._vectorvert);
            //Decoration fields
            cColorStyle c = new cColorStyle();

            c.copy(ppolygon.pcolorstyle());
            ColorStyle = c;
            cColorStyle c2 = new cColorStyle();

            c2.copy(ppolygon.DotColorStyle);
            DotColorStyle        = c2;
            _dotted              = ppolygon._dotted;
            _realdotradiusweight = ppolygon._realdotradiusweight;
            //Helper fields
            _convex = ppolygon._convex;
        }
예제 #5
0
        public static readonly float ACCENTRELIEF = 0.1f; //Raise the accent poly this much
        //Constructors

        public cSpriteBubble()
        {
            cPolygon pcircle = new cPolygon(cSpriteCircle.CIRCLESLICES);

            add(pcircle);
            setAccentPoly();
        }
예제 #6
0
        } /* Start out with no basepoly and no tipshape, user must
           *            fix this with a call to mutate or to setBasePoly and setTipShape. */

        public cPolyPolygon(int baseverts, int tipverts)
        {
            BasePoly = new cPolygon(baseverts);
            TipShape = new cPolygon(tipverts);
            randomize(cSprite.MF_RADIUS | cPolygon.MF_COLOR);
            //Randomize the tip rotations.
            _tipangvelocity = Framework.randomOb.randomReal(cPolyPolygon.MINTIPANGLEVELOCITY,
                                                            cPolyPolygon.MAXTIPANGLEVELOCITY);
            _tipangvelocity *= Framework.randomOb.randomSign();
        }
예제 #7
0
        public virtual void setAccentPoly()
        {
            cPolygon p = AccentPoly;

            if (p != null)
            {
                _childspriteptr.RemoveAt(1);
            }
            float side = 0.33f * (CirclePoly.Radius);

            cVector3[] pverts = new cVector3[] { new cVector3(0.0f, 0.0f, 0.0f), new cVector3(2 * side, 0.0f, 0.0f),
                                                 new cVector3(2 * side, side, 0.0f), new cVector3(0.0f, side, 0.0f) };
            cPolygon prectpoly = new cPolygon(4, pverts);

            prectpoly.SpriteAttitude = cMatrix3.translation(new cVector3(side, 0.5f * side, cSpriteBubble.ACCENTRELIEF));
            add(prectpoly);                   //Decoration rectangle.
            FillColor = CirclePoly.FillColor; //Make the accent color match the circle.
        }
예제 #8
0
        public cCritterTreasure(cGame pownergame, cVector3 position) :
            base(pownergame)
        {
            /* The sprites look nice from afar, but bitmap speed is really slow
             * when you get close to them, so don't use this. */
            cPolygon ppoly = new cPolygon(24);

            ppoly.Filled          = false;
            ppoly.LineWidthWeight = 0.5f;
            Sprite           = ppoly;
            _collidepriority = cCollider.CP_PLAYER + 1;                               /* Let this guy call collide on the
                                                                                       * player, as his method is overloaded in a special way. */
            rotate(new cSpin((float)Math.PI / 2.0f, new cVector3(0.0f, 0.0f, 1.0f))); /* Trial and error shows this
                                                                                       * rotation works to make it face the z diretion. */
            setRadius(cGame3D.TREASURERADIUS);
            FixedFlag = true;
            moveTo(position);
        }
예제 #9
0
        //Mutators 

        public void setEndsThicknessHeight(cVector3 enda, cVector3 endb,
            float thickness = THICKNESS, float height = WALLPRISMDZ)
        {
            _position = enda.add(endb).mult(0.5f);
            _wrapposition1.copy(_position);
            _wrapposition2.copy(_position);
            _wrapposition3.copy(_position);
            /* This line is important, as otherwise the 
        cCritter.draw will thing this thing was wrapped,
        and it'll get drawn in two places. */
            _tangent = endb.sub(enda);
            float length = _tangent.Magnitude;
            _tangent.normalize();
            _oldtangent.copy(_tangent);
            _normal = _tangent.defaultNormal(); /* We orient so that
			the normal is oriented to the tangent as the "y-axis"
			is to the the "x-axis".*/
            _binormal = _tangent.mult(_normal);
            _attitude = new cMatrix3(_tangent, _normal, _binormal, _position);
            Skeleton = new cRealBox3(length, thickness, height);
            Speed = 0.0f; /* Also sets _velocity to ZEROVECTOR,
			but doesn't wipe out _direction. */
            /*In looking at these settings, think of the wall as aligned horizontally with endb - enda pointing to the right and the normal pointing into the screen*/
            cPolygon ppolygon = new cPolygon(4);
            ppolygon.Edged = true;
            ppolygon.FillColor = Color.Gray;
            ppolygon.LineWidthWeight = cColorStyle.LW_IGNORELINEWIDTHWEIGHT;
            ppolygon.LineWidth = 1;
            //Means draw a one-pixel edge line.
            ppolygon.setVertex(0, new cVector3(0.5f * length, 0.5f * thickness));
            ppolygon.setVertex(1, new cVector3(-0.5f * length, 0.5f * thickness));
            ppolygon.setVertex(2, new cVector3(-0.5f * length, -0.5f * thickness));
            ppolygon.setVertex(3, new cVector3(0.5f * length, -0.5f * thickness));
            ppolygon.fixCenterAndRadius(); /* Use this call after a bunch
			of setVertex if points are just where you want. */
            ppolygon.SpriteAttitude = cMatrix3.translation(new cVector3(0.0f, 0.0f, -height / 2.0f));
            /* This corrects for the fact that we always draw the ppolygon with its
        bottom face in the xy plane and its top in the plane z = height.  We
        shift it down so it's drawn to match the skeleton positon. */
            Sprite = ppolygon; /* Also sets cSprite._prismdz to
			cCritter._defaultprismdz, which we set to 
			CritterWall.WALLPRISMDZ in our cCritterWall 
			constructor. */
        }
예제 #10
0
        /// <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
        }
예제 #11
0
 public virtual void drawstarpolygon(cPolygon ppolygon, int drawflags)
 {
 }