Esempio n. 1
0
 public override void CollideWithObject(GameObject obj, Room room, BBox collision)
 {
     if (obj is Player && obj.Color == Color && !Symbolizing)
     {
         if (this != room.CorrectPortal)
         {
             Unlocked = true;
             room.Failed = true;
             room.Finish();
         }
         else
         {
             if (type != RoomType.Acceptance)
             {
                 curSymAnimation = animations.Find((set) => set.IsCalled(SYM + "1"));
                 Symbolizing = true;
             }
             else
             {
                 Unlocked = true;
             }
         }
     }
     base.CollideWithObject(obj, room, collision);
 }
Esempio n. 2
0
        public override void Update(Room room, GameTime gameTime)
        {
            base.Update(room, gameTime);
            if (!dying)
            {
                splatterAnimation.Update();

                if (Velocity.Y == 0)
                    maxSpeed.Y = MAX_SPEED_Y;
                if (canJump && jumpKeys.Any(Input.IsKeyDown))
                    DoJump(room);

                // allow player to shortcircuit their jump
                //if (Velocity.Y < -5 && !jumpKeys.Any(Input.IsKeyDown))
                //    velocity.Y = -5;

                // wait until we've recovered from the recoil of landing before moving again
                if (!Landing)
                {
                    if (leftKeys.Any(Input.IsKeyDown))
                        Move(room, new Vector2(-1, 0));
                    else if (rightKeys.Any(Input.IsKeyDown))
                        Move(room, new Vector2(1, 0));
                    else
                        Move(room, Vector2.Zero);
                }
                // we still need to call Move at least once per update for collisions etc.
                else
                    Move(room, new Vector2(0, 0));

                if (Math.Abs(velocity.Y) >= MIN_FALL_SPEED * GravitySign)
                    onGround = false;

                // wait until the landing animation is done playing before changing it
                if (onGround && !Landing)
                {
                    Landing = false;
                    if (!curAnimation.IsCalled(WALK)) ChangeAnimation(IDLE);
                }
                else if (!hasCollidedWithWall)
                    ChangeAnimation(JUMP);

                if (onGround && Math.Abs(velocity.X) > 0)
                    ChangeAnimation(WALK);

                //if (color.Contains(Color.Blue) && (velocity.Y * GravitySign) > (MAX_BLUE_FALL_SPEED * GravitySign) && jumpKeys.Any(Input.IsKeyDown))
                //    velocity.Y = MAX_BLUE_FALL_SPEED * GravitySign;

                rotation = velocity.ToAngle();
            }
            else
            {
                deathTimer++;
                if (deathTimer == DEATH_TIME)
                {
                    room.Failed = true;
                    room.Finish();
                }
            }
        }