コード例 #1
0
        public GlobalVehicleInfo(map_id unitTypeID,
                                 int researchTopic,
                                 string unitName,
                                 string codeName,

                                 int hitPoints,
                                 int armor,
                                 int oreCost,
                                 int rareOreCost,
                                 int buildTime,
                                 int sightRange,

                                 VehicleFlags vehicleFlags,
                                 TrackType trackType,

                                 int movePoints,
                                 int turnRate,
                                 int cargoCapacity,
                                 int productionRate,
                                 int repairAmount
                                 )
            : base(unitTypeID, researchTopic, unitName, codeName,
                   hitPoints, armor, oreCost, rareOreCost, buildTime, sightRange)
        {
            VehicleFlags = vehicleFlags;
            TrackType    = trackType;

            MovePoints     = movePoints;
            TurnRate       = turnRate;
            CargoCapacity  = cargoCapacity;
            ProductionRate = productionRate;
            RepairAmount   = repairAmount;
        }
コード例 #2
0
        public GlobalWeaponInfo(map_id unitTypeID,
                                int researchTopic,
                                string unitName,
                                string codeName,

                                int oreCost,
                                int rareOreCost,
                                int buildTime,

                                int damageRadius,
                                int pixelsSkippedWhenFiring,

                                int weaponRange,
                                int turretTurnRate,
                                int concussionDamage,
                                int penetrationDamage,
                                int reloadTime
                                )
            : base(unitTypeID, researchTopic, unitName, codeName,
                   0, 0, oreCost, rareOreCost, buildTime, 0)
        {
            DamageRadius            = damageRadius;
            PixelsSkippedWhenFiring = pixelsSkippedWhenFiring;

            WeaponRangeInTiles = weaponRange;
            TurretTurnRate     = turretTurnRate;
            ConcussionDamage   = concussionDamage;
            PenetrationDamage  = penetrationDamage;
            ReloadTime         = reloadTime;
        }
コード例 #3
0
        private string GetCargoText(UnitData unit)
        {
            switch (unit.typeID)
            {
            case map_id.CargoTruck:
                // Show cargo and amount, or starship module
                if (unit.cargoType >= 1 && unit.cargoType <= 7)
                {
                    return(((TruckCargo)unit.cargoType).ToString() + ":" + unit.cargoAmount);
                }
                else if (unit.cargoType >= 8 && unit.cargoType <= 9)
                {
                    return(((map_id)unit.cargoAmount).ToString());
                }

                return("Gene Bank");

            case map_id.ConVec:
                // Show structure kit
                map_id kit = (map_id)unit.cargoType;
                if (kit != map_id.GuardPost)
                {
                    return(kit.ToString());
                }
                else
                {
                    return(kit.ToString() + ":" + ((map_id)unit.cargoAmount).ToString());
                }
            }

            return(null);
        }
コード例 #4
0
        public GlobalUnitInfo(
            map_id unitTypeID,
            int researchTopic,
            string unitName,
            string codeName,

            int hitPoints,
            int armor,
            int oreCost,
            int rareOreCost,
            int buildTime,
            int sightRange)
        {
            UnitType      = unitTypeID;
            ResearchTopic = researchTopic;
            UnitName      = unitName;
            CodeName      = codeName;

            HitPoints   = hitPoints;
            Armor       = armor;
            OreCost     = oreCost;
            RareOreCost = rareOreCost;
            BuildTime   = buildTime;
            SightRange  = sightRange;
        }
コード例 #5
0
        public static RectInt GetBulldozedStructureArea(Vector2Int position, map_id unitType)
        {
            RectInt bulldozedArea = GetStructureArea(position, unitType);

            bulldozedArea.min -= Vector2Int.one;
            bulldozedArea.max += Vector2Int.one;

            return(bulldozedArea);
        }
コード例 #6
0
 public VehicleInfo(map_id unitTypeID, int playerID, int hitPoints, int armor, int oreCost, int rareOreCost, int buildTime, int sightRange,
                    int movePoints, int turnRate, int cargoCapacity, int productionRate, int repairAmount)
     : base(unitTypeID, playerID, hitPoints, armor, oreCost, rareOreCost, buildTime, sightRange)
 {
     MovePoints     = movePoints;
     TurnRate       = turnRate;
     CargoCapacity  = cargoCapacity;
     ProductionRate = productionRate;
     RepairAmount   = repairAmount;
 }
