Exemple #1
0
        public override void walk(float directionAndVelocityAsPercentOfSpeed)
        {
            float bonusSpeed = 0;
            SortedList <float, StatusEffect> speedList;

            statusEffects.TryGetValue(StatusEffect.status.SPEED, out speedList);
            if (speedList != null && speedList.Count > 0)
            {
                bonusSpeed = speedList.ElementAt(speedList.Count - 1).Value.potency;
            }
            impulse += new Vector2(directionAndVelocityAsPercentOfSpeed * walkSpeed * (1 + bonusSpeed), 0);
            if (bonusSpeed > 0)
            {
                //ensure speed boost particle baseline
                if (rand.NextDouble() < .1f)
                {
                    ParticleSpeedBoost particle = new ParticleSpeedBoost(location + new Vector2(0, this.height), world, new Vector2(directionAndVelocityAsPercentOfSpeed * -5, 0), 100);
                    world.addEntity(particle);
                }
                for (int i = 0; i < rand.Next((int)(bonusSpeed * 7)); i++)
                {
                    ParticleSpeedBoost particle = new ParticleSpeedBoost(location + new Vector2(0, this.height), world, new Vector2(directionAndVelocityAsPercentOfSpeed * -5, 0), 100);
                    world.addEntity(particle);
                }
            }
        }
        public override void prePhysicsUpdate(GameTime time)
        {
            base.prePhysicsUpdate(time);

            ParticleSpeedBoost particle = new ParticleSpeedBoost(location + new Vector2(-width / 2, height / 2), world, new Vector2() /*velocity * -1*/, 100);

            world.addEntity(particle);

            if ((collideBottom || collideLeft || collideRight || collideTop) && !struckGround)
            {
                struckGround = true;
                stuckLoc     = location;
            }

            if (struckGround)
            {
                timeBeforeExplosion--;
                if (timeBeforeExplosion % 16 == 0)
                {
                    world.addEntity(new ParticleGunFlash(location, world, 3));
                }

                if (timeBeforeExplosion <= 0)
                {
                    SoundManager.getSound("explode_sticky").playWithVariance(0, 1f / Vector2.Distance(location, world.player.location) * 70, (location - world.player.location).X, SoundType.MONSTER);
                    for (int x = -radious; x <= radious; x++)
                    {
                        for (int y = -radious; y <= radious; y++)
                        {
                            Vector2 tileLoc      = location + new Vector2(x * Chunk.tileDrawWidth, y * Chunk.tileDrawWidth);
                            Vector2 tileBelowLoc = location + new Vector2(x * Chunk.tileDrawWidth, (y + 1) * Chunk.tileDrawWidth);

                            if (world.getBlock(tileLoc) == null || world.getBlock(tileBelowLoc) == null)
                            {
                                continue;
                            }

                            if (world.getBlock(tileLoc).tags.Contains(TagReferencer.AIR) && world.getBlock(tileBelowLoc).tags.Contains(TagReferencer.SOLID))
                            {
                                world.placeTile(TileTypeReferencer.SLIME, tileLoc);
                            }
                            //world.addEntity(new ParticleTileBreak(tileLoc, world, new Vector2(), world.getBlock(tileLoc), 150));
                        }
                    }

                    world.addEntity(new ParticleGunFlash(location, world, 3));
                    for (int i = 0; i < 16; i++)
                    {
                        world.addEntity(new ParticleGunSparks(location, world, new Vector2(), 50));
                    }

                    world.killEntity(this);
                }
            }
        }
