コード例 #1
0
        /// <summary>
        /// Get the minimum experience needed for a Pokemon to be a certain level using a specified growth type
        /// </summary>
        /// <param name="level">The queried level</param>
        /// <param name="growthType">The growth type to use</param>
        /// <returns>The minimum experience needed</returns>
        public static int GetMinimumExperienceForLevel(byte level,
                                                       GrowthType growthType)
        {
            Entry entry = GetEntry(level);

            switch (growthType)
            {
            case GrowthType.Slow:
                return(entry.slow);

            case GrowthType.MediumSlow:
                return(entry.mediumSlow);

            case GrowthType.MediumFast:
                return(entry.mediumFast);

            case GrowthType.Fast:
                return(entry.fast);

            case GrowthType.Erratic:
                return(entry.erratic);

            case GrowthType.Fluctuating:
                return(entry.fluctuating);

            default:
                Debug.LogWarning("Invalid growth type found - " + growthType);
                return(0);
            }
        }
コード例 #2
0
        /// <summary>
        /// Get a the level a Pokemon should be if it has a certain amount of experience
        /// </summary>
        /// <param name="experience">The experience of the pokemon</param>
        /// <param name="growthType">The growth type to search using</param>
        /// <returns></returns>
        public static byte GetLevelFromExperience(int experience,
                                                  GrowthType growthType)
        {
            byte maxLevel   = 1;
            bool entryFound = false;

            foreach (Entry entry in data)
            {
                if (entry.Get(growthType) <= experience)
                {
                    if (entry.level > maxLevel)
                    {
                        maxLevel = entry.level;
                    }

                    entryFound = true;
                }
            }

            if (!entryFound)
            {
                Debug.LogWarning("No suitable level found for growth type " + growthType + " and experience " + experience);
            }

            return(maxLevel);
        }
コード例 #3
0
            public int Get(GrowthType growthType)
            {
                switch (growthType)
                {
                case GrowthType.Slow:
                    return(slow);

                case GrowthType.MediumSlow:
                    return(mediumSlow);

                case GrowthType.MediumFast:
                    return(mediumFast);

                case GrowthType.Fast:
                    return(fast);

                case GrowthType.Erratic:
                    return(erratic);

                case GrowthType.Fluctuating:
                    return(fluctuating);

                default:
                    Debug.LogWarning("Invalid growth type found - " + growthType);
                    return(0);
                }
            }
コード例 #4
0
 public Faction(int id, string name, Color color, bool isPlayerFaction,
                bool isDefaultFaction, bool canInfiltrate, GrowthType growthType,
                IReadOnlyDictionary <int, Species> species,
                IReadOnlyDictionary <int, SoldierTemplate> soldierTemplates,
                IReadOnlyDictionary <int, SquadTemplate> squadTemplates,
                IReadOnlyDictionary <int, UnitTemplate> unitTemplates,
                IReadOnlyDictionary <int, BoatTemplate> boatTemplates,
                IReadOnlyDictionary <int, ShipTemplate> shipTemplates,
                IReadOnlyDictionary <int, FleetTemplate> fleetTemplates)
 {
     Id               = id;
     Name             = name;
     Color            = color;
     IsPlayerFaction  = isPlayerFaction;
     IsDefaultFaction = isDefaultFaction;
     CanInfiltrate    = canInfiltrate;
     GrowthType       = growthType;
     Species          = species;
     SoldierTemplates = soldierTemplates;
     SquadTemplates   = squadTemplates;
     UnitTemplates    = unitTemplates;
     BoatTemplates    = boatTemplates ?? new Dictionary <int, BoatTemplate>();
     ShipTemplates    = shipTemplates ?? new Dictionary <int, ShipTemplate>();
     FleetTemplates   = fleetTemplates ?? new Dictionary <int, FleetTemplate>();
     foreach (UnitTemplate template in UnitTemplates?.Values ?? Enumerable.Empty <UnitTemplate>())
     {
         template.Faction = this;
     }
     Units = new List <Unit>();
 }