コード例 #7
0
 public StructureInfo(map_id unitTypeID, int playerID, int hitPoints, int armor, int oreCost, int rareOreCost, int buildTime, int sightRange,
                      int powerRequired, int workersRequired, int scientistsRequired, int productionRate, int storageCapacity, int productionCapacity, int numStorageBays)
     : base(unitTypeID, playerID, hitPoints, armor, oreCost, rareOreCost, buildTime, sightRange)
 {
     PowerRequired      = powerRequired;
     WorkersRequired    = workersRequired;
     ScientistsRequired = scientistsRequired;
     ProductionRate     = productionRate;
     StorageCapacity    = storageCapacity;
     ProductionCapacity = productionCapacity;
     NumStorageBays     = numStorageBays;
 }
コード例 #8
0
        private RectInt GetStructureArea(Vector2Int position, map_id unitType)
        {
            Vector2Int size = GetStructureSize(unitType);

            RectInt rect = new RectInt();

            rect.xMin = position.x - size.x / 2;
            rect.yMin = position.y - size.y / 2;
            rect.xMax = position.x + (size.x - 1) / 2 + 1;
            rect.yMax = position.y + (size.y - 1) / 2 + 1;

            return(rect);
        }
コード例 #9
0
        public UnitInfoState(map_id unitTypeID, int playerID, int hitPoints, int armor, int oreCost, int rareOreCost, int buildTime, int sightRange)
        {
            UnitType = unitTypeID;

            PlayerID = playerID;

            HitPoints   = hitPoints;
            Armor       = armor;
            OreCost     = oreCost;
            RareOreCost = rareOreCost;
            BuildTime   = buildTime;
            SightRange  = sightRange;
        }
コード例 #10
0
        public GlobalStructureInfo(map_id unitTypeID,
                                   int researchTopic,
                                   string unitName,
                                   string codeName,

                                   int hitPoints,
                                   int armor,
                                   int oreCost,
                                   int rareOreCost,
                                   int buildTime,
                                   int sightRange,

                                   string produceListName,
                                   int sizeX,
                                   int sizeY,
                                   BuildingFlags buildingFlags,
                                   int resourcePriority,
                                   int rareRubble,
                                   int rubble,
                                   int edenDockPos,
                                   int plymDockPos,

                                   int powerRequired,
                                   int workersRequired,
                                   int scientistsRequired,
                                   int storageCapacity,
                                   int productionCapacity,
                                   int numStorageBays,
                                   int explosionSize
                                   )
            : base(unitTypeID, researchTopic, unitName, codeName,
                   hitPoints, armor, oreCost, rareOreCost, buildTime, sightRange)
        {
            ProduceListName  = produceListName;
            SizeX            = sizeX;
            SizeY            = sizeY;
            BuildingFlags    = buildingFlags;
            ResourcePriority = resourcePriority;
            RareRubble       = rareRubble;
            Rubble           = rubble;
            EdenDockPos      = edenDockPos;
            PlymDockPos      = plymDockPos;

            PowerRequired      = powerRequired;
            WorkersRequired    = workersRequired;
            ScientistsRequired = scientistsRequired;
            StorageCapacity    = storageCapacity;
            ProductionCapacity = productionCapacity;
            NumStorageBays     = numStorageBays;
            ExplosionSize      = explosionSize;
        }
コード例 #11
0
        public void OnChanged_CargoType()
        {
            switch (GetMapIDFromName(m_SelectedButtonName))
            {
            case map_id.ConVec:
                map_id convecCargoID = GetCargoTypeForConvecOption(m_DropdownCargoType.value);
                if (convecCargoID == map_id.GuardPost)
                {
                    // Show weapon options for guard post
                    m_InputCargoAmount.gameObject.SetActive(false);
                    m_DropdownCargoSubtype.gameObject.SetActive(true);
                    m_DropdownCargoSubtype.interactable = true;
                    RefreshSubtypeAsWeaponOptions();
                    RefreshOverlay();
                    return;
                }
                break;

            case map_id.CargoTruck:
                int truckCargoID = GetCargoTypeForTruckOption(m_DropdownCargoType.value);
                if (IsQuantifiedCargo(truckCargoID))
                {
                    // Show cargo amount
                    m_DropdownCargoSubtype.gameObject.SetActive(false);
                    m_InputCargoAmount.gameObject.SetActive(true);
                    m_InputCargoAmount.interactable = true;
                    RefreshOverlay();
                    return;
                }
                else if (truckCargoID == 8 || truckCargoID == 9)
                {
                    // Show starship modules
                    m_InputCargoAmount.gameObject.SetActive(false);
                    m_DropdownCargoSubtype.gameObject.SetActive(true);
                    m_DropdownCargoSubtype.interactable = true;
                    RefreshSubtypeAsStarshipOptions();
                    RefreshOverlay();
                    return;
                }
                break;
            }

            // No subtype or amount to change
            m_DropdownCargoSubtype.interactable = false;
            m_InputCargoAmount.interactable     = false;
            RefreshOverlay();
        }
