Exemplo n.º 1
0
 protected Ship(int shipId, int health, MissileDef missileDef, Vector2[] missileSpawns, Team team = Team.None) :
     base(team)
 {
     ShipId             = shipId;
     this.missileSpawns = missileSpawns;
     Region             = Assets.Sprites[$"spaceShips_{shipId:D3}"];
     MaxHealth          = Health = health;
     ChangeMissile(missileDef);
 }
        public Missile(MissileDef missileDef, Team team) : base(team)
        {
            this.missileDef = missileDef;
            Region          = missileDef.Texture;
            switch (team)
            {
            case Team.Player:
                Velocity = new Vector2(0, -missileDef.Speed);
                break;

            case Team.Enemy:
                Velocity = new Vector2(0, missileDef.Speed);
                Effects  = SpriteEffects.FlipVertically;
                break;

            default:
                throw new ArgumentException(nameof(team));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Every faction will start with some components defined and ready to use, though the engines and sensors shouldn't be here just yet.
        /// </summary>
        public void AddInitialComponents()
        {
            /// <summary>
            /// Watch total component count when adding or subtracting from this function
            /// </summary>
            TotalComponents = 0;

            GeneralComponentDefTN CrewQ  = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN CrewQS = new GeneralComponentDefTN("Crew Quarters - Small", 0.2f, 0, 2.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT  = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.0m, ComponentTypeTN.Fuel);
            GeneralComponentDefTN FuelTS = new GeneralComponentDefTN("Fuel Storage - Small", 0.2f, 0, 3.0m, ComponentTypeTN.Fuel);
            GeneralComponentDefTN EBay   = new GeneralComponentDefTN("Engineering Spaces", 1.0f, 5, 10.0m, ComponentTypeTN.Engineering);
            GeneralComponentDefTN Bridge = new GeneralComponentDefTN("Bridge", 1.0f, 5, 10.0m, ComponentTypeTN.Bridge);

            TotalComponents = TotalComponents + 6;

            CrewQuarters.Add(CrewQ);
            CrewQuarters.Add(CrewQS);
            FuelStorage.Add(FuelT);
            FuelStorage.Add(FuelTS);
            EngineeringSpaces.Add(EBay);
            OtherComponents.Add(Bridge);

            /// <summary>
            /// These components aren't really basic, but I'll put them in anyway for the time being. Count 6 to 17
            /// </summary>
            EngineDefTN          EngDef     = new EngineDefTN("25 EP Nuclear Thermal Engine", 5.0f, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);
            ActiveSensorDefTN    ActDef     = new ActiveSensorDefTN("Search 5M - 5000", 1.0f, 10, 5, 100, false, 1.0f, 1);
            PassiveSensorDefTN   ThPasDef   = new PassiveSensorDefTN("Thermal Sensor TH1-5", 1.0f, 5, PassiveSensorType.Thermal, 1.0f, 1);
            PassiveSensorDefTN   EMPasDef   = new PassiveSensorDefTN("EM Sensor EM1-5", 1.0f, 5, PassiveSensorType.EM, 1.0f, 1);
            BeamFireControlDefTN BFCDef     = new BeamFireControlDefTN("Fire Control S01 10-1250", 0, 0, 1.0f, 1.0f, false, false, 1.0f, 1);
            BeamDefTN            BeamDef    = new BeamDefTN("10cm C1 Infrared Laser", ComponentTypeTN.Laser, 0, 0, 0, 1.0f);
            ReactorDefTN         ReactDef   = new ReactorDefTN("PWR S1 P2", 0, 1.0f, 1.0f);
            ShieldDefTN          AShieldDef = new ShieldDefTN("Alpha R300/240 Shields", 0, 0, 1.0f, 1.0f, ComponentTypeTN.Shield);
            MissileLauncherDefTN TubeDef    = new MissileLauncherDefTN("Size 1 Launcher", 1.0f, 1, false, 0);
            MagazineDefTN        MagDef     = new MagazineDefTN("Mag S1", 1.0f, 1, 0, 0, 1);
            ActiveSensorDefTN    MFCDef     = new ActiveSensorDefTN("Wasp I FC", 1.0f, 10, 5, 100, true, 1.0f, 1);

            TotalComponents = TotalComponents + 11;


            Engines.Add(EngDef);
            ActiveSensorDef.Add(ActDef);
            PassiveSensorDef.Add(ThPasDef);
            PassiveSensorDef.Add(EMPasDef);

            BeamFireControlDef.Add(BFCDef);
            BeamWeaponDef.Add(BeamDef);
            ReactorDef.Add(ReactDef);

            ShieldDef.Add(AShieldDef);

            MLauncherDef.Add(TubeDef);
            MagazineDef.Add(MagDef);
            MissileFireControlDef.Add(MFCDef);

            TurretableBeamDef.Add(BeamDef);


            /// <summary>
            /// Everyone starts with cargoholds. Count 17 to 19
            /// </summary>
            CargoDefTN CargoStandard = new CargoDefTN("Cargo Hold - Standard", 500.0f, 50.0m, 5);
            CargoDefTN CargoSmall    = new CargoDefTN("Cargo Hold - Small", 100.0f, 12.5m, 2);

            TotalComponents = TotalComponents + 2;

            CargoHoldDef.Add(CargoStandard);
            CargoHoldDef.Add(CargoSmall);

            /// <summary>
            /// Cryostorage is a TN only starting option. otherwise it must be researched. Count, 19 to 22
            /// </summary>
            ColonyDefTN ColonyStandard  = new ColonyDefTN("Cryogenic Transport", 50.0f, 100.0m, 10);
            ColonyDefTN ColonySmall     = new ColonyDefTN("Cryogenic Transport - Small", 5.0f, 20.0m, 2);
            ColonyDefTN ColonyEmergency = new ColonyDefTN("Cryogenic Transport - Emergency", 1.0f, 5.0m, 0);

            TotalComponents = TotalComponents + 3;

            ColonyBayDef.Add(ColonyStandard);
            ColonyBayDef.Add(ColonySmall);
            ColonyBayDef.Add(ColonyEmergency);


            /// <summary>
            /// Only TN starts begin with this component for now. the improved,advanced, and grav-assisted variants have to be researched. Count 22, to 23
            /// </summary>
            CargoHandlingDefTN CHS = new CargoHandlingDefTN("Cargo Handling System", 5, 10.0m);

            CargoHandleSystemDef.Add(CHS);
            TotalComponents = TotalComponents + 1;

            /// <summary>
            /// Alpha build components: Count 23, to 39
            /// </summary>

            EngineDefTN          AlphaEngine        = new EngineDefTN("Ion Engine 120", 12.0f, 1.0f, 0.7f, 1.0f, 1, 10.0f, -1.0f);
            ActiveSensorDefTN    AlphaBigSensor     = new ActiveSensorDefTN("Search 181M - 10000", 10.0f, 16, 8, 200, false, 1.0f, 1);
            ActiveSensorDefTN    AlphaSmallSensor   = new ActiveSensorDefTN("Search 57M - 1000", 10.0f, 16, 8, 20, false, 1.0f, 1);
            ActiveSensorDefTN    AlphaMissileSensor = new ActiveSensorDefTN("Search 1.4M - Missile", 10.0f, 16, 8, 1, false, 1.0f, 1);
            PassiveSensorDefTN   AlphaEMSensor      = new PassiveSensorDefTN("EM Detection Sensor EM10-80", 10.0f, 8, PassiveSensorType.EM, 1.0f, 1);
            PassiveSensorDefTN   AlphaTHSensor      = new PassiveSensorDefTN("TH Detection Sensor TH10-80", 10.0f, 8, PassiveSensorType.Thermal, 1.0f, 1);
            BeamFireControlDefTN AlphaFireControl   = new BeamFireControlDefTN("Primary III FC R96K T6K", 2, 2, 4.0f, 2.0f, false, false, 1.0f, 1);

            BeamDefTN AlphaRailGun  = new BeamDefTN("15cm Railgun V3/C3", ComponentTypeTN.Rail, 2, 2, 2, 1.0f);
            BeamDefTN AlphaLaser    = new BeamDefTN("15cm C3 Near UV Laser", ComponentTypeTN.Laser, 2, 2, 2, 1.0f);
            BeamDefTN AlphaParticle = new BeamDefTN("PBW-4 150K", ComponentTypeTN.Particle, 2, 2, 2, 1.0f);
            BeamDefTN AlphaPlasma   = new BeamDefTN("15cm C3 Plasma Beam", ComponentTypeTN.Plasma, 2, 2, 2, 1.0f);
            BeamDefTN AlphaMeson    = new BeamDefTN("R9/C3 Meson Cannon", ComponentTypeTN.Meson, 2, 2, 2, 1.0f);
            BeamDefTN AlphaHPM      = new BeamDefTN("R9/C3 Microwave", ComponentTypeTN.Microwave, 2, 2, 2, 1.0f);
            BeamDefTN AlphaGauss    = new BeamDefTN("Gauss R3-100", ComponentTypeTN.Gauss, 0, 2, 2, 1.0f);

            ReactorDefTN AlphaReactor = new ReactorDefTN("GCFR S1 P4.5", 2, 1.0f, 1.0f);

            ShieldDefTN AlphaShield = new ShieldDefTN("Gamma R300/336 Shields", 2, 2, 0.7f, 1.0f, ComponentTypeTN.Shield);

            TotalComponents = TotalComponents + 16;

            Engines.Add(AlphaEngine);

            ActiveSensorDef.Add(AlphaBigSensor);
            ActiveSensorDef.Add(AlphaSmallSensor);
            ActiveSensorDef.Add(AlphaMissileSensor);

            PassiveSensorDef.Add(AlphaEMSensor);
            PassiveSensorDef.Add(AlphaTHSensor);

            BeamFireControlDef.Add(AlphaFireControl);

            BeamWeaponDef.Add(AlphaRailGun);
            BeamWeaponDef.Add(AlphaLaser);
            BeamWeaponDef.Add(AlphaParticle);
            BeamWeaponDef.Add(AlphaPlasma);
            BeamWeaponDef.Add(AlphaMeson);
            BeamWeaponDef.Add(AlphaHPM);
            BeamWeaponDef.Add(AlphaGauss);

            ReactorDef.Add(AlphaReactor);

            ShieldDef.Add(AlphaShield);

            TurretableBeamDef.Add(AlphaLaser);
            TurretableBeamDef.Add(AlphaMeson);
            TurretableBeamDef.Add(AlphaGauss);

            /// <summary>
            /// Missile Combat Alpha Components: Count at 44 from 39 OrdnanceDefTN and MissileEngineDefTN are _NOT_ included in the total count.
            /// </summary>
            EngineDefTN          AlphaMCEngine             = new EngineDefTN("Military 5000 EP Photonic Drive", 100.0f, 1.0f, 0.1f, 1.0f, 1, 50.0f, -1.0f);
            ActiveSensorDefTN    AlphaMCSensor             = new ActiveSensorDefTN("Active Search Sensor MR13500-R100", 10.0f, 180, 75, 100, false, 1.0f, 0);
            ActiveSensorDefTN    AlphaMCMissileFireControl = new ActiveSensorDefTN("Missile Fire Control FC40500-R100", 10.0f, 180, 75, 100, true, 1.0f, 0);
            MagazineDefTN        MagazineMCDef             = new MagazineDefTN("Capacity 587 Magazine: Exp 1%  HTK4", 30.0f, 4, 8, 8, 12);
            MissileLauncherDefTN TubeMCDef          = new MissileLauncherDefTN("Size 4 Launcher", 4.0f, 11, false, 0);
            MissileEngineDefTN   MissileEngineMCDef = new MissileEngineDefTN("Photonic Missile Drive", 100.0f, 1.0f, 0.1f, 1.5f);
            OrdnanceDefTN        MissileMCDef       = new OrdnanceDefTN("Size 4 Missile", null, 0.5f, 11, 1.0f, 1.0f, 11, 0.0f, 0, 0.0f, 0, 0.0f, 0, 0.0f, 0, 100, 0, 0.0f, 0.0f, 0, false, 0, false, 0,
                                                                        MissileEngineMCDef, 1);

            TotalComponents = TotalComponents + 5;

            Engines.Add(AlphaMCEngine);
            ActiveSensorDef.Add(AlphaMCSensor);
            MissileFireControlDef.Add(AlphaMCMissileFireControl);
            MagazineDef.Add(MagazineMCDef);
            MLauncherDef.Add(TubeMCDef);
            MissileEngineDef.Add(MissileEngineMCDef);
            MissileDef.Add(MissileMCDef);

            MissileLauncherDefTN TubeAMMDef          = new MissileLauncherDefTN("Size 1 Launcher", 1.0f, 11, false, 0);
            MissileEngineDefTN   MissileEngineAMMDef = new MissileEngineDefTN("Small Photonic Missile Drive", 100.0f, 6.0f, 0.1f, 0.4f);
            ActiveSensorDefTN    AMMSensor           = new ActiveSensorDefTN("AMM Sensor", 10.0f, 180, 75, 1, false, 1.0f, 0);
            ActiveSensorDefTN    AMMMFC        = new ActiveSensorDefTN("AMM MFC", 10.0f, 180, 75, 1, true, 1.0f, 0);
            OrdnanceDefTN        MissileAMMDef = new OrdnanceDefTN("Size 1 Missile", null, 0.14f, 11, 0.23f, 0.23f, 11, 0.0f, 0, 0.0f, 0, 0.0f, 0, 0.0f, 0, 1, 0, 0.0f, 0.0f, 0, false, 0, false, 0,
                                                                   MissileEngineAMMDef, 1);

            TotalComponents = TotalComponents + 3;

            MLauncherDef.Add(TubeAMMDef);
            MissileEngineDef.Add(MissileEngineAMMDef);
            ActiveSensorDef.Add(AMMSensor);
            MissileFireControlDef.Add(AMMMFC);
            MissileDef.Add(MissileAMMDef);


            /// <summary>
            /// Sensor components should be added upon researching the appropriate technology, as they cannot be designed, Count should be at 46
            /// </summary>
            SurveySensorDefTN GeoSurvey  = new SurveySensorDefTN("Geological Survey Sensor", SurveySensorDefTN.SurveySensorType.Geological, 1.0f);
            SurveySensorDefTN GravSurvey = new SurveySensorDefTN("Gravitational Survey Sensor", SurveySensorDefTN.SurveySensorType.Gravitational, 1.0f);

            SurveySensorDef.Add(GeoSurvey);
            SurveySensorDef.Add(GravSurvey);

            TotalComponents = TotalComponents + 2;
        }
Exemplo n.º 4
0
 public Missile(MissileDef def, int x, int y) : base(def, x, y)
 {
     MoveDirection = Vector3.Zero;
 }
Exemplo n.º 5
0
 public void ChangeMissile(MissileDef missileDef)
 {
     CurrentMissile = missileDef ?? throw new ArgumentNullException(nameof(missileDef));
 }
Exemplo n.º 6
0
 public EnemyShip(int shipId, int health, MissileDef missileDef, params Vector2[] missileSpawns) :
     base(shipId, health, missileDef, missileSpawns, Team.Enemy)
 {
 }
Exemplo n.º 7
0
        private int convertObject(MapDef mapdef, int oid, byte tile)
        {
            Debug.Assert(already.Add(oid));
            Debug.Assert(oid != oidFree);
            Debug.Assert(oid != oidEnd);
            int    dir    = (oid >> 14) & 3;
            int    cat    = (oid >> 10) & 15;
            int    num    = (oid) & 1023;
            int    objRef = d.objs.Count;
            ObjDef newObj = null;

            si.Position = offsetsToDatabase[cat] + dbSizes[cat] * num;
            int  nextOid = br.ReadUInt16();
            bool isWall  = ((tileTypeIndex)(tile >> 5)) == tileTypeIndex.ttWall;

            switch ((dbIndex)cat)
            {
            case dbIndex.dbDoor: {
                int  attr        = br.ReadUInt16();
                bool doorType1   = 0 != (attr & 1);
                int  ornateIndex = (attr >> 1) & 15;

                d.objs.Add(newObj = new DoorDef {
                        doorType              = doorType1 ? mapdef.doorType1 : mapdef.doorType0,
                        doorOrnate            = mapdef.doorDecorationGraphics[ornateIndex],
                        openVertical          = 0 != ((attr >> 5) & 1),
                        button                = 0 != ((attr >> 6) & 1),
                        destroyablebyFireball = 0 != ((attr >> 7) & 1),
                        bashablebyChopping    = 0 != ((attr >> 8) & 1),
                        //9
                        //10
                        //11
                        buttonState = 0 != ((attr >> 12) & 1),
                        //13
                        //14
                        //15
                    });
                break;
            }

            case dbIndex.dbTeleporter: {
                int attr  = br.ReadUInt16();
                int attr2 = br.ReadUInt16();
                d.objs.Add(newObj = new TeleporterDef {
                        destMap          = (attr2 >> 8) & 255,
                        destX            = (attr >> 0) & 31,
                        destY            = (attr >> 5) & 31,
                        rotation         = (attr >> 10) & 3,
                        absoluteRotation = 0 != ((attr >> 12) & 1),
                        scope            = (attr >> 13) & 3,
                        sound            = 0 != ((attr >> 15) & 1),
                    });
                break;
            }

            case dbIndex.dbText: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new TextDef {
                        textVisibility = 0 != ((attr >> 0) & 1),
                        textMode       = (attr >> 1) & 3,
                        textIndex      = (attr >> 3) & 0x1fff,
                    });
                break;
            }

            case dbIndex.dbActuator: {
                int attr  = br.ReadUInt16();
                int attr2 = br.ReadUInt16();
                int attr3 = br.ReadUInt16();
                d.objs.Add(newObj = new ActuatorDef {
                        actuatorType = (attr >> 0) & 127,
                        actuatorData = (attr >> 7) & 511,

                        onceOnlyActuator = 0 != ((attr2 >> 2) & 1),
                        actionType       = (attr2 >> 3) & 3,
                        inversion        = 0 != ((attr2 >> 5) & 1),
                        sound            = 0 != ((attr2 >> 6) & 1),
                        delay            = (attr2 >> 7) & 15,
                        floorOrnate      = isWall ? -1 : (attr2 >> 12) & 15,
                        wallOrnate       = isWall ? (attr2 >> 12) & 15 : -1,

                        newDirection = (attr3 >> 4) & 3,
                        xCoord       = (attr3 >> 6) & 31,
                        yCoord       = (attr3 >> 11) & 31,
                    });
                break;
            }

            case dbIndex.dbCreature: {
                int         childOid     = br.ReadUInt16();
                int         creatureType = br.ReadByte();
                int         position     = br.ReadByte();
                int         hp1          = br.ReadUInt16();
                int         hp2          = br.ReadUInt16();
                int         hp3          = br.ReadUInt16();
                int         hp4          = br.ReadUInt16();
                CreatureDef me;
                d.objs.Add(newObj = me = new CreatureDef {
                        creatureType = creatureType,
                        position     = position,
                        hp1          = hp1,
                        hp2          = hp2,
                        hp3          = hp3,
                        hp4          = hp4,
                    });
                if (childOid != oidEnd)
                {
                    me.childObjRef = convertObject(mapdef, childOid, tile);
                }

                break;
            }

            case dbIndex.dbWeapon: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new WeaponDef {
                        itemType  = (attr >> 0) & 127,
                        important = 0 != ((attr >> 7) & 1),
                        charges   = (attr >> 10) & 15,
                    });
                break;
            }

            case dbIndex.dbCloth: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new ClothDef {
                        itemType  = (attr >> 0) & 127,
                        important = 0 != ((attr >> 7) & 1),
                        charges   = (attr >> 10) & 15,
                    });
                break;
            }

            case dbIndex.dbScroll: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new ScrollDef {
                        referredText = attr & 0x3ff,
                    });
                break;
            }

            case dbIndex.dbPotion: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new PotionDef {
                        potionPower  = (attr >> 0) & 255,
                        potionType   = (attr >> 8) & 127,
                        visiblePower = 0 != ((attr >> 15) & 1),
                    });
                break;
            }

            case dbIndex.dbContainer: {
                int          childOid = br.ReadUInt16();
                int          attr     = br.ReadByte();
                int          attr2    = br.ReadByte();
                int          attr3    = br.ReadUInt16();
                ContainerDef me;
                d.objs.Add(newObj = me = new ContainerDef {
                        isOpened      = 0 != ((attr >> 0) & 1),
                        containerType = (attr >> 1) & 3,
                        destX         = (attr3 >> 0) & 31,
                        destY         = (attr3 >> 5) & 31,
                        destMap       = (attr >> 10) & 63,
                    });
                if (childOid != oidEnd)
                {
                    me.childObjRef = convertObject(mapdef, childOid, tile);
                }
                break;
            }

            case dbIndex.dbMiscellaneous_item: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new MiscItemDef {
                        itemType  = (attr >> 0) & 127,
                        important = 0 != ((attr >> 7) & 1),
                        charges   = (attr >> 8) & 0x3f,
                    });
                break;
            }

            case dbIndex.dbMissile: {
                int        childOid = br.ReadUInt16();
                MissileDef me;
                d.objs.Add(newObj = me = new MissileDef {
                    });
                if (childOid != oidEnd)
                {
                    me.childObjRef = convertObject(mapdef, childOid, tile);
                }
                break;
            }

            case dbIndex.dbCloud: {
                d.objs.Add(newObj = new CloudDef {
                    });
                break;
            }

            default:
                throw new NotSupportedException();
            }
            newObj.direction = dir;
            if (nextOid != oidEnd)
            {
                newObj.nextObjRef = convertObject(mapdef, nextOid, tile);
            }
            return(objRef);
        }