Beispiel #1
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);
 }
Beispiel #2
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:
                oContactElement          = new ContactElement(a_oDefaultEffect, oContact);
                oContactElement.EntityID = oContact.Id;

                v3ContactPos = new Vector3((float)oContact.TaskGroup.Contact.XSystem, (float)oContact.TaskGroup.Contact.YSystem, 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, oContact.TaskGroup.Name);

                oContactElement.Lable            = oNameLable;
                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:
                oContactElement          = new ContactElement(a_oDefaultEffect, oContact);
                oContactElement.EntityID = oContact.Id;

                v3ContactPos = new Vector3((float)oContact.MissileGroup.contact.XSystem, (float)oContact.MissileGroup.contact.YSystem, 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, oContact.MissileGroup.Name);

                oContactElement.Lable            = oNameLable;
                oContactElement.PrimaryPrimitive = oContactQuad;
                oContactElement.AddPrimitive(oContactQuad);
                oContactElement.RealSize = new Vector2(0.0001f, 0.0001f);
                this.AddElement(oContactElement);
                (oContactElement as ContactElement).ParentSceen = this;
                break;
            }

            oContact.ContactElementCreated = SystemContact.CEState.Created;
        }
Beispiel #3
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;
        }
Beispiel #4
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;
         }
     }
 }
Beispiel #5
0
        public ActionResult Contact(SystemContact model)
        {
            // Make this internal and use a canned view model to make it happen (public email service should be canned)???
            // i.e. Cohort.Send(Email.Contact, model);
            _emailService.Send("Contact", new
            {
                // From the system
                To      = Cohort.Site.Email.FromAddress,         // This should be to any recipients in the recipient list
                From    = Cohort.Site.Email.FromAddress,
                Subject = Cohort.Site.Email.ContactSubject,

                // From the contacter
                model.ContactMessage,
                model.ContactSubject,
                model.ContactEmail
            });
            return(View());
        }
Beispiel #6
0
        /// <summary>
        /// Constructor for missile groups.
        /// </summary>
        /// <param name="LaunchedFrom">TG this launched from. additional missiles may be added this tick but afterwards no more.</param>
        /// <param name="Missile">Initial missile that prompted the creation of this ordnance group.</param>
        /// <param name="MissileTarget">The target this group is aimed at.</param>
        public OrdnanceGroupTN(TaskGroupTN LaunchedFrom, OrdnanceTN Missile)
        {
            Name = String.Format("Ordnance Group #{0}", LaunchedFrom.TaskGroupFaction.MissileGroups.Count);
            Id = Guid.NewGuid();
            if (LaunchedFrom.IsOrbiting == true)
            {
                LaunchedFrom.GetPositionFromOrbit();
            }

            SSEntity = StarSystemEntityType.Missile;

            Position.X = LaunchedFrom.Contact.Position.X;
            Position.Y = LaunchedFrom.Contact.Position.Y;

            Contact = new SystemContact(LaunchedFrom.TaskGroupFaction, this);

            Missiles = new BindingList<OrdnanceTN>();

            /// <summary>
            /// Missile Detection Statistics:
            /// This is the first missile so created, so it is in spot 0.
            /// </summary>
            Missile.ThermalDetection = new BindingList<int>();
            Missile.EMDetection = new BindingList<int>();
            Missile.ActiveDetection = new BindingList<int>();

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

            OrdnanceGroupFaction = LaunchedFrom.TaskGroupFaction;

            Contact.Position.System = LaunchedFrom.Contact.Position.System;
            LaunchedFrom.Position.System.SystemContactList.Add(Contact);
            DrawTravelLine = 0;

            ShipsTargetting = new BindingList<ShipTN>();


            Missiles.Add(Missile);
            Missile.missileGroup = this;

            MissilesDestroyed = 0;

            OrdGroupsTargetting = new BindingList<OrdnanceGroupTN>();

            /// <summary>
            /// Tell the sensor contact element to determine what if any sensors should be displayed.
            /// </summary>
            _SensorUpdateAck = 1;
        }
Beispiel #7
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;
            }
        }
Beispiel #8
0
        /// <summary>
        /// Intercept target calculates whether the current CIWS can hit this incoming missile, and how many shots that would take.
        /// </summary>
        /// <param name="RNG">RNG passed from caller, this should be the one in _SE_ ultimately.</param>
        /// <param name="OrdnanceSpeed">Speed of incoming missile, this and tracking are the only determinants here</param>
        /// <returns></returns>
        public bool InterceptTarget(Random RNG, float OrdnanceSpeed, Faction ShipFaction, SystemContact Contact)
        {
            /// <summary>
            /// Can this CIWS fire?
            /// </summary>
            bool CIWSFired = FireCIWS();

            if (CIWSFired == false)
            {
                return(false);
            }

            /// <summary>
            /// Calculate the chance that this CIWS can intercept the given target.
            /// </summary>
            float InterceptChance = ((float)CIWSDef.tracking / OrdnanceSpeed);

            if (InterceptChance >= 1.0f)
            {
                InterceptChance = 50.0f;
            }
            else
            {
                InterceptChance = InterceptChance * 50.0f; // 0.5f * 100.0f
            }

            /// <summary>
            /// If this CIWS can fire this will be true, loop until either the hit is "made" or this CIWS runs out of shots.
            /// </summary>
            while (CIWSFired)
            {
                ushort Hit = (ushort)RNG.Next(1, 100);
                if (InterceptChance >= (float)Hit)
                {
                    String       Entry = String.Format("CIWS {0} Fired at 10,000 km and hit.", Name);
                    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("CIWS {0} Fired at 10,000 km and missed.", Name);
                    MessageEntry Msg   = new MessageEntry(MessageEntry.MessageType.FiringMissed, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                          GameState.Instance.LastTimestep, Entry);
                    ShipFaction.MessageLog.Add(Msg);
                }

                CIWSFired = FireCIWS();
            }
            return(false);
        }