Ejemplo n.º 1
0
 public Beam(GameObject gameObject,
     Model model,
     ExplosionObject[] explosions,
     Effect effect,
     float modelSize,
     Vector3 rot)
     : base(gameObject, model, modelSize, 1f, rot)
 {
     mEffect = effect;
       mVertices = new VertexPositionColor[12];
       mExplosions = explosions;
 }
Ejemplo n.º 2
0
        private void CreateShipExplosion(Vector3 position)
        {
            var explosionObject1 = new ExplosionObject(position, mExplosionTex, Color.White, 4, 5, 0.8f, 0.7f);
              var explosionObject2 = new ExplosionObject(position, mExplosionTex, Color.Red, 4, 5);
              mExplosionList.Add(explosionObject1);
              mExplosionList.Add(explosionObject2);

              mSound.PlayExplosion();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new graphical representation
        /// based on the specified logic object
        /// </summary>
        /// <param name="logicRef">reference to the logic representation</param>
        public void CreateGraphicObject(GameObject logicRef)
        {
            Model model;
              Texture2D texture = null;
              var lightShader = mContent.Load<Effect>("Shader/light");
              var basicShader = mContent.Load<Effect>("Shader/basic");
              Vector3 rotation = Vector3.Zero;
              float modelScale = 1f;
              float boundingScale = 1f;

              if (logicRef is Interceptor)
              {
            model = mContent.Load<Model>("Models/Ships/Interceptor");
            texture = mContent.Load<Texture2D>("Textures/interceptor");
            modelScale = 0.2f;
            boundingScale = 0.25f;
              }
              else if (logicRef is Predator)
              {
            model = mContent.Load<Model>("Models/Ships/Predator");
            texture = mContent.Load<Texture2D>("Textures/interceptor");
            modelScale = 0.2f;
            boundingScale = 0.25f;
              }
              else if (logicRef is Defender)
              {
            model = mContent.Load<Model>("Models/Ships/Defender");
            texture = mContent.Load<Texture2D>("Textures/interceptor");
            modelScale = 0.2f;
            boundingScale = 0.25f;
              }
              else if (logicRef is Planet)
              {
            model = mContent.Load<Model>("Models/TerrestricalPlanet");

            switch (((Planet) logicRef).PlanetSize)
            {
              case PlanetSize.Small:
              {
            texture = mContent.Load<Texture2D>("Textures/Planets/planet_tex_1");
            modelScale = 1f;
            boundingScale = 1.2f;
            break;
              }
              case PlanetSize.Medium:
              {
            texture = mContent.Load<Texture2D>("Textures/Planets/planet_tex_2");
            modelScale = 1.5f;
            boundingScale = 1.8f;
            break;
              }
              case PlanetSize.Large:
              {
            texture = mContent.Load<Texture2D>("Textures/Planets/planet_tex_3");
            modelScale = 2.0f;
            boundingScale = 2.4f;
            break;
              }
            }
              }
              else if (logicRef is Minion)
              {
            model = mContent.Load<Model>("Models/Ships/minion2");
            texture = mContent.Load<Texture2D>("Textures/minion");
            modelScale = 0.15f;
            boundingScale = 0f;
            rotation = new Vector3(MathHelper.ToRadians(-90), 0, 0);
              }
              else if (logicRef is DeathStar)
              {
            model = mContent.Load<Model>("Models/Deathstarss");
            modelScale = 100f;
            boundingScale = 2500f;
            rotation = new Vector3(0, 5.3f, 0);
              }
              else if (logicRef is Laser)
              {
            switch (((Laser) logicRef).mLaserType)
            {
              default:
            model = mContent.Load<Model>("Models/shot");
            modelScale = 0.09f;
            mSound.PlayAttackSoundInterceptor();
            break;
              case LaserType.Predator:
            model = mContent.Load<Model>("Models/shot");
            modelScale = 0.09f;
            mSound.PlayAttackSoundPredator();
            break;
              case LaserType.Defender:
            model = mContent.Load<Model>("Models/shot_big");
            modelScale = 0.1f;
            mSound.PlayAttackSoundDefender();
            break;
              case LaserType.DeathStarLaser:
            model = mContent.Load<Model>("Models/shot_big");
            modelScale = 0.1f;
            mSound.PlayAttackSoundDeathstarShip();
            break;
              case LaserType.DeathStarBeam:
            model = mContent.Load<Model>("Models/shot_big");
            modelScale = 0.3f /** (((Laser)logicRef).mLength) / 300*/;
            var tmpLaser = logicRef as Laser;

            Vector2 surfacePoint = tmpLaser.mTargetPosition -
                                   100 / (tmpLaser.mTargetPosition - tmpLaser.mStartPosition).Length() *
                                   (tmpLaser.mTargetPosition - tmpLaser.mStartPosition);

            var explosions = new ExplosionObject[2];

            explosions[0] = new ExplosionObject(new Vector3(surfacePoint, 0),
                                                mExplosionTex,
                                                Color.Blue,
                                                4,
                                                5,
                                                1,
                                                0.5f,
                                                false);
            explosions[1] = new ExplosionObject(new Vector3(surfacePoint, 0),
                                                mExplosionTex,
                                                Color.LightBlue,
                                                4,
                                                5,
                                                0.5f,
                                                0.5f,
                                                false);

            mExplosionList.Add(explosions[0]);
            mExplosionList.Add(explosions[1]);

            mGraphicObjects.Add(new Beam(logicRef, model, explosions, basicShader, 1f, Vector3.Zero));

            mSound.PlayAttackSoundDeathstar();
            break;
            }
            rotation = new Vector3(MathHelper.ToRadians(0), 180, MathHelper.ToRadians(0));
              }
              else if (logicRef is Asteroid)
              {
            model = mContent.Load<Model>("Models/asteroid_01");
            texture = mContent.Load<Texture2D>("Textures/asteroid");
            modelScale = 0.075f + (float) mRandom.NextDouble() * 0.025f;
            rotation = new Vector3((float) (Math.PI * mRandom.NextDouble()), 0, (float) (Math.PI * mRandom.NextDouble()));
            boundingScale = 0f;
              }
              else
              {
            model = mContent.Load<Model>("Models/dummy");
              }

              if (logicRef is Laser)
              {
            if (((Laser) logicRef).mLaserType != LaserType.DeathStarBeam)
              mGraphicObjects.Add(new EffectObject(logicRef, model, modelScale, 0, rotation));
              }
              else
            mGraphicObjects.Add(new ModelObject(logicRef, model, texture, lightShader, modelScale, boundingScale, rotation));
        }
Ejemplo n.º 4
0
 public void RemoveExplosion(ExplosionObject explosionObject)
 {
     mExplosionList.Remove(explosionObject);
 }