public GangManager()
        {
            instance = this;

            enemyGangs = new List <GangAI>();

            //classes below are all singletons, so no need to hold their ref here
            new ModOptions();
            new SpawnManager();

            gangData = PersistenceHandler.LoadFromFile <GangData>("GangData");
            if (gangData == null)
            {
                gangData = new GangData();

                //setup initial gangs... the player's and an enemy
                CreateNewPlayerGang();

                CreateNewEnemyGang();
            }
            else
            {
                PlayerGang.AdjustStatsToModOptions();
            }

            if (gangData.gangs.Count == 1 && ModOptions.instance.maxCoexistingGangs > 1)
            {
                //we're alone.. add an enemy!
                CreateNewEnemyGang();
            }

            SetUpAllGangs();

            timeLastReward = ModCore.curGameTime;
        }
Exemple #2
0
 void OnTick(object sender, EventArgs e)
 {
     if (ModOptions.instance == null)
     {
         return;
     }
     if (ModOptions.instance.msAutoSaveInterval <= 0)               //reset if invalid
     {
         ModOptions.instance.msAutoSaveInterval = 3000;
     }
     Wait(ModOptions.instance.msAutoSaveInterval);
     if (gangDataDirty)
     {
         PersistenceHandler.SaveToFile(GangManager.instance.gangData, "GangData", gangDataNotifySave);
         gangDataDirty      = false;
         gangDataNotifySave = false;
         return;
     }
     if (zoneDataDirty)
     {
         PersistenceHandler.SaveToFile(ZoneManager.instance.zoneData, "TurfZoneData", zoneDataNotifySave);
         zoneDataDirty      = false;
         zoneDataNotifySave = false;
         return;
     }
 }
Exemple #3
0
        /// <summary>
        /// adds the gang to a xml file that contains a list of gangs that have been wiped out,
        ///  so that the player can reuse their data in the future
        /// </summary>
        /// <param name="gangToAdd"></param>
        public void AddGangToWipedOutList(Gang gangToAdd)
        {
            List <Gang> WOList = PersistenceHandler.LoadFromFile <List <Gang> >("wipedOutGangsList");

            if (WOList == null)
            {
                WOList = new List <Gang>();
            }
            WOList.Add(gangToAdd);
            PersistenceHandler.SaveToFile(WOList, "wipedOutGangsList");
        }
        public static bool AddVehicleAndSavePool(PotentialGangVehicle newCar)
        {
            //check if there isn't an identical entry in the pool
            if (!CarPool.HasIdenticalEntry(newCar))
            {
                CarPool.carList.Add(newCar);
                PersistenceHandler.SaveToFile <PotentialCarPool>(CarPool, "VehiclePool");
                return(true);
            }

            return(false);
        }
Exemple #5
0
        public static bool AddMemberAndSavePool(PotentialGangMember newMember)
        {
            //check if there isn't an identical entry in the pool
            if (!MemberPool.HasIdenticalEntry(newMember))
            {
                MemberPool.memberList.Add(newMember);
                PersistenceHandler.SaveToFile <PotentialMemberPool>(MemberPool, "MemberPool");
                return(true);
            }

            return(false);
        }
        public static bool RemoveVehicleAndSavePool(PotentialGangVehicle newCar)
        {
            int identicalEntryIndex = 0;

            //check if there is an identical entry in the pool
            if (CarPool.HasIdenticalEntry(newCar, ref identicalEntryIndex))
            {
                CarPool.carList.RemoveAt(identicalEntryIndex);
                PersistenceHandler.SaveToFile <PotentialCarPool>(CarPool, "VehiclePool");
                return(true);
            }

            return(false);
        }
