예제 #1
0
        public Missile(ParentGame game, Model modelObj, Texture2D[] modelTextures, DrawingClass drawClass, GameplayScreen Screen)
            : base(game, modelObj, modelTextures)
        {
            this.drawClass = drawClass;
            this.Screen = Screen;

            _body = new Body();
            _skin = new CollisionSkin(_body);
            _body.CollisionSkin = _skin;

            Box box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(1f,1f,4f));
            _skin.AddPrimitive(box, new MaterialProperties(0.8f, 0.8f, 0.7f));

            Vector3 com = SetMass(2.0f);

            _body.MoveTo(position, Matrix.Identity);
            _skin.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            _body.EnableBody();

            Body.ExternalData = this;

            Vector3 pos = position;
            Vector3 forwardVec = Body.Orientation.Forward;
            forwardVec.Normalize();

            pos -= forwardVec * 10;
            // Use the particle emitter helper to output our trail particles.
            trailEmitter = new ParticleEmitter(drawClass.projectileTrailParticles,
                                               trailParticlesPerSecond, position);

            rgob = new RagdollObject(parentGame, null, null, null, RagdollObject.RagdollType.Simple, 1.0f, 3);
            rgob.Position = position;
            //rgob.PutToSleep();

            //rgob.limbs[0].PhysicsBody.AngularVelocity = (new Vector3(1, 1, 0) * 2000);

            RagdollTransforms = new List<Matrix>();

            RagdollTransforms = rgob.GetWorldMatrix();

            foreach (JigLibX.Objects.PhysicObject lim in rgob.limbs)
                DisableCollisions(lim.PhysicsBody, Body);

            foreach (JigLibX.Objects.PhysicObject lim in rgob.limbs)
                foreach (BuildingPiece pic in Screen.PieceList)
                    DisableCollisions(lim.PhysicsBody, pic.Body);

            foreach (JigLibX.Objects.PhysicObject lim in rgob.limbs)
                foreach (Building bld in Screen.Buildings)
                    DisableCollisions(lim.PhysicsBody, bld.Body);

            foreach (JigLibX.Objects.PhysicObject lim in rgob.limbs)
                DisableCollisions(lim.PhysicsBody, Screen.terrainActor.Body);

            foreach (JigLibX.Objects.PhysicObject limb0 in rgob.limbs)
                foreach (Missile mis in Screen.BulletList)
                    foreach (JigLibX.Objects.PhysicObject limb1 in mis.rgob.limbs)
                        DisableCollisions(limb1.PhysicsBody, limb0.PhysicsBody);
        }
예제 #2
0
        public BuildingPiece(ParentGame game, Model modelObj, Texture2D[] modelTextures,
            DrawingClass drawClass, GameplayScreen Screen, float Length, float Width, float Height)
            : base(game, modelObj, modelTextures)
        {
            // Use the particle emitter helper to output our trail particles.
            trailEmitter = new ParticleEmitter(drawClass.smokePlumeParticles,
                                               3, position);

            fireEmitter = new ParticleEmitter(drawClass.fireParticles,
                                               30, position);

            this.Screen = Screen;
            this.drawClass = drawClass;

            _body = new Body();
            _skin = new CollisionSkin(_body);
            _body.CollisionSkin = _skin;

            //Box box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(10f, 7f, 7f));
            Box box = new Box(Vector3.Zero, Matrix.Identity, new Vector3(Length, Width, Height));
            if (Length > Width && Length > Height)
                boundSphere.Radius = Length;
            else if (Width > Length && Width > Height)
                boundSphere.Radius = Width;
            else
                boundSphere.Radius = Height;
            _skin.AddPrimitive(box, new MaterialProperties(0.8f, 0.8f, 0.7f));

            Vector3 com = SetMass(3.0f);

            _body.MoveTo(position, Matrix.Identity);
            _skin.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            _body.EnableBody();

            Body.ExternalData = this;

            SetBody(rotation);

            Body.AllowFreezing = true;
            Body.SetDeactivationTime(1);

            foreach (BuildingPiece pic in Screen.PieceList)
                DisableCollisions(this.Body, pic.Body);

            foreach (Building bld in Screen.Buildings)
                DisableCollisions(this.Body, bld.Body);
        }