Exemple #3
0
        public virtual void transformPlayer(PlayerBase newPlayer)
        {
            Random rand = new Random();

            for (int i = 0; i < 40; i++)
            {
                ParticleSpeedBoost particle = new ParticleSpeedBoost(playerLoc + new Vector2(rand.Next(30) - 15, rand.Next(30) - 15), this, new Vector2((float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1), 100);
                addEntity(particle);
            }
            newPlayer.velocity = player.velocity;
            addEntity(newPlayer);
            killEntity(player);
            player = newPlayer;
        }
Exemple #4
0
 private void spawnSpeedBoostParticles(float bonusSpeed, float directionAndVelocityAsPercentOfSpeed)
 {
     if (bonusSpeed > 0)
     {
         //ensure speed boost particle baseline
         if (rand.NextDouble() < .1f)
         {
             ParticleSpeedBoost particle = new ParticleSpeedBoost(location + new Vector2(0, this.height), world, new Vector2(directionAndVelocityAsPercentOfSpeed * -5, 0), 100);
             world.addEntity(particle);
         }
         for (int i = 0; i < rand.Next((int)(bonusSpeed * 7)); i++)
         {
             ParticleSpeedBoost particle = new ParticleSpeedBoost(location + new Vector2(0, this.height), world, new Vector2(directionAndVelocityAsPercentOfSpeed * -5, 0), 100);
             world.addEntity(particle);
         }
     }
 }
        public override void update(GameTime time)
        {
            //if the fire has been placed inside a block, move it out.
            TileType tileOn           = world.getBlock(location);
            TileType tileOnBackground = world.getBackgroundBlock(location);

            if (tileOn != null && tileOn.tags.Contains(TagReferencer.SOLID))
            {
                TileType tileBelow = world.getBlock(location + new Vector2(0, Chunk.tileDrawWidth));
                TileType tileAbove = world.getBlock(location + new Vector2(0, -Chunk.tileDrawWidth));
                TileType tileRight = world.getBlock(location + new Vector2(Chunk.tileDrawWidth, 0));
                TileType tileLeft  = world.getBlock(location + new Vector2(-Chunk.tileDrawWidth, 0));
                if (tileAbove != null && tileAbove.tags.Contains(TagReferencer.AIR))
                {
                    location = location + new Vector2(0, -Chunk.tileDrawWidth);
                }
                else if (tileRight != null && tileRight.tags.Contains(TagReferencer.AIR))
                {
                    location = location + new Vector2(Chunk.tileDrawWidth, 0);
                }
                else if (tileLeft != null && tileLeft.tags.Contains(TagReferencer.AIR))
                {
                    location = location + new Vector2(-Chunk.tileDrawWidth, 0);
                }
                else if (tileBelow != null && tileBelow.tags.Contains(TagReferencer.AIR))
                {
                    location = location + new Vector2(0, Chunk.tileDrawWidth);;
                }
                tileOn = world.getBlock(location);
            }

            if (world is World && tileOnBackground != null)
            {
                if (world.decorator.weatherManager.weather == WeatherManager.Weather.RAINY && !tileOnBackground.tags.Contains(TagReferencer.Shelter) || tileOn.tags.Contains(TagReferencer.WATER))
                {
                    health--;
                }
            }



            impulse = new Vector2();
            ticksExisted++;
            currentTexSwap--;
            if (currentTexSwap <= 0)
            {
                Texture2D nextTex = Game1.texture_entity_fire[rand.Next(Game1.texture_entity_fire.Length)];
                while (nextTex == currentTex)
                {
                    nextTex = Game1.texture_entity_fire[rand.Next(Game1.texture_entity_fire.Length)];
                }
                currentTex     = nextTex;
                currentTexSwap = texSwapPoint;
            }
            if (ticksExisted % 3 == 0)
            {
                glowSize = rand.Next(20);
            }

            velocity += impulse;

            //Spawn fire-ey particles
            world.addEntity(new ParticleGunFlash(location, world, 3));
            if (rand.NextDouble() < .1)
            {
                ParticleGunSparks sparks = new ParticleGunSparks(location, world, new Vector2(0, -1), 50);
                sparks.velocity          = new Vector2((float)rand.NextDouble() * .5f - .25f, -1);
                sparks.gravityMultiplier = -.5f;
                sparks.width            *= .5f;
                sparks.height           *= .5f;
                sparks.color             = Color.Yellow;
                sparks.deathColor        = Color.Yellow;
                world.addEntity(sparks);
            }

            if (rand.NextDouble() < .25)
            {
                ParticleSpeedBoost particle = new ParticleSpeedBoost(location + new Vector2(-width / 4, 0), world, new Vector2((float)rand.NextDouble() - .5f, 0) /*velocity * -1*/, particleDuration);
                particle.gravityMultiplier = -.15f;
                particle.width             = 20;
                particle.height            = 20;
                particle.deltaSize         = 1.002f;
                particle.opacityModifier   = .4f;


                world.addEntity(particle);
            }


            //spread the fire
            if (rand.NextDouble() < .01f)
            {
                TileType tileBelow = world.getBlock(location + new Vector2(0, Chunk.tileDrawWidth));
                TileType tileAbove = world.getBlock(location + new Vector2(0, -Chunk.tileDrawWidth));
                TileType tileRight = world.getBlock(location + new Vector2(Chunk.tileDrawWidth, 0));
                TileType tileLeft  = world.getBlock(location + new Vector2(-Chunk.tileDrawWidth, 0));

                //TODO: add spreadable fire

                /*if(tileBelow.tags.Contains(TagReferencer.FLAMMABLE))
                 * {
                 *  EntityFire fire = new EntityFire(location + new Vector2(0, Chunk.tileDrawWidth), world);
                 *  world.addEntity(fire);
                 * }
                 * if (tileAbove.tags.Contains(TagReferencer.FLAMMABLE))
                 * {
                 *  EntityFire fire = new EntityFire(location + new Vector2(0, -Chunk.tileDrawWidth), world);
                 *  world.addEntity(fire);
                 * }
                 * if (tileRight.tags.Contains(TagReferencer.FLAMMABLE))
                 * {
                 *  EntityFire fire = new EntityFire(location + new Vector2(Chunk.tileDrawWidth, 0), world);
                 *  world.addEntity(fire);
                 * }
                 * if (tileLeft.tags.Contains(TagReferencer.FLAMMABLE))
                 * {
                 *  EntityFire fire = new EntityFire(location + new Vector2(-Chunk.tileDrawWidth, 0), world);
                 *  world.addEntity(fire);
                 * }*/
            }
            collideBottom = false;
            collideLeft   = false;
            collideRight  = false;
            collideTop    = false;

            /*foreach(Entity victim in world.entities)
             * {
             *  if(!victim.Equals(this) && getCollisionBox().Intersects(victim.getCollisionBox()))
             *  {
             *      victim.damage(3, this, Vector2.Normalize(world.player.location - location) + new Vector2(0, -1));
             *  }
             * }*/

            if (health <= 0 || Vector2.Distance(location, world.player.location) > 2000)
            {
                world.killEntity(this);
            }
        }
Exemple #6
0
        public override void prePhysicsUpdate(GameTime time)
        {
            base.prePhysicsUpdate(time);

            ParticleSpeedBoost particle = new ParticleSpeedBoost(location + new Vector2(-width / 2, height / 2), world, new Vector2() /*velocity * -1*/, 100);

            world.addEntity(particle);

            if ((collideBottom || collideLeft || collideRight || collideTop) && !stuck)
            {
                stuck    = true;
                stuckLoc = location;
            }

            if (stuck)
            {
                impulse  = new Vector2();
                velocity = new Vector2();
                location = stuckLoc;

                timeBeforeExplosion--;

                if (timeBeforeExplosion % 16 == 0)
                {
                    world.addEntity(new ParticleGunFlash(location + new Vector2(-20, -20), world, 3));
                }

                if (timeBeforeExplosion <= 0)
                {
                    SoundManager.getSound("explode").playWithVariance(0, 1f / Vector2.Distance(location, world.player.location) * 70, (location - world.player.location).X, SoundType.MONSTER);

                    for (int x = -radious; x <= radious; x++)
                    {
                        for (int y = -radious; y <= radious; y++)
                        {
                            Vector2  tileLoc           = location + new Vector2(x * Chunk.tileDrawWidth, y * Chunk.tileDrawWidth);
                            TileType destroyedTileType = world.getBlock(tileLoc);
                            if (destroyedTileType != null)
                            {
                                world.addEntity(new ParticleTileBreak(tileLoc, world, new Vector2(), destroyedTileType, 150));
                                world.placeTile(TileTypeReferencer.AIR, tileLoc);
                            }
                        }
                    }

                    world.addEntity(new ParticleGunFlash(location, world, 3));
                    for (int i = 0; i < 16; i++)
                    {
                        world.addEntity(new ParticleGunSparks(location, world, new Vector2(), 50));
                    }

                    foreach (Entity entity in world.entities)
                    {
                        if (Vector2.Distance(entity.location, this.location) < radious * Chunk.tileDrawWidth)
                        {
                            entity.damage(40, this, Vector2.Normalize(entity.location - this.location) * 40);
                        }
                    }

                    world.shakeScreen(50, 400);
                    world.killEntity(this);
                }
            }
        }