Esempio n. 1
0
        public ProspectSituations GetProspectSituation(int planetID, string biome, double longitude, double lattitude, double altitude, out GoldStrikeLode lode)
        {
            GoldStrikeChance chance         = GetGoldStrikeChance(planetID, biome);
            double           travelDistance = chance.GetDistanceFromLastLocation(longitude, lattitude, altitude);

            //Set the lode object
            lode = FindNearestLode(planetID, biome, longitude, lattitude);

            //Are we out of chances?
            if (chance.chancesRemaining <= 0)
            {
                return(ProspectSituations.OutOfChances);
            }

            //Is there a lode in the area?
            if (lode != null)
            {
                return(ProspectSituations.LodeAlreadyExists);
            }

            //Have we traveled far enough?
            if (travelDistance < GoldStrikeSettings.DistanceBetweenProspects)
            {
                debugLog("Calculated distance between current location and last prospect location: " + travelDistance);
                return(ProspectSituations.NotEnoughDistance);
            }

            return(ProspectSituations.Valid);
        }
Esempio n. 2
0
        public int GetProspectAttemptsRemaining(int planetID, string biome)
        {
            string           planetBiomeKey   = planetID.ToString() + biome;
            GoldStrikeChance goldStrikeChance = null;

            if (goldStrikeChances.ContainsKey(planetBiomeKey) == false)
            {
                goldStrikeChance = new GoldStrikeChance();
                goldStrikeChances.Add(planetBiomeKey, goldStrikeChance);
            }

            goldStrikeChance = goldStrikeChances[planetBiomeKey];
            return(goldStrikeChance.chancesRemaining);
        }
Esempio n. 3
0
        public GoldStrikeChance GetGoldStrikeChance(int planetID, string biome)
        {
            string           planetBiomeKey   = planetID.ToString() + biome;
            GoldStrikeChance goldStrikeChance = null;

            if (goldStrikeChances.ContainsKey(planetBiomeKey) == false)
            {
                goldStrikeChance          = new GoldStrikeChance();
                goldStrikeChance.planetID = planetID;
                goldStrikeChance.biome    = biome;
                goldStrikeChances.Add(planetBiomeKey, goldStrikeChance);
            }

            goldStrikeChance = goldStrikeChances[planetBiomeKey];
            debugLog("GetGoldStrikeChance retrieved " + goldStrikeChance.ToString());
            return(goldStrikeChance);
        }
Esempio n. 4
0
        public Vector3d GetLastProspectLocation(int planetID, string biome)
        {
            string           planetBiomeKey   = planetID.ToString() + biome;
            GoldStrikeChance goldStrikeChance = null;
            Vector3d         lastLocation     = Vector3d.zero;

            if (goldStrikeChances.ContainsKey(planetBiomeKey) == false)
            {
                return(Vector3d.zero);
            }

            goldStrikeChance = goldStrikeChances[planetBiomeKey];

            lastLocation.x = goldStrikeChance.lastProspectLocation.x;
            lastLocation.y = goldStrikeChance.lastProspectLocation.y;
            lastLocation.z = goldStrikeChance.lastProspectLocation.z;

            return(lastLocation);
        }
Esempio n. 5
0
        public int DecrementProspectAttempts(int planetID, string biome)
        {
            string           planetBiomeKey   = planetID.ToString() + biome;
            GoldStrikeChance goldStrikeChance = null;

            if (goldStrikeChances.ContainsKey(planetBiomeKey) == false)
            {
                goldStrikeChance          = new GoldStrikeChance();
                goldStrikeChance.planetID = planetID;
                goldStrikeChance.biome    = biome;
                goldStrikeChances.Add(planetBiomeKey, goldStrikeChance);
            }

            goldStrikeChance = goldStrikeChances[planetBiomeKey];
            goldStrikeChance.chancesRemaining -= 1;

            //Save the game
            GamePersistence.SaveGame("quicksave", HighLogic.SaveFolder, SaveMode.BACKUP);

            return(goldStrikeChance.chancesRemaining);
        }
Esempio n. 6
0
        public void SetLastProspectLocation(int planetID, string biome, double longitude, double latitude, double altitude)
        {
            string           planetBiomeKey   = planetID.ToString() + biome;
            GoldStrikeChance goldStrikeChance = null;

            if (goldStrikeChances.ContainsKey(planetBiomeKey) == false)
            {
                goldStrikeChance          = new GoldStrikeChance();
                goldStrikeChance.planetID = planetID;
                goldStrikeChance.biome    = biome;
                goldStrikeChances.Add(planetBiomeKey, goldStrikeChance);
            }

            goldStrikeChance = goldStrikeChances[planetBiomeKey];
            goldStrikeChance.lastProspectLocation.x = longitude;
            goldStrikeChance.lastProspectLocation.y = latitude;
            goldStrikeChance.lastProspectLocation.z = altitude;

            //Save the game
            GamePersistence.SaveGame("quicksave", HighLogic.SaveFolder, SaveMode.BACKUP);
        }
