Ejemplo n.º 1
0
        //add a bi-direction particle spread at the center of a pair of objects
        static void addScrapeEffect(GameObjectPair objects)
        {
            Vector2 normal = GameObject.GetNormal(objects);

            //first emitter
            ParticleEmitter temp1 = new ParticleEmitter(
                SCRAPE_PARTICLES,
                objects.CenterPoint(), //use center of both as reference
                ExplosionParticleTextures,
                SCRAPE_COLORS.ToList<Color>(),
                SCRAPE_FRAMES_TO_LIVE,
                true,
                true, //fading enabled
                PARTICLE_TIME_TO_EMIT,
                SCRAPE_PARTICLES / PARTICLE_TIME_TO_EMIT,
                SCRAPE_EJECTION_SPEED,
                PARTICLERANDOMIZATION,
                MathHelper.ToDegrees(normal.RotateTo()), //get the velocity angle + 90 degrees
                SCRAPE_SPRAY);

            //second emitter
            ParticleEmitter temp2 = new ParticleEmitter(
                SCRAPE_PARTICLES,
                objects.CenterPoint(),
                ExplosionParticleTextures,
                SCRAPE_COLORS.ToList<Color>(),
                SCRAPE_FRAMES_TO_LIVE,
                true,
                true,
                PARTICLE_TIME_TO_EMIT,
                SCRAPE_PARTICLES / PARTICLE_TIME_TO_EMIT,
                SCRAPE_EJECTION_SPEED,
                PARTICLERANDOMIZATION,
                MathHelper.ToDegrees(normal.RotateTo() + 180),
                SCRAPE_SPRAY);

            //inherit velocities
            Vector2 temp = objects.Object1.Velocity.Center(objects.Object2.Velocity);
            temp1.VelocityToInherit = temp;
            temp2.VelocityToInherit = temp;

            //set depths
            temp1.ParticleDrawDepth = EFFECT_DRAW_DEPTH;
            temp2.ParticleDrawDepth = EFFECT_DRAW_DEPTH;

            emitters.Add(temp1);
            emitters.Add(temp2);
        }
Ejemplo n.º 2
0
        //add an omni-directional particle burst at specified point
        static void addExplosion(Vector2 point)
        {
            ParticleEmitter temp = new ParticleEmitter(
                EXPLOSION_PARTICLES, //random amount of particles
                point, //at the point
                ExplosionParticleTextures,
                EXPLOSION_COLORS.ToList<Color>(), //colors to list
                EXPLOSION_FRAMES_TO_LIVE,
                true,
                true,
                PARTICLE_TIME_TO_EMIT,
                EXPLOSION_PARTICLES / PARTICLE_TIME_TO_EMIT, //emit max particles in one tick
                EXPLOSION_EJECTION_SPEED,
                PARTICLERANDOMIZATION,
                0f, //no direction needed
                ParticleEmitter.EXPLOSIONSPRAY); //360 degree explosion

            temp.ParticleDrawDepth = EFFECT_DRAW_DEPTH;

            emitters.Add(temp);
        }
Ejemplo n.º 3
0
        //reset the player, location, and explosion emitter
        public static void Reset()
        {
            StoredOre += CurrentOre;
            //Health = STARTING_HEALTH;

            //reset the ship object
            Ship.Animating = false;
            Ship.CurrentFrame = 0;
            Ship.WorldCenter = new Vector2(Camera.WorldRectangle.Width / 2, Camera.WorldRectangle.Height);
            Ship.RotationalVelocity = 0f;
            Ship.Rotation = 0f;
            Ship.Velocity = new Vector2(0, -50);

            //the engine trails
            LeftEngineTrail.Emitting = false;
            RightEngineTrail.Emitting = false;

            //equipment and flags
            ActiveSlot = INITIAL_ACTIVE_SLOT;
            CurrentOre = STARTING_ORE;
            dead = false;
            StabilizeRotation = true;
            Ship.Active = true;

            //and the on-death particle emitter
            ExplosionEmitter = new ParticleEmitter(
                EXPLOSION_PARTICLES_TO_EMIT,
                Ship.WorldCenter,
                explosionParticles,
                EXPLOSION_COLORS.ToList<Color>(),
                EXPLOSION_FTL,
                false,
                true,
                EXPLOSION_TIME_TO_EMIT,
                EXPLOSION_PARTICLES_TO_EMIT / EXPLOSION_TIME_TO_EMIT,
                EXPLOSION_EJECTION_SPEED,
                EXPLOSION_RANDOMIZATION,
                0f, 180f);
            ExplosionEmitter.WorldPosition = Ship.WorldCenter;
        }
