Example #1
0
        private static string GetShipClassBadge(ShipClass shipClass, string className)
        {
            string str = "CR";

            switch (shipClass)
            {
            case ShipClass.Cruiser:
                if (className == "Command")
                {
                    str = "CR_CMD";
                    break;
                }
                break;

            case ShipClass.Dreadnought:
                str = !(className == "Command") ? "DN" : "DN_CMD";
                break;

            case ShipClass.Leviathan:
                str = "LV_CMD";
                break;
            }
            return(str);
        }
Example #2
0
        public Ship(Game game, PlayerIndex player, ShipClass shipNumber, int shipSkin, Vector3 initialPosition, Projectiles bullets, Particles particles)
            : base(game, new EvolvedShape(game, EvolvedShapes.Ship, player, (int)shipNumber, shipSkin, LightingType.InGame), initialPosition)
        {
            this.player    = player;
            this.bullets   = bullets;
            this.particles = particles;
            this.evolved   = true;

            //Evolved needs scaling
            scale     = new Vector3(SpacewarGame.Settings.ShipScale, SpacewarGame.Settings.ShipScale, SpacewarGame.Settings.ShipScale);
            rotation  = new Vector3(MathHelper.ToRadians(90), 0, 0);
            direction = new Vector3((float)(-Math.Sin(Rotation.Z)), (float)(Math.Cos(Rotation.Z)), 0);

            if (game != null)
            {
                IGraphicsDeviceService graphicsService = (IGraphicsDeviceService)game.Services.GetService(typeof(IGraphicsDeviceService));
                batch = new SpriteBatch(graphicsService.GraphicsDevice);
            }

            if (shipNumber == ShipClass.Pencil)
            {
                extendedExtent = new Vector3[2];
            }
        }
        public void RequestTargetFromParent(SwarmerAttackerControl sac)
        {
            if (this.m_TargetList.Count == 0)
            {
                return;
            }
            SwarmerTarget swarmerTarget1 = (SwarmerTarget)null;
            SwarmerTarget swarmerTarget2 = (SwarmerTarget)null;
            SwarmerTarget swarmerTarget3 = (SwarmerTarget)null;
            float         num1           = float.MaxValue;
            float         num2           = float.MaxValue;
            float         num3           = float.MaxValue;

            foreach (SwarmerTarget target1 in this.m_TargetList)
            {
                int   num4 = 0;
                int   num5 = 0;
                float num6 = 0.0f;
                if (target1.Target is Ship)
                {
                    Ship      target2   = target1.Target as Ship;
                    ShipClass shipClass = target2.ShipClass;
                    num4 = SwarmerAttackerControl.NumSwarmersPerShip(shipClass) - target1.SwarmersOnTarget;
                    num5 = SwarmerAttackerControl.NumGuardiansPerShip(shipClass) - target1.GuardiansOnTarget;
                    num6 = (target2.Position - sac.GetShip().Position).LengthSquared;
                    if ((double)num6 < (double)num3)
                    {
                        num3           = num6;
                        swarmerTarget3 = target1;
                    }
                }
                else if (target1.Target is StellarBody)
                {
                    StellarBody target2       = target1.Target as StellarBody;
                    int         num7          = this.m_NumSwarmersToAttackPlanet - this.m_AttackingPlanetSwarmers.Count;
                    int         num8          = this.m_NumGardiansToAttackPlanet - this.m_AttackingPlanetGardians.Count;
                    float       lengthSquared = (target2.Parameters.Position - sac.GetShip().Position).LengthSquared;
                    if ((double)lengthSquared < (double)num2)
                    {
                        num2           = lengthSquared;
                        swarmerTarget2 = target1;
                        continue;
                    }
                    continue;
                }
                if (sac.Type == SwarmerAttackerType.GAURDIAN)
                {
                    if (num5 <= 0)
                    {
                        continue;
                    }
                }
                else if (num4 <= 0)
                {
                    continue;
                }
                if ((double)num6 < (double)num1)
                {
                    num1           = num6;
                    swarmerTarget1 = target1;
                }
            }
            if (swarmerTarget2 != null)
            {
                if (this.m_AttackingPlanetSwarmers.Contains(sac.GetShip().ObjectID) || this.m_AttackingPlanetGardians.Contains(sac.GetShip().ObjectID))
                {
                    swarmerTarget1 = swarmerTarget2;
                }
                else if ((sac.Type == SwarmerAttackerType.GAURDIAN ? this.m_NumGardiansToAttackPlanet - this.m_AttackingPlanetGardians.Count : this.m_NumSwarmersToAttackPlanet - this.m_AttackingPlanetSwarmers.Count) > 0)
                {
                    swarmerTarget1 = swarmerTarget2;
                }
            }
            if (swarmerTarget1 != null || swarmerTarget3 != null)
            {
                if (sac.Type == SwarmerAttackerType.GAURDIAN)
                {
                    if (swarmerTarget1 != null)
                    {
                        swarmerTarget1.IncGuardiansOnTarget();
                    }
                    else
                    {
                        swarmerTarget3.IncGuardiansOnTarget();
                    }
                }
                else if (swarmerTarget1 != null)
                {
                    swarmerTarget1.IncSwarmersOnTarget();
                }
                else
                {
                    swarmerTarget3.IncSwarmersOnTarget();
                }
                if (swarmerTarget1 != null)
                {
                    sac.SetTarget(swarmerTarget1.Target);
                    if (!(swarmerTarget1.Target is StellarBody) || this.m_AttackingPlanetSwarmers.Contains(sac.GetShip().ObjectID) || this.m_AttackingPlanetGardians.Contains(sac.GetShip().ObjectID))
                    {
                        return;
                    }
                    if (sac.Type == SwarmerAttackerType.GAURDIAN)
                    {
                        this.m_AttackingPlanetGardians.Add(sac.GetShip().ObjectID);
                    }
                    else
                    {
                        this.m_AttackingPlanetSwarmers.Add(sac.GetShip().ObjectID);
                    }
                }
                else
                {
                    sac.SetTarget(swarmerTarget3.Target);
                }
            }
            else
            {
                sac.SetTarget((IGameObject)null);
            }
        }
Example #4
0
 public void UnregisterShip(ShipClass ship, List <ShipClass> list)
 {
     list.Remove(ship);
     ship.GetComponent <UIController>().ToggleUI(false);
 }