コード例 #12
0
        public static bool HasTubes(map_id type)
        {
            switch (type)
            {
            case map_id.LightTower:
            case map_id.CommonOreMine:
            case map_id.RareOreMine:
            case map_id.MagmaWell:
            case map_id.Tokamak:
            case map_id.SolarPowerArray:
            case map_id.MHDGenerator:
            case map_id.GeothermalPlant:
                return(false);
            }

            return(IsStructure(type));
        }
コード例 #13
0
ファイル: SheetReader.cs プロジェクト: TechCor8/OP2TerraNova
        /// <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);
        }
コード例 #14
0
ファイル: WeaponInfo.cs プロジェクト: TechCor8/OP2TerraNova
        public WeaponInfo(map_id unitTypeID,
                          int playerID,
                          int oreCost,
                          int rareOreCost,
                          int buildTime,

                          int weaponRange,
                          int turretTurnRate,
                          int concussionDamage,
                          int penetrationDamage,
                          int reloadTime)
            : base(unitTypeID, playerID, 0, 0, oreCost, rareOreCost, buildTime, 0)
        {
            WeaponRange       = weaponRange;
            TurretTurnRate    = turretTurnRate;
            ConcussionDamage  = concussionDamage;
            PenetrationDamage = penetrationDamage;
            ReloadTime        = reloadTime;
        }
コード例 #15
0
        private string GetShortName(map_id wreckageType)
        {
            switch (wreckageType)
            {
            case map_id.EDWARDSatellite:    return("ED");

            case map_id.SolarSatellite:             return("Solar");

            case map_id.IonDriveModule:             return("Ion");

            case map_id.FusionDriveModule:  return("Fuse");

            case map_id.CommandModule:              return("Comm");

            case map_id.FuelingSystems:             return("Fuel");

            case map_id.HabitatRing:                return("Ring");

            case map_id.SensorPackage:              return("Sensr");

            case map_id.Skydock:                    return("Dock");

            case map_id.StasisSystems:              return("Stasis");

            case map_id.OrbitalPackage:             return("Orbital");

            case map_id.PhoenixModule:              return("Fenix");

            case map_id.RareMetalsCargo:    return("Rare");

            case map_id.CommonMetalsCargo:  return("Metal");

            case map_id.FoodCargo:                  return("Food");

            case map_id.EvacuationModule:   return("Evac");

            case map_id.ChildrenModule:             return("Child");
            }

            return(wreckageType.ToString());
        }
コード例 #16
0
ファイル: SheetReader.cs プロジェクト: TechCor8/OP2TerraNova
        /// <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);
        }
コード例 #17
0
 private bool Isbeacon(map_id unitType)
 {
     return(unitType == map_id.MiningBeacon);
 }
コード例 #18
0
 private bool IsMine(map_id unitType)
 {
     return(unitType == map_id.CommonOreMine || unitType == map_id.RareOreMine);
 }
コード例 #19
0
 private bool IsStructure(map_id unitType)
 {
     return((int)unitType >= 21 && (int)unitType <= 58);
 }
コード例 #20
0
 private bool IsVehicle(map_id unitType)
 {
     return((int)unitType >= 1 && (int)unitType <= 15);
 }
