Exemplo n.º 1
0
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="parent"></param>
 public DistanceTable(SystemContact parent)
 {
     m_distances        = new Dictionary <SystemContact, float>();
     m_lastUpdateSecond = new Dictionary <SystemContact, int>();
     m_lastUpdateYear   = new Dictionary <SystemContact, int>();
     m_parent           = parent;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="parent"></param>
 public DistanceTable(SystemContact parent)
 {
     m_distances = new Dictionary<SystemContact, float>();
     m_lastUpdateSecond = new Dictionary<SystemContact, int>();
     m_lastUpdateYear = new Dictionary<SystemContact, int>();
     m_parent = parent;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Calculates distance between the parent and the specified contact.
 /// distance parameter is garenteed to be populated.
 /// </summary>
 /// <param name="contact"></param>
 /// <param name="distance"></param>
 /// <returns>true if distance was already in table. False if it distance was calculated. distance is in AUs.</returns>
 public bool GetDistance(SystemContact contact, out float distance)
 {
     if (m_distances.TryGetValue(contact, out distance))
     {
         if (m_lastUpdateSecond[contact] == GameState.Instance.CurrentSecond && m_lastUpdateYear[contact] == GameState.Instance.CurrentYear)
         {
             return(true);
         }
     }
     distance = m_parent.Position.GetDistanceTo(contact.Position);
     UpdateDistance(contact, distance);
     contact.DistTable.UpdateDistance(m_parent, distance);
     return(false);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Calculates distance between the parent and the specified contact.
 /// distance parameter is garenteed to be populated.
 /// </summary>
 /// <param name="contact"></param>
 /// <param name="distance"></param>
 /// <returns>true if distance was already in table. False if it distance was calculated. distance is in AUs.</returns>
 public bool GetDistance(SystemContact contact, out float distance)
 {
     if (m_distances.TryGetValue(contact, out distance))
     {
         if (m_lastUpdateSecond[contact] == GameState.Instance.CurrentSecond && m_lastUpdateYear[contact] == GameState.Instance.CurrentYear)
         {
             return true;
         }
     }
     distance = m_parent.Position.GetDistanceTo(contact.Position);
     UpdateDistance(contact, distance);
     contact.DistTable.UpdateDistance(m_parent, distance);
     return false;
 }
Exemplo n.º 5
0
        /// <summary>
        /// This function removes contacts from the system wide contact list when a contact deletion event occurs.
        /// This happens whenever a ship is scrapped or otherwise destroyed, ships/fighters land on a hangar, missiles hit their target or run out of endurance, and jump point exits.
        /// </summary>
        /// <param name="Contact">Contact to be removed.</param>
        public void RemoveContact(SystemContact Contact)
        {
            int index = SystemContactList.IndexOf(Contact);

            if (index != -1)
            {
                /// <summary>
                /// Remove the contact from each of the faction contact lists as well as the System contact list.
                /// </summary>
                for (int loop = 0; loop < FactionDetectionLists.Count; loop++)
                {
                    FactionDetectionLists[loop].RemoveContact(index);
                }

                SystemContactList.Remove(Contact);

                /// <summary>
                /// Distance Table is updated every tick, and doesn't care about last tick's info. so deleting simply the last entry
                /// causes no issues with distance calculations.
                /// </summary>
                for (int loop = 0; loop < SystemContactList.Count; loop++)
                {
                    SystemContactList[loop].DistanceTable.RemoveAt(SystemContactList.Count - 1);
                    SystemContactList[loop].DistanceUpdate.RemoveAt(SystemContactList.Count - 1);
                }

                /// <summary>
                /// inform the display that this contact needs to be deleted.
                /// </summary>
                ContactDeleteList.Add(Contact);

                /// <summary>
                /// also clean up the contact create list if this contact hasn't been created yet by the display.
                /// </summary>
                if (ContactCreateList.Contains(Contact) == true)
                {
                    ContactCreateList.Remove(Contact);
                }
            }
            else
            {
                String       Entry  = String.Format("Index for the system contact list is {0} for system {1}", index, Name);
                MessageEntry Entry2 = new MessageEntry(MessageEntry.MessageType.Error, Contact.CurrentSystem, Contact,
                                                       GameState.Instance.GameDateTime, (GameState.SE.CurrentTick - GameState.SE.lastTick), Entry);
                GameState.Instance.Factions[0].MessageLog.Add(Entry2);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Systems have to store a global(or perhaps system wide) list of contacts. This function adds a contact in the event one is generated.
        /// Generation events include construction, hangar launches, missile launches, and Jump Point Entry into the System.
        /// </summary>
        /// <param name="Contact">Contact to be added.</param>
        public void AddContact(SystemContact Contact)
        {
            /// <summary>
            /// Add a new entry to every distance table for every contact.
            /// </summary>
            for (int loop = 0; loop < SystemContactList.Count; loop++)
            {
                SystemContactList[loop].DistanceTable.Add(0.0f);
                SystemContactList[loop].DistanceUpdate.Add(-1);
            }


            SystemContactList.Add(Contact);
            Contact.UpdateSystem(this);

            /// <summary>
            /// Update all the faction contact lists with the new contact.
            /// </summary>
            for (int loop = 0; loop < FactionDetectionLists.Count; loop++)
            {
                FactionDetectionLists[loop].AddContact();
            }

            /// <summary>
            /// Inform the systemmap/sceen that a new contact needs to be created.
            /// </summary>
            ContactCreateList.Add(Contact);

            /// <summary>
            /// In the event that this contact is in the delete list, it probably means that this contact travelled through this system, left, and is back in the system, without being drawn.
            /// If so put it in the contactCreateList and take it out of the contactDeleteList.
            /// </summary>
            if (ContactDeleteList.Contains(Contact) == true)
            {
                ContactDeleteList.Remove(Contact);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Each tick every faction contact should be updated on the basis of collected sensor data.
        /// </summary>
        /// <param name="Thermal">Thermal detection?</param>
        /// <param name="Em">Detected on EM?</param>
        /// <param name="Active">Detected by actives?</param>
        /// <param name="tick">Current tick.</param>
        public void updateFactionContact(Faction CurrentFaction, bool Thermal, bool Em, int EMSig, bool Active, uint tick, uint year)
        {
            if (thermal == Thermal && EM == Em && active == Active)
            {
                return;
            }

            String Contact = "N/A";

            MessageEntry.MessageType type = MessageEntry.MessageType.Count;

            if (Thermal == false && Em == false && Active == false)
            {
                Contact = "Existing contact lost";
                type    = MessageEntry.MessageType.ContactLost;
            }
            else
            {
                Contact = "Update on existing contact:";
                type    = MessageEntry.MessageType.ContactUpdate;

                if (thermal == false && Thermal == true)
                {
                    /// <summary>
                    /// New thermal detection event, message logic should be here.
                    /// </summary>
                    thermalTick = tick;
                    thermalYear = year;

                    if (ship != null)
                    {
                        Contact = String.Format("{0} Thermal Signature {1}", Contact, ship.CurrentThermalSignature);
                    }
                    else if (missileGroup != null)
                    {
                        Contact = String.Format("{0} Thermal Signature {1} x{2}", Contact, (int)Math.Ceiling(missileGroup.missiles[0].missileDef.totalThermalSignature), missileGroup.missiles.Count);
                    }
                    else if (pop != null)
                    {
                        Contact = String.Format("{0} Thermal Signature {1}", Contact, pop.ThermalSignature);
                    }
                    else
                    {
                        type    = MessageEntry.MessageType.Error;
                        Contact = "Error: ship,missile, and pop are null in UpdateFactionContact.";
                    }
                }
                else if (thermal == true && Thermal == false)
                {
                    /// <summary>
                    /// Thermal contact lost.
                    /// </summary>
                    Contact = String.Format("{0} Thermal contact lost", Contact);
                }

                if (EM == false && Em == true)
                {
                    /// <summary>
                    /// New EM detection event, message logic should be here.
                    /// </summary>
                    EMTick = tick;
                    EMYear = year;

                    EMSignature = EMSig;


                    if (ship != null)
                    {
                        Contact = String.Format("{0} EM Signature {1}", Contact, EMSignature);
                    }
                    else if (missileGroup != null)
                    {
                        if (missileGroup.missiles[0].missileDef.aSD != null)
                        {
                            Contact = String.Format("{0} EM Signature {1} x{2}", Contact, missileGroup.missiles[0].missileDef.aSD.gps, missileGroup.missiles.Count);
                        }
                        else
                        {
                            type    = MessageEntry.MessageType.Error;
                            Contact = "Error: Missile lacks a sensor, but is emitting EM in UpdateFactionContact.";
                        }
                    }
                    else if (pop != null)
                    {
                        Contact = String.Format("{0} EM Signature {1}", Contact, pop.EMSignature);
                    }
                    else
                    {
                        type    = MessageEntry.MessageType.Error;
                        Contact = "Error: ship,missile, and pop are null in UpdateFactionContact.";
                    }
                }
                if (EM == true && Em == false)
                {
                    EMSignature = -1;
                    /// <summary>
                    /// EM contact lost.
                    /// </summary>
                    Contact = String.Format("{0} EM contact lost", Contact);
                }

                if (active == false && Active == true)
                {
                    /// <summary>
                    /// New active detection event, message logic should be here.
                    /// </summary>
                    activeTick = tick;
                    activeYear = year;

                    if (ship != null)
                    {
                        Contact = String.Format("{0} TCS {1}", Contact, ship.TotalCrossSection);
                    }
                    else if (missileGroup != null)
                    {
                        Contact = String.Format("{0} TCS_MSP {1} x{2}", Contact, (int)Math.Ceiling(missileGroup.missiles[0].missileDef.size), missileGroup.missiles.Count);
                    }
                    else if (pop != null)
                    {
                        Contact = String.Format("{0} Active Ping", Contact); //don't bother printing TCS for planets.
                    }
                    else
                    {
                        type    = MessageEntry.MessageType.Error;
                        Contact = "Error: ship,missile, and pop are null in UpdateFactionContact.";
                    }
                }
                if (active == true && Active == false)
                {
                    /// <summary>
                    /// Active contact lost.
                    /// </summary>

                    Contact = String.Format("{0} Active contact lost", Contact);
                }
            }

            SystemContact SysCon = null;

            if (ship != null)
            {
                SysCon = ship.ShipsTaskGroup.Contact;
            }
            else if (missileGroup != null)
            {
                SysCon = missileGroup.contact;
            }
            else if (pop != null)
            {
                SysCon = pop.Contact;
            }
            else
            {
                type    = MessageEntry.MessageType.Error;
                Contact = "Error: ship,missile, and pop are null in UpdateFactionContact.";
            }

            MessageEntry NMsg;

            if (type == MessageEntry.MessageType.Error)
            {
                NMsg = new MessageEntry(type, null, null, GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Contact);
            }
            else
            {
                NMsg = new MessageEntry(type, SysCon.Position.System, SysCon,
                                        GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Contact);
            }

            CurrentFaction.MessageLog.Add(NMsg);

            thermal = Thermal;
            EM      = Em;
            active  = Active;
        }
Exemplo n.º 8
0
        /// <summary>
        /// This function calculates whether a given BFC can intercept a missile
        /// </summary>
        /// <param name="RNG">RNG to use, should be the global one in _SE_</param>
        /// <param name="IncrementDistance">Range to the target missile</param>
        /// <param name="Ordnance">Ordnance we want to shoot at.</param>
        /// <param name="ShipFaction">Faction of the ship this BFC is on.</param>
        /// <param name="Contact">Contact of the taskgroup this BFC is in.</param>
        /// <param name="ShipOn">Ship this BFC is on.</param>
        /// <param name="WeaponsFired">Whether or not a weapon was fired. this is for the recharge list further up</param>
        /// <returns>whether the missile was intercepted.</returns>
        public bool InterceptTarget(Random RNG, int IncrementDistance, OrdnanceTN Ordnance, Faction ShipFaction, SystemContact Contact, ShipTN ShipOn, out bool WeaponsFired)
        {
            WeaponsFired = false;

            float ShipSpeed = ShipOn.CurrentSpeed;

            float track = (float)ShipFaction.BaseTracking;
            if (ShipSpeed > track)
                track = ShipSpeed;
            if (m_oBeamFireControlDef.tracking < track)
                track = m_oBeamFireControlDef.tracking;

            /// <summary>
            /// Throwaway target for point defense purposes.
            /// </summary>
            TargetTN OverrideTarget = new TargetTN(Ordnance.missileGroup);

            float Acc = GetFiringAccuracy(IncrementDistance, (int)track, OverrideTarget);
            int toHit = (int)Math.Floor(Acc * 100.0f);
            int range = (IncrementDistance + 1) * 10000;
            String Range = range.ToString("#,###0");

            foreach (BeamTN LinkedWeapon in m_lLinkedWeapons)
            {
                /// <summary>
                /// Certain weapons will have already fired one or more of their shots, but may still have more available.
                /// </summary>
                bool AcceptPartialFire = (LinkedWeapon.beamDef.componentType == ComponentTypeTN.Rail || LinkedWeapon.beamDef.componentType == ComponentTypeTN.AdvRail ||
                        LinkedWeapon.beamDef.componentType == ComponentTypeTN.Gauss) && (LinkedWeapon.shotsExpended < LinkedWeapon.beamDef.shotCount);

                if (LinkedWeapon.readyToFire() == true || AcceptPartialFire == true)
                {
                    if (LinkedWeapon.beamDef.componentType == ComponentTypeTN.Rail || LinkedWeapon.beamDef.componentType == ComponentTypeTN.AdvRail ||
                        LinkedWeapon.beamDef.componentType == ComponentTypeTN.Gauss)
                    {

                        WeaponsFired = LinkedWeapon.Fire();

                        /// <summary>
                        /// multi-hit weapons will be a little wierd as far as PD goes.
                        /// </summary>
                        if (WeaponsFired == false && AcceptPartialFire == true)
                            WeaponsFired = true;


                        int expended = LinkedWeapon.shotsExpended;
                        int ShotCount = LinkedWeapon.beamDef.shotCount;

                        for (int BeamShotIterator = expended; BeamShotIterator < ShotCount; BeamShotIterator++)
                        {
                            ushort Hit = (ushort)RNG.Next(1, 100);
                            LinkedWeapon.shotsExpended++;

                            if (toHit >= Hit)
                            {
                                String Entry = String.Format("{0} Fired at {1} km and hit.", LinkedWeapon.Name, Range);
                                MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                                   GameState.Instance.LastTimestep, Entry);
                                ShipFaction.MessageLog.Add(Msg);
                                return true;
                            }
                            else
                            {
                                String Entry = String.Format("{0} Fired at {1} km and missed.", LinkedWeapon.Name, Range);
                                MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                                   GameState.Instance.LastTimestep, Entry);
                                ShipFaction.MessageLog.Add(Msg);
                            }
                        }

                    }
                    else
                    {
                        ushort Hit = (ushort)RNG.Next(1, 100);

                        WeaponsFired = LinkedWeapon.Fire();

                        if (toHit >= Hit)
                        {
                            String Entry = String.Format("{0} Fired at {1} km and hit.", LinkedWeapon.Name, Range);
                            MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                               GameState.Instance.LastTimestep, Entry);
                            ShipFaction.MessageLog.Add(Msg);
                            return true;
                        }
                        else
                        {
                            String Entry = String.Format("{0} Fired at {1} km and missed.", LinkedWeapon.Name, Range);
                            MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                               GameState.Instance.LastTimestep, Entry);
                            ShipFaction.MessageLog.Add(Msg);
                        }
                    }
                }
            }

            foreach (TurretTN LinkedTurret in m_lLinkedTurrets)
            {
                /// <summary>
                /// Double, triple, and quad turrets have multiple shots.
                /// </summary>
                bool AcceptPartialFire = (LinkedTurret.shotsExpended < LinkedTurret.turretDef.totalShotCount);
                if (LinkedTurret.readyToFire() == true || AcceptPartialFire == true)
                {
                    WeaponsFired = LinkedTurret.Fire();

                    /// <summary>
                    /// multi-hit weapons will be a little wierd as far as PD goes.
                    /// </summary>
                    if (WeaponsFired == false && AcceptPartialFire == true)
                        WeaponsFired = true;

                    int expended = LinkedTurret.shotsExpended;
                    int ShotCount = LinkedTurret.turretDef.totalShotCount;

                    for (int TurretShotIterator = expended; TurretShotIterator < ShotCount; TurretShotIterator++)
                    {
                        ushort Hit = (ushort)RNG.Next(1, 100);
                        LinkedTurret.shotsExpended++;

                        if (toHit >= Hit)
                        {
                            String Entry = String.Format("{0} Fired at {1} km and hit.", LinkedTurret.Name, Range);
                            MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                               GameState.Instance.LastTimestep, Entry);
                            ShipFaction.MessageLog.Add(Msg);
                            return true;
                        }
                        else
                        {
                            String Entry = String.Format("{0} Fired at {1} km and missed.", LinkedTurret.Name, Range);
                            MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                               GameState.Instance.LastTimestep, Entry);
                            ShipFaction.MessageLog.Add(Msg);
                        }
                    }
                }
            }

            return false;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Constructor for population.
        /// </summary>
        /// <param name="a_oPlanet">Planet this population is on</param>
        /// <param name="a_oFaction">Faction this population belongs to</param>
        /// <param name="CurrentTimeSlice">Tick this population was created</param>
        /// <param name="a_oName">Name of the population</param>
        /// <param name="a_oSpecies">Species that will reside on this population.</param>
        public Population(SystemBody a_oPlanet, Faction a_oFaction, int CurrentTimeSlice, String a_oName = "Earth", Species a_oSpecies = null)
        {
            Id = Guid.NewGuid();
            // initialise minerials:
            m_aiMinerials = new float[Constants.Minerals.NO_OF_MINERIALS];
            for (int i = 0; i < Constants.Minerals.NO_OF_MINERIALS; ++i)
            {
                m_aiMinerials[i] = 0;
            }

            m_aoInstallations = new Installation[Installation.NO_OF_INSTALLATIONS];
            for (int i = 0; i < Installation.NO_OF_INSTALLATIONS; ++i)
            {
                m_aoInstallations[i] = new Installation((Installation.InstallationType)i);
            }

            CivilianPopulation = 0;
            PopulationGrowthRate = 0.1f;
            FuelStockpile = 0;
            MaintenanceSupplies = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing = 1.0f;
            ModifierPoliticalStability = 1.0f;
            ModifierProduction = 1.0f;
            ModifierWealthAndTrade = 1.0f;

            Name = a_oName;  // just a default Value!

            Faction = a_oFaction;
            Planet = a_oPlanet;


            if (a_oSpecies == null)
            {
                Species = Faction.Species;
            }
            else
            {
                Species = a_oSpecies;
            }

            SSEntity = StarSystemEntityType.Population;

            Planet.Populations.Add(this); // add us to the list of pops on the planet!
            Planet.Position.System.Populations.Add(this);
            Contact = new SystemContact(Faction, this);
            Contact.Position.System = Planet.Position.System;
            Contact.Position.X = Planet.Position.X;
            Contact.Position.Y = Planet.Position.Y;
            Planet.Position.System.SystemContactList.Add(Contact);

            GovernorPresent = false;
            AdminRating = 0;

            ComponentStockpile = new BindingList<ComponentDefTN>();
            ComponentStockpileCount = new BindingList<float>();
            ComponentStockpileLookup = new Dictionary<Guid, int>();
            MissileStockpile = new Dictionary<OrdnanceDefTN, float>();

            _OrbitalTerraformModules = 0.0f;

            PoliticalPopStatus = PoliticalStatus.Imperial;

            for (int InstallationIterator = 0; InstallationIterator < (int)Installation.InstallationType.InstallationCount; InstallationIterator++)
            {
                Installations[InstallationIterator].Number = 0.0f;
            }

            FuelStockpile = 0.0f;
            MaintenanceSupplies = 0.0f;
            EMSignature = 0;
            ThermalSignature = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing = 1.0f;
            ModifierProduction = 1.0f;
            ModifierWealthAndTrade = 1.0f;
            ModifierPoliticalStability = 1.0f;

            ConstructionBuildQueue = new BindingList<ConstructionBuildQueueItem>();
            MissileBuildQueue = new BindingList<MissileBuildQueueItem>();
            FighterBuildQueue = new BindingList<FighterBuildQueueItem>();

            IsRefining = false;

            ShipyardTasks = new Dictionary<Installation.ShipyardInformation.ShipyardTask, Installation.ShipyardInformation>();

            ThermalDetection = new BindingList<int>();
            EMDetection = new BindingList<int>();
            ActiveDetection = new BindingList<int>();

            for (int loop = 0; loop < Constants.Faction.FactionMax; loop++)
            {
                ThermalDetection.Add(CurrentTimeSlice);
                EMDetection.Add(CurrentTimeSlice);
                ActiveDetection.Add(CurrentTimeSlice);
            }

            ShipsTargetting = new BindingList<ShipTN>();
            MissilesInFlight = new BindingList<OrdnanceGroupTN>();

            _SensorUpdateAck = 0;

            /// <summary>
            /// Terraforming Section:
            /// </summary>
            _GasAddSubtract = false;
            _GasAmt = 0.0f;
            _GasToAdd = null;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Removes a contact element from the display. This is controlled by SystemContact.ContactElementCreated.
        /// </summary>
        /// <param name="a_oDefaultEffect"></param>
        /// <param name="oContact"></param>
        public void RemoveContactElement(GLEffect a_oDefaultEffect, SystemContact oContact)
        {
            foreach (SceenElement Ele in m_lElements)
            {
                /// <summary>
                /// Have to use Guid to identify elements and get rid of the one we no longer want. 
                /// Update: as it turns out Id was not being declared anywhere.
                /// </summary>
                if (Ele.EntityID == oContact.Id)
                {
                    m_lElements.Remove(Ele);
                    break;
                }
            }

        }
Exemplo n.º 11
0
        /// <summary>
        /// creates a new post sceen creation contact element.
        /// </summary>
        /// <param name="a_oDefaultEffect">default effect, I don't know what these are really.</param>
        /// <param name="oContact">The system contact to be created.</param>
        public void AddContactElement(GLEffect a_oDefaultEffect, SystemContact oContact)
        {
            SceenElement oContactElement;
            Vector3 v3ContactPos;
            GLUtilities.GLFont oNameLable;
            GLUtilities.GLQuad oContactQuad;

            switch (oContact.SSEntity)
            {
                case StarSystemEntityType.TaskGroup:
                    TaskGroupTN TaskGroup = oContact.Entity as TaskGroupTN;
                    oContactElement = new ContactElement(a_oDefaultEffect, oContact);
                    oContactElement.EntityID = oContact.Id;

                    v3ContactPos = new Vector3((float)TaskGroup.Contact.Position.X, (float)TaskGroup.Contact.Position.Y, 0.0f);

                    oContactQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                    v3ContactPos,
                                                                    new Vector2(0.0001f, 0.0001f),                   // what size is a task groug anyway???
                                                                    oContact.faction.FactionColor,
                                                                    UIConstants.Textures.DEFAULT_TASKGROUP_ICON);

                    oNameLable = new GLUtilities.GLFont(a_oDefaultEffect, v3ContactPos,
                    UIConstants.DEFAULT_TEXT_SIZE, oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_GLFONT2, TaskGroup.Name);

                    oContactElement.Lable = oNameLable;
                    oContactElement.Lable.Size = UIConstants.DEFAULT_TEXT_SIZE / m_fZoomScaler; //Initial taskgroup names weren't being scaled properly for whatever reason.
                    oContactElement.PrimaryPrimitive = oContactQuad;
                    oContactElement.AddPrimitive(oContactQuad);
                    oContactElement.RealSize = new Vector2(0.0001f, 0.0001f);
                    this.AddElement(oContactElement);
                    (oContactElement as ContactElement).ParentSceen = this;
                    break;
                case StarSystemEntityType.Missile:
                    OrdnanceGroupTN MissileGroup = oContact.Entity as OrdnanceGroupTN;
                    oContactElement = new ContactElement(a_oDefaultEffect, oContact);
                    oContactElement.EntityID = oContact.Id;

                    v3ContactPos = new Vector3((float)MissileGroup.contact.Position.X, (float)MissileGroup.contact.Position.Y, 0.0f);

                    oContactQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                v3ContactPos,
                                                                new Vector2(0.0001f, 0.0001f),                   // what size is a missile?
                                                                oContact.faction.FactionColor,
                                                                UIConstants.Textures.DEFAULT_TASKGROUP_ICON);

                    oNameLable = new GLUtilities.GLFont(a_oDefaultEffect, v3ContactPos,
                    UIConstants.DEFAULT_TEXT_SIZE, oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_GLFONT2, MissileGroup.Name);

                    oContactElement.Lable = oNameLable;
                    oContactElement.Lable.Size = UIConstants.DEFAULT_TEXT_SIZE / m_fZoomScaler; //Same problem may exist with missile labels.
                    oContactElement.PrimaryPrimitive = oContactQuad;
                    oContactElement.AddPrimitive(oContactQuad);
                    oContactElement.RealSize = new Vector2(0.0001f, 0.0001f);
                    this.AddElement(oContactElement);
                    (oContactElement as ContactElement).ParentSceen = this;
                    break;
                case StarSystemEntityType.Population:
                    Population CurrentPopulation = oContact.Entity as Population;
                    oContactElement = new ContactElement(a_oDefaultEffect, oContact);
                    oContactElement.EntityID = oContact.Id;

                    v3ContactPos = new Vector3((float)CurrentPopulation.Contact.Position.X, (float)CurrentPopulation.Contact.Position.Y, 0.0f);

                    oContactQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                v3ContactPos,
                                                                new Vector2(0.0001f, 0.0001f),                   // what size is a population?
                                                                oContact.faction.FactionColor,
                                                                UIConstants.Textures.DEFAULT_TASKGROUP_ICON);

                    oNameLable = new GLUtilities.GLFont(a_oDefaultEffect, v3ContactPos,
                    UIConstants.DEFAULT_TEXT_SIZE, oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_GLFONT2, CurrentPopulation.Name);

                    oContactElement.Lable = oNameLable;
                    oContactElement.Lable.Size = UIConstants.DEFAULT_TEXT_SIZE / m_fZoomScaler; //Same problem may exist with population labels.
                    oContactElement.PrimaryPrimitive = oContactQuad;
                    oContactElement.AddPrimitive(oContactQuad);
                    oContactElement.RealSize = new Vector2(0.0001f, 0.0001f);
                    this.AddElement(oContactElement);
                    (oContactElement as ContactElement).ParentSceen = this;
                    break;
            }

        }
