Пример #1
0
        private void RepositionItems(List <Location> ItemLocs)
        {
            if (ItemLocs.Count > 0)
            {
                //We are currently looking guns + ammo
                List <TR2Entities> targetents = TR2EntityUtilities.GetListOfGunTypes();
                targetents.AddRange(TR2EntityUtilities.GetListOfAmmoTypes());

                for (int i = 0; i < _levelInstance.Entities.Count(); i++)
                {
                    if (targetents.Contains((TR2Entities)_levelInstance.Entities[i].TypeID) && (i != _planeCargoWeaponIndex))
                    {
                        Location RandomLocation = ItemLocs[_generator.Next(0, ItemLocs.Count)];

                        Location GlobalizedRandomLocation = SpatialConverters.TransformToLevelSpace(RandomLocation, _levelInstance.Rooms[RandomLocation.Room].Info);

                        _levelInstance.Entities[i].Room       = Convert.ToInt16(GlobalizedRandomLocation.Room);
                        _levelInstance.Entities[i].X          = GlobalizedRandomLocation.X;
                        _levelInstance.Entities[i].Y          = GlobalizedRandomLocation.Y;
                        _levelInstance.Entities[i].Z          = GlobalizedRandomLocation.Z;
                        _levelInstance.Entities[i].Intensity1 = -1;
                        _levelInstance.Entities[i].Intensity2 = -1;
                    }
                }
            }
        }