コード例 #21
0
        private static GlobalTechInfo ParseTechValues(List <List <string> > techValues)
        {
            // Process tech header
            string techName = techValues[0][1];

            int techId;

            if (!int.TryParse(techValues[0][2], out techId))
            {
                Debug.LogError("Tech '" + techName + "' has an invalid tech Id!");
            }

            TechCategory            category        = TechCategory.Basic;
            string                  description     = "";
            string                  teaser          = "";
            string                  improveDesc     = "";
            int                     edenCost        = 0;
            int                     plymouthCost    = 0;
            int                     maxScientists   = 0;
            LabType                 labType         = LabType.Standard;
            List <int>              requiredTechIDs = new List <int>();
            List <UnitPropertyInfo> unitProperties  = new List <UnitPropertyInfo>();


            // Process tech values
            for (int i = 0; i < techValues.Count; ++i)
            {
                if (techValues[i].Count < 2)
                {
                    Debug.LogError("TechID " + techId + ": Not enough values specified for type: " + techValues[i][0]);
                    continue;
                }

                int value;
                int.TryParse(techValues[i][1], out value);

                switch (techValues[i][0])
                {
                case "CATEGORY":                        category = (TechCategory)value;         break;

                case "DESCRIPTION":                     description = techValues[i][1];         break;

                case "TEASER":                          teaser = techValues[i][1];                      break;

                case "IMPROVE_DESC":            improveDesc = techValues[i][1];         break;

                case "REQUIRES":                        requiredTechIDs.Add(value);                     break;

                case "COST":                            edenCost = plymouthCost = value;        break;

                case "EDEN_COST":                       edenCost = value;                                       break;

                case "PLYMOUTH_COST":           plymouthCost = value;                           break;

                case "MAX_SCIENTISTS":          maxScientists = value;                          break;

                case "LAB":                                     labType = (LabType)value;                       break;

                case "UNIT_PROP":
                    if (techValues[i].Count < 4)
                    {
                        Debug.LogError("TechID " + techId + ": Not enough values specified for type: " + techValues[i][0]);
                        continue;
                    }

                    map_id mapId = SheetReader.GetMapIdFromCodeName(techValues[i][1]);
                    if (mapId == map_id.None)
                    {
                        Debug.LogError("TechID " + techId + ": Bad unit specifier: " + techValues[i][1]);
                        break;
                    }

                    UnitProperty property = GetUnitProperty(techValues[i][2]);
                    if (property == UnitProperty.None)
                    {
                        Debug.LogError("TechID " + techId + ": Bad property specifier: " + techValues[i][2]);
                        break;
                    }

                    int.TryParse(techValues[i][3], out value);

                    unitProperties.Add(new UnitPropertyInfo(mapId, property, value));

                    break;
                }
            }

            return(new GlobalTechInfo(techId, category, plymouthCost, edenCost, maxScientists, labType, techName, description, teaser, improveDesc, requiredTechIDs, unitProperties));
        }
コード例 #22
0
        private Vector2Int GetStructureSize(map_id type)
        {
            switch (type)
            {
            case map_id.CommonOreMine:                      return(new Vector2Int(2, 1));

            case map_id.RareOreMine:                        return(new Vector2Int(2, 1));

            case map_id.GuardPost:                          return(new Vector2Int(1, 1));

            case map_id.LightTower:                         return(new Vector2Int(1, 1));

            case map_id.CommonStorage:                      return(new Vector2Int(1, 2));

            case map_id.RareStorage:                        return(new Vector2Int(1, 2));

            case map_id.Forum:                                      return(new Vector2Int(2, 2));

            case map_id.CommandCenter:                      return(new Vector2Int(3, 2));

            case map_id.MHDGenerator:                       return(new Vector2Int(2, 2));

            case map_id.Residence:                          return(new Vector2Int(2, 2));

            case map_id.RobotCommand:                       return(new Vector2Int(2, 2));

            case map_id.TradeCenter:                        return(new Vector2Int(2, 2));

            case map_id.BasicLab:                           return(new Vector2Int(2, 2));

            case map_id.MedicalCenter:                      return(new Vector2Int(2, 2));

            case map_id.Nursery:                            return(new Vector2Int(2, 2));

            case map_id.SolarPowerArray:            return(new Vector2Int(3, 2));

            case map_id.RecreationFacility:         return(new Vector2Int(2, 2));

            case map_id.University:                         return(new Vector2Int(2, 2));

            case map_id.Agridome:                           return(new Vector2Int(3, 2));

            case map_id.DIRT:                                       return(new Vector2Int(3, 2));

            case map_id.Garage:                                     return(new Vector2Int(3, 2));

            case map_id.MagmaWell:                          return(new Vector2Int(2, 1));

            case map_id.MeteorDefense:                      return(new Vector2Int(2, 2));

            case map_id.GeothermalPlant:            return(new Vector2Int(2, 1));

            case map_id.ArachnidFactory:            return(new Vector2Int(2, 2));

            case map_id.ConsumerFactory:            return(new Vector2Int(3, 3));

            case map_id.StructureFactory:           return(new Vector2Int(4, 3));

            case map_id.VehicleFactory:                     return(new Vector2Int(4, 3));

            case map_id.StandardLab:                        return(new Vector2Int(3, 2));

            case map_id.AdvancedLab:                        return(new Vector2Int(3, 3));

            case map_id.Observatory:                        return(new Vector2Int(2, 2));

            case map_id.ReinforcedResidence:        return(new Vector2Int(3, 2));

            case map_id.AdvancedResidence:          return(new Vector2Int(3, 3));

            case map_id.CommonOreSmelter:           return(new Vector2Int(4, 3));

            case map_id.Spaceport:                          return(new Vector2Int(5, 4));

            case map_id.RareOreSmelter:                     return(new Vector2Int(4, 3));

            case map_id.GORF:                                       return(new Vector2Int(3, 2));

            case map_id.Tokamak:                            return(new Vector2Int(2, 2));
            }

            return(new Vector2Int(1, 1));
        }