Exemplo n.º 12
0
 /// <summary>
 /// Moves the specified contact from the distance table.
 /// </summary>
 /// <param name="contact"></param>
 public void Remove(SystemContact contact)
 {
     m_distances.Remove(contact);
     m_lastUpdateSecond.Remove(contact);
     m_lastUpdateYear.Remove(contact);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Updates/Adds the contact in the distance table with the correct distance/timestamp.
 /// </summary>
 /// <param name="contact"></param>
 /// <param name="distance"></param>
 private void UpdateDistance(SystemContact contact, float distance)
 {
     m_distances[contact] = distance;
     m_lastUpdateSecond[contact] = GameState.Instance.CurrentSecond;
     m_lastUpdateYear[contact] = GameState.Instance.CurrentYear;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Constructor for the taskgroup, sets name, faction, planet the TG starts in orbit of.
        /// </summary>
        /// <param name="Title">Name</param>
        /// <param name="FID">Faction</param>
        /// <param name="StartingBody">body taskgroup will orbit at creation.</param>
        public TaskGroupTN(string Title, Faction FID, OrbitingEntity StartingBody, StarSystem StartingSystem)
        {
            Name = Title;
            /// <summary>
            /// create these or else anything that relies on a unique global id will break.
            /// </summary>
            Id = Guid.NewGuid();

            TaskGroupFaction = FID;

            IsOrbiting = true;
            OrbitingBody = StartingBody;
            (OrbitingBody as SystemBody).TaskGroupsInOrbit.Add(this);

            SSEntity = StarSystemEntityType.TaskGroup;

            Position.System = StartingSystem;
            Position.X = OrbitingBody.Position.X;
            Position.Y = OrbitingBody.Position.Y;

            Contact = new SystemContact(TaskGroupFaction, this);

            Contact.LastPosition.X = Contact.Position.X;
            Contact.LastPosition.Y = Contact.Position.Y;

            StartingSystem.SystemContactList.Add(Contact);
            DrawTravelLine = 3;

            CurrentSpeed = 1;
            MaxSpeed = 1;

            CurrentSpeedX = 0.0;
            CurrentSpeedY = 0.0;
            CurrentHeading = 0.0;
            TimeRequirement = 0;

            TaskGroupOrders = new BindingList<Order>();

            TotalOrderDistance = 0.0;

            /// <summary>
            /// Change this for PDCS and starbases.
            /// </summary>
            CanOrder = Constants.ShipTN.OrderState.AcceptOrders;

            /// <summary>
            /// Ships start in the unordered state, so new orders will have to have GetHeading/speed/other functionality performed.
            /// </summary>
            NewOrders = true;

            Ships = new BindingList<ShipTN>();
            ShipOutOfFuel = false;

            ActiveSensorQue = new BindingList<ActiveSensorTN>();
            ActiveSensorCount = new BindingList<int>();

            TaskGroupLookUpST = new BindingList<int>();

            /// <summary>
            /// Resolution Max needs to go into global constants, or ship constants I think.
            /// </summary>
            for (int loop = 0; loop < Constants.ShipTN.ResolutionMax; loop++)
            {
                /// <summary>
                /// TaskGroupLookUpST will be initialized to zero.
                /// </summary>
                TaskGroupLookUpST.Add(0);
            }

            TaskGroupLookUpMT = new BindingList<int>();
            for (int loop = 0; loop < 15; loop++)
            {
                /// <summary>
                /// TaskGroupLookUpMT will be initialized to zero.
                /// </summary>
                TaskGroupLookUpMT.Add(0);
            }

            BestThermalCount = 0;
            BestEMCount = 0;

            ThermalSortList = new LinkedList<int>();
            EMSortList = new LinkedList<int>();
            ActiveSortList = new LinkedList<int>();

            TotalCargoTonnage = 0;
            CurrentCargoTonnage = 0;

            TotalCryoCapacity = 0;
            CurrentCryoStorage = 0;

            TaskGroupsOrdered = new BindingList<TaskGroupTN>();

            TaskGroupPDL = new PointDefenseList();

            IsInShipyard = false;

            SensorUpdateAck = 0;

            //add default legal order for targeting TGs.
            _legalOrders.Add(Constants.ShipTN.OrderType.Follow);
            _legalOrders.Add(Constants.ShipTN.OrderType.Join);
            _legalOrders.Add(Constants.ShipTN.OrderType.Absorb);
            _legalOrders.Add(Constants.ShipTN.OrderType.RefuelTargetFleet);
            _legalOrders.Add(Constants.ShipTN.OrderType.ResupplyTargetFleet);
            _legalOrders.Add(Constants.ShipTN.OrderType.ReloadTargetFleet);



            _legalOrders.Add(Constants.ShipTN.OrderType.LandOnAssignedMothership);
            _legalOrders.Add(Constants.ShipTN.OrderType.LandOnMotherShipNoAssign);
            _legalOrders.Add(Constants.ShipTN.OrderType.LandOnMothershipAssign);
            _legalOrders.Add(Constants.ShipTN.OrderType.TractorSpecifiedShip);
            _legalOrders.Add(Constants.ShipTN.OrderType.TractorSpecifiedShipyard);


        }
Exemplo n.º 15
0
 /// <summary>
 /// Updates/Adds the contact in the distance table with the correct distance/timestamp.
 /// </summary>
 /// <param name="contact"></param>
 /// <param name="distance"></param>
 private void UpdateDistance(SystemContact contact, float distance)
 {
     m_distances[contact]        = distance;
     m_lastUpdateSecond[contact] = GameState.Instance.CurrentSecond;
     m_lastUpdateYear[contact]   = GameState.Instance.CurrentYear;
 }
Exemplo n.º 16
0
        public Population(SystemBody a_oPlanet, Faction a_oFaction, String a_oName = "Earth", Species a_oSpecies = null)
        {
            Id = Guid.NewGuid();
            // initialise minerials:
            m_aiMinerials = new float[Constants.Minerals.NO_OF_MINERIALS];
            for (int i = 0; i < Constants.Minerals.NO_OF_MINERIALS; ++i)
            {
                m_aiMinerials[i] = 0;
            }

            m_aoInstallations = new Installation[Installation.NO_OF_INSTALLATIONS];
            for (int i = 0; i < Installation.NO_OF_INSTALLATIONS; ++i)
            {
                m_aoInstallations[i] = new Installation((Installation.InstallationType)i);
            }

            CivilianPopulation         = 0;
            PopulationGrowthRate       = 0.1f;
            FuelStockpile              = 0;
            MaintenanceSupplies        = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing       = 1.0f;
            ModifierPoliticalStability = 1.0f;
            ModifierProduction         = 1.0f;
            ModifierWealthAndTrade     = 1.0f;

            Name = a_oName;  // just a default Value!

            Faction = a_oFaction;
            Planet  = a_oPlanet;


            if (a_oSpecies == null)
            {
                Species = Faction.Species;
            }
            else
            {
                Species = a_oSpecies;
            }
            Planet.Populations.Add(this); // add us to the list of pops on the planet!
            Planet.Position.System.Populations.Add(this);
            Contact = new SystemContact(Faction, this);

            GovernorPresent = false;
            AdminRating     = 0;

            ComponentStockpile       = new BindingList <ComponentDefTN>();
            ComponentStockpileCount  = new BindingList <float>();
            ComponentStockpileLookup = new Dictionary <Guid, int>();
            MissileStockpile         = new Dictionary <OrdnanceDefTN, float>();

            OrbitalTerraformModules = 0.0f;

            PoliticalPopStatus = PoliticalStatus.Imperial;

            for (int InstallationIterator = 0; InstallationIterator < (int)Installation.InstallationType.InstallationCount; InstallationIterator++)
            {
                Installations[InstallationIterator].Number = 0.0f;
            }

            FuelStockpile              = 0.0f;
            MaintenanceSupplies        = 0.0f;
            EMSignature                = 0;
            ThermalSignature           = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing       = 1.0f;
            ModifierProduction         = 1.0f;
            ModifierWealthAndTrade     = 1.0f;
            ModifierPoliticalStability = 1.0f;

            ConstructionBuildQueue = new BindingList <ConstructionBuildQueueItem>();
            MissileBuildQueue      = new BindingList <MissileBuildQueueItem>();
            FighterBuildQueue      = new BindingList <FighterBuildQueueItem>();

            IsRefining = false;

            ShipyardTasks = new Dictionary <Installation.ShipyardInformation.ShipyardTask, Installation.ShipyardInformation>();

            SSEntity = StarSystemEntityType.Population;
        }
Exemplo n.º 17
0
 /// <summary>
 /// Moves the specified contact from the distance table.
 /// </summary>
 /// <param name="contact"></param>
 public void Remove(SystemContact contact)
 {
     m_distances.Remove(contact);
     m_lastUpdateSecond.Remove(contact);
     m_lastUpdateYear.Remove(contact);
 }
Exemplo n.º 18
0
        public ContactElement(GLEffect a_oDefaultEffect, SystemContact a_oContact)
            : base(a_oContact)
        {
            // Create travel Line element:
            m_oTravelLine = new TravelLine(a_oDefaultEffect, a_oContact.faction.FactionColor);
            this.Children.Add(m_oTravelLine);

            _LastSensorUpdateAck = 0;
            _SensorContactElements = new Dictionary<Guid,SensorElement>();
            _DefaultEffect = a_oDefaultEffect;
        }