示例#1
0
 private void MoveIfNeeded(GameObject gameObject)
 {
     switch (gameObject.Type)
     {
         case GameObjectType.Obstacle:
         case GameObjectType.Collectable:
         case GameObjectType.Civilian:
             gameObject.Location.Y += distance - oldDistance;
             break;
     }
 }
示例#2
0
        private void CheckCollisionWithPlayer(GameObject gameObject)
        {
            if (gameObject == player)
                return;
            switch (gameObject.Type)
            {
                case GameObjectType.Collectable:
                    if (gameObject.DoesCollideWith(player))
                    {
                        gameObject.OnCollect(player);
                        if (gameObject is Life)
                            sound.Play(Sounds.LifePickup);
                        else
                            sound.Play(Sounds.Pickup);
                    }
                    break;

                case GameObjectType.Civilian:
                case GameObjectType.Obstacle:
                    if (gameObject.DoesCollideWith(player) && !blinking)
                    {
                        sound.Play(Sounds.Hit);
                        actionManager
                            .AddToQueue(
                                () =>
                                {
                                    blinking = true;
                                    blinkingTimer = 0;
                                    livesCount -= 1;
                                    if (livesCount < 0)
                                        isGameOver = true;
                                })
                            .AddToQueue(
                                (dt) =>
                                {
                                    blinkingTimer += dt;
                                    if (blinkingTimer > 0.1)
                                    {
                                        blinkingTimer = 0;
                                        player.Visible = !player.Visible;
                                    }
                                },
                                2.0d)
                            .AddToQueue(
                                () =>
                                {
                                    player.Visible = true;
                                    blinking = false;
                                    blinkingTimer = -1;
                                });
                    }
                    break;
            }
        }
示例#3
0
 public override void OnCollect(GameObject gameObject)
 {
     base.OnCollect(gameObject);
     (gameObject as Player).FuelLevel += Utility.FUEL_ADD;
 }
示例#4
0
 public override void OnCollect(GameObject gameObject)
 {
     (gameObject as Player).OnLifeCollect();
     base.OnCollect(gameObject);
 }
示例#5
0
 public virtual void OnCollect(GameObject gameObject)
 {
     Active = false;
 }
示例#6
0
 public bool DoesCollideWith(GameObject gameObject)
 {
     return GetAbsoluteCollisonRect().IntersectsWith(gameObject.GetAbsoluteCollisonRect());
 }