Ejemplo n.º 4
0
        public static void Initialize()
        {
            #region Equipment Definitions

            Slot1 = LASER_KEY; //set initial equipment
            Slot2 = TORPEDO_KEY;
            EquipmentDictionary = new Dictionary<string, EquipmentData>(); //initialize the dictionary

            //add torpedoes
            EquipmentDictionary.Add(TORPEDO_KEY, new EquipmentData(
                ContentHandler.Textures[TORPEDO_KEY],
                300,
                0f,
                TORPEDO_KEY,
                COLLISION_SFX,
                2000,
                30,
                20,
                50,
                1,
                0,
                "Torpedo Launcher",
                true, true));

            //add lasers
            EquipmentDictionary.Add(LASER_KEY, new EquipmentData(
                ContentHandler.Textures[LASER_KEY],
                750,
                150,
                LASER_KEY,
                COLLISION_SFX,
                450,
                10,
                6,
                5,
                1,
                0,
                "Pulse Laser"));

            //add shell
            EquipmentDictionary.Add(SHELL_KEY, new EquipmentData(
                ContentHandler.Textures[SHELL_KEY],
                1000,
                300,
                SHELL_KEY,
                COLLISION_SFX,
                175,
                10,
                3,
                50,
                35,
                30,
                "Scatter-Fire",
                false, true));

            //add rapid-fire sliver
            EquipmentDictionary.Add(SLIVER_KEY, new EquipmentData(
                ContentHandler.Textures[SLIVER_KEY],
                450,
                50,
                SLIVER_KEY,
                IMPACT_SFX,
                400,
                1,
                5,
                1,
                2,
                45,
                "Shrapnel Projector"));

            //add missiles
            EquipmentDictionary.Add(MISSILE_KEY, new EquipmentData(
                ContentHandler.Textures[MISSILE_KEY],
                1000,
                0,
                MISSILE_KEY,
                COLLISION_SFX,
                500,
                20,
                10,
                30,
                1,
                40,
                "Rapid-Missile Launcher",
                true,
                true));

            #endregion

            Health = STARTING_HEALTH;
            CurrentOre = STARTING_ORE;

            CollectableOre = LevelManager.Levels[0].CollectableOre;

            ActiveSlot = INITIAL_ACTIVE_SLOT;
            StabilizeRotation = true;

            #region Component Initialization

            //init the ship
            Ship = new GameObject(
                ContentHandler.Textures[SHIP_TEXTURE],
                new Vector2(Camera.WorldRectangle.Width / 2, Camera.WorldRectangle.Height),
                new Vector2(0, -50),
                Color.White,
                false,
                0f,
                0f,
                1f,
                SHIP_DEPTH,
                false,
                ContentHandler.Textures[SHIELD_KEY].GetMeanRadius(), //use the shield texture as a collision boundary
                0, 0, SpriteEffects.None, 8, 1, 8, 2, SHIP_FRAME_DELAY);

            //init the shield overlay
            Shield = new GameObject(
                ContentHandler.Textures[SHIELD_KEY],
                Ship.WorldCenter,
                Ship.Velocity,
                Color.Transparent);

            //init the left-side particle engine trail
            LeftEngineTrail = new ParticleEmitter(
                Int32.MaxValue,
                GameObject.GetOffset(Ship, THRUST_OFFSET, ROTATION_OFFSET),
                ContentHandler.Textures["particle"].ToTextureList(),
                TRAIL_COLORS.ToList<Color>(),
                TRAIL_FTL,
                false,
                true,
                -1,
                TRAIL_PPT,
                TRAIL_EJECTION_SPEED,
                TRAIL_RANDOM_MARGIN,
                0f,
                TRAIL_SPRAYWIDTH);

            //same for right side
            RightEngineTrail = new ParticleEmitter(
                Int32.MaxValue,
                GameObject.GetOffset(Ship, THRUST_OFFSET, -ROTATION_OFFSET),
                ContentHandler.Textures["particle"].ToTextureList(),
                TRAIL_COLORS.ToList<Color>(),
                TRAIL_FTL,
                false,
                true,
                -1,
                TRAIL_PPT,
                TRAIL_EJECTION_SPEED,
                TRAIL_RANDOM_MARGIN,
                0f,
                TRAIL_SPRAYWIDTH);

            //explosion particle textures
            explosionParticles.Add(ContentHandler.Textures["junk1"]);
            explosionParticles.Add(ContentHandler.Textures["junk2"]);
            explosionParticles.Add(ContentHandler.Textures["junk3"]);

            ExplosionEmitter = new ParticleEmitter(
                EXPLOSION_PARTICLES_TO_EMIT,
                Ship.WorldCenter,
                explosionParticles,
                EXPLOSION_COLORS.ToList<Color>(),
                EXPLOSION_FTL,
                false,
                true,
                EXPLOSION_TIME_TO_EMIT,
                EXPLOSION_PARTICLES_TO_EMIT / EXPLOSION_TIME_TO_EMIT,
                EXPLOSION_EJECTION_SPEED,
                EXPLOSION_RANDOMIZATION,
                0f, 180f);

            #endregion

            StoredOre = 100; //TEMP

            SpawnCircle = new Circle(Ship.WorldCenter, MIN_SPAWN_DISTANCE);
        }
