Esempio n. 1
0
        /// <summary>
        /// Returns true if a new discovery is succesfully made and added to the ResearchHandler
        /// </summary>
        /// <returns></returns>
        ResearchResult _tryNewDiscovery()
        {
            IEnumerable <ResearchDiscoveries> remainingDiscoveries = AllDiscoveries.Except(Discoveries);

            if (remainingDiscoveries.Count() != 0)
            {
                ResearchDiscoveries s = remainingDiscoveries.ElementAt(Rand.Random.Next(0, remainingDiscoveries.Count()));
                Discoveries.Add(s);
                DiscoveryLevels.Add(s, 1);

#if DEBUG
                ConsoleManager.WriteLine("Discovered " + s.ToString(), ConsoleMessageType.Debug);
#endif


                return(new ResearchResult()
                {
                    Discovery = s, Level = 1
                });
            }
            else
            {
                return(null);
            }
        }
    public void AddDiscoveryToFind(Discovery discovery)
    {
        if (Discoveries.ContainsKey(discovery.Id))
        {
            return;
        }

        if (DiscoveriesToFind.ContainsKey(discovery.Id))
        {
            return;
        }

        DiscoveriesToFind.Add(discovery.Id, discovery);
    }
Esempio n. 3
0
        /// <summary>
        /// Chooses and adds a new or levels up an existing discovery
        /// </summary>
        ResearchResult _makeDiscovery()
        {
            float pNewDiscovery = .30f;//66% chance that an existing discovery will be leveled as opposed to finding a new discovery

            //Roll for new discovery
            if (Rand.Random.NextDouble() < pNewDiscovery || Discoveries.Count() == 0)
            {
                if (_tryNewDiscovery() == null)
                {
                    return(_tryUpgradeDiscovery());
                }
            }
            else
            {
                return(_tryUpgradeDiscovery());
            }

            return(null);
        }
Esempio n. 4
0
 private void Awake()
 {
     instance = this;
 }