示例#1
0
 public void SetColonyType(int index)
 {
     Debug.Assert(
         index >= 0 && index < colonyTypeList.colonyTypes.Length,
         "Index have to be in range [0, size of colonyTypeList]");
     currentColonyType = colonyTypeList.colonyTypes[index];
 }
示例#2
0
        /// <summary>
        /// Read weapon sheet.
        /// </summary>
        public static Dictionary <map_id, GlobalWeaponInfo> ReadWeaponSheet()
        {
            string[][] weaponSheet = ReadSheet("weapons.txt");
            if (weaponSheet == null)
            {
                return(null);
            }

            Dictionary <map_id, GlobalWeaponInfo> infoRecords = new Dictionary <map_id, GlobalWeaponInfo>(weaponSheet.GetLength(0));

            // Read rows
            for (int i = 0; i < weaponSheet.GetLength(0); ++i)
            {
                string[] row = weaponSheet[i];

                // Skip rows that don't contain enough data (probably empty line)
                if (row.Length < 14)
                {
                    continue;
                }

                string     codeName            = row[0];                                // Code_Name
                string     weaponName          = row[1];                                // Weapon Name
                int        damageRadius        = ReadInt(row[2]);                       // Damage Radius
                int        pixelsSkippedFiring = ReadInt(row[3]);                       // Pixels skipped when firing
                int        weaponRange         = ReadInt(row[4]);                       // Weapon range in tiles
                int        turretTurnRate      = ReadInt(row[5]);                       // Turret turn rate
                ColonyType owner             = ReadOwner(row[6]);                       // Owner [P/E/B/G]
                int        concussionDamage  = ReadInt(row[7]);                         // Concussion damage
                int        penetrationDamage = ReadInt(row[8]);                         // Penetration damage
                int        commonOreCost     = ReadInt(row[9]);                         // Common Ore Cost
                int        rareOreCost       = ReadInt(row[10]);                        // Rare Ore Cost
                int        buildTime         = ReadInt(row[11]);                        // Build Time
                int        reloadTime        = ReadInt(row[12]);                        // Reload Time
                int        researchTopic     = ReadInt(row[13]);                        // Research topic (leading zero, tech ID)

                map_id unitTypeId = GetMapIdFromCodeName(codeName);

                infoRecords[unitTypeId] = new GlobalWeaponInfo(unitTypeId, researchTopic, weaponName, codeName,
                                                               /*hitPoints, armorClass,*/ commonOreCost, rareOreCost, buildTime, /*sightRange,*/
                                                               damageRadius, pixelsSkippedFiring, weaponRange, turretTurnRate, concussionDamage, penetrationDamage, reloadTime
                                                               );
            }

            return(infoRecords);
        }
示例#3
0
    private void InitColonyTypes()
    {
        colonyTypeDropdown.ClearOptions();

        List <string> options = new List <string>();

        foreach (ColonyType colonyType in colonyTypeList.colonyTypes)
        {
            options.Add(colonyType.name);
        }

        colonyTypeDropdown.AddOptions(options);
        colonyTypeDropdown.value = 0;
        colonyTypeDropdown.RefreshShownValue();

        currentColonyType = colonyTypeList.colonyTypes[0];
    }
示例#4
0
        public void Initialize(string name, string lordName, ColonyType ctype)
        {
            this.Name       = name;
            this.LordName   = lordName;
            this.ColonyType = ctype;

            this.Tax     = GLOBALS.StartTax;
            this.Liberty = GLOBALS.StartLiberty;

            this.Happiness = GLOBALS.StartHappiness;
            this.Morality  = GLOBALS.StartMorality;

            this.Money      = GLOBALS.StartMoney;
            this.Population = GLOBALS.StartPopulation;

            this.Food    = GLOBALS.StartFood;
            this.Houses  = GLOBALS.StartHouses;
            this.Culture = GLOBALS.StartCulture;

            this.Dead = false;
        }