Пример #2
0
        private void RepositionItems(List <Location> ItemLocs, string lvl)
        {
            if (IsDevelopmentModeOn)
            {
                PlaceAllItems(ItemLocs);
                return;
            }

            if (ItemLocs.Count > 0)
            {
                //We are currently looking guns + ammo
                List <TR2Entities> targetents = TR2EntityUtilities.GetListOfGunTypes();
                targetents.AddRange(TR2EntityUtilities.GetListOfAmmoTypes());

                //And also key items...
                if (IncludeKeyItems)
                {
                    targetents.AddRange(TR2EntityUtilities.GetListOfKeyItemTypes());
                }

                //It's important to now start zoning key items as softlocks must be avoided.
                ZonedLocationCollection ZonedLocations = new ZonedLocationCollection();
                ZonedLocations.PopulateZones(lvl, ItemLocs, ZonePopulationMethod.KeyPuzzleQuestOnly);

                for (int i = 0; i < _levelInstance.Entities.Count(); i++)
                {
                    if (targetents.Contains((TR2Entities)_levelInstance.Entities[i].TypeID) && (i != _unarmedLevelPistolIndex))
                    {
                        Location RandomLocation        = new Location();
                        bool     FoundPossibleLocation = false;

                        if (TR2EntityUtilities.IsKeyItemType((TR2Entities)_levelInstance.Entities[i].TypeID))
                        {
                            TR2Entities type = (TR2Entities)_levelInstance.Entities[i].TypeID;

                            // Apply zoning for key items
                            switch (type)
                            {
                            case TR2Entities.Puzzle1_S_P:
                                if (ZonedLocations.Puzzle1Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Puzzle1Zone[_generator.Next(0, ZonedLocations.Puzzle1Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Puzzle2_S_P:
                                if (ZonedLocations.Puzzle2Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Puzzle2Zone[_generator.Next(0, ZonedLocations.Puzzle2Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Puzzle3_S_P:
                                if (ZonedLocations.Puzzle3Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Puzzle3Zone[_generator.Next(0, ZonedLocations.Puzzle3Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Puzzle4_S_P:
                                if (ZonedLocations.Puzzle4Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Puzzle4Zone[_generator.Next(0, ZonedLocations.Puzzle4Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Key1_S_P:
                                if (ZonedLocations.Key1Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Key1Zone[_generator.Next(0, ZonedLocations.Key1Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Key2_S_P:
                                if (ZonedLocations.Key2Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Key2Zone[_generator.Next(0, ZonedLocations.Key2Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Key3_S_P:
                                if (ZonedLocations.Key3Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Key3Zone[_generator.Next(0, ZonedLocations.Key3Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Key4_S_P:
                                if (ZonedLocations.Key4Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Key4Zone[_generator.Next(0, ZonedLocations.Key4Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Quest1_S_P:
                                if (ZonedLocations.Quest1Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Quest1Zone[_generator.Next(0, ZonedLocations.Quest1Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Quest2_S_P:
                                if (ZonedLocations.Quest2Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Quest2Zone[_generator.Next(0, ZonedLocations.Quest2Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            //Place standard items as normal for now
                            RandomLocation        = ItemLocs[_generator.Next(0, ItemLocs.Count)];
                            FoundPossibleLocation = true;
                        }

                        if (FoundPossibleLocation)
                        {
                            Location GlobalizedRandomLocation = SpatialConverters.TransformToLevelSpace(RandomLocation, _levelInstance.Rooms[RandomLocation.Room].Info);

                            _levelInstance.Entities[i].Room       = Convert.ToInt16(GlobalizedRandomLocation.Room);
                            _levelInstance.Entities[i].X          = GlobalizedRandomLocation.X;
                            _levelInstance.Entities[i].Y          = GlobalizedRandomLocation.Y;
                            _levelInstance.Entities[i].Z          = GlobalizedRandomLocation.Z;
                            _levelInstance.Entities[i].Intensity1 = -1;
                            _levelInstance.Entities[i].Intensity2 = -1;
                        }
                    }
                }
            }
        }
Пример #3
0
        private void RepositionItems(List <Location> ItemLocs)
        {
            if (IsDevelopmentModeOn)
            {
                PlaceAllItems(ItemLocs);
                return;
            }

            if (ItemLocs.Count > 0)
            {
                //We are currently looking guns + ammo
                List <TR2Entities> targetents = TR2EntityUtilities.GetListOfGunTypes();
                targetents.AddRange(TR2EntityUtilities.GetListOfAmmoTypes());

                //And also key items...
                if (IncludeKeyItems)
                {
                    targetents.AddRange(TR2EntityUtilities.GetListOfKeyItemTypes());
                }

                //It's important to now start zoning key items as softlocks must be avoided.
                ZonedLocationCollection ZonedLocations = new ZonedLocationCollection();
                ZonedLocations.PopulateZones(_levelInstance.Name, ItemLocs, ZonePopulationMethod.KeyPuzzleQuestOnly);

                for (int i = 0; i < _levelInstance.Data.Entities.Count(); i++)
                {
                    if (targetents.Contains((TR2Entities)_levelInstance.Data.Entities[i].TypeID) && (i != _unarmedLevelPistolIndex))
                    {
                        Location RandomLocation        = new Location();
                        bool     FoundPossibleLocation = false;

                        if (TR2EntityUtilities.IsKeyItemType((TR2Entities)_levelInstance.Data.Entities[i].TypeID))
                        {
                            TR2Entities type = (TR2Entities)_levelInstance.Data.Entities[i].TypeID;

                            // Apply zoning for key items
                            switch (type)
                            {
                            case TR2Entities.Puzzle1_S_P:
                                if (ZonedLocations.Puzzle1Zone.Count > 0)
                                {
                                    if (_levelInstance.Name == LevelNames.DA)
                                    {
                                        int burnerChipID  = 120;
                                        int consoleChipID = 7;

                                        RandomLocation = ZonedLocations.Puzzle1Zone[_generator.Next(0, ZonedLocations.Puzzle1Zone.Count)];

                                        //Special case - multiple chips
                                        if (i == burnerChipID)
                                        {
                                            //Burner Chip
                                            List <int> AllowedBurnerRooms = new List <int>()
                                            {
                                                13, 14, 15, 16, 21, 22, 23, 24, 25, 26, 29, 30, 32, 34, 75, 80, 83, 84, 85, 86, 87, 88, 89
                                            };

                                            while (!AllowedBurnerRooms.Contains(RandomLocation.Room))
                                            {
                                                RandomLocation = ZonedLocations.Puzzle1Zone[_generator.Next(0, ZonedLocations.Puzzle1Zone.Count)];
                                            }

                                            FoundPossibleLocation = true;
                                        }
                                        else if (i == consoleChipID)
                                        {
                                            //Center Console Chip
                                            List <int> AllowedConsoleRooms = new List <int>()
                                            {
                                                2, 12, 13, 14, 15, 16, 17, 21, 22, 23, 24, 25, 26, 29, 30, 32, 34, 35, 64, 65, 66, 68, 69, 70, 75, 80, 82, 83, 84, 85, 86, 87, 88, 89
                                            };

                                            while (!AllowedConsoleRooms.Contains(RandomLocation.Room))
                                            {
                                                RandomLocation = ZonedLocations.Puzzle1Zone[_generator.Next(0, ZonedLocations.Puzzle1Zone.Count)];
                                            }

                                            FoundPossibleLocation = true;
                                        }
                                        else
                                        {
                                            RandomLocation        = ZonedLocations.Puzzle1Zone[_generator.Next(0, ZonedLocations.Puzzle1Zone.Count)];
                                            FoundPossibleLocation = true;
                                        }
                                    }
                                    else
                                    {
                                        RandomLocation        = ZonedLocations.Puzzle1Zone[_generator.Next(0, ZonedLocations.Puzzle1Zone.Count)];
                                        FoundPossibleLocation = true;
                                    }
                                }
                                break;

                            case TR2Entities.Puzzle2_S_P:
                                if (ZonedLocations.Puzzle2Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Puzzle2Zone[_generator.Next(0, ZonedLocations.Puzzle2Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Puzzle3_S_P:
                                if (ZonedLocations.Puzzle3Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Puzzle3Zone[_generator.Next(0, ZonedLocations.Puzzle3Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Puzzle4_S_P:
                                if (ZonedLocations.Puzzle4Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Puzzle4Zone[_generator.Next(0, ZonedLocations.Puzzle4Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Key1_S_P:
                                if (ZonedLocations.Key1Zone.Count > 0)
                                {
                                    if (_levelInstance.Name == LevelNames.OPERA)
                                    {
                                        int startKeyID = 172;
                                        int fanKeyID   = 118;

                                        //Special case - multiple keys
                                        if (i == startKeyID)
                                        {
                                            //Start key
                                            List <int> AllowedStartRooms = new List <int>()
                                            {
                                                10, 23, 25, 27, 29, 30, 31, 32, 33, 35, 127, 162, 163
                                            };

                                            while (!AllowedStartRooms.Contains(RandomLocation.Room))
                                            {
                                                RandomLocation = ZonedLocations.Key1Zone[_generator.Next(0, ZonedLocations.Key1Zone.Count)];
                                            }

                                            FoundPossibleLocation = true;
                                        }
                                        else if (i == fanKeyID)
                                        {
                                            //Fan area key
                                            List <int> AllowedFanRooms = new List <int>()
                                            {
                                                1, 5, 8, 16, 37, 38, 44, 46, 47, 48, 49, 50, 52, 53, 55, 57, 59, 60, 63, 65, 66, 67, 68, 69, 70, 71, 72, 75, 76, 77, 78, 82, 83, 86, 87, 88, 89, 90, 93, 95, 96, 100, 102, 103, 105, 107, 109, 111, 120, 132, 139, 141, 143, 144, 151, 153, 154, 155, 156, 158, 159, 161, 174, 176, 177, 178, 179, 183, 185, 187, 188, 189
                                            };

                                            while (!AllowedFanRooms.Contains(RandomLocation.Room))
                                            {
                                                RandomLocation = ZonedLocations.Key1Zone[_generator.Next(0, ZonedLocations.Key1Zone.Count)];
                                            }

                                            FoundPossibleLocation = true;
                                        }
                                        else
                                        {
                                            RandomLocation        = ZonedLocations.Key1Zone[_generator.Next(0, ZonedLocations.Key1Zone.Count)];
                                            FoundPossibleLocation = true;
                                        }
                                    }
                                    else
                                    {
                                        RandomLocation        = ZonedLocations.Key1Zone[_generator.Next(0, ZonedLocations.Key1Zone.Count)];
                                        FoundPossibleLocation = true;
                                    }
                                }
                                break;

                            case TR2Entities.Key2_S_P:
                                if (ZonedLocations.Key2Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Key2Zone[_generator.Next(0, ZonedLocations.Key2Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Key3_S_P:
                                if (ZonedLocations.Key3Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Key3Zone[_generator.Next(0, ZonedLocations.Key3Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Key4_S_P:
                                if (ZonedLocations.Key4Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Key4Zone[_generator.Next(0, ZonedLocations.Key4Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Quest1_S_P:
                                if (ZonedLocations.Quest1Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Quest1Zone[_generator.Next(0, ZonedLocations.Quest1Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            case TR2Entities.Quest2_S_P:
                                if (ZonedLocations.Quest2Zone.Count > 0)
                                {
                                    RandomLocation        = ZonedLocations.Quest2Zone[_generator.Next(0, ZonedLocations.Quest2Zone.Count)];
                                    FoundPossibleLocation = true;
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            //Place standard items as normal for now
                            RandomLocation        = ItemLocs[_generator.Next(0, ItemLocs.Count)];
                            FoundPossibleLocation = true;
                        }

                        if (FoundPossibleLocation)
                        {
                            Location GlobalizedRandomLocation = SpatialConverters.TransformToLevelSpace(RandomLocation, _levelInstance.Data.Rooms[RandomLocation.Room].Info);

                            _levelInstance.Data.Entities[i].Room       = Convert.ToInt16(GlobalizedRandomLocation.Room);
                            _levelInstance.Data.Entities[i].X          = GlobalizedRandomLocation.X;
                            _levelInstance.Data.Entities[i].Y          = GlobalizedRandomLocation.Y;
                            _levelInstance.Data.Entities[i].Z          = GlobalizedRandomLocation.Z;
                            _levelInstance.Data.Entities[i].Intensity1 = -1;
                            _levelInstance.Data.Entities[i].Intensity2 = -1;
                        }
                    }
                }
            }
        }