public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager)
        {
            base.use(user, world, location, time, inputManager);

            bool showUse = true;

            foreach (UsableEntity ue in user.world.useableEntities)
            {
                if (ue is EntityRopeSegment && ue.getUseBounds().Intersects(user.getCollisionBox()))
                {
                    EntityRopeSegment currentRopeSegment = (EntityRopeSegment)ue;
                    int numRecoveredRopes = 0;
                    while (currentRopeSegment.child != null)
                    {
                        world.killEntity(currentRopeSegment);
                        numRecoveredRopes++;
                        currentRopeSegment = currentRopeSegment.child;
                    }
                    world.killEntity(currentRopeSegment);
                    world.addEntity(new ItemDropEntity(user.location, world, new Item_Rope((int)((float)numRecoveredRopes * .75f))));

                    break;
                }

                if (ue is EntityBetterRopeSegment && ue.getUseBounds().Intersects(user.getCollisionBox()))
                {
                    showUse = false;
                    EntityBetterRopeSegment currentRopeSegment = (EntityBetterRopeSegment)ue;
                    int numRecoveredRopes = 0;
                    while (currentRopeSegment.child != null)
                    {
                        world.killEntity(currentRopeSegment);
                        numRecoveredRopes++;
                        currentRopeSegment = currentRopeSegment.child;
                    }

                    currentRopeSegment = (EntityBetterRopeSegment)ue;
                    while (currentRopeSegment.parent != null)
                    {
                        world.killEntity(currentRopeSegment);
                        numRecoveredRopes++;
                        currentRopeSegment = currentRopeSegment.parent;
                    }

                    world.killEntity(currentRopeSegment);
                    world.addEntity(new ItemDropEntity(user.location, world, new Item_Rope((int)((float)numRecoveredRopes * .75f))));

                    break;
                }
            }

            if (showUse)
            {
                user.speechManager.addSpeechBubble(Game1.texture_item_rope);
            }

            return(0);
        }
示例#2
0
        public override void use(WorldBase world, Vector2 location, Entity user)
        {
            world.killEntity(this);
            Random rand = new Random();

            foreach (Item item in items)
            {
                ItemDropEntity drop = new ItemDropEntity(location, world, item);
                drop.velocity += new Vector2(rand.Next(1) - 2, -rand.Next(10));
                world.addEntity(drop);
            }
        }
示例#3
0
 public override void use(WorldBase world, Vector2 location, Entity user)
 {
     MetaData.unlocks.Add(kit.id);
     world.killEntity(this);
 }
 public override void use(WorldBase world, Vector2 location, Entity user)
 {
     world.killEntity(this);
     world.addEntity(new ItemDropEntity(location, world, new Item_Snare(1)));
 }
示例#5
0
        public virtual void update(GameTime time)
        {
            foreach (SortedList <float, StatusEffect> statusList in statusEffects.Values)
            {
                List <float> removeKeys = new List <float>();
                foreach (StatusEffect effect in statusList.Values)
                {
                    effect.update(this);
                    if (effect.timeRemaining <= 0)
                    {
                        removeKeys.Add(effect.potency);
                    }
                }
                foreach (float fl in removeKeys)
                {
                    statusList.Remove(fl);
                }
            }

            StatusEffect healthRegen    = getEffect(StatusEffect.status.HEALTHREGEN);
            float        healthRegenAmt = 0;

            if (healthRegen != null)
            {
                healthRegenAmt = healthRegen.potency;
                if (rand.NextDouble() < .1f)
                {
                    ParticleHealth particle = new ParticleHealth(location, world, new Vector2(0, 0), 30);
                    world.addEntity(particle);
                }
                for (int i = 0; i < rand.Next((int)(healthRegenAmt) / 3); i++)
                {
                    ParticleHealth particle = new ParticleHealth(location, world, new Vector2(0, 0), 30);
                    world.addEntity(particle);
                }
            }

            StatusEffect poison    = getEffect(StatusEffect.status.POISON);
            float        poisonamt = 0;

            if (poison != null)
            {
                poisonamt = poison.potency;
            }
            spawnPoisonParticles(poisonamt);

            ticksExisted++;

            if (collideBottom && velocity.Y > 0)
            {
                velocity = new Vector2(velocity.X, 0);
            }
            if (collideLeft && velocity.X < 0)
            {
                velocity = new Vector2(0, velocity.Y);
            }
            if (collideRight && velocity.X > 0)
            {
                velocity = new Vector2(0, velocity.Y);
            }
            if (collideTop && velocity.Y < 0)
            {
                velocity = new Vector2(velocity.X, 0);
            }

            if (collideBottom)
            {
                framesCollidingBottom++;
            }
            else
            {
                framesCollidingBottom = 0;
            }

            prePhysicsUpdate(time);
            performPhysics(time);


            if (health <= 0)
            {
                world.killEntity(this);
            }

            remainingDamageImmunityTime--;
        }