Esempio n. 7
0
        public void ResetProspects()
        {
            //Since it costs science, ask for confirmation.
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                float scienceCost = GoldStrikeSettings.ProspectResetCost;

                //Confirmed, pay the science cost.
                if (prospectResetConfirmed)
                {
                    ResearchAndDevelopment.Instance.AddScience(-scienceCost, TransactionReasons.Any);
                }

                else
                {
                    prospectResetConfirmed = true;
                    string message = string.Format("It will cost {0:f2} Science to renew your prospecting chances in this biome. Click to confirm.", scienceCost);
                    ScreenMessages.PostScreenMessage(message, kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER);
                    return;
                }
            }

            //Reset the chances
            string biomeName = string.Empty;
            int    planetID  = -1;

            GoldStrikeUtils.GetBiomeAndPlanet(out biomeName, out planetID, this.part.vessel, asteroid);
            GoldStrikeChance chance = WBIPathfinderScenario.Instance.GetGoldStrikeChance(planetID, biomeName);

            chance.chancesRemaining = GoldStrikeSettings.ProspectsPerBiome;

            //Hide the reset button
            Events["ResetProspects"].guiActive          = false;
            Events["ResetProspects"].guiActiveUnfocused = false;

            //Save the game
            GamePersistence.SaveGame("quicksave", HighLogic.SaveFolder, SaveMode.BACKUP);
        }
Esempio n. 8
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            ConfigNode[]     efficiencyNodes     = node.GetNodes(kEfficiencyData);
            ConfigNode[]     toolTipsShown       = node.GetNodes(kToolTip);
            ConfigNode[]     goldStrikeNodes     = GameDatabase.Instance.GetConfigNodes(kGoldStrikeDataNode);
            ConfigNode[]     goldStrikeLodeNodes = node.GetNodes(kGoldStrikeLodeNode);
            ConfigNode[]     strikeChances       = node.GetNodes(kGoldStrikeChance);
            string           value  = node.GetValue(kReputationIndex);
            GoldStrikeChance chance = null;

            if (string.IsNullOrEmpty(value) == false)
            {
                reputationIndex = int.Parse(value);
            }

            debugLog("OnLoad: there are " + goldStrikeNodes.Length + " GOLDSTRIKE items to load.");
            foreach (ConfigNode goldStrikeDataNode in goldStrikeNodes)
            {
                GoldStrikeData strikeData = new GoldStrikeData();
                strikeData.Load(goldStrikeDataNode);
                if (string.IsNullOrEmpty(strikeData.resourceName) == false)
                {
                    goldStrikeResources.Add(strikeData.resourceName, strikeData);
                }
            }

            debugLog("OnLoad: there are " + goldStrikeLodeNodes.Length + " GoldStrikeLode items to load.");
            foreach (ConfigNode goldStrikeLodeNode in goldStrikeLodeNodes)
            {
                GoldStrikeLode lode = new GoldStrikeLode();
                Dictionary <string, GoldStrikeLode> lodeMap = null;
                string planetBiomeKey, lodeKey;

                lode.Load(goldStrikeLodeNode);
                planetBiomeKey = lode.planetID.ToString() + lode.biome;

                if (goldStrikeLodes.ContainsKey(planetBiomeKey) == false)
                {
                    lodeMap = new Dictionary <string, GoldStrikeLode>();
                    goldStrikeLodes.Add(planetBiomeKey, lodeMap);
                }
                lodeMap = goldStrikeLodes[planetBiomeKey];

                //Add the new lode
                lodeKey = lode.longitude.ToString() + lode.lattitude.ToString() + lode.resourceName;
                lodeMap.Add(lodeKey, lode);
            }

            debugLog("OnLoad: there are " + strikeChances.Length + " GoldStrikeChance items to load.");
            foreach (ConfigNode chanceNode in strikeChances)
            {
                chance = new GoldStrikeChance();
                chance.Load(chanceNode);
                string planetBiomeKey = chance.planetID.ToString() + chance.biome;
                goldStrikeChances.Add(planetBiomeKey, chance);
            }

            foreach (ConfigNode efficiencyNode in efficiencyNodes)
            {
                EfficiencyData efficiencyData = new EfficiencyData();
                efficiencyData.Load(efficiencyNode);
                efficiencyDataMap.Add(efficiencyData.Key, efficiencyData);
            }

            foreach (ConfigNode toolTipNode in toolTipsShown)
            {
                if (toolTipNode.HasValue(kName) == false)
                {
                    continue;
                }
                value = toolTipNode.GetValue(kName);

                if (toolTips.ContainsKey(value))
                {
                    toolTips[value] = toolTipNode;
                }
                else
                {
                    toolTips.Add(value, toolTipNode);
                }
            }
        }