Example #5
0
        public Ship(Game game, PlayerIndex player, ShipClass shipNumber, int shipSkin, Vector3 initialPosition, Projectiles bullets, Particles particles)
            : base(game, new EvolvedShape(game, EvolvedShapes.Ship, player, (int)shipNumber, shipSkin, LightingType.InGame), initialPosition)
        {
            this.player = player;
            this.bullets = bullets;
            this.particles = particles;
            this.evolved = true;

            //Evolved needs scaling
            scale = new Vector3(SpacewarGame.Settings.ShipScale, SpacewarGame.Settings.ShipScale, SpacewarGame.Settings.ShipScale);
            rotation = new Vector3(MathHelper.ToRadians(90), 0, 0);
            direction = new Vector3((float)(-Math.Sin(Rotation.Z)), (float)(Math.Cos(Rotation.Z)), 0);

            if (game != null)
            {
                IGraphicsDeviceService graphicsService = (IGraphicsDeviceService)game.Services.GetService(typeof(IGraphicsDeviceService));
                batch = new SpriteBatch(graphicsService.GraphicsDevice);
            }

            if (shipNumber == ShipClass.Pencil)
                extendedExtent = new Vector3[2];
        }
        public override void FindNewTarget(IEnumerable <IGameObject> objs)
        {
            List <SwarmerTarget> source            = new List <SwarmerTarget>();
            List <SwarmerTarget> swarmerTargetList = new List <SwarmerTarget>();

            foreach (SwarmerTarget target in this.m_TargetList)
            {
                target.ClearNumTargets();
            }
            source.AddRange((IEnumerable <SwarmerTarget>) this.m_TargetList);
            foreach (IGameObject gameObject in objs)
            {
                if (gameObject is Ship)
                {
                    Ship ship = gameObject as Ship;
                    if (Ship.IsActiveShip(ship) && (this.m_IsDeepSpace || ship.IsDetected(this.m_SwarmerSpawner.Player)) && ship.Player != this.m_SwarmerSpawner.Player)
                    {
                        swarmerTargetList.Add(new SwarmerTarget()
                        {
                            Target = (IGameObject)ship
                        });
                        SwarmerTarget swarmerTarget = source.FirstOrDefault <SwarmerTarget>((Func <SwarmerTarget, bool>)(x => x.Target == ship));
                        if (swarmerTarget != null)
                        {
                            source.Remove(swarmerTarget);
                        }
                    }
                }
                else if (gameObject is StellarBody)
                {
                    StellarBody planet = gameObject as StellarBody;
                    if (planet.Population > 0.0)
                    {
                        swarmerTargetList.Add(new SwarmerTarget()
                        {
                            Target = (IGameObject)planet
                        });
                        SwarmerTarget swarmerTarget = source.FirstOrDefault <SwarmerTarget>((Func <SwarmerTarget, bool>)(x => x.Target == planet));
                        if (swarmerTarget != null)
                        {
                            source.Remove(swarmerTarget);
                        }
                    }
                }
            }
            if (source.Count > 0)
            {
                foreach (SwarmerAttackerControl spawnedSwarmer in this.m_SpawnedSwarmers)
                {
                    SwarmerAttackerControl swarmer = spawnedSwarmer;
                    if (source.Any <SwarmerTarget>((Func <SwarmerTarget, bool>)(x => x.Target == swarmer.GetTarget())))
                    {
                        swarmer.SetTarget((IGameObject)null);
                    }
                }
                foreach (SwarmerAttackerControl spawnedGuardian in this.m_SpawnedGuardians)
                {
                    SwarmerAttackerControl guardian = spawnedGuardian;
                    if (source.Any <SwarmerTarget>((Func <SwarmerTarget, bool>)(x => x.Target == guardian.GetTarget())))
                    {
                        guardian.SetTarget((IGameObject)null);
                    }
                }
            }
            if (swarmerTargetList.Count > this.m_TargetList.Count)
            {
                foreach (SwarmerTarget target in this.m_TargetList)
                {
                    target.ClearNumTargets();
                    int num1 = 0;
                    int num2 = 0;
                    if (target.Target is Ship)
                    {
                        ShipClass shipClass = (target.Target as Ship).ShipClass;
                        num1 = SwarmerAttackerControl.NumSwarmersPerShip(shipClass);
                        num2 = SwarmerAttackerControl.NumGuardiansPerShip(shipClass);
                    }
                    else if (target.Target is StellarBody)
                    {
                        num1 = this.m_NumSwarmersToAttackPlanet;
                        num2 = this.m_NumGardiansToAttackPlanet;
                    }
                    foreach (SwarmerAttackerControl spawnedSwarmer in this.m_SpawnedSwarmers)
                    {
                        if (spawnedSwarmer.GetTarget() == target.Target)
                        {
                            if (num1 > 0)
                            {
                                --num1;
                                target.IncSwarmersOnTarget();
                            }
                            else
                            {
                                spawnedSwarmer.SetTarget((IGameObject)null);
                            }
                        }
                    }
                    foreach (SwarmerAttackerControl spawnedGuardian in this.m_SpawnedGuardians)
                    {
                        if (spawnedGuardian.GetTarget() == target.Target)
                        {
                            if (num2 > 0)
                            {
                                --num2;
                                target.IncGuardiansOnTarget();
                            }
                            else
                            {
                                spawnedGuardian.SetTarget((IGameObject)null);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (SwarmerAttackerControl spawnedSwarmer in this.m_SpawnedSwarmers)
                {
                    SwarmerAttackerControl swarmer = spawnedSwarmer;
                    if (swarmer.GetTarget() != null)
                    {
                        this.m_TargetList.FirstOrDefault <SwarmerTarget>((Func <SwarmerTarget, bool>)(x => x.Target == swarmer.GetTarget()))?.IncSwarmersOnTarget();
                    }
                }
                foreach (SwarmerAttackerControl spawnedGuardian in this.m_SpawnedGuardians)
                {
                    SwarmerAttackerControl guardian = spawnedGuardian;
                    if (guardian.GetTarget() != null)
                    {
                        this.m_TargetList.FirstOrDefault <SwarmerTarget>((Func <SwarmerTarget, bool>)(x => x.Target == guardian.GetTarget()))?.IncGuardiansOnTarget();
                    }
                }
            }
            foreach (SwarmerTarget swarmerTarget in swarmerTargetList)
            {
                SwarmerTarget target = swarmerTarget;
                if (!this.m_TargetList.Any <SwarmerTarget>((Func <SwarmerTarget, bool>)(x => x.Target == target.Target)))
                {
                    target.ClearNumTargets();
                    this.m_TargetList.Add(target);
                }
            }
            this.m_UpdateTargetList = false;
        }
    // Use this for initialization
    public override void Start()
    {
        base.Start();


        GameObject planetPre = Resources.Load("PlanetPrefab") as GameObject;

        for (int i = 0; i < 1; ++i)
        {
            GameObject newObj = GameObject.Instantiate(planetPre);
            float      radius = Random.Range(100.0f, 1000.0f);
            newObj.transform.localScale = new Vector3(radius * 2.0f, radius * 2.0f, 1.0f);
            newObj.transform.position   =
                new Vector3(
                    Random.Range(-100000.0f, 100000.0f),
                    Random.Range(-100000.0f, 100000.0f),
                    -41.0f);

            float density = 200.0f;
            newObj.GetComponent <Rigidbody2D>().mass = density * Mathf.PI * radius * radius;
            planets.Add(newObj);
        }

        int     startingPlanet = Random.Range(0, planets.Count - 1);
        Vector2 startDir       = new Vector2(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f));

        startDir.Normalize();
        startPos = (startDir * (planets[startingPlanet].transform.localScale.x + 4.0f)) +
                   (Vector2)planets[startingPlanet].transform.position;
        GameObject player = GameObject.Find("Player");

        player.transform.localPosition = new Vector3(startPos.x, startPos.y, player.transform.position.z);
        player.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, Vector2.SignedAngle(new Vector2(0.0f, 1.0f), startDir));

        GameObject farCam = GameObject.Find("Main Camera");

        farCam.transform.position = new Vector3(player.transform.position.x, player.transform.position.y, farCam.transform.position.z);



        GameObject      ship     = GameObject.Find("Player");
        ShipClass       shipComp = ship.GetComponent <ShipClass>();
        LaunchStage     newStage = new LaunchStage();
        List <ShipPart> partList = newStage.parts;
        ShipPart        part     = (ShipPart)ship.GetComponent <CabinPart>();

        if (part)
        {
            partList.Add(part);
        }
        GameObject engineObj = GameObject.Find("Engine");

        part = engineObj.GetComponent <ShipPart>();
        if (part)
        {
            partList.Add(part);
        }
        GameObject fuelObj = GameObject.Find("FuelTank");

        part = fuelObj.GetComponent <ShipPart>();
        if (part)
        {
            partList.Add(part);
        }
        shipComp.stages.Add(newStage);
        Debug.Log("sim");

        planetPosition.x = Random.Range(-10000.0f, 10000.0f);
        planetPosition.y = Random.Range(-10000.0f, 10000.0f);
    }
Example #8
0
 public Ship(ShipClass Class)
 {
     this.Class = Class;
 }
Example #9
0
 public IEnumerable <Conversion> GetPossibleConversions(ShipClass baseClass, bool minorOnly, int turn = int.MaxValue)
 {
     return((minorOnly ? _conversionMap[baseClass].Where(c => (c.IsMinor || c.Cost <= 3.0f) && c.NewClass.DateAvailable <= turn) : _conversionMap[baseClass]).Where(c => c.NewClass.DateAvailable <= turn));
 }
Example #10
0
    public Ship(ref DataPool worldData)
    {
        shipFacilities = new Dictionary <ManagerProtocol.FacilityShortcut, Facility> ();

        shipClass = ShipClass.ship1;
    }
Example #11
0
 public ClientShip(int id, ShipClass shipClass = ShipClass.OneDeck, Orientation orientation = Orientation.Horizontal, Location location = null)
     : base(id, shipClass, orientation, location)
 {
 }
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            RandNum = new Random();

            MyAsteroids = new List<AsteroidClass>();
            MyMissiles = new List<MissileClass>();

            Ship = new ShipClass();

            // Function initiating
            InitalizeShip();
            InitalizeAsteroid();

            base.Initialize();
        }
Example #13
0
        public void LoadFromXml(
            AssetDatabase assetdb,
            string filename,
            string faction,
            ShipSectionType sectionType,
            ShipClass sectionClass)
        {
            ShipSection ss = new ShipSection();

            ShipXmlUtility.LoadShipSectionFromXml(filename, ref ss);
            this.Type        = sectionType;
            this.Class       = sectionClass;
            this.Faction     = faction;
            this.SectionName = Path.GetFileNameWithoutExtension(filename);
            string str1 = "";

            switch (this.Class)
            {
            case ShipClass.Cruiser:
                str1 = "CR";
                break;

            case ShipClass.Dreadnought:
                str1 = "DN";
                break;

            case ShipClass.Leviathan:
                str1 = "LV";
                break;

            case ShipClass.BattleRider:
                str1 = "BR";
                break;

            case ShipClass.Station:
                str1 = "SN";
                break;
            }
            this.ModelName = FileSystemHelpers.StripMountName(ss.ModelPath);
            string str2 = Path.Combine(Path.GetDirectoryName(this.ModelName), "Damage_" + str1 + "_" + this.Type.ToString() + "_Default.scene");

            this.DestroyedModelName = string.IsNullOrEmpty(ss.DestroyedModelPath) ? str2 : ss.DestroyedModelPath;
            this.DamagedModelName   = ss.DamageModelPath;
            this.AmbientSound       = ss.AmbientSound;
            this.EngineSound        = ss.EngineSound;
            string str3 = string.Format("COMBAT_023-01_{0}_GeneralShipsBeingAttacked", (object)faction);
            string str4 = "";

            switch (this.Class)
            {
            case ShipClass.Cruiser:
                str4 = string.Format("COMBAT_029-01_{0}_CruiserDestroyed", (object)faction);
                break;

            case ShipClass.Dreadnought:
                str4 = string.Format("COMBAT_030-01_{0}_DreadnoughtDestroyed", (object)faction);
                break;

            case ShipClass.Leviathan:
                str4 = string.Format("COMBAT_031-01_{0}_LeviathanDestroyed", (object)faction);
                break;

            case ShipClass.BattleRider:
                str4 = string.Format("COMBAT_020-01_{0}_BattleRiderDestroyed", (object)faction);
                break;

            case ShipClass.Station:
                switch (this.StationType)
                {
                case StationType.NAVAL:
                    str3 = string.Format("COMBAT_067-01_{0}_NavalStationUnderAttack", (object)faction);
                    str4 = string.Format("COMBAT_066-01_{0}_NavalStationDestroyed", (object)faction);
                    break;

                case StationType.SCIENCE:
                    str3 = string.Format("COMBAT_069-01_{0}_ScienceStationUnderAttack", (object)faction);
                    str4 = string.Format("COMBAT_068-01_{0}_ScienceStationDestroyed", (object)faction);
                    break;

                case StationType.CIVILIAN:
                    str3 = string.Format("COMBAT_071-01_{0}_CivilianStationUnderAttack", (object)faction);
                    str4 = string.Format("COMBAT_072-01_{0}_CivilianStationDestroyed", (object)faction);
                    break;

                case StationType.DIPLOMATIC:
                    str3 = string.Format("COMBAT_070a-01_{0}_DiplomaticStationUnderAttack", (object)faction);
                    str4 = string.Format("COMBAT_070-01_{0}_DiplomaticStationDestroyed", (object)faction);
                    break;
                }
                break;
            }
            this.UnderAttackSound = string.IsNullOrEmpty(ss.UnderAttackSound) ? str3 : ss.UnderAttackSound;
            this.DestroyedSound   = string.IsNullOrEmpty(ss.DestroyedSound) ? str4 : ss.DestroyedSound;
            this.Title            = ss.Title;
            this.Description      = ss.Description;
            if (string.IsNullOrWhiteSpace(this.Title))
            {
                this.Title = Path.GetFileNameWithoutExtension(filename);
            }
            string withoutExtension = Path.GetFileNameWithoutExtension(filename);

            this.CombatAIType = !string.IsNullOrEmpty(ss.CombatAiType) ? (SectionEnumerations.CombatAiType)Enum.Parse(typeof(SectionEnumerations.CombatAiType), ss.CombatAiType) : SectionEnumerations.CombatAiType.Normal;
            switch (this.CombatAIType)
            {
            case SectionEnumerations.CombatAiType.Drone:
                this.SetBattleRiderType(BattleRiderTypes.drone);
                break;

            case SectionEnumerations.CombatAiType.AssaultShuttle:
                this.SetBattleRiderType(BattleRiderTypes.assaultshuttle);
                break;

            case SectionEnumerations.CombatAiType.NodeFighter:
                this.SetBattleRiderType(BattleRiderTypes.nodefighter);
                break;

            case SectionEnumerations.CombatAiType.Swarmer:
            case SectionEnumerations.CombatAiType.SwarmerGuardian:
            case SectionEnumerations.CombatAiType.VonNeumannPyramid:
            case SectionEnumerations.CombatAiType.LocustFighter:
            case SectionEnumerations.CombatAiType.MorrigiCrow:
                this.SetBattleRiderType(BattleRiderTypes.battlerider);
                break;

            case SectionEnumerations.CombatAiType.VonNeumannSeekerProbe:
                this.SetBattleRiderType(BattleRiderTypes.assaultshuttle);
                break;

            default:
                this.SetBattleRiderType(ObtainShipClassTypes.GetBattleRiderTypeByName(this.Class, withoutExtension));
                break;
            }
            if (withoutExtension.Contains("protectorate"))
            {
                this.ShipFleetAbilityType = ShipFleetAbilityType.Protectorate;
            }
            else if (withoutExtension.Contains("suulka_the_hidden"))
            {
                this.ShipFleetAbilityType = ShipFleetAbilityType.Hidden;
            }
            else if (withoutExtension.Contains("suulka_the_deaf"))
            {
                this.ShipFleetAbilityType = ShipFleetAbilityType.Deaf;
            }
            this.IsSuperTransport  = this.SectionName.StartsWith("lv_supertransport", StringComparison.InvariantCultureIgnoreCase);
            this.IsBoreShip        = this.SectionName.EndsWith("bore", StringComparison.InvariantCultureIgnoreCase);
            this.IsSupplyShip      = this.SectionName.Contains("_supply");
            this.IsGateShip        = this.SectionName.StartsWith("cr_mis_gate", StringComparison.InvariantCultureIgnoreCase);
            this.IsTrapShip        = this.SectionName.StartsWith("cr_mis_colonytrickster", StringComparison.InvariantCultureIgnoreCase);
            this.IsGravBoat        = this.SectionName.StartsWith("cr_mis_gravboat", StringComparison.InvariantCultureIgnoreCase);
            this.IsAbsorberSection = this.SectionName.Contains("_absorber") || this.SectionName.Contains("_absorbtion");
            this.IsListener        = this.SectionName.Contains("_listener");
            this.IsFireControl     = this.Title.Contains("CR_CMD_FIRECONTROL") || this.Title.Contains("CR_CMD_FIRE_CONTROL");
            this.IsAIControl       = this.Title.Contains("CR_CMD_AI") || this.Title.Contains("DN_CMD_AI");
            this.SuulkaType        = this.GetSuulkaType(this.SectionName);
            this.IsFreighter       = ss.isFreighter;
            this.FreighterSpace    = ss.FreighterSpace;
            this.isPolice          = ss.isPolice;
            this.SlaveCapacity     = ss.SlaveCapacity;
            this.isPropaganda      = this.SectionName.StartsWith("cr_mis_propaganda", StringComparison.InvariantCultureIgnoreCase);
            this.IsAccelerator     = this.SectionName.StartsWith("cr_mis_ngp", StringComparison.InvariantCultureIgnoreCase);
            this.IsLoaCube         = this.SectionName.StartsWith("cr_mis_cube", StringComparison.InvariantCultureIgnoreCase);
            this.IsScavenger       = this.FileName.Contains("mis_scavenger") || this.FileName.Contains("dn_mis_subjugator");
            this.IsWraithAbductor  = this.FileName.Contains("wraith_abductor");
            this.Armor[1]          = new Kerberos.Sots.Framework.Size()
            {
                X = ss.TopArmor.X,
                Y = ss.TopArmor.Y
            };
            this.Armor[3] = new Kerberos.Sots.Framework.Size()
            {
                X = ss.BottomArmor.X,
                Y = ss.BottomArmor.Y
            };
            this.Armor[2] = this.Armor[0] = new Kerberos.Sots.Framework.Size()
            {
                X = ss.SideArmor.X,
                Y = ss.SideArmor.Y
            };
            this.Structure          = ss.Struct;
            this.LowStruct          = ss.StructDamageAmount;
            this.Mass               = (float)ss.Mass;
            this.SavingsCost        = ss.SavingsCost;
            this.ProductionCost     = ss.ProductionCost;
            this.ColonizationSpace  = ss.ColonizerSpace;
            this.TerraformingSpace  = ss.TerraformingPoints;
            this.ConstructionPoints = ss.ConstructionPoints;
            this.ReserveSize        = ss.BattleRiderReserveSize;
            this.RepairPoints       = ss.RepairPoints;
            this.FtlSpeed           = ss.FtlSpeed;
            this.NodeSpeed          = ss.NodeSpeed;
            this.MissionTime        = ss.MissionTime;
            this.LaunchDelay        = ss.LaunchDelay;
            this.DockingDelay       = ss.DockingDelay;
            this.Crew               = ss.Crew;
            this.CrewRequired       = ss.CrewRequired;
            this.Power              = ss.Power;
            this.Supply             = ss.Supply;
            this.ECM                 = ss.ECM;
            this.ECCM                = ss.ECCM;
            this.CommandPoints       = ss.CommandPoints;
            this.Signature           = ss.Signature;
            this.TacticalSensorRange = ss.TacticalSensorRange;
            this.ShipExplosiveDamage = ss.DeathDamage;
            this.ShipExplosiveRange  = ss.ExplosionRadius;
            this.PsionicPowerLevel   = ss.PsionicPowerLevel;
            if ((double)this.TacticalSensorRange <= 0.0)
            {
                this.TacticalSensorRange = 20000f;
            }
            this.DamageEffect = new LogicalEffect()
            {
                Name = !string.IsNullOrEmpty(ss.DamageEffectPath) ? ss.DamageEffectPath : ShipSectionAsset.GetShipDefaultDeathEffect(this.Class, this.BattleRiderType)
            };
            this.DeathEffect = new LogicalEffect()
            {
                Name = !string.IsNullOrEmpty(ss.DestroyedEffectPath) ? ss.DestroyedEffectPath : ShipSectionAsset.GetShipDefaultDeathEffect(this.Class, this.BattleRiderType)
            };
            this.ReactorFailureDeathEffect = new LogicalEffect()
            {
                Name = ShipSectionAsset.GetReactorShieldFailureDeathEffect(this.Class, this.Type)
            };
            this.ReactorCriticalDeathEffect = new LogicalEffect()
            {
                Name = ShipSectionAsset.GetReactorCriticalDeathEffect(this.Class, this.Type, withoutExtension)
            };
            this.AbsorbedDeathEffect = new LogicalEffect()
            {
                Name = ShipSectionAsset.GetAbsorbedDeathEffect(this.Class, this.Type)
            };
            this.StrategicSensorRange = ss.StrategicSensorRange;
            this.FleetSpeedModifier   = ss.FleetSpeedModifier;
            if ((double)this.StrategicSensorRange <= 0.0)
            {
                this.StrategicSensorRange = assetdb.DefaultStratSensorRange;
            }
            this.StationType                = ss.StationType != null ? SectionEnumerations.StationTypesWithInvalid[ss.StationType] : StationType.INVALID_TYPE;
            this.StationLevel               = ss.StationLevel;
            this.isConstructor              = ss.isConstructor;
            this.Maneuvering.LinearAccel    = ss.Acceleration;
            this.Maneuvering.RotAccel.X     = ss.RotationalAccelerationYaw;
            this.Maneuvering.RotAccel.Y     = ss.RotationalAccelerationPitch;
            this.Maneuvering.RotAccel.Z     = ss.RotationalAccelerationRoll;
            this.Maneuvering.Deacceleration = ss.Decceleration;
            this.Maneuvering.LinearSpeed    = ss.LinearSpeed;
            this.Maneuvering.RotationSpeed  = ss.RotationSpeed;
            HashSet <string> source1 = new HashSet <string>();

            foreach (Kerberos.Sots.Data.ShipFramework.Tech tech in ss.Techs)
            {
                source1.Add(tech.Name);
                this.isDeepScan = this.isDeepScan || tech.Name == "CCC_Advanced_Sensors";
                this.hasJammer  = this.hasJammer || tech.Name == "CCC_Sensor_Jammer";
                if (this.cloakingType == CloakingType.None)
                {
                    switch (tech.Name)
                    {
                    case "SLD_Cloaking":
                        this.cloakingType = CloakingType.Cloaking;
                        continue;

                    case "SLD_Improved_Cloaking":
                        this.cloakingType = CloakingType.ImprovedCloaking;
                        continue;

                    default:
                        continue;
                    }
                }
            }
            List <HashSet <string> > stringSetList = new List <HashSet <string> >();

            foreach (ShipOptionGroup shipOptionGroup in ss.ShipOptionGroups)
            {
                HashSet <string> stringSet = new HashSet <string>();
                foreach (ShipOption shipOption in shipOptionGroup.ShipOptions)
                {
                    stringSet.Add(shipOption.Name);
                }
                stringSetList.Add(stringSet);
            }
            switch (sectionClass)
            {
            case ShipClass.Cruiser:
                source1.Add("ENG_Cruiser_Construction");
                break;

            case ShipClass.Dreadnought:
                source1.Add("ENG_Dreadnought_Construction");
                break;

            case ShipClass.Leviathan:
                source1.Add("ENG_Leviathian_Construction");
                break;
            }
            List <LogicalModuleMount> logicalModuleMountList = new List <LogicalModuleMount>();

            foreach (ModuleMount module in ss.Modules)
            {
                LogicalModuleMount logicalModuleMount = new LogicalModuleMount()
                {
                    Section = this
                };
                logicalModuleMount.AssignedModuleName = module.AssignedModuleName;
                logicalModuleMount.ModuleType         = module.Type;
                logicalModuleMount.NodeName           = module.NodeName;
                logicalModuleMount.FrameX             = module.FrameX;
                logicalModuleMount.FrameY             = module.FrameY;
                logicalModuleMountList.Add(logicalModuleMount);
            }
            List <LogicalBank>  banks            = new List <LogicalBank>();
            List <LogicalMount> logicalMountList = new List <LogicalMount>();

            foreach (Bank bank in ss.Banks)
            {
                LogicalBank logicalBank = new LogicalBank()
                {
                    TurretSize        = (WeaponEnums.WeaponSizes)Enum.Parse(typeof(WeaponEnums.WeaponSizes), bank.Size),
                    Section           = this,
                    Module            = (LogicalModule)null,
                    GUID              = Guid.Parse(bank.Id),
                    DefaultWeaponName = bank.DefaultWeapon
                };
                logicalBank.TurretClass = (WeaponEnums.TurretClasses)Enum.Parse(typeof(WeaponEnums.TurretClasses), bank.Class);
                logicalBank.FrameX      = bank.FrameX;
                logicalBank.FrameY      = bank.FrameY;
                this.IsCarrier          = this.IsCarrier || WeaponEnums.IsBattleRider(logicalBank.TurretClass);
                this.isMineLayer        = this.isMineLayer || logicalBank.TurretClass == WeaponEnums.TurretClasses.Minelayer;
                banks.Add(logicalBank);
                foreach (Mount mount in bank.Mounts)
                {
                    LogicalMount logicalMount = new LogicalMount()
                    {
                        Bank           = logicalBank,
                        NodeName       = mount.NodeName,
                        TurretOverload = mount.TurretOverload,
                        BarrelOverload = mount.BarrelOverload,
                        BaseOverload   = mount.BaseOverload,
                        FireAnimName   = mount.SectionFireAnimation != null ? mount.SectionFireAnimation : "",
                        ReloadAnimName = mount.SectionReloadAnimation != null ? mount.SectionReloadAnimation : "",
                        Yaw            =
                        {
                            Min = mount.YawMin,
                            Max = mount.YawMax
                        },
                        Pitch =
                        {
                            Min = mount.PitchMin,
                            Max = mount.PitchMax
                        }
                    };
                    logicalMount.Pitch.Min = Math.Max(-90f, logicalMount.Pitch.Min);
                    logicalMount.Pitch.Max = Math.Min(90f, logicalMount.Pitch.Max);
                    logicalMountList.Add(logicalMount);
                }
            }
            if (this.IsCarrier)
            {
                this.CarrierType = ShipSectionAsset.GetCarrierType(banks);
            }
            List <string>          stringList          = new List <string>();
            List <ShipSectionType> shipSectionTypeList = new List <ShipSectionType>();

            foreach (ExcludedSection excludedSection in ss.ExcludedSections)
            {
                stringList.Add(excludedSection.Name);
            }
            foreach (ExcludedType excludedType in ss.ExcludedTypes)
            {
                ShipSectionType shipSectionType = ShipSectionType.Command;
                if (excludedType.Name == "Engine")
                {
                    shipSectionType = ShipSectionType.Engine;
                }
                else if (excludedType.Name == "Mission")
                {
                    shipSectionType = ShipSectionType.Mission;
                }
                shipSectionTypeList.Add(shipSectionType);
            }
            List <SectionEnumerations.PsionicAbility> psionicAbilityList = new List <SectionEnumerations.PsionicAbility>();

            foreach (AvailablePsionicAbility psionicAbility in ss.PsionicAbilities)
            {
                psionicAbilityList.Add((SectionEnumerations.PsionicAbility)Enum.Parse(typeof(SectionEnumerations.PsionicAbility), psionicAbility.Name));
            }
            foreach (IEnumerable <string> source2 in stringSetList)
            {
                this.ShipOptions.Add(source2.ToArray <string>());
            }
            this.RequiredTechs       = source1.ToArray <string>();
            this.Banks               = banks.ToArray();
            this.Mounts              = logicalMountList.ToArray();
            this.Modules             = logicalModuleMountList.ToArray();
            this.ExcludeSections     = stringList.ToArray();
            this.ExcludeSectionTypes = shipSectionTypeList.ToArray();
            this.PsionicAbilities    = psionicAbilityList.ToArray();
            if (!ss.RealShipClass.HasValue)
            {
                if (this.RealClass != RealShipClasses.BattleCruiser && this.RealClass != RealShipClasses.BattleShip)
                {
                    this.RealClass = ObtainShipClassTypes.GetRealShipClass(this.Class, this.BattleRiderType, filename);
                }
            }
            else
            {
                this.RealClass = ss.RealShipClass.Value;
            }
            if (this.CombatAIType != SectionEnumerations.CombatAiType.VonNeumannDisc)
            {
                return;
            }
            this.cloakingType = CloakingType.ImprovedCloaking;
        }
Example #14
0
 void Awake()
 {
     shipClass = GetComponent <ShipClass>();
     SpawnUI();
     ToggleUI(false);
 }
Example #15
0
 public Ship(ShipClass shipClass, ShipDirection direction = ShipDirection.East)
 {
     Class          = shipClass;
     this.Direction = direction;
     Status         = ShipStatus.Sailing;
 }
Example #16
0
 public void CmdCopyShip(string name, int hh, int mhh, int sh, int msh, 
     int cs, int can, int fs, int cn, int dc, Cargo car, int dm, int rs,
     string st, int mc, int s, int cm, ShipClass c, int p, int cc)
 {
     Name = name;
     HullHealth = hh;
     MaxHullHealth = mhh;
     SailHealth = sh;
     MaxSailHealth = msh;
     CargoSpace = cs;
     Cannons = can;
     FullSpeed = fs;
     CrewNeeded = cn;
     DodgeChance = dc;
     Cargo = car;
     DamageMod = dm;
     ReloadSpeed = rs;
     ShipType = st;
     MaxCannons = mc;
     Speed = s;
     CrewMorale = cm;
     Class = c;
     Price = p;
     CurrentCrew = cc;
 }
Example #17
0
 public List <Substitution> GetPossibleSubstitutions(ShipClass baseClass)
 {
     return(_substitutionMap[baseClass]);
 }
Example #18
0
    /// <summary>
    /// Server-side function to set the ship class, which determines base stats
    /// </summary>
    /// <param name="new_class">Class to set ship class to</param>
    public void SetClass(ShipClass new_class)
    {
        Class = new_class;
        ShipType = new_class.ToString();

        switch(new_class)
        {
            case ShipClass.Pinnace:
                HullHealth = MaxHullHealth = 50;
                SailHealth = MaxSailHealth = 50;
                CargoSpace = 15;
                Cannons = MaxCannons = 4;
                Speed = FullSpeed = 5;
                CrewNeeded = 6;
                DodgeChance = 40;
                Price = 50;
                break;
            case ShipClass.Sloop:
                HullHealth = MaxHullHealth = 60;
                SailHealth = MaxSailHealth = 70;
                CargoSpace = 35;
                Cannons = MaxCannons = 6;
                Speed = FullSpeed = 5;
                CrewNeeded = 9;
                DodgeChance = 35;
                Price = 100;
                break;
            case ShipClass.Barque:
                HullHealth = MaxHullHealth = 80;
                SailHealth = MaxSailHealth = 80;
                CargoSpace = 45;
                Cannons = MaxCannons = 8;
                Speed = FullSpeed = 4;
                CrewNeeded = 11;
                DodgeChance = 30;
                Price = 150;
                break;
            case ShipClass.Brig:
                HullHealth = MaxHullHealth = 120;
                SailHealth = MaxSailHealth = 100;
                CargoSpace = 100;
                Cannons = MaxCannons = 10;
                Speed = FullSpeed = 3;
                CrewNeeded = 14;
                DodgeChance = 25;
                Price = 200;
                break;
            case ShipClass.Merchantman:
                HullHealth = MaxHullHealth = 120;
                SailHealth = MaxSailHealth = 100;
                CargoSpace = 150;
                Cannons = MaxCannons = 8;
                Speed = FullSpeed = 3;
                CrewNeeded = 12;
                DodgeChance = 25;
                Price = 200;
                break;
            case ShipClass.MerchantGalleon:
                HullHealth = MaxHullHealth = 200;
                SailHealth = MaxSailHealth = 200;
                CargoSpace = 450;
                Cannons = MaxCannons = 12;
                Speed = FullSpeed = 2;
                CrewNeeded = 19;
                DodgeChance = 15;
                ShipType = "Merchant Galleon";
                Price = 500;
                break;
            case ShipClass.CombatGalleon:
                HullHealth = MaxHullHealth = 250;
                SailHealth = MaxSailHealth = 250;
                CargoSpace = 400;
                Cannons = MaxCannons = 24;
                Speed = FullSpeed = 2;
                CrewNeeded = 31;
                DodgeChance = 15;
                ShipType = "Combat Galleon";
                Price = 800;
                break;
            case ShipClass.Frigate:
                HullHealth = MaxHullHealth = 300;
                SailHealth = MaxSailHealth = 300;
                CargoSpace = 600;
                Cannons = MaxCannons = 32;
                Speed = FullSpeed = 1;
                CrewNeeded = 43;
                DodgeChance = 10;
                Price = 1500;
                break;
        }
    }
Example #19
0
 private bool ValidateShipPlacement(ShipClass shipClass, Direction direction, Coordinate coordinates)
 {
     return(VerifyEndpointWithinGrid(ShipClassSize.ShipSize[shipClass], direction, coordinates));
 }
Example #20
0
 public void Upgrade()
 {
     shipClass = ShipCatalog.instance.GetShipClassForName(shipClass.nextShipClassName);
     GetComponent <SpriteRenderer>().sprite = shipClass.sprite;
 }
Example #21
0
 public ShipModel()
 {
     InitInstance();
     ShipClass x = Class;
 }
Example #22
0
 // Use this for initialization
 void Start()
 {
     ShipClass = GetComponent <ShipClass> ();
     ship      = GetComponent <Ship> ();
 }
Example #23
0
        public ShipDummy(App game, CreateShipDummyParams dummyParams)
        {
            this.ShipID = dummyParams.ShipID;
            this._checkStatusBootstrapped = false;
            this._shipClass = dummyParams.Sections.First <ShipSectionAsset>().Class;
            ShipSectionAsset shipSectionAsset = dummyParams.Sections.FirstOrDefault <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.Type == ShipSectionType.Mission));

            ShipDummy.ShipDummyPart shipDummyPart1 = new ShipDummy.ShipDummyPart();
            shipDummyPart1.Model     = game.AddObject <StaticModel>((object)Ship.FixAssetNameForDLC(shipSectionAsset.ModelName, dummyParams.PreferredMount));
            shipDummyPart1.IsSection = true;
            this._dummyParts.Add(shipDummyPart1);
            this._objects.Add((IGameObject)shipDummyPart1.Model);
            foreach (ShipSectionAsset section in dummyParams.Sections)
            {
                ShipDummy.ShipDummyPart sectionPart = shipDummyPart1;
                if (section != shipSectionAsset)
                {
                    ShipDummy.ShipDummyPart shipDummyPart2 = new ShipDummy.ShipDummyPart();
                    shipDummyPart2.Model            = game.AddObject <StaticModel>((object)Ship.FixAssetNameForDLC(section.ModelName, dummyParams.PreferredMount));
                    shipDummyPart2.AttachedModel    = (IGameObject)shipDummyPart1.Model;
                    shipDummyPart2.AttachedNodeName = section.Type.ToString();
                    shipDummyPart2.IsSection        = true;
                    this._dummyParts.Add(shipDummyPart2);
                    this._objects.Add((IGameObject)shipDummyPart2.Model);
                    sectionPart = shipDummyPart2;
                }
                for (int index = 0; index < section.Banks.Length; ++index)
                {
                    LogicalBank bank = section.Banks[index];
                    this.AddTurretsToShipDummy(game, dummyParams.PreferredMount, dummyParams.ShipFaction, section, sectionPart, dummyParams.AssignedWeapons, dummyParams.PreferredWeapons, game.AssetDatabase.Weapons, game.AssetDatabase.TurretHousings, (LogicalModule)null, (ShipDummy.ShipDummyPart)null, bank);
                }
                for (int sectionModuleMountIndex = 0; sectionModuleMountIndex < section.Modules.Length; ++sectionModuleMountIndex)
                {
                    LogicalModuleMount moduleMount = section.Modules[sectionModuleMountIndex];
                    if (dummyParams.AssignedModules != null)
                    {
                        LogicalModule    module           = (LogicalModule)null;
                        ModuleAssignment moduleAssignment = dummyParams.AssignedModules.FirstOrDefault <ModuleAssignment>((Func <ModuleAssignment, bool>)(x => x.ModuleMount == moduleMount));
                        if (moduleAssignment != null)
                        {
                            module = moduleAssignment.Module;
                        }
                        if (module == null)
                        {
                            module = LogicalModule.EnumerateModuleFits(dummyParams.PreferredModules, section, sectionModuleMountIndex, false).FirstOrDefault <LogicalModule>();
                        }
                        if (module != null)
                        {
                            ShipDummy.ShipDummyPart modulePart = new ShipDummy.ShipDummyPart();
                            modulePart.Model            = game.AddObject <StaticModel>((object)module.ModelPath);
                            modulePart.AttachedModel    = (IGameObject)sectionPart.Model;
                            modulePart.AttachedNodeName = moduleMount.NodeName;
                            this._dummyParts.Add(modulePart);
                            this._objects.Add((IGameObject)modulePart.Model);
                            for (int index = 0; index < module.Banks.Length; ++index)
                            {
                                LogicalBank bank = module.Banks[index];
                                this.AddTurretsToShipDummy(game, dummyParams.PreferredMount, dummyParams.ShipFaction, section, sectionPart, dummyParams.AssignedWeapons, dummyParams.PreferredWeapons, game.AssetDatabase.Weapons, game.AssetDatabase.TurretHousings, module, modulePart, bank);
                            }
                        }
                    }
                }
            }
            this._objects.Add((IGameObject)game.AddObject <RigidBody>((object)1f, (object)false));
        }