コード例 #5
0
        private List <Faction> GetFactionTemplates(IDbConnection connection,
                                                   Dictionary <int, List <Species> > factionSpeciesMap,
                                                   Dictionary <int, List <SoldierTemplate> > factionSoldierTemplateMap,
                                                   Dictionary <int, List <SquadTemplate> > factionSquadMap,
                                                   Dictionary <int, List <UnitTemplate> > factionUnitMap,
                                                   Dictionary <int, List <BoatTemplate> > factionBoatMap,
                                                   Dictionary <int, List <ShipTemplate> > factionShipMap,
                                                   Dictionary <int, List <FleetTemplate> > factionFleetMap)
        {
            List <Faction> factionList = new List <Faction>();
            IDbCommand     command     = connection.CreateCommand();

            command.CommandText = "SELECT * FROM Faction";
            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                int        id            = reader.GetInt32(0);
                string     name          = reader[1].ToString();
                Color      color         = ConvertDatabaseObjectToColor(reader[2]);
                bool       isPlayer      = (bool)reader[3];
                bool       isDefault     = (bool)reader[4];
                bool       canInfiltrate = (bool)reader[5];
                GrowthType growthType    = (GrowthType)reader.GetInt32(6);

                var speciesMap = factionSpeciesMap.ContainsKey(id) ?
                                 factionSpeciesMap[id].ToDictionary(st => st.Id) : null;
                var soldierMap = factionSoldierTemplateMap.ContainsKey(id) ?
                                 factionSoldierTemplateMap[id].ToDictionary(st => st.Id) : null;
                var squadMap = factionSquadMap.ContainsKey(id) ?
                               factionSquadMap[id].ToDictionary(st => st.Id) : null;
                var unitMap = factionUnitMap.ContainsKey(id) ?
                              factionUnitMap[id].ToDictionary(ut => ut.Id) : null;
                Dictionary <int, BoatTemplate>  boatMap  = null;
                Dictionary <int, ShipTemplate>  shipMap  = null;
                Dictionary <int, FleetTemplate> fleetMap = null;
                if (factionShipMap.ContainsKey(id))
                {
                    boatMap  = factionBoatMap[id].ToDictionary(bt => bt.Id);
                    shipMap  = factionShipMap[id].ToDictionary(st => st.Id);
                    fleetMap = factionFleetMap[id].ToDictionary(ft => ft.Id);
                }

                Faction factionTemplate = new Faction(id, name, color, isPlayer, isDefault,
                                                      canInfiltrate, growthType, speciesMap,
                                                      soldierMap, squadMap, unitMap, boatMap,
                                                      shipMap, fleetMap);
                factionList.Add(factionTemplate);
            }
            return(factionList);
        }
コード例 #6
0
        /*********
        ** Static methods
        *********/

        public static int CalculateTuftsToAdd(bool isQuick, GrowthType growthType)
        {
            double rand         = Game1.random.NextDouble();
            float  averageTufts = 0f;

            switch (growthType)
            {
            case GrowthType.Standard:
                averageTufts = isQuick ? ModEntry.config.quickAverageTufts : ModEntry.config.vanillaAverageTufts;
                break;

            case GrowthType.Cut:
                averageTufts = isQuick ? ModEntry.config.quickCutAverageTufts : ModEntry.config.vanillaCutAverageTufts;
                break;

            case GrowthType.Spread:
                averageTufts = (isQuick ? ModEntry.config.quickSpreadAverageTufts : ModEntry.config.vanillaSpreadAverageTufts) * 0.25f;
                break;

            case GrowthType.SpreadConsolidate:
                averageTufts = isQuick ? ModEntry.config.quickSpreadAverageTufts : ModEntry.config.vanillaSpreadAverageTufts;
                break;
            }
            int tuftsToAdd = 0;

            if (ModEntry.config.simplifyGrassGrowth)
            {
                tuftsToAdd = (int)(averageTufts + (averageTufts >= 1 && averageTufts <= 3 ? -1 : 0) + rand * (averageTufts >= 1 && averageTufts <= 3 ? 3 : 1));
            }
            else
            {
                if (averageTufts >= 4.0f)
                {
                    tuftsToAdd = 4;
                }
                else if (averageTufts >= 3.0f)
                {
                    tuftsToAdd = Game1.random.Next(2, 4);
                }
                else if (averageTufts >= 2.0f)
                {
                    tuftsToAdd = Game1.random.Next(1, 4);
                }
                else if (rand <= averageTufts * 0.5f)
                {
                    tuftsToAdd = Game1.random.Next(1, 4);
                }
            }

            return(tuftsToAdd);
        }
コード例 #7
0
        public static byte GetLevel(int natid, uint exp)
        {
            GrowthType growth = GrowthTypes[natid];

            int[] growthtable = null;

            switch (growth)
            {
            default:
            case GrowthType.Slow: growthtable = m_SlowExpByLevel; break;

            case GrowthType.Fast: growthtable = m_FastExpByLevel; break;

            case GrowthType.Medium: growthtable = m_MediumExpByLevel; break;

            case GrowthType.Parabolic: growthtable = m_ParabolicExpByLevel; break;

            case GrowthType.Flux: growthtable = m_FluxExpByLevel; break;

            case GrowthType.Erratic: growthtable = m_ErraticExpByLevel; break;
            }

            if (exp < growthtable[2])
            {
                return(1);
            }
            else if (exp >= growthtable[growthtable.Length - 1])
            {
                return(100);
            }

            for (byte i = 3; i < growthtable.Length; i++)
            {
                if (exp >= growthtable[i] && exp < growthtable[i + 1])
                {
                    return(i);
                }
            }

            return(0);
        }