示例#5
0
        /// <summary>
        /// Read starship sheet.
        /// </summary>
        public static Dictionary <map_id, GlobalUnitInfo> ReadStarshipSheet()
        {
            string[][] starshipSheet = ReadSheet("space.txt");
            if (starshipSheet == null)
            {
                return(null);
            }

            Dictionary <map_id, GlobalUnitInfo> infoRecords = new Dictionary <map_id, GlobalUnitInfo>(starshipSheet.GetLength(0));

            // Read rows
            for (int i = 0; i < starshipSheet.GetLength(0); ++i)
            {
                string[] row = starshipSheet[i];

                // Skip rows that don't contain enough data (probably empty line)
                if (row.Length < 7)
                {
                    continue;
                }

                string     codeName      = row[0];                                      // Code_Name
                string     unitName      = row[1];                                      // Unit Name
                ColonyType owner         = ReadOwner(row[2]);                           // Owner [P/E/B]
                int        commonOreCost = ReadInt(row[3]);                             // Common Ore Cost
                int        rareOreCost   = ReadInt(row[4]);                             // Rare Ore Cost
                int        buildTime     = ReadInt(row[5]);                             // Build Time
                int        researchTopic = ReadInt(row[6]);                             // Research topic (leading zero, tech ID)

                map_id unitTypeId = GetMapIdFromCodeName(codeName);

                infoRecords[unitTypeId] = new GlobalUnitInfo(unitTypeId, researchTopic, unitName, codeName,
                                                             0, 0, commonOreCost, rareOreCost, buildTime, 0
                                                             );
            }

            return(infoRecords);
        }
        private void SetExportState(ColonyType colonyType)
        {
            bool FSexport =false;
            bool PSexport = false;
            int pc = 0;
            foreach(Planet planet in this.Owner.GetPlanets())
            {
                pc++;
                if(planet.fs == GoodState.IMPORT)
                {
                    FSexport = true;
                }
                if(planet.ps == GoodState.IMPORT)
                {
                    PSexport = true;
                }
            }
            if(pc==1)
            {
                FSexport = false;
                PSexport = false;
            }
            float PRatio = this.ProductionHere /this.MAX_STORAGE;
            float FRatio = this.FoodHere /this.MAX_STORAGE;
            switch (colonyType)
            {

                case ColonyType.Colony:
                case ColonyType.Military:
                case ColonyType.Industrial:
                    if (this.NetProductionPerTurn > this.developmentLevel)
                    {
                        if (PRatio < .9 && this.ConstructionQueue.Count > 0)
                            this.ps = GoodState.IMPORT;
                        else if (this.ConstructionQueue.Count == 0)
                        {
                            this.ps = GoodState.EXPORT;
                        }
                        else
                            this.ps = GoodState.STORE;

                    }
                    else
                    {
                        if (PRatio < .75)
                            this.ps = GoodState.IMPORT;
                        else
                            this.ps = GoodState.STORE;
                    }
                    if (FRatio > .75f)
                        this.fs = Planet.GoodState.STORE;
                    else
                        this.fs = Planet.GoodState.IMPORT;
                break;

                case ColonyType.Agricultural:
                if(PRatio >.75)
                    this.ps = Planet.GoodState.STORE;
                else
                    this.ps = Planet.GoodState.IMPORT;

                if (this.NetFoodPerTurn >0 )
                    this.fs = Planet.GoodState.EXPORT;
                else if (FRatio> .75f )
                    this.fs = Planet.GoodState.STORE;
                else
                    this.fs = Planet.GoodState.IMPORT;

                break;

                case ColonyType.Research:

                {
                    if (PRatio > .75f)
                        this.ps = Planet.GoodState.STORE;
                    else
                        this.ps = Planet.GoodState.IMPORT;

                    if (FRatio > .75f)
                        this.fs = Planet.GoodState.STORE;
                    else
                        this.fs = Planet.GoodState.IMPORT;

                    break;
                }

                case ColonyType.Core:
                case ColonyType.TradeHub:
                if(this.NetProductionPerTurn >this.developmentLevel)
                {

                    if (PRatio > .33f )
                        this.ps = GoodState.EXPORT;
                    else if ( PRatio < .33 )
                        this.ps = GoodState.STORE;
                    else
                        this.ps = GoodState.IMPORT;
                }
                else
                {
                    if (PRatio > .75)
                        this.ps = GoodState.STORE;
                    else
                        this.ps = GoodState.IMPORT;
                }

                if (FRatio > .25)
                    this.fs = GoodState.EXPORT;
                else if (this.NetFoodPerTurn > this.developmentLevel * .5)
                    this.fs = GoodState.STORE;
                else
                    this.fs = GoodState.IMPORT;

                break;

                default:
                    break;
            }
            if(!PSexport)
                this.PSexport = true;
            else
            {
                this.PSexport = false;
            }
            if(!FSexport)
                this.FSexport = true;
            else
            {
                this.FSexport = true;
            }
            if(this.developmentLevel>1 && this.ps == GoodState.EXPORT && !PSexport)
            {

                this.ps = GoodState.STORE;
            }

            if(this.developmentLevel>1 && this.fs == GoodState.EXPORT && !FSexport)
            {

                this.fs = GoodState.STORE;
            }
        }
