Esempio n. 1
0
        public Ship(Game1 game)
            : base(game)
        {
            this.game = game;

            lastNodePos = Vector2.Zero;
            pos = new Vector3(90, 4.5f, 0);
            moveSpeed = 0;
            accel = 0.5f;
            maxSpeed = 0.2f;
            boostSpeed = 0.6f;
            direction = new Vector3(0, 0, -1);
            currentTurnSpeed = 0;
            maxTurnSpeed = MathHelper.PiOver4 / 30;

            boundingBox = new OOBB(pos, direction, 1.5f, 1.5f); // Need to be changed to be actual ship dimentions
            circleCol = new CircleCollider(pos, 0.75f);

            shipModel = new ShipModel(this, game);
            //shipModel = new ShipModel(game.Content.Load<Model>(@"Models/Enemies/Cubes/guncube"), this);
            skyboxModel = new SkyboxModel(game.Content.Load<Model>(@"Models/Misc/Skybox/skybox"), this);
            speedCyl = new SpeedCylModel(game.Content.Load<Model>(@"Models/Misc/speedCyl"), this, ((Game1)Game));
            rbowTun = new RainbowTunnelModel(game.Content.Load<Model>(@"Models/Misc/Rbow/rbowTun"), this, ((Game1)Game));

            game.modelManager.addObject(shipModel);
            game.modelManager.add(skyboxModel);
            game.modelManager.addObject(rbowTun);
            game.modelManager.addTransparent(speedCyl);

            weapons = new WeaponSystem(this, this.game);
            moneyManager = new MoneyManager(this.game);
            particles = new ShipParticleSystem(this.game, this);
            shipHealth = new ShipHealthSystem(this.game, this);

            game.Components.Add(weapons);
            game.Components.Add(moneyManager);
            game.Components.Add(particles);
            game.Components.Add(shipHealth);

            ((WeaponDrill)weapons.weapons.ElementAt(4)).dome.setShip(this);
            alive = true;
        }
        public ShipThrustParticle(Game1 game, Ship ship, ShipParticleSystem particles, int type)
            : base()
        {
            if(type != 4)
                this.model = TextureManager.square;
            else
                this.model = TextureManager.flameSquare;

            this.game = game;
            this.ship = ship;
            this.particles = particles;
            this.type = type;
            time = 0;

            switch(type)
            {
                default:
                    break;
                case 0:
                    tex = TextureManager.particle1small;
                    fScale = 0.015f;
                    distance = -0.35f;
                    break;

                case -1:
                case 1:
                    tex = TextureManager.particle1small;
                    sb = new SpriteBatch(game.GraphicsDevice);
                    rTarg = new RenderTarget2D(game.GraphicsDevice, 64, 64);
                    fScale = 0.02f;
                    rot.Z = Utilities.nextFloat() * MathHelper.PiOver2;
                    distance = -0.35f;
                    alpha = 1;
                    col = Color.White;
                    pos = ship.pos+ship.direction*distance;
                    break;
                case 2:
                case 3:
                    tex = TextureManager.smoke1;
                    sb = new SpriteBatch(game.GraphicsDevice);
                    rTarg = new RenderTarget2D(game.GraphicsDevice, 64, 64);
                    fScale = 0.02f;
                    rot.Z = Utilities.nextFloat() * MathHelper.PiOver2;
                    distance = -0.35f;
                    alpha = 1;
                    if (type == 2)
                        col = Color.Orange;
                    else
                        col = Color.Cyan;
                    pos = ship.pos+ship.direction*distance;
                    break;
                case 4:
                    tex = TextureManager.boostFlame;
                    rTarg = new RenderTarget2D(game.GraphicsDevice, 64, 128);
                    sb = new SpriteBatch(game.GraphicsDevice);
                    alpha = 1;
                    fScale = 0;
                    distance = -0.35f;
                    time = 0;
                    rot = new Vector3(-.3f, MathHelper.Pi, Utilities.nextFloat()*MathHelper.Pi*2);

                    rotAxis.X = (float)Math.Sin(rot.Y);
                    rotAxis.Z = (float)Math.Cos(rot.Y);
                    rotAxis.Y = (float)Math.Sin(rot.X);
                    rotAxis.Normalize();
                    break;
                case 5:
                    fScale = 0;
                    distance = -0.35f;
                    pos = ship.pos + ship.direction * distance;
                    rot.Z = (float)Utilities.random.NextDouble() * MathHelper.Pi * 2;
                    tex = TextureManager.particle3small;
                    model = TextureManager.square;
                    col = Color.Cyan;
                    sb = new SpriteBatch(game.GraphicsDevice);
                    rTarg = new RenderTarget2D(game.GraphicsDevice, 64, 64);
                    alpha = 1;
                    break;
            }
        }