public void checkItemCollisions(Sprite active)
 {
     foreach(Item item in stationaryobjects ){
        /* if (item.GetType() == typeof(PushBox))
         {
             Console.Out.WriteLine("pushbox: " + item.Position);
         }*/
         if(item.HitBox .Intersects (active .HitBox )){
             item.activate(active);
         }
     }
 }
Пример #2
0
        public override void activate(Sprite collider)
        {
            if (((collider.Velocity.X > 0 && direction) || (collider.Velocity.X < 0 && !direction)) && collider.GetType() == typeof(Bunny))
            {
                connectedRamp.Velocity = new Vector2(collider.Velocity.X, connectedRamp.Velocity.Y);
                collider.state = State.Pushing;

                soundeffect.Play();
            }
            else
            {
                connectedRamp.Velocity = new Vector2(0, connectedRamp.Velocity.Y);
            }
        }
Пример #3
0
        public override void activate(Sprite collider)
        {
            if (collider.GetType() == typeof(Clyde))
            {
                if (collider.state == State.Airbourne) { soundeffect.Play(); }

                    collider.Velocity = Vector2.Zero;

                collider.state = State.Swimming;

            }
            else if (collider.GetType() == typeof(Bunny))
            {
                if (collider.state == State.Airbourne || collider.state == State.Default) { soundeffect.Play(); }
                Bunny bunny = (Bunny)collider;
                level.bunnydead = true;

            //    bunny.Position = bunny.SpawnPoint;
             //   bunny.die.Width = bunny.mapwidth;
             //   bunny.Velocity = Vector2.Zero;
            }
        }
Пример #4
0
 public override void activate(Sprite collider)
 {
     if(!collider.HitBox .Intersects(clyde.HitBox )){
         collider.state = State.Riding;
     }
 }
        public void moveSprite(Sprite sprite)
        {
            Vector2 velocity = sprite.Velocity;
            bool removed = false;
            bool removedProblem = false;
            if (solids.Contains(sprite))
            {
                removed = true;
                solids.Remove(sprite);
            }
            Sprite problem = getInitialCollision(sprite.testBox(0, 0));
            if (problem == null)
            {

            }
            else {
                solids.Remove(problem);
                removedProblem = true;
            }

            if (checkPlatformCollision(sprite.testBox(0, velocity.Y)))
            {
                resolveCollision(sprite, new Vector2(0,velocity.Y));

                sprite.Velocity = new Vector2(velocity.X, 0);

                Console.WriteLine(sprite.Velocity);
                if (velocity.Y > 0)
                {
                    //this is for ramp falling sound, fix later
                    if (velocity.Y == 0.6)
                    {
                        if (sprite.imageName == "gate_block")
                        {
                            Ramp r = (Ramp)sprite;
                            r.soundeffect.Play();
                        }
                    }
                    sprite.state = Sprite.State.Default;

                }
                else
                {

                }

            }
            else
            {
                sprite.Position += new Vector2 (0, velocity .Y);
                sprite.Update(new GameTime());
            }
            if (checkPlatformCollision(sprite.testBox(velocity.X, 0)))
            {
                resolveCollision(sprite, new Vector2(velocity.X, 0));
            }
            else
            {
                sprite.Position += new Vector2(velocity.X, 0);
                sprite.Update(new GameTime());
            }
            if (removed)
            {
                solids.Add(sprite);
            }
            if (removedProblem)
            {
                solids.Add(problem);
            }
            //sprite.Update(new GameTime());
               // sprite.Velocity = new Vector2(0.5f * sprite .Velocity .X, sprite.Velocity.Y);
        }
 public void addSolid(Sprite s)
 {
     solids.Add(s);
 }
 public void addMoving(Sprite s)
 {
     movingObjects.Add(s);
 }
        public void resolveCollision(Sprite s, Vector2 velocity)
        {
            return;
            float time = 0.5f;
            int i = 1;
            bool collides = true;
            while (i <= 5 )
            {
                collides = checkPlatformCollision(s.testBox(velocity.X * time, velocity.Y * time));
                i++;
                if (collides)
                {
                    time -= 1 / (float)Math.Pow (2,i);
                }
                else
                {
                    time += 1 / (float)Math.Pow (2,i);
                }

            }
            if (time == 0.015625f)
            {
                time = 0;
            }
            s.Position += velocity * time;
            s.Speed = s.Speed;
        }
Пример #9
0
 public override void activate(Sprite collider)
 {
 }
Пример #10
0
        public override void activate(Sprite collider)
        {
            //oh well...

            //working buy is annoying right now since it plays during every collision   soundeffect.Play();
        }
Пример #11
0
 public abstract void activate(Sprite collider);