Exemplo n.º 1
0
        public bool CharHitsProjectile(Character character, Projectile projectile)
        {
            // Skip Character if they cast the projectile.
            if (projectile.ByCharacterId == character.id)
            {
                return(false);
            }

            DirCardinal dir = CollideDetect.GetDirectionOfCollision(character, projectile);

            // Set the projectile to bounce off of the screen:
            EndBounceParticle.SetParticle(character.room, Systems.mapper.atlas[(byte)AtlasGroup.Objects], projectile.SpriteName, new Vector2(projectile.posX, projectile.posY), Systems.timer.Frame + 40, 1, 0.5f, 0f);

            // Destroy the Projectile
            projectile.Destroy();

            // If this projectile can be jumped on:
            if (projectile.SafelyJumpOnTop)
            {
                // Hit from above (projectile is below):
                if (dir == DirCardinal.Down)
                {
                    //character.BounceUp(projectile.posX + projectile.bounds.MidX, 1, 0, 0);
                    ActionMap.Jump.StartAction(character, 1, 0, 0, true, false);
                    Systems.sounds.bulletJump.Play();
                    return(true);
                }

                // Hit from below (projectile is above):
                else if (dir == DirCardinal.Up && character.status.action is Action)
                {
                    character.status.action.EndAction(character);
                }
            }

            // If wearing a hard hat, can ignore damage from above.
            if (dir == DirCardinal.Up)
            {
                if (character.hat is HardHat)
                {
                    return(true);
                }
            }

            character.wounds.ReceiveWoundDamage(projectile.Damage);

            return(true);
        }
Exemplo n.º 2
0
        public static EndBounceParticle SetParticle(RoomScene room, Atlas atlas, string spriteName, Vector2 pos, int frameEnd, float bounceHeight = 3, float gravity = 0.5f, float rotateSpeed = 0.12f)
        {
            // Retrieve an available particle from the pool.
            EndBounceParticle particle = EndBounceParticle.endBouncePool.GetObject();

            particle.atlas         = atlas;
            particle.spriteName    = spriteName;
            particle.pos           = pos;
            particle.frameEnd      = frameEnd;
            particle.gravity       = gravity;
            particle.vel           = new Vector2(CalcRandom.FloatBetween(-3, 3), CalcRandom.FloatBetween(-bounceHeight - 1.5f, -bounceHeight + 1.5f));
            particle.rotationSpeed = CalcRandom.FloatBetween(-rotateSpeed, rotateSpeed);

            // Add the Particle to the Particle Handler
            room.particleHandler.AddParticle(particle);

            return(particle);
        }