Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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. */
        }