Пример #1
0
        /// <summary>
        /// Uses the dwarf's pickaxe to mine the nearest rock.
        /// </summary>
        public void UsePickaxe()
        {
            foreach (Rock rock in this.Game.ObjectManager.Objects.Where(p => p is Rock))
            {
                if (rock.CollisionBounds.IntersectsWith(this.Game.Character.PickaxeBounds))
                {
                    Random random = new Random();
                    rock.Hitpoints -= random.GenerateNumber(0, this.Game.Character.PickaxeLevel.GetMaximumDamage());

                    if (rock.Hitpoints == 0 && rock.Ore != OresAndMetals.Boulder)
                    {
                        this.Game.RocksCollected[rock.Ore]++;
                    }

                    this.Game.Sound.Play(SoundComponent.Sound.Pickaxe);

                    break;
                }
            }

            this.Game.ObjectManager.Objects.RemoveAll(p => p is Rock && ((Rock)p).IsDestroyed);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MedicalCrate"/> class.
 /// </summary>
 /// <param name="game">Reference to the <see cref="Game"/> instance.</param>
 public MedicalCrate(Game game)
     : base(game, Resources.medical_crate)
 {
     Random random = new Random();
     this.Healing = random.GenerateNumber(50, 200);
 }
Пример #3
0
 /// <summary>
 /// Sets the object's position so that it is on the ceiling at a random X coordinate on the screen.
 /// </summary>
 public void SetCeilingPosition()
 {
     Random random = new Random();
     this.Location = new Point(random.GenerateNumber(0, this.Game.ScreenSize.Width - this.Size.Width), 0 - this.Size.Height);
 }