Example #24
0
 public Ship(ShipClass shipClass)
 {
     ShipClass  = shipClass;
     Modules    = new List <IShipModule>(shipClass.Modules); // Clone to get our own copy for health purposes
     HullHealth = 1;
 }
Example #25
0
    /// <summary>
    /// Server-side function to set the ship class, which determines base stats
    /// </summary>
    /// <param name="new_class">Class to set ship class to</param>
    public void SetClass(ShipClass new_class)
    {
        Class    = new_class;
        ShipType = new_class.ToString();

        switch (new_class)
        {
        case ShipClass.Pinnace:
            HullHealth  = MaxHullHealth = 50;
            SailHealth  = MaxSailHealth = 50;
            CargoSpace  = 15;
            Cannons     = MaxCannons = 4;
            Speed       = FullSpeed = 5;
            CrewNeeded  = 6;
            DodgeChance = 40;
            Price       = 50;
            break;

        case ShipClass.Sloop:
            HullHealth  = MaxHullHealth = 60;
            SailHealth  = MaxSailHealth = 70;
            CargoSpace  = 35;
            Cannons     = MaxCannons = 6;
            Speed       = FullSpeed = 5;
            CrewNeeded  = 9;
            DodgeChance = 35;
            Price       = 100;
            break;

        case ShipClass.Barque:
            HullHealth  = MaxHullHealth = 80;
            SailHealth  = MaxSailHealth = 80;
            CargoSpace  = 45;
            Cannons     = MaxCannons = 8;
            Speed       = FullSpeed = 4;
            CrewNeeded  = 11;
            DodgeChance = 30;
            Price       = 150;
            break;

        case ShipClass.Brig:
            HullHealth  = MaxHullHealth = 120;
            SailHealth  = MaxSailHealth = 100;
            CargoSpace  = 100;
            Cannons     = MaxCannons = 10;
            Speed       = FullSpeed = 3;
            CrewNeeded  = 14;
            DodgeChance = 25;
            Price       = 200;
            break;

        case ShipClass.Merchantman:
            HullHealth  = MaxHullHealth = 120;
            SailHealth  = MaxSailHealth = 100;
            CargoSpace  = 150;
            Cannons     = MaxCannons = 8;
            Speed       = FullSpeed = 3;
            CrewNeeded  = 12;
            DodgeChance = 25;
            Price       = 200;
            break;

        case ShipClass.MerchantGalleon:
            HullHealth  = MaxHullHealth = 200;
            SailHealth  = MaxSailHealth = 200;
            CargoSpace  = 450;
            Cannons     = MaxCannons = 12;
            Speed       = FullSpeed = 2;
            CrewNeeded  = 19;
            DodgeChance = 15;
            ShipType    = "Merchant Galleon";
            Price       = 500;
            break;

        case ShipClass.CombatGalleon:
            HullHealth  = MaxHullHealth = 250;
            SailHealth  = MaxSailHealth = 250;
            CargoSpace  = 400;
            Cannons     = MaxCannons = 24;
            Speed       = FullSpeed = 2;
            CrewNeeded  = 31;
            DodgeChance = 15;
            ShipType    = "Combat Galleon";
            Price       = 800;
            break;

        case ShipClass.Frigate:
            HullHealth  = MaxHullHealth = 300;
            SailHealth  = MaxSailHealth = 300;
            CargoSpace  = 600;
            Cannons     = MaxCannons = 32;
            Speed       = FullSpeed = 1;
            CrewNeeded  = 43;
            DodgeChance = 10;
            Price       = 1500;
            break;
        }
    }
