Beispiel #1
0
        public static Vector2 ExplosionForce(ModelContainar ball, Vector3 bombPosition)
        {
            Vector2 direction = new Vector2(ball.Position.X - bombPosition.X, ball.Position.Z - bombPosition.Z);
            float   distance  = (float)(Math.Pow(direction.X, 2) + Math.Pow(direction.Y, 2));

            direction.Normalize();
            Vector2 force = 10000000 / distance * direction;

            force.X = (Math.Abs(force.X) > 100000) ? Math.Sign(force.X) * 100000 : force.X;
            force.Y = (Math.Abs(force.Y) > 100000) ? Math.Sign(force.Y) * 100000 : force.Y;
            return(-force / ball.Mass);
        }
Beispiel #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            Configuration conf = Content.Load <Configuration>("Config");

            Globals.config = conf;

            explosionParticles       = new ParticleSystem(this, Content, "Particle\\ExplosionSettings");
            explosionSmokeParticles  = new ParticleSystem(this, Content, "Particle\\ExplosionSmokeSettings");
            projectileTrailParticles = new ParticleSystem(this, Content, "Particle\\ProjectileTrailSettings");

            explosionSmokeParticles.DrawOrder  = 200;
            projectileTrailParticles.DrawOrder = 300;
            explosionParticles.DrawOrder       = 400;

            scene     = new Scene(this);
            ball      = new ModelContainar(this);
            table     = new ModelContainar(this);
            baseTable = new ModelContainar(this);
            maze      = new ModelContainar(this);
            bomb      = new ModelContainar(this);

            holes = new ModelContainar[Globals.config.numberOfHoles];

            Components.Add(scene);
            Components.Add(ball);
            Components.Add(table);
            Components.Add(baseTable);
            Components.Add(maze);
            Components.Add(bomb);

            Components.Add(explosionParticles);
            Components.Add(explosionSmokeParticles);
            Components.Add(projectileTrailParticles);


            for (int i = 0; i < Globals.config.numberOfHoles; i++)
            {
                holes[i] = new ModelContainar(this);
                Components.Add(holes[i]);
            }
        }
Beispiel #3
0
 public Physics(ModelContainar model)
 {
     this.model = model;
 }
Beispiel #4
0
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public Game()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);

            Configuration conf = Content.Load <Configuration>("Config");

            Globals.config = conf;

            graphics.PreferredBackBufferWidth  = 1024;
            graphics.PreferredBackBufferHeight = 768;

            explosionParticles       = new ParticleSystem(this, Content, Globals.config.particleExplosion);
            explosionSmokeParticles  = new ParticleSystem(this, Content, Globals.config.particleExplosionSmoke);
            projectileTrailParticles = new ParticleSystem(this, Content, Globals.config.particleProjectileTrail);
            smokePlumeParticles      = new ParticleSystem(this, Content, Globals.config.particleSmokePlume);


            smokePlumeParticles.DrawOrder      = 100;
            explosionSmokeParticles.DrawOrder  = 200;
            projectileTrailParticles.DrawOrder = 300;
            explosionParticles.DrawOrder       = 400;

            environmentMap = new EnvironmentMap(this);

            table     = new ModelContainar(this);
            baseTable = new ModelContainar(this);
            maze      = new ModelContainar(this);

            ball = new ModelContainar(this, Globals.config.ballRollingPath, Globals.config.ballHittingPath, string.Empty);

            lensFlare = new LensFlareComponent(this);

            hole = new ModelContainar[Globals.config.numberOfHoles];

            for (int i = 0; i < Globals.config.numberOfHoles; i++)
            {
                hole[i] = new ModelContainar(this);
            }

            bomb        = new ModelContainar[Globals.config.numberOfBombs];
            bombHole    = new ModelContainar[Globals.config.numberOfBombs];
            redButton   = new ModelContainar[Globals.config.numberOfBombs];
            greenButton = new ModelContainar[Globals.config.numberOfBombs];

            for (int i = 0; i < Globals.config.numberOfBombs; i++)
            {
                bomb[i]        = new ModelContainar(this, Globals.config.explosionTimerPath, Globals.config.explosionPath, Globals.config.neutralizationPath);
                bombHole[i]    = new ModelContainar(this);
                redButton[i]   = new ModelContainar(this);
                greenButton[i] = new ModelContainar(this);
            }

            checkpoint = new ModelContainar[Globals.config.numberOfCheckpoint];

            for (int i = 0; i < Globals.config.numberOfCheckpoint; i++)
            {
                checkpoint[i] = new ModelContainar(this, Globals.config.checkpointPath, string.Empty, string.Empty);
            }


            // Create the screen manager component.
            screenManager           = new ScreenManager(this);
            screenManager.DrawOrder = 1000;
            Components.Add(screenManager);

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(this), null);
        }