void Pickup(Item i, HeroDude gameHero, Map gameMap, bool[,] mapFog) { switch (i.Type) { case ItemType.Health: AudioController.PlaySFX("medkit", 0.5f, -0.4f, -0.4f, i.Position); gameHero.Health += 25f + (float)Helper.Random.Next(25); break; case ItemType.Ammo: AudioController.PlaySFX("ammo", 1f, 0f, 0f, i.Position); gameHero.Ammo += 10 + Helper.Random.Next(15); break; case ItemType.CompoundMap: List<Compound> c = gameMap.FindNearestCompounds(gameHero.Position); if (c[0].Discovered == false) { gameMap.DiscoverCompound(c[0], mapFog); if(!c[0].Bounds.Contains(Helper.VtoP(i.Position/100))) Hud.Instance.Ticker.AddLine("> An enemy compound has been revealed! (Tab/Back for map)"); else Hud.Instance.Ticker.AddLine("> This compound has been revealed!"); } else { foreach (Compound nc in c) { if (nc.Discovered == false) { gameMap.DiscoverCompound(nc, mapFog); if (!nc.Bounds.Contains(Helper.VtoP(i.Position / 100))) Hud.Instance.Ticker.AddLine("> An enemy compound has been revealed! (Tab/Back for map)"); else Hud.Instance.Ticker.AddLine("> This compound has been revealed!"); break; } } } break; case ItemType.GeneralMap: EnemyController.Instance.DiscoverGeneral(i.Position); break; case ItemType.Pistol: case ItemType.Shotgun: case ItemType.SMG: case ItemType.Rifle: gameHero.Ammo += 10 + Helper.Random.Next(15); gameHero.GiveWeapon(i.Type); break; } i.Active = false; }
public override void Update(GameTime gameTime, Map gameMap, bool[,] mapFog, HeroDude gameHero) { base.Update(gameTime, gameMap, mapFog, gameHero); HuntedLevel.Update(gameTime); HeadTorch.Position = Helper.PointOnCircle(ref Position, 32, Rotation - MathHelper.PiOver2); HeadTorch.Rotation = Rotation - MathHelper.PiOver2; foreach (Compound c in gameMap.Compounds) { if (!c.Discovered && (c.Position-Position).Length()<1000f) { gameMap.DiscoverCompound(c, mapFog); Hud.Instance.Ticker.AddLine("> This compound has been revealed!"); } } if (drivingVehicle!=null) { HeadTorch.Active = false; Position = drivingVehicle.Position; Rotation = drivingVehicle.Rotation + MathHelper.PiOver2; } else if(!Dead) HeadTorch.Active = true; if (Health < 30f) { if(Helper.Random.Next((int)Health*10)==1) ParticleController.Instance.AddBlood(Position); if(Health<10f) if (Helper.Random.Next((int)Health * 100) == 1) ParticleController.Instance.AddBloodPool(Position); } if (Health <= 0 && !Dead) { deadTime = 5000; deadAlpha = 1f; Dead = true; HeadTorch.Active = false; ParticleController.Instance.AddBloodPool(Position); } if (Dead) { if (deadTime < 3000) { deadAlpha -= 0.01f; } if (deadTime < 1000) { Position = gameMap.HeroSpawn; Camera.Instance.Position = Position; Camera.Instance.Target = Position; Health = 100f; HeadTorch.Active = true; Dead = false; Weapons.Clear(); Weapons.Add(new Knife(this)); SelectedWeapon = 0; HuntedLevel.Level = 0f; EnemyController.Instance.ClearSpawn(gameMap.HeroSpawn); VehicleController.Instance.ClearSpawn(gameMap.HeroSpawn); VehicleController.Instance.SpawnNearestVehicles(gameMap.HeroSpawn, gameMap); Ammo = 0; } } if (!(drivingVehicle is Chopper)) { foreach (Compound c in gameMap.Compounds) foreach (Building b in c.Buildings) if (b.Type == BuildingType.Building) { Point pos = Helper.VtoP(Position / 100); if (b.Rect.Contains(pos) && b.RoofFade > 0.1f) b.RoofFade -= 0.01f; else if (b.RoofFade < 1f) b.RoofFade += 0.01f; } } if (!Dead && deadAlpha < 1f) deadAlpha += 0.01f; }