コード例 #23
0
ファイル: SheetReader.cs プロジェクト: TechCor8/OP2TerraNova
        /// <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);
        }
コード例 #24
0
 public static bool IsStructure(map_id type)
 {
     return((int)type >= 21 && (int)type <= 58);
 }
コード例 #25
0
ファイル: SheetReader.cs プロジェクト: TechCor8/OP2TerraNova
        /// <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);
        }
コード例 #26
0
        private UnitData GetVehicleData()
        {
            // Get unit type
            map_id selectedTypeID = GetMapIDFromName(m_SelectedButtonName);

            // Get cargo type
            int selectedCargoTypeID = 0;

            if (selectedTypeID == map_id.CargoTruck)
            {
                selectedCargoTypeID = GetCargoTypeForTruckOption(m_DropdownCargoType.value);
            }
            else if (selectedTypeID == map_id.ConVec)
            {
                selectedCargoTypeID = (int)GetCargoTypeForConvecOption(m_DropdownCargoType.value);
            }
            else
            {
                selectedCargoTypeID = (int)GetCargoMapIDFromName(m_SelectedButtonName);
            }

            int id;

            int.TryParse(m_InputID.text, out id);

            int cargoAmount = 0;

            // Cargo amount represents different things depending on cargo type.
            switch (selectedTypeID)
            {
            case map_id.ConVec:
                // Get guard post weapon for convec
                if ((map_id)selectedCargoTypeID == map_id.GuardPost)
                {
                    cargoAmount = GetSubtypeForWeaponOption(m_DropdownCargoSubtype.value);
                }
                break;

            case map_id.CargoTruck:
                // Get cargo amount for quantified cargo type, or starship module for starship cargo type
                if (IsQuantifiedCargo(selectedCargoTypeID))
                {
                    int.TryParse(m_InputCargoAmount.text, out cargoAmount);
                }
                else if (selectedCargoTypeID == 8 || selectedCargoTypeID == 9)                         // Starship || Wreckage
                {
                    cargoAmount = GetSubtypeForStarshipOption(m_DropdownCargoSubtype.value);
                }
                else if (selectedCargoTypeID == (int)map_id.IonDriveModule) // Gene bank
                {
                    cargoAmount = 5;                                        // Dunno why this is 5.
                }
                break;
            }

            // Create vehicle data
            UnitData vehicle = new UnitData();

            // Standard info
            vehicle.id          = id;
            vehicle.typeID      = selectedTypeID;
            vehicle.health      = m_SliderHealth.value;
            vehicle.lights      = m_ToggleLights.isOn;
            vehicle.cargoType   = selectedCargoTypeID;
            vehicle.cargoAmount = cargoAmount;
            vehicle.direction   = (UnitDirection)m_DropdownDirection.value;
            vehicle.position    = new DataLocation(new LOCATION(1, 1));

            return(vehicle);
        }
コード例 #27
0
 public UnitPropertyInfo(map_id unitType, UnitProperty property, int value)
 {
     UnitType = unitType;
     Property = property;
     Value    = value;
 }