protected virtual void setDrop() { //Select an Item to drop double randNum = rand.NextDouble(); if (randNum > 0.75f) { Drop = new HealthPack(Position); } else if (randNum > 0.65f) { Drop = new Salvage(Position); } else if (randNum > 0.40f) { Drop = new Ammo(Position); } else if (randNum > 0.30f) { Drop = new GunItem(Position, this); } //---Drops--- //Salvage //Health Kit //Ammo //Bomb //~~Money }
public bool pickUp(Item item) { //Send Item to appropriate class if (item.GetType() == typeof(Salvage)) { invent.add(item); } else if (item.GetType() == typeof(HealthPack)) { int oldhealth = Health; Health += (int)(MaxHealth * 0.05f + 0.5f); return(oldhealth < MaxHealth); } else if (item.GetType() == typeof(Ammo)) { if (CurGun == null) { return(false); } return(CurGun.addAmmo((Ammo)item)); } else if (item.GetType() == typeof(GunItem)) { GunItem gun = (GunItem)item; switch (gun.TechType) { case TechType.HUMAN: guns.Add(new PhysicalGun(this, gun.GunShell)); break; case TechType.ALIEN: guns.Add(new PlasmaGun(this, gun.GunShell)); break; case TechType.ROBOT: guns.Add(new LaserGun(this, gun.GunShell)); break; } } return(true); }