Example #26
0
        public override void FindNewTarget(IEnumerable <IGameObject> objs)
        {
            this.m_Planets.Clear();
            List <LocustTarget> locustTargetList = new List <LocustTarget>();
            List <LocustTarget> source           = new List <LocustTarget>();

            foreach (LocustTarget target in this.m_TargetList)
            {
                target.ClearNumTargets();
            }
            source.AddRange((IEnumerable <LocustTarget>) this.m_TargetList);
            foreach (IGameObject gameObject in objs)
            {
                if (gameObject is Ship)
                {
                    Ship ship = gameObject as Ship;
                    if (Ship.IsActiveShip(ship) && ship.Player != this.m_LocustNest.Player)
                    {
                        bool flag = ship.IsDetected(this.m_LocustNest.Player);
                        foreach (LocustFighterControl spawnedFighter in this.m_SpawnedFighters)
                        {
                            if (ship == spawnedFighter.GetTarget())
                            {
                                if (!flag)
                                {
                                    spawnedFighter.SetTarget((IGameObject)null);
                                    break;
                                }
                                break;
                            }
                        }
                        if (flag)
                        {
                            locustTargetList.Add(new LocustTarget()
                            {
                                Target = ship
                            });
                            LocustTarget locustTarget = source.FirstOrDefault <LocustTarget>((Func <LocustTarget, bool>)(x => x.Target == ship));
                            if (locustTarget != null)
                            {
                                source.Remove(locustTarget);
                            }
                        }
                    }
                }
                if (gameObject is StellarBody)
                {
                    StellarBody stellarBody = gameObject as StellarBody;
                    if (this.m_Game.GameDatabase.GetColonyInfoForPlanet(stellarBody.Parameters.OrbitalID) != null)
                    {
                        this.m_Planets.Add(stellarBody);
                    }
                }
            }
            if (source.Count > 0)
            {
                foreach (LocustFighterControl spawnedFighter in this.m_SpawnedFighters)
                {
                    LocustFighterControl fighter = spawnedFighter;
                    if (source.Any <LocustTarget>((Func <LocustTarget, bool>)(x => x.Target == fighter.GetTarget())))
                    {
                        fighter.SetTarget((IGameObject)null);
                    }
                }
            }
            if (locustTargetList.Count > this.m_TargetList.Count)
            {
                foreach (LocustTarget target in this.m_TargetList)
                {
                    ShipClass shipClass = target.Target.ShipClass;
                    target.ClearNumTargets();
                    int num = LocustFighterControl.NumFightersPerShip(shipClass);
                    foreach (LocustFighterControl spawnedFighter in this.m_SpawnedFighters)
                    {
                        if (spawnedFighter.GetTarget() == target.Target)
                        {
                            if (num > 0)
                            {
                                --num;
                                target.IncFightersOnTarget();
                            }
                            else
                            {
                                spawnedFighter.SetTarget((IGameObject)null);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (LocustFighterControl spawnedFighter in this.m_SpawnedFighters)
                {
                    LocustFighterControl fighter = spawnedFighter;
                    if (fighter.GetTarget() != null)
                    {
                        this.m_TargetList.FirstOrDefault <LocustTarget>((Func <LocustTarget, bool>)(x => x.Target == fighter.GetTarget()))?.IncFightersOnTarget();
                    }
                }
            }
            foreach (LocustTarget locustTarget in locustTargetList)
            {
                LocustTarget target = locustTarget;
                if (!this.m_TargetList.Any <LocustTarget>((Func <LocustTarget, bool>)(x => x.Target == target.Target)))
                {
                    target.ClearNumTargets();
                    this.m_TargetList.Add(target);
                }
            }
            this.m_UpdateTargetList = false;
        }
Example #27
0
 public Substitution(ShipClass baseClass, ShipClass newClass)
 {
     BaseClass = baseClass;
     NewClass  = newClass;
 }