示例#7
0
        /// <summary>
        /// Read building sheet.
        /// </summary>
        public static Dictionary <map_id, GlobalStructureInfo> ReadBuildingSheet()
        {
            string[][] buildingSheet = ReadSheet("building.txt");
            if (buildingSheet == null)
            {
                return(null);
            }

            Dictionary <map_id, GlobalStructureInfo> infoRecords = new Dictionary <map_id, GlobalStructureInfo>(buildingSheet.GetLength(0));

            // Read rows
            for (int i = 0; i < buildingSheet.GetLength(0); ++i)
            {
                string[] row = buildingSheet[i];

                // Skip rows that don't contain enough data (probably empty line)
                if (row.Length < 32)
                {
                    continue;
                }

                string     codeName           = row[0];                                 // Code_Name
                string     produceName        = row[1];                                 // Produce List Name
                string     buildingName       = row[2];                                 // Building Name
                int        sizeX              = ReadInt(row[3]);                        // X-size
                int        sizeY              = ReadInt(row[4]);                        // y-size
                ColonyType owner              = ReadOwner(row[5]);                      // Owner [P/E/B]
                int        hitPoints          = ReadInt(row[6]);                        // Hit Points
                int        armorClass         = ReadInt(row[7]);                        // Armor Class
                bool       border             = ReadBool(row[8]);                       // Border [Y/N]
                int        commonOreCost      = ReadInt(row[9]);                        // Common Ore Cost
                int        rareOreCost        = ReadInt(row[10]);                       // Rare Ore Cost
                bool       structureKit       = ReadBool(row[11]);                      // Structure Kit [Y/N]
                int        buildingPoints     = ReadInt(row[12]);                       // Building Points
                int        commonRubble       = ReadInt(row[13]);                       // Normal Rubble (tile count)
                int        rareRubble         = ReadInt(row[14]);                       // Rare Rubble (tile count)
                int        powerRequired      = ReadInt(row[15]);                       // Power Required
                int        workersRequired    = ReadInt(row[16]);                       // Workers Required
                int        scientistsRequired = ReadInt(row[17]);                       // Scientists Required
                int        sightRange         = ReadInt(row[18]);                       // Sight Range
                bool       dockingAll         = ReadBool(row[19]);                      // Docking All [Y/N]
                bool       dockingTruck       = ReadBool(row[20]);                      // Docking Truck [Y/N]
                bool       dockingConvec      = ReadBool(row[21]);                      // Docking Convec [Y/N]
                bool       dockingEvac        = ReadBool(row[22]);                      // Docking Evac [Y/N]
                int        dockingLocationE   = ReadInt(row[23]);                       // Docking Loc E
                int        dockingLocationP   = ReadInt(row[24]);                       // Docking Loc P
                int        storageCapacity    = ReadInt(row[25]);                       // Storage Capacity
                int        productionCapacity = ReadInt(row[26]);                       // Production Capacity
                int        storageBays        = ReadInt(row[27]);                       // Storage bays
                bool       autoTargeted       = ReadBool(row[28]);                      // Can be autotargeted [Y/N]
                int        explosionSize      = ReadInt(row[29]);                       // Explosion size
                int        resourcePriority   = ReadInt(row[30]);                       // Resource priority
                int        researchTopic      = ReadInt(row[31]);                       // Research topic (leading zero, tech ID)

                map_id unitTypeId = GetMapIdFromCodeName(codeName);

                BuildingFlags buildingFlags = 0;

                if (structureKit)
                {
                    buildingFlags |= BuildingFlags.StructureKit;
                }
                if (dockingAll)
                {
                    buildingFlags |= BuildingFlags.DockingAll;
                }
                if (dockingTruck)
                {
                    buildingFlags |= BuildingFlags.DockingTruck;
                }
                if (dockingConvec)
                {
                    buildingFlags |= BuildingFlags.DockingConvec;
                }
                if (dockingEvac)
                {
                    buildingFlags |= BuildingFlags.DockingEvac;
                }
                if (autoTargeted)
                {
                    buildingFlags |= BuildingFlags.CanBeAutoTargeted;
                }

                infoRecords[unitTypeId] = new GlobalStructureInfo(unitTypeId, researchTopic, buildingName, codeName,
                                                                  hitPoints, armorClass, commonOreCost, rareOreCost, buildingPoints, sightRange,
                                                                  produceName, sizeX, sizeY, buildingFlags, resourcePriority, rareRubble, commonRubble, dockingLocationE, dockingLocationP,
                                                                  powerRequired, workersRequired, scientistsRequired, storageCapacity, productionCapacity, storageBays, explosionSize);
            }

            return(infoRecords);
        }
