Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        private void SpawnDrops(Map gameMap, HeroDude gameHero)
        {
            bool hasweapon = false;
            foreach(Weapon w in gameHero.Weapons)
                if(w.GetType()==Weapons[SelectedWeapon].GetType()) hasweapon = true;

            if (hasweapon)
            {
                int drop = Helper.Random.Next(65);
                if (drop < 5) return;
                if (drop >= 5 && drop < 35)
                {
                    if (Helper.Random.Next(2) == 0)
                    {
                        List<Compound> c = gameMap.FindNearestCompounds(Position);
                        if (c[0].Discovered == false) ItemController.Instance.Spawn(ItemType.CompoundMap, Position);
                        else if (BelongsToCompound)
                        {
                            bool found = false;
                            for (int i = 1; i <= 2; i++)
                            {
                                if (c[i].Discovered == false)
                                {
                                    ItemController.Instance.Spawn(ItemType.CompoundMap, Position);
                                    found = true;
                                    break;
                                }
                            }
                            if (!found) ItemController.Instance.Spawn(ItemType.Ammo, Position);
                        }
                        else ItemController.Instance.Spawn(ItemType.Health, Position);
                    }
                    else ItemController.Instance.Spawn(ItemType.Health, Position);
                }
                if (drop >= 35 && drop < 58)
                {
                    if (Helper.Random.Next(2) == 0)
                    {
                        List<Compound> c = gameMap.FindNearestCompounds(Position);
                        if (c[0].Discovered == false) ItemController.Instance.Spawn(ItemType.CompoundMap, Position);
                        else if (BelongsToCompound)
                        {
                            bool found = false;
                            for (int i = 1; i <= 2; i++)
                            {
                                if (c[i].Discovered == false)
                                {
                                    ItemController.Instance.Spawn(ItemType.CompoundMap, Position);
                                    found = true;
                                    break;
                                }
                            }
                            if (!found) ItemController.Instance.Spawn(ItemType.Ammo, Position);
                        }
                        else ItemController.Instance.Spawn(ItemType.Ammo, Position);
                    }
                    else ItemController.Instance.Spawn(ItemType.Ammo, Position);
                }
                if (drop >= 58 && BelongsToCompound)
                {
                    foreach (AIDude e in EnemyController.Instance.Enemies.Where(en => en.IsGeneral).OrderBy(en => (en.Position - Position).Length()))
                    {
                        if (!e.Discovered && (e.Position - Position).Length() < 20000)
                        {
                            ItemController.Instance.Spawn(ItemType.GeneralMap, Position);
                            break;
                        }
                        else break;
                    }
                }
            }
            else
            {
                if (Weapons[SelectedWeapon] is Pistol) ItemController.Instance.Spawn(ItemType.Pistol, Position);
                if (Weapons[SelectedWeapon] is Shotgun) ItemController.Instance.Spawn(ItemType.Shotgun, Position);
                if (Weapons[SelectedWeapon] is SMG) ItemController.Instance.Spawn(ItemType.SMG, Position);
                if (Weapons[SelectedWeapon] is Rifle) ItemController.Instance.Spawn(ItemType.Rifle, Position);

            }
        }