예제 #3
0
        public Building(ParentGame game, Model modelObj, Texture2D[] modelTextures,
            Vector3 Position, float Scale, Vector3 Rotation, string Type, GameplayScreen Screen)
            : base(game, modelObj, modelTextures)
        {
            // Use the particle emitter helper to output our trail particles.
            //trailEmitter = new ParticleEmitter(parentGame.projectileTrailParticles,
            //                                   trailParticlesPerSecond, position);

            this.Screen = Screen;
            this.drawClass = Screen.NormalDrawing;
            this.Type = Type;

            position = Position;
            scale = Scale;
            rotation = Rotation;

            Initialize();
        }
예제 #4
0
        /// <summary>
        /// Unload graphics content used by the game.
        /// </summary>
        public override void UnloadContent()
        {
            List<Body> Bodies = new List<Body>();
            foreach (Body body in PhysicsSystem.CurrentPhysicsSystem.Bodies)
                Bodies.Add(body);

            foreach (Body body in Bodies)
                PhysicsSystem.CurrentPhysicsSystem.RemoveBody(body);

            List<CollisionSkin> Skins = new List<CollisionSkin>();
            foreach (CollisionSkin skin in PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.CollisionSkins)
                Skins.Add(skin);

            foreach (CollisionSkin skin in Skins)
                PhysicsSystem.CurrentPhysicsSystem.CollisionSystem.RemoveCollisionSkin(skin);

            parentGame.Components.Remove(terrainActor);
            terrainActor.Dispose();

            NormalDrawing.Unload();
            terrainEngine.Unload();

            Player.baseRotationValue = 0;
            Player.cannonRotationValue = 0;
            Player.turretRotationValue = 0;

            Player.baseBone.Transform = Matrix.Identity;
            Player.Unload();

            Player = null;
            MouseCam = null;
            terrainEngine = null;

            //LevelVars = null;
            NormalDrawing = null;

            //ambieCue = parentGame.soundBank.GetCue("ambient");
            //ambieCue.Stop(AudioStopOptions.Immediate);

            if (ambieCue != null && ambieCue.IsPlaying)
                ambieCue.Stop(AudioStopOptions.Immediate);

            if (birdCue.IsCreated && birdCue.IsPlaying)
                birdCue.Stop(AudioStopOptions.Immediate);

            if (cue != null && cue.IsPlaying)
                cue.Stop(AudioStopOptions.Immediate);

            SetScore();

            #if XBOX
            parentGame.SaveGame();
            #endif

            parentGame = null;

            content.Unload();
        }
예제 #5
0
        /// <summary>
        /// Assign variables the proper loaded objects.
        /// </summary>
        void LevelPostLoad()
        {
            parentGame.InitializePhysics();

            LoadTerrain();
            LoadObjects();
            LoadCamera();

            BulletList = new List<Missile>();
            Buildings = new List<Building>();
            PieceList = new List<BuildingPiece>();

            Particles = new List<ParticleEmitter>();

            NormalDrawing = new DrawingClass(parentGame, this,
                BulletList, Buildings, PieceList);

            float screenscale =
                (float)parentGame.device.Viewport.Width / 800f;
            SpriteScale = Matrix.CreateScale(screenscale, screenscale, 1);

            RotateCue = parentGame.soundBank.GetCue("rotate");
            ElevateCue = parentGame.soundBank.GetCue("elevate");
            PowerCue = parentGame.soundBank.GetCue("power");
            FireworkCue = parentGame.soundBank.GetCue("firework");

            TerrEditor = new TerrainEditor(parentGame, this, terrainEngine);

            parentGame.SlowTime = false;
        }