示例#8
0
        /// <summary>
        /// Read vehicle sheet.
        /// </summary>
        public static Dictionary <map_id, GlobalVehicleInfo> ReadVehicleSheet()
        {
            string[][] vehicleSheet = ReadSheet("vehicles.txt");
            if (vehicleSheet == null)
            {
                return(null);
            }

            Dictionary <map_id, GlobalVehicleInfo> infoRecords = new Dictionary <map_id, GlobalVehicleInfo>(vehicleSheet.GetLength(0));

            // Read rows
            for (int i = 0; i < vehicleSheet.GetLength(0); ++i)
            {
                string[] row = vehicleSheet[i];

                // Skip rows that don't contain enough data (probably empty line)
                if (row.Length < 19)
                {
                    continue;
                }

                string     codeName        = row[0];                            // Code_Name
                string     unitName        = row[1];                            // Unit Name
                string     strTrackType    = row[2];                            // Track Type [W/T/L/M]
                ColonyType owner           = ReadOwner(row[3]);                 // Owner [P/E/B]
                int        hitPoints       = ReadInt(row[4]);                   // Hit Points
                int        armorClass      = ReadInt(row[5]);                   // Armor Class
                int        movePoints      = ReadInt(row[6]);                   // Move Points
                int        turnRate        = ReadInt(row[7]);                   // Turn Rate
                int        commonOreCost   = ReadInt(row[8]);                   // Common Ore Cost
                int        rareOreCost     = ReadInt(row[9]);                   // Rare Ore Cost
                int        buildTime       = ReadInt(row[10]);                  // Build Time
                bool       vehicleFactory  = ReadBool(row[11]);                 // VF [Y/N]
                bool       arachnidFactory = ReadBool(row[12]);                 // AF [Y/N]
                int        cargoCapacity   = ReadInt(row[13]);                  // Cargo Capacity
                int        sightRange      = ReadInt(row[14]);                  // Sight Range
                bool       weaponEnabled   = ReadBool(row[15]);                 // Weapon Enabled [Y/N]
                int        researchTopic   = ReadInt(row[16]);                  // Research topic (leading zero, tech ID)
                int        productionRate  = ReadInt(row[17]);                  // Production Rate
                int        repairAmount    = ReadInt(row[18]);                  // Repair Amount

                map_id unitTypeId = GetMapIdFromCodeName(codeName);

                VehicleFlags vehicleFlags = 0;

                if (vehicleFactory)
                {
                    vehicleFlags |= VehicleFlags.VehicleFactory;
                }
                if (arachnidFactory)
                {
                    vehicleFlags |= VehicleFlags.ArachnidFactory;
                }
                if (weaponEnabled)
                {
                    vehicleFlags |= VehicleFlags.WeaponEnabled;
                }

                TrackType trackType = TrackType.Wheeled;

                switch (strTrackType)
                {
                case "W":       trackType = TrackType.Wheeled;  break;

                case "T":       trackType = TrackType.Tracked;  break;

                case "L":       trackType = TrackType.Legged;   break;

                case "M":       trackType = TrackType.Miner;    break;
                }

                infoRecords[unitTypeId] = new GlobalVehicleInfo(unitTypeId, researchTopic, unitName, codeName,
                                                                hitPoints, armorClass, commonOreCost, rareOreCost, buildTime, sightRange,
                                                                vehicleFlags, trackType, movePoints, turnRate, cargoCapacity, productionRate, repairAmount
                                                                );
            }

            return(infoRecords);
        }
示例#9
0
 private static void AddSingleColonyType(Queue <string> args)
 {
     ColonyTypes.Add(
         ColonyType.Create(args, ReadNecessaryResourses(args))
         );
 }