Exemple #7
0
        public static bool RemoveMemberAndSavePool(PotentialGangMember newMember)
        {
            //find an identical or similar entry and remove it
            PotentialGangMember similarEntry = MemberPool.GetSimilarEntry(newMember);

            if (similarEntry != null)
            {
                MemberPool.memberList.Remove(similarEntry);
                PersistenceHandler.SaveToFile <PotentialMemberPool>(MemberPool, "MemberPool");
                return(true);
            }

            return(false);
        }
 public void KillGang(GangAI aiWatchingTheGang)
 {
     UI.Notify("The " + aiWatchingTheGang.watchedGang.name + " have been wiped out!");
     enemyGangs.Remove(aiWatchingTheGang);
     //save the fallen gang in a file
     PersistenceHandler.SaveAppendToFile(aiWatchingTheGang.watchedGang, "wipedOutGangs");
     gangData.gangs.Remove(aiWatchingTheGang.watchedGang);
     if (enemyGangs.Count == 0 && ModOptions.instance.maxCoexistingGangs > 1)
     {
         //create a new gang right away... but do it silently to not demotivate the player too much
         Gang createdGang = CreateNewEnemyGang(false);
         if (createdGang != null)
         {
             enemyGangs.Add(new GangAI(createdGang));
         }
     }
     SaveGangData(false);
 }
        public ZoneManager()
        {
            instance = this;

            zoneData = PersistenceHandler.LoadFromFile <TurfZoneData>("TurfZoneData");
            if (zoneData == null)
            {
                zoneData = new TurfZoneData();
            }

            for (int i = 0; i < zoneData.zoneList.Count; i++)
            {
                List <AreaBlip> zoneCircleList = zoneData.zoneList[i].zoneCircles;
                for (int j = 0; j < zoneCircleList.Count; j++)
                {
                    Blip circleBlip = World.CreateBlip(zoneCircleList[j].position, zoneCircleList[j].radius);
                    circleBlip.Alpha = 50; //TODO add mod option to control alpha!
                    zoneData.zoneList[i].myCircleBlips.Add(circleBlip);
                }
            }
        }
