コード例 #1
0
        public override bool collide(cCritter pcritter)
        {
            bool collided = base.collide(pcritter);

            if (collided && pcritter.IsKindOf("cCritter3DPlayer"))
            {
                count++;
                cCritter3DPlayer player = (cCritter3DPlayer)pcritter;
                if (count >= DELAY)
                {
                    player.damage(DAMAGE);
                    count = 0;
                }
            }

            return(collided);
        }
コード例 #2
0
        public override bool collide(cCritter pcritter)
        {
            cCritter3DPlayer player = (cCritter3DPlayer)pcritter;

            if (contains(player)) //disk of pcritter is wholly inside my disk
            {
                Framework.snd.play(Sound.Clap);
                player.Health = cCritter3DPlayer.MAX_HEALTH;
                // one time use for the med pack
                delete_me();
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public cGame3D()
        {
            cRoom Room = new cRoom(this, 3);

            player = new cCritter3DPlayer(this);
            setPlayer(player);
            Room.Place(player, 4, 4);



            /*
             * doorcollision = false;
             * _menuflags &= ~ cGame.MENU_BOUNCEWRAP;
             * _menuflags |= cGame.MENU_HOPPER; //Turn on hopper listener option.
             * _spritetype = cGame.ST_MESHSKIN;
             *
             *
             * setBorder( 64.0f, 16.0f, 64.0f ); // size of the world
             *
             * cRealBox3 skeleton = new cRealBox3();
             * skeleton.copy(_border);
             *
             * SkyBox.setSideSolidColor( cRealBox3.HIZ, Color.Aqua ); //Make the near HIZ transparent
             * SkyBox.setSideSolidColor( cRealBox3.LOZ, Color.Aqua ); //Far wall
             * SkyBox.setSideSolidColor( cRealBox3.LOX, Color.DarkOrchid ); //left wall
             * SkyBox.setSideTexture( cRealBox3.HIX, BitmapRes.Wall2, 2 ); //right wall
             * SkyBox.setSideTexture( cRealBox3.LOY, BitmapRes.Graphics3 ); //floor
             * SkyBox.setSideTexture( cRealBox3.HIY, BitmapRes.Sky ); //ceiling
             *
             * WrapFlag = cCritter.BOUNCE;
             * _seedcount = 7;
             * setPlayer( new cCritter3DPlayer( this ));
             * _ptreasure = new cCritterTreasure( this );
             * shape = new cCritterShape(this);
             * shape.Sprite = new cSphere( 3, Color.DarkBlue );
             * shape.moveTo(new cVector3( Border.Midx, Border.Hiy, Border.Midz ));
             *
             *
             * float height = 0.1f * _border.YSize;
             * float ycenter = -_border.YRadius + height / 2.0f;
             * float wallthickness = cGame3D.WALLTHICKNESS;
             * cCritterWall pwall = new cCritterWall(
             *      new cVector3( _border.Midx + 2.0f, ycenter, zpos ),
             *      new cVector3( _border.Hix, ycenter, zpos ),
             *      height, //thickness param for wall's dy which goes perpendicular to the
             *              //baseline established by the frist two args, up the screen
             *      wallthickness, //height argument for this wall's dz  goes into the screen
             *      this );
             * cSpriteTextureBox pspritebox =
             *      new cSpriteTextureBox( pwall.Skeleton, BitmapRes.Wall3, 16 ); //Sets all sides
             *
             * pwall.Sprite = pspritebox;
             *
             *
             * //Then draw a ramp to the top of the wall.  Scoot it over against the right wall.
             * float planckwidth = 0.75f * height;
             * pwall = new cCritterWall(
             *      new cVector3( _border.Hix -planckwidth / 2.0f, _border.Loy, _border.Hiz - 2.0f),
             *      new cVector3( _border.Hix - planckwidth / 2.0f, _border.Loy + height, zpos ),
             *      planckwidth, //thickness param for wall's dy which is perpenedicualr to the baseline,
             *                      //which goes into the screen, so thickness goes to the right
             *      wallthickness, //_border.zradius(),  //height argument for wall's dz which goes into the screen
             *      this );
             * cSpriteTextureBox stb = new cSpriteTextureBox(pwall.Skeleton,
             * BitmapRes.Wood2, 2 );
             * pwall.Sprite = stb;
             *
             * cCritterDoor pdwall = new cCritterDoor(
             *      new cVector3( _border.Lox, _border.Loy, _border.Midz ),
             *      new cVector3( _border.Lox, _border.Midy - 3, _border.Midz ),
             *      0.1f, 2, this );
             * cSpriteTextureBox pspritedoor =
             *      new cSpriteTextureBox( pdwall.Skeleton, BitmapRes.Door );
             * pdwall.Sprite = pspritedoor;
             *
             */
        }
コード例 #4
0
        public override void listen(float dt, cCritter pcritter)
        {
            pcritter.Acceleration = new cVector3(0.0f, pcritter.Acceleration.Y, 0.0f);

            bool left     = Framework.Keydev[vk.A];
            bool right    = Framework.Keydev[vk.D];
            bool up       = Framework.Keydev[vk.W];
            bool down     = Framework.Keydev[vk.S];
            bool space    = Framework.Keydev[vk.Space];
            bool pagedown = Framework.Keydev[vk.PageDown];
            bool lControl = Framework.Keydev[vk.ControlLeft];

            cCritter3DPlayer playerCritter = (cCritter3DPlayer)pcritter;

            if (!left && !right && !down && !up && !pagedown && !space && !lControl && !playerCritter.CountingFrames)
            {
                pcritter.Velocity          = new cVector3(0.0f, pcritter.Velocity.Y, 0.0f);
                pcritter.Acceleration      = new cVector3(0.0f, pcritter.Acceleration.Y, 0.0f);
                pcritter.Sprite.ModelState = State.Idle;
                return;
            }

            if ((up || down || right || left) && !_hopping && !playerCritter.CountingFrames)
            {
                pcritter.Sprite.ModelState = State.Run;
            }


            if (up)
            {
                pcritter.Velocity = new cVector3(-pcritter.MaxSpeed / 4, pcritter.Velocity.Y, pcritter.Velocity.Z);
            }

            else if (down)
            {
                pcritter.Velocity = new cVector3(pcritter.MaxSpeed / 4, pcritter.Velocity.Y, pcritter.Velocity.Z);
            }
            else
            {
                pcritter.Velocity = new cVector3(0, pcritter.Velocity.Y, pcritter.Velocity.Z);
            }
            if (space && !_hopping)
            {
                pcritter.Acceleration      = new cVector3(0.0f, _hopStrength, 0.0f);
                pcritter.Sprite.ModelState = State.Jump;
                Framework.snd.play(Sound.Blink);
                _hopping = true;
            }

            //   if (pagedown)
            //     pcritter.Velocity = new cVector3(0.0f, pcritter.MaxSpeed, 0.0f);
            if (right)
            {
                pcritter.Velocity = new cVector3(pcritter.Velocity.X, pcritter.Velocity.Y, -pcritter.MaxSpeed / 4);
            }
            else if (left)
            {
                pcritter.Velocity = new cVector3(pcritter.Velocity.X, pcritter.Velocity.Y, pcritter.MaxSpeed / 4);
            }
            else
            {
                pcritter.Velocity = new cVector3(pcritter.Velocity.X, pcritter.Velocity.Y, 0);
            }

            //Now match the attitude.
            if (pcritter.AttitudeToMotionLock)
            {
                /* Need this condition if you want
                 * to have a "spaceinvaders" type shooter that always points up as in
                 * the textbook problem 3.11 */
                pcritter.copyMotionMatrixToAttitudeMatrix();
            }
            //Note that if pcritter is cCritterArmed*, then the cCritterArmed.listen does more stuff.

            if (pcritter.Position.Y <= pcritter.Game.Border.Loy + 2)
            {
                _hopping = false;
            }

            if (lControl)
            {
                if (pcritter.IsKindOf("cCritter3DPlayer"))
                {
                    _meleeAttacking = true;
                    cCritter3DPlayer player = (cCritter3DPlayer)pcritter;
                    player.MeleeAttack();
                    _meleeAttacking = false;
                }
            }
        }