Ejemplo n.º 5
0
        public NPC(
            string texturekey,
            string damagekey,
            string deathkey,
            AIState initialState,
            Vector2 initialPos,
            Vector2 initialVel,
            Vector2 initialTarget,
            Color tintColor,
            int startingHealth,
            EquipmentData equip,
            int colRadius,
            int activationRadius,
            float trailOffset,
            float weaponOffset,
            float maxSpeed,
            float trackSpeed,
            float maxAccelSpeed,
            float initialRot = 0f,
            float initialRotVel = 0f,
            int totalFrames = 0,
            int rows = 1,
            int columns = 1,
            int startingFrame = 0,
            float frameDelay = 0,
            FoF_Ident ident = FoF_Ident.Enemy,
            bool activated = false)
        {
            Ship = new GameObject(
                ContentHandler.Textures[texturekey],
                initialPos,
                initialVel,
                tintColor,
                false,
                initialRot,
                initialRotVel,
                1f,
                NPC_DEPTH,
                false,
                colRadius,
                0, 0,
                SpriteEffects.None,
                totalFrames,
                rows,
                columns,
                startingFrame,
                frameDelay);

            Shield = new GameObject(
                ContentHandler.Textures[texturekey + NPCManager.SHIELD_TEXTURE],
                Ship.WorldCenter,
                Ship.Velocity,
                Color.Transparent,
                false,
                Ship.Rotation,
                Ship.RotationalVelocity,
                Ship.Scale,
                Ship.Depth);

            CurrentState = initialState;
            LastState = initialState;
            DamageSoundKey = damagekey;
            DeathSoundKey = deathkey;
            Weapon = equip;
            if (equip != null) { firedelay = equip.RefireDelay; }
            ActivationRadius = activationRadius;
            Activated = activated;
            TrailOffset = trailOffset;
            WeaponOffset = weaponOffset;
            MaxSpeed = maxSpeed;
            TrackSpeed = trackSpeed;
            AccelerationSpeed = maxAccelSpeed;
            Target = Vector2.Normalize(initialTarget);

            Identification = ident;
            StartingHealth = startingHealth;
            Health = StartingHealth;

            trail = new ParticleEmitter( //initialize the engine trail particle emitter
                TRAIL_MAX_PARTICLES,
                GameObject.GetOffset(Ship, TrailOffset),
                ContentHandler.Textures[TRAIL_PARTICLE].ToTextureList(),
                TRAIL_COLORS.ToList<Color>(),
                TRAIL_FTL,
                false,
                true,
                -1,
                TRAIL_PPT,
                TRAIL_EJECTION_SPEED,
                TRAIL_RANDOM_MARGIN,
                Ship.RotationDegrees + 180,
                TRAIL_SPRAYWIDTH);

            //initialize the state logic
            switchState(initialState);

            //pick a slightly randomized evasion damage threshold
            dmgThreshold = Util.rnd.Next(
                EVADE_DMG_THRESHOLD_MIN,
                EVADE_DMG_THRESHOLD_MAX);

            reattackTime = Util.rnd.Next(
                REATTACK_TIME_MIN,
                REATTACK_TIME_MAX);

            evadeTime = Util.rnd.Next(
                EVADE_TIME_MIN,
                EVADE_TIME_MAX);

            shotsBeforeCooldown = Util.rnd.Next(
                COOLDOWN_MIN,
                COOLDOWN_MAX);
            shotsCounter = 0;
        }
Ejemplo n.º 6
0
        static void addOrePickupEffect(Particle ore)
        {
            ParticleEmitter temp = new ParticleEmitter(
                ORE_EFFECT_PARTICLES,
                ore.WorldCenter,
                OreEffectTextures,
                ORE_PICKUP_COLORS.ToList<Color>(),
                ORE_EFFECT_FTL,
                true,
                true,
                PARTICLE_TIME_TO_EMIT,
                ORE_EFFECT_PARTICLES,
                ORE_EFFECT_EJECTION_SPEED,
                PARTICLERANDOMIZATION,
                0f, ParticleEmitter.EXPLOSIONSPRAY);

            emitters.Add(temp);
        }