Exemple #10
0
        public void LoadOptions()
        {
            ModOptions loadedOptions = PersistenceHandler.LoadFromFile <ModOptions>("ModOptions");

            if (loadedOptions != null)
            {
                //get the loaded options
                this.msAutoSaveInterval = loadedOptions.msAutoSaveInterval;

                this.gangMemberAggressiveness = loadedOptions.gangMemberAggressiveness;

                this.addToGroupKey   = loadedOptions.addToGroupKey;
                this.mindControlKey  = loadedOptions.mindControlKey;
                this.openGangMenuKey = loadedOptions.openGangMenuKey;
                this.openZoneMenuKey = loadedOptions.openZoneMenuKey;

                this.possibleGangFirstNames     = loadedOptions.possibleGangFirstNames;
                this.possibleGangLastNames      = loadedOptions.possibleGangLastNames;
                this.buyableWeapons             = loadedOptions.buyableWeapons;
                this.similarColors              = loadedOptions.similarColors;
                this.extraPlayerExclusiveColors = loadedOptions.extraPlayerExclusiveColors;

                this.startingGangMemberHealth = loadedOptions.startingGangMemberHealth;
                this.maxGangMemberHealth      = loadedOptions.maxGangMemberHealth;
                this.maxGangMemberArmor       = loadedOptions.maxGangMemberArmor;
                this.maxGangMemberAccuracy    = loadedOptions.maxGangMemberAccuracy;

                this.emptyZoneDuringWar = loadedOptions.emptyZoneDuringWar;
                this.maxDistToWarBlipBeforePlayerLeavesWar = loadedOptions.maxDistToWarBlipBeforePlayerLeavesWar;
                this.ticksBeforeWarEndWithPlayerAway       = loadedOptions.ticksBeforeWarEndWithPlayerAway;
                this.postWarBackupsAmount              = loadedOptions.postWarBackupsAmount;
                this.baseNumKillsBeforeWarVictory      = loadedOptions.baseNumKillsBeforeWarVictory;
                this.extraKillsPerTurfValue            = loadedOptions.extraKillsPerTurfValue;
                this.killsBetweenEnemySpawnReplacement = loadedOptions.killsBetweenEnemySpawnReplacement;
                this.ticksBetweenEnemySpawnReplacement = loadedOptions.ticksBetweenEnemySpawnReplacement;

                this.msTimeBetweenTurfRewards            = loadedOptions.msTimeBetweenTurfRewards;
                this.ticksBetweenGangAIUpdates           = loadedOptions.ticksBetweenGangAIUpdates;
                this.minMsTimeBetweenAttacksOnPlayerTurf = loadedOptions.minMsTimeBetweenAttacksOnPlayerTurf;
                this.ticksBetweenGangMemberAIUpdates     = loadedOptions.ticksBetweenGangMemberAIUpdates;
                this.baseRewardPerZoneOwned = loadedOptions.baseRewardPerZoneOwned;
                this.maxRewardPerZoneOwned  = loadedOptions.maxRewardPerZoneOwned;
                this.maxTurfValue           = loadedOptions.maxTurfValue;

                this.rewardMultiplierPerZone = loadedOptions.rewardMultiplierPerZone;

                this.baseCostToTakeTurf       = loadedOptions.baseCostToTakeTurf;
                this.rewardForTakingEnemyTurf = loadedOptions.rewardForTakingEnemyTurf;

                this.baseCostToUpgradeGeneralGangTurfValue = loadedOptions.baseCostToUpgradeGeneralGangTurfValue;
                this.baseCostToUpgradeSingleTurfValue      = loadedOptions.baseCostToUpgradeSingleTurfValue;
                this.baseCostToUpgradeArmor    = loadedOptions.baseCostToUpgradeArmor;
                this.baseCostToUpgradeHealth   = loadedOptions.baseCostToUpgradeHealth;
                this.baseCostToUpgradeAccuracy = loadedOptions.baseCostToUpgradeAccuracy;

                this.wanderingDriverDrivingStyle       = loadedOptions.wanderingDriverDrivingStyle;
                this.driverWithDestinationDrivingStyle = loadedOptions.driverWithDestinationDrivingStyle;

                this.numUpgradesUntilMaxMemberAttribute = loadedOptions.numUpgradesUntilMaxMemberAttribute;
                this.costToCallBackupCar            = loadedOptions.costToCallBackupCar;
                this.costToCallParachutingMember    = loadedOptions.costToCallParachutingMember;
                this.ticksCooldownBackupCar         = loadedOptions.ticksCooldownBackupCar;
                this.ticksCooldownParachutingMember = loadedOptions.ticksCooldownParachutingMember;

                this.minWantedFactorWhenInGangTurf = loadedOptions.minWantedFactorWhenInGangTurf;
                this.maxWantedLevelInMaxedGangTurf = loadedOptions.maxWantedLevelInMaxedGangTurf;
                this.freezeWantedLevelDuringWars   = loadedOptions.freezeWantedLevelDuringWars;

                this.notificationsEnabled      = loadedOptions.notificationsEnabled;
                this.loggerLevel               = loadedOptions.loggerLevel;
                this.preventAIExpansion        = loadedOptions.preventAIExpansion;
                this.membersSpawnWithMeleeOnly = loadedOptions.membersSpawnWithMeleeOnly;
                this.warAgainstPlayerEnabled   = loadedOptions.warAgainstPlayerEnabled;
                this.ambientSpawningEnabled    = loadedOptions.ambientSpawningEnabled;
                this.forceSpawnCars            = loadedOptions.forceSpawnCars;
                this.joypadControls            = loadedOptions.joypadControls;

                this.showGangMemberBlips = loadedOptions.showGangMemberBlips;

                this.gangsStartWithPistols               = loadedOptions.gangsStartWithPistols;
                this.gangsCanBeWipedOut                  = loadedOptions.gangsCanBeWipedOut;
                this.maxCoexistingGangs                  = loadedOptions.maxCoexistingGangs;
                this.extraProfitForAIGangsFactor         = loadedOptions.extraProfitForAIGangsFactor;
                this.spawnedMembersBeforeAmbientGenStops = loadedOptions.spawnedMembersBeforeAmbientGenStops;
                this.msBaseIntervalBetweenAmbientSpawns  = loadedOptions.msBaseIntervalBetweenAmbientSpawns;
                this.spawnedMemberLimit                  = loadedOptions.spawnedMemberLimit;
                this.numSpawnsReservedForCarsDuringWars  = loadedOptions.numSpawnsReservedForCarsDuringWars;
                this.minDistanceCarSpawnFromPlayer       = loadedOptions.minDistanceCarSpawnFromPlayer;
                this.minDistanceMemberSpawnFromPlayer    = loadedOptions.minDistanceMemberSpawnFromPlayer;
                this.maxDistanceCarSpawnFromPlayer       = loadedOptions.maxDistanceCarSpawnFromPlayer;
                this.maxDistanceMemberSpawnFromPlayer    = loadedOptions.maxDistanceMemberSpawnFromPlayer;

                if (similarColors.Count == 0)
                {
                    SetColorTranslationDefaultValues();
                }
                else
                {
                    if (similarColors[0].blipColors == null)
                    {
                        SetColorTranslationDefaultValues();
                    }
                }

                SaveOptions();
            }
            else
            {
                SetAllValuesToDefault();
                SetNameListsDefaultValues();
                SetColorTranslationDefaultValues();
                PersistenceHandler.SaveToFile(this, "ModOptions");
            }
        }
Exemple #11
0
 public void SaveOptions(bool notifyMsg = true)
 {
     PersistenceHandler.SaveToFile(this, "ModOptions", notifyMsg);
 }
Exemple #12
0
 public void SaveZoneData(bool notifySuccess = true)
 {
     PersistenceHandler.SaveToFile <TurfZoneData>(zoneData, "TurfZoneData", notifySuccess);
 }