Esempio n. 1
0
        public PolygonValue GetPolygonValue()
        {
            PolygonValue p = new PolygonValue();

            for (int i = 0; i < xPoints.Count; i++)
            {
                p.points.Add(new PolygonValue.PolygonPoint(xPoints[i], yPoints[i]));
            }

            return p;
        }
Esempio n. 2
0
        private PolygonValue GetFirescoutAORegion()
        {
            if (Firescout_AO == null)
            {
                Firescout_AO = new PolygonValue();
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(39000, 8400));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(125800, 8700));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(126500, 88200));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(109600, 86950));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(93000, 82400));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(79200, 76000));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(66400, 66500));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(55800, 55900));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(45700, 40700));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(40500, 24000));
                Firescout_AO.points.Add(new PolygonValue.PolygonPoint(39000, 8400));
            }

            return Firescout_AO;
        }
Esempio n. 3
0
        private PolygonValue GetBamsAORegion()
        {
            if (BAMS_AO == null)
            {
                BAMS_AO = new PolygonValue();
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(200, 76200));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(0, 8800));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(39100, 8600));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(40500, 24000));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(45700, 40700));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(55800, 55900));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(66400, 66500));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(79200, 76000));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(93000, 82400));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(109600, 86950));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(126500, 88200));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(126200, 103200));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(28900, 103200));
                BAMS_AO.points.Add(new PolygonValue.PolygonPoint(200, 76200));
            }

            return BAMS_AO;
        }
Esempio n. 4
0
        /// <summary>
        /// Takes an xml string, and returns a DataValue object.
        /// Returns null if the xml doesn't represent a DataValue.
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static DataValue XMLDeserialize(string xml)
        {
            Match m = typeregex.Match(xml);
            if (m.Success)
            {
                Group g = m.Groups[1];

                string dataType = g.ToString();
                switch (dataType)
                {
                    case "StringType":
                        StringValue sv = new StringValue();
                        sv.FromXML(xml);
                        return sv;
                    case "DoubleType":
                        DoubleValue dv = new DoubleValue();
                        dv.FromXML(xml);
                        return dv;
                    case "IntegerType":
                        IntegerValue iv = new IntegerValue();
                        iv.FromXML(xml);
                        return iv;
                    case "BooleanType":
                        BooleanValue bv = new BooleanValue();
                        bv.FromXML(xml);
                        return bv;
                    case "LocationType":
                        LocationValue lv = new LocationValue();
                        lv.FromXML(xml);
                        return lv;
                    case "VelocityType":
                        VelocityValue vv = new VelocityValue();
                        vv.FromXML(xml);
                        return vv;
                    case "AttributeCollectionType":
                        AttributeCollectionValue av = new AttributeCollectionValue();
                        av.FromXML(xml);
                        return av;
                    case "CustomAttributesType":
                        CustomAttributesValue cav = new CustomAttributesValue();
                        cav.FromXML(xml);
                        return cav;
                    case "StringListType":
                        StringListValue slv = new StringListValue();
                        slv.FromXML(xml);
                        return slv;
                    case "PolygonType":
                        PolygonValue polyv = new PolygonValue();
                        polyv.FromXML(xml);
                        return polyv;
                    case "StateTableType":
                        StateTableValue stv = new StateTableValue();
                        stv.FromXML(xml);
                        return stv;
                    case "CapabilityType":
                        CapabilityValue cv = new CapabilityValue();
                        cv.FromXML(xml);
                        return cv;
                    case "VulnerabilityType":
                        VulnerabilityValue vv2 = new VulnerabilityValue();
                        vv2.FromXML(xml);
                        return vv2;
                    case "ConeType":
                        ConeValue cv2 = new ConeValue();
                        cv2.FromXML(xml);
                        return cv2;
                    case "SensorType":
                        SensorValue sv2 = new SensorValue();
                        sv2.FromXML(xml);
                        return sv2;
                    case "SensorArrayType":
                        SensorArrayValue sav = new SensorArrayValue();
                        sav.FromXML(xml);
                        return sav;
                    case "EmitterType":
                        EmitterValue ev = new EmitterValue();
                        ev.FromXML(xml);
                        return ev;
                    case "RangeRingDisplayType":
                        RangeRingDisplayValue rrdv = new RangeRingDisplayValue();
                        rrdv.FromXML(xml);
                        return rrdv;
                    case "AttackCollectionType":
                        AttackCollectionValue attCV = new AttackCollectionValue();
                        attCV.FromXML(xml);
                        return attCV;
                    case "WrapperType":
                        WrapperValue wrapper = new WrapperValue();
                        wrapper.FromXML(xml);
                        return wrapper;
                    case "ClassificationDisplayRulesType":
                        ClassificationDisplayRulesValue cdrv = new ClassificationDisplayRulesValue();
                        cdrv.FromXML(xml);
                        return cdrv;
                    default:
                        return null;
                }
            }
            else
            {
                return null;
            }

        }
Esempio n. 5
0
        public static bool DeriveReferenceFromVertexList(String currentReferencePoint, String vertexList, out String referencePoint, out String updatedVertexList)
        {
            referencePoint = "0 0";
            updatedVertexList = vertexList;

            if (vertexList.Trim().Length == 0)
                return false;
            //list is formed as (x, y), (x2, y2), etc
            char[] del = { ' ' };
            string[] pairDel = { ")," };
            String[] refPt = currentReferencePoint.Split(del);
            Vec2D curRefPt = new Vec2D(0, 0);
            if (refPt.Length == 2)
            {
                curRefPt = new Vec2D(Double.Parse(refPt[0].Trim()), Double.Parse(refPt[1].Trim()));
            }
            String[] pair = vertexList.Split(pairDel, StringSplitOptions.RemoveEmptyEntries);
            PolygonValue poly = new PolygonValue();

            double minX = 0, maxX = 0, minY = 0, maxY = 0;
            bool set = false;

            foreach (String p in pair)
            {
                String[] pp = p.Replace('(', ' ').Replace(')', ' ').Split(del, StringSplitOptions.RemoveEmptyEntries);
                double x = Double.Parse(pp[0].Replace(",","").Replace("\r\n","").Trim());
                double y = Double.Parse(pp[1].Replace("\r\n", "").Trim());
                if (pp.Length == 2)
                {
                    if (!set)
                    {
                        minX = maxX = x;
                        minY = maxY = y;
                        set = true;
                    }
                    else
                    {
                        if (x < minX)
                        {
                            minX = x;
                        }
                        else if (x > maxX)
                        {
                            maxX = x;
                        }
                        if (y < minY)
                        {
                            minY = y;
                        }
                        else if (y > maxY)
                        {
                            maxY = y;
                        }
                    }
                    poly.points.Add(new PolygonValue.PolygonPoint(x, y));
                }
                else
                {
                    Console.WriteLine("Something's wrong!");
                }
            }
            Polygon2D p2d = new Polygon2D();
            p2d.FromPolygon(poly);
            if (!Polygon2D.IsPointInside(p2d, curRefPt))
            {
                //find new ref point
                Vec2D tempPt = new Vec2D((maxX + minX) / 2, (maxY + minY) / 2);
                Random r = new Random(DateTime.Now.Millisecond);
                while (!Polygon2D.IsPointInside(p2d, tempPt))
                {
                    double newX = r.NextDouble() * (maxX - minX) + minX;
                    double newY = r.NextDouble() * (maxY - minY) + minY;
                    tempPt = new Vec2D(newX, newY);
                }
                curRefPt = tempPt;
            }
            referencePoint = String.Format("{0} {1}", curRefPt.X, curRefPt.Y);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < poly.points.Count - 1; i++)
            {
                sb.AppendFormat("({0}, {1}), ", poly.points[i].X - curRefPt.X, poly.points[i].Y - curRefPt.Y);
            }
            //then once more for count -1 
            sb.AppendFormat("({0}, {1})", poly.points[poly.points.Count - 1].X - curRefPt.X, poly.points[poly.points.Count - 1].Y - curRefPt.Y);
            updatedVertexList = sb.ToString();

            return true;
        }
Esempio n. 6
0
        //isPirate here refers to the objects we are trying to find, e.g. isPirate = true means find pirates
        private List<SeamateAdapter.DDD.DDDAdapter.SeamateObject> findObjectsInPlay(LocationValue nearby, PolygonValue pirateEntryRegion, T_Groupings grouping, bool isPirate)
        {
            List<DDDAdapter.SeamateObject> vessels = new List<DDDAdapter.SeamateObject>();
            foreach (DDDAdapter.SeamateObject vessel in ddd.GetAllRevealedSeaVessels()) { 
                if (isPirate && vessel.Owner == "Pirate DM" || !isPirate && vessel.Owner == "Merchant DM") { }
                else continue;
                double distance = new Vec2D(vessel.Location).ScalerDistanceTo(new Vec2D(nearby));
                bool inSameEntryRegionAsPirate = false;
                if (pirateEntryRegion != null) 
                    inSameEntryRegionAsPirate = Polygon2D.IsPointInside(new Polygon2D(pirateEntryRegion),new Vec2D(vessel.Location));

                if (grouping == T_Groupings.One && distance < oneGroupingDistance && !inSameEntryRegionAsPirate)
                {
                    vessels.Add(vessel);
                }
                else if (grouping == T_Groupings.Two && distance > twoGroupingDistance && !inSameEntryRegionAsPirate)
                {
                    vessels.Add(vessel);

                }
            }
            return vessels;
        }
Esempio n. 7
0
 /// <summary>
 /// A constructor.
 /// </summary>
 public SimActiveRegion()
 {
     m_shape = new PolygonValue();
 }
Esempio n. 8
0
        /// <summary>
        /// This method receives a ScenCon event, and transforms the
        /// data into a valid SimCore event.  At this point, the 
        /// event is sent out to the network, and received by those
        /// objects subscribing to those types of events.
        /// Parameter:
        /// sendingEvent: A base ScenCon event, using GetType we can
        /// find out what type of event it is, and based on that info
        /// we can create the correct SimCore event to distribute.
        /// <param name="sendingEvent">
        /// <br><B>Sending event</B> is a Dennis style event, whose info gets converted
        /// and packaged in a Gabe styled event, and then added to the outgoing queue.
        /// </br></param>
        /// </summary>
        public static void SendEvent(RootEventType sendingEvent)
        {
            //This will discover the RootEventType's actual Type of event,
            //and then based on that, will break out the information into 
            //a simulation model event, and then putEvent to the NetworkClient
            string eventType;
            eventType = sendingEvent.GetType().Name.ToString();
            SimulationEvent e = null;
            Dictionary<string, DataValue> myAtt;

            switch (eventType)
            {
                case "StartupCompleteNotice":
                    SendStartupCompleteEvent();
                    break;

                /******************New Object Event Type Creation ******************************/
                case "Create_EventType":
                    SendCreateEvent((Create_EventType)sendingEvent);
                    break; //Break from New Event Type

                /******************Move Object Event Type Creation******************************/
                case "Move_EventType":
                    SendMoveEvent((Move_EventType)sendingEvent);
                    break;
                /*****************Update Tag Event Type ***************/
                case "UpdateTagType":
                    SendUpdateTagEvent((UpdateTagType)sendingEvent);
                    break;

                /******************Tick Event Type Creation*************************************/
                case "TickEventType":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "TimeTick");
                    e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);//ConvertInteger(sendingEvent.Timer);
                    e["SimulationTime"] = DataValueFactory.BuildString(((TickEventType)sendingEvent).SimulationTime);
                    latestTick = sendingEvent.Time;
                    server.PutEvent(e);
                    break;

                /******************Attack Object Event Type Creation****************************/
                case "AttackObjectEvent":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "AttackObject");

                    try
                    {
                        e["ObjectID"] = DataValueFactory.BuildString(((AttackObjectEvent)sendingEvent).UnitID);//ConvertString(((AttackObjectEvent)sendingEvent).UnitID);
                        e["TargetObjectID"] = DataValueFactory.BuildString(((AttackObjectEvent)sendingEvent).TargetObjectID);//ConvertString(((AttackObjectEvent)sendingEvent).TargetObjectID);
                        e["CapabilityName"] = DataValueFactory.BuildString(((AttackObjectEvent)sendingEvent).CapabilityName);//ConvertString(((AttackObjectEvent)sendingEvent).CapabilityName);
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);//(sendingEvent.Timer);
                    }
                    catch
                    {
                        throw new Exception("Missing required members of Attack Object Event");
                    }
                    server.PutEvent(e);
                    break;

                /******************Playfield Event Entered *************************************/
                case "PlayfieldEventType":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "Playfield");

                    try
                    {
                        e["MapDataFile"] = DataValueFactory.BuildString(((PlayfieldEventType)sendingEvent).MapFileName);//ConvertString(((PlayfieldEventType)sendingEvent).MapFileName);
                        e["IconLibrary"] = DataValueFactory.BuildString(((PlayfieldEventType)sendingEvent).IconLibrary);//ConvertString(((PlayfieldEventType)sendingEvent).IonLibrary);
                        e["UTMZone"] = DataValueFactory.BuildString(((PlayfieldEventType)sendingEvent).UTMZone); //ConvertString(((PlayfieldEventType)sendingEvent).UTMZone);


                        //e["UTMNorthing"] = DataValueFactory.BuildDouble(((PlayfieldEventType)sendingEvent).VerticalScale);
                        //e["UTMEasting"] = DataValueFactory.BuildDouble(((PlayfieldEventType)sendingEvent).HorizontalScale);
                        e["VerticalScale"] = DataValueFactory.BuildDouble(((PlayfieldEventType)sendingEvent).VerticalScale);
                        e["HorizontalScale"] = DataValueFactory.BuildDouble(((PlayfieldEventType)sendingEvent).HorizontalScale);


                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);//ConvertInteger(sendingEvent.Timer);
                        e["Name"] = DataValueFactory.BuildString(((PlayfieldEventType)sendingEvent).ScenarioName);//ConvertString(((PlayfieldEventType)sendingEvent).ScenarioName);
                        string description = ((PlayfieldEventType)sendingEvent).Description;
                        description = description.Replace("\n", " ");
                        description = description.Replace("\t", " ");
                        e["Description"] = DataValueFactory.BuildString(description);//ConvertString(description);

                        e["DefaultDisplayLabels"] = DataValueFactory.BuildString(((PlayfieldEventType)sendingEvent).DisplayLabels);//ConvertString(description);
                        e["DefaultDisplayTags"] = DataValueFactory.BuildString(((PlayfieldEventType)sendingEvent).DisplayTags);//ConvertString(description);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for Playfield");
                    }
                    server.PutEvent(e);
                    break;

                /******************Decision Maker Entered **************************************/

                case "DecisionMakerType":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "NewObject");
                    myAtt = new Dictionary<string, DataValue>();

                    try
                    {
                        e["ObjectType"] = DataValueFactory.BuildString("DecisionMaker");
                        myAtt.Add("RoleName", DataValueFactory.BuildString(((DecisionMakerType)sendingEvent).Role));
                        myAtt.Add("TeamMember", DataValueFactory.BuildString(((DecisionMakerType)sendingEvent).Team));
                        myAtt.Add("Color", DataValueFactory.BuildInteger(((DecisionMakerType)sendingEvent).Chroma));
                        myAtt.Add("Briefing", DataValueFactory.BuildString(((DecisionMakerType)sendingEvent).Briefing));
                        myAtt.Add("CanTransfer", DataValueFactory.BuildBoolean(((DecisionMakerType)sendingEvent).HasTransferAuthority));
                        myAtt.Add("ReportsTo", DataValueFactory.BuildStringList(((DecisionMakerType)sendingEvent).Supervisors));
                        myAtt.Add("CanForceTransfer", DataValueFactory.BuildBoolean(((DecisionMakerType)sendingEvent).HasForcedTransferAuthority));
                        myAtt.Add("CanChat", DataValueFactory.BuildStringList(((DecisionMakerType)sendingEvent).ChatPartners));
                        myAtt.Add("CanWhiteboard", DataValueFactory.BuildStringList(((DecisionMakerType)sendingEvent).WhiteboardPartners));
                        myAtt.Add("CanSpeak", DataValueFactory.BuildStringList(((DecisionMakerType)sendingEvent).VoicePartners));
                        myAtt.Add("IsObserver", DataValueFactory.BuildBoolean(((DecisionMakerType)sendingEvent).IsObserver));
                        ////myAtt.Add("ComputerControlled", DataValueFactory.BuildBoolean(((DecisionMakerType)sendingEvent).ComputerControlled));
                        myAtt.Add("ComputerControlled", DataValueFactory.BuildBoolean(false));
                        e["ID"] = DataValueFactory.BuildString(((DecisionMakerType)sendingEvent).Identifier);
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);
                        e["Attributes"] = DataValueFactory.BuildAttributeCollection(myAtt);
                        
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for Decision Maker");
                    }
                    server.PutEvent(e);
                    break;

                /*************** Reveal Event Entered ****************************/

                case "Reveal_EventType":
                    SendRevealEvent((Reveal_EventType)sendingEvent);
                    break;

                /*************** Random Seed Event Entered ****************************/
                case "RandomSeedType":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "RandomSeed");
                    try
                    {
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);//ConvertInteger(sendingEvent.Timer);
                        e["SeedValue"] = DataValueFactory.BuildInteger(((RandomSeedType)sendingEvent).seed);//ConvertInteger(((RandomSeedType)sendingEvent).seed);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for Random Seed.");
                    }
                    server.PutEvent(e);
                    break;

                /**********************************Team Definition Event *********************/

                case "TeamType":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "NewObject");

                    try
                    {
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);
                        myAtt = new Dictionary<string, DataValue>();
                        myAtt.Add("TeamName", DataValueFactory.BuildString(((TeamType)sendingEvent).Name));
                        List<string> hostilities = new List<string>();
                        for (int x = 0; x < ((TeamType)sendingEvent).Count(); x++)
                        {
                            hostilities.Add(((TeamType)sendingEvent)[x]);
                        }
                        StringListValue listOfHostiles = new StringListValue();
                        listOfHostiles.strings = hostilities;
                        myAtt.Add("TeamHostility", (DataValue)listOfHostiles);
                        e["Attributes"] = DataValueFactory.BuildAttributeCollection(myAtt);
                        e["ID"] = DataValueFactory.BuildString(((TeamType)sendingEvent).Name);
                        e["ObjectType"] = DataValueFactory.BuildString("Team");
                        //e["StateTable"] = DataValueFactory.BuildString(string.Empty);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for Team definition.");
                    }
                    server.PutEvent(e);
                    break;

                /**********************************Network Definition Event *********************/

                case "NetworkType":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "NewObject");

                    try
                    {
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);
                        myAtt = new Dictionary<string, DataValue>();
                        List<string> members = new List<string>();
                        for (int x = 0; x < ((NetworkType)sendingEvent).Count(); x++)
                        {
                            members.Add(((NetworkType)sendingEvent)[x]);
                        }
                        StringListValue listOfMembers = new StringListValue();
                        listOfMembers.strings = members;
                        myAtt.Add("DMMembers", (DataValue)listOfMembers);
                        e["Attributes"] = DataValueFactory.BuildAttributeCollection(myAtt);
                        e["ID"] = DataValueFactory.BuildString(((NetworkType)sendingEvent).Name);
                        e["ObjectType"] = DataValueFactory.BuildString("SensorNetwork");
                        //e["StateTable"] = DataValueFactory.BuildString(string.Empty);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for Network definition.");
                    }
                    server.PutEvent(e);
                    break;

                /******************* Region Definition ********************************************/

                case "RegionEventType":
 
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "NewObject");

                    try
                    {
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);
                        myAtt = new Dictionary<string, DataValue>();
                        List<PolygonValue.PolygonPoint> listOfPoints = new List<PolygonValue.PolygonPoint>();
                        PolygonValue.PolygonPoint point;
                        foreach (PointType pt in ((RegionEventType)sendingEvent).Vertices)
                        {
                            point = new PolygonValue.PolygonPoint(pt.X, pt.Y);
                            listOfPoints.Add(point);
                        }
                        PolygonValue pointsList = new PolygonValue();
                        pointsList.points = listOfPoints;
                        myAtt.Add("Polygon", (DataValue)pointsList);
                        e["ObjectType"] = DataValueFactory.BuildString("LandRegion");
                        if (((RegionEventType)sendingEvent).End != null)
                        {
                            myAtt.Add("EndHeight", DataValueFactory.BuildDouble((double)((RegionEventType)sendingEvent).End));
                            e["ObjectType"] = DataValueFactory.BuildString("ScoringRegion");
                        }
                        if (((RegionEventType)sendingEvent).Start != null)
                        {
                            myAtt.Add("StartHeight", DataValueFactory.BuildDouble((double)((RegionEventType)sendingEvent).Start));
                        }

                        if (((RegionEventType)sendingEvent).ReferencePoint != null) {
                            PointType refPoint = ((RegionEventType)sendingEvent).ReferencePoint;
                            myAtt.Add("ReferencePoint", DataValueFactory.BuildLocation(refPoint.X,refPoint.Y,0,true));
                        }

                        if (((RegionEventType)sendingEvent).IsDynamicRegion != null)
                        {
                       
                            myAtt.Add("IsDynamicRegion", DataValueFactory.BuildBoolean((bool)((RegionEventType)sendingEvent).IsDynamicRegion));
                        }

                        if (((RegionEventType)sendingEvent).SpeedMultiplier != null)
                        {
                            myAtt.Add("SpeedMultiplier", DataValueFactory.BuildDouble((double)((RegionEventType)sendingEvent).SpeedMultiplier));
                            e["ObjectType"] = DataValueFactory.BuildString("ActiveRegion");
                        }
                        if (((RegionEventType)sendingEvent).BlocksMovement != null)
                        {
                            myAtt.Add("BlocksMovement", DataValueFactory.BuildBoolean((Boolean)((RegionEventType)sendingEvent).BlocksMovement));
                        }
                        //if (((RegionEventType)sendingEvent).BlocksMovement != null)
                        //{
                        //    myAtt.Add("BlocksMovement", DataValueFactory.BuildBoolean((Boolean)((RegionEventType)sendingEvent).BlocksMovement));
                        //}


                        List<string> sensorsBlocked = new List<string>();
                        if (
                            (((RegionEventType)sendingEvent).SensorsBlocked != null)
                            &&
                            (((RegionEventType)sendingEvent).SensorsBlocked.Count > 0))
                        {
                            //                string sensorBlocked;
                            for (int sensor = 0; sensor < ((RegionEventType)sendingEvent).SensorsBlocked.Count; sensor++)
                            {

                                sensorsBlocked.Add(((RegionEventType)sendingEvent).SensorsBlocked[sensor]);
                            }

                        }
                        StringListValue mySensorsBlocked = new StringListValue();
                        mySensorsBlocked.strings = sensorsBlocked;
                        myAtt.Add("BlocksSensorTypes", (DataValue)mySensorsBlocked);

                        myAtt.Add("IsVisible", DataValueFactory.BuildBoolean((Boolean)((RegionEventType)sendingEvent).IsVisible));
                        myAtt.Add("IsActive", DataValueFactory.BuildBoolean((Boolean)((RegionEventType)sendingEvent).IsActive));
 
                        myAtt.Add("DisplayColor", DataValueFactory.BuildInteger((int)((RegionEventType)sendingEvent).Chroma));
                        try
                        {
                            if (((RegionEventType)sendingEvent).ObstructedViewImage != "" && ((RegionEventType)sendingEvent).ObstructedViewImage != null)
                            {
                                myAtt.Add("ObstructedViewImage", DataValueFactory.BuildString(((RegionEventType)sendingEvent).ObstructedViewImage));
                            }
                        }catch(Exception ex)
                        {}
                        try
                        { 
                            myAtt.Add("ObstructionOpacity", DataValueFactory.BuildString(((RegionEventType)sendingEvent).ObstructionOpacity.ToString()));
                        }catch(Exception ex2)
                        {}

                        //e["BlocksSensorTypes"]=
                        e["ID"] = DataValueFactory.BuildString(((RegionEventType)sendingEvent).UnitID);
                        e["Attributes"] = DataValueFactory.BuildAttributeCollection(myAtt);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for Region definition");
                    }
                    server.PutEvent(e);

                    break;

                case "ActiveRegionUpdateType":
                    SendActiveRegionUpdateEvent((ActiveRegionUpdateType)sendingEvent);
                    break;
                case "WeaponLaunch_EventType":
                    SendWeaponLaunchEvent((WeaponLaunch_EventType)sendingEvent);
                    break;
                case "WeaponLaunchFailure_EventType":
                    SendWeaponLaunchFailureEvent((WeaponLaunchFailure_EventType)sendingEvent);
                    break;
                case "LaunchEventType":
                    SendLaunchEvent((LaunchEventType)sendingEvent);
                    break;
                case "WeaponLaunchEventType":
                    SendWeaponLaunchEvent((WeaponLaunchEventType)sendingEvent);
                    break;
                case "SubplatformLaunchType":
                    SendSubplatformLaunchEvent((SubplatformLaunchType)sendingEvent);
                    break;
                case "SubplatformDockType":
                    SendSubplatformDockEvent((SubplatformDockType)sendingEvent);
                    break;
                case "StateChangeEvent":
                    SendStateChangeEvent((StateChangeEvent)sendingEvent);
                    break;
                case "OpenChatRoomType":
                    SendOpenChatRoomEvent((OpenChatRoomType)sendingEvent);
                    break;
                case "CloseChatRoomType":
                    SendCloseChatRoomType((CloseChatRoomType)sendingEvent);
                    break;
                case "OpenWhiteboardRoomType":
                    SendOpenWhiteboardRoomEvent((OpenWhiteboardRoomType)sendingEvent);
                    break;
                case "OpenVoiceChannelType":
                    SendOpenVoiceChannelEvent((OpenVoiceChannelType)sendingEvent);
                    break;
                case "CloseVoiceChannelType":
                    SendCloseVoiceChannelType((CloseVoiceChannelType)sendingEvent);
                    break;
                    /*
                case "GrantVoiceAccessType":
                    SendAddToVoiceChannelEvent((GrantVoiceAccessType)sendingEvent);
                    break;
                case "RemoveVoiceAccessType":
                    SendRemoveFromVoiceChannelEvent((RemoveVoiceAccessType)sendingEvent);
                    break;
                    
                case "CreateChatRoomFailureType":
                    SendCreateChatRoomFailureType((CreateChatRoomFailureType)sendingEvent);
                    break;*/
                case "TransferEvent":
                    SendTransferEvent((TransferEvent)sendingEvent);
                    break;
                    case "EngramSettingType":
                    SendEngramValue(((EngramSettingType)sendingEvent));
                    break;
                case "ChangeEngramType":
                    SendEngramValue(((ChangeEngramType)sendingEvent));
                    break;
                case "ClientSideAssetTransferType":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "ClientSideAssetTransferAllowed");
                    try
                    {
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);//ConvertInteger(sendingEvent.Timer);
                        e["EnableAssetTransfer"] = DataValueFactory.BuildBoolean(((ClientSideAssetTransferType)sendingEvent).assetTransferEnabled);//ConvertInteger(((RandomSeedType)sendingEvent).seed);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for ClientSideAssetTransferType");
                    }
                    server.PutEvent(e);
                    break;
                case "ClientSideStartingLabelVisibleType":
                    /* AD: TODO
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "ClientSideAssetTransferAllowed");
                    try
                    {
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);//ConvertInteger(sendingEvent.Timer);
                        e["EnableAssetTransfer"] = DataValueFactory.BuildBoolean(((ClientSideAssetTransferType)sendingEvent).assetTransferEnabled);//ConvertInteger(((RandomSeedType)sendingEvent).seed);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for ClientSideAssetTransferType");
                    }
                    server.PutEvent(e);
                     */
                    break;
                case "ClientSideRangeRingVisibilityType":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "ClientSideRangeRingDisplayLevel");
                    try
                    {
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);
                        e["Value"] = DataValueFactory.BuildString(((ClientSideRangeRingVisibilityType)sendingEvent).clientSideRangeRingVisibility);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for ClientSideRangeRingVisibilityType");
                    }
                    server.PutEvent(e);
                    break;
                case "SendChatMessageType":
                    SendChatMessageType scm = (SendChatMessageType)sendingEvent;
                    /* Done in Timer...  
                       * if (!ChatRooms.IsRoom(scm.RoomName))
                           break;  */

                    try
                    {
                        e = SimulationEventFactory.BuildEvent(ref simModelInfo, "TextChatRequest");
                        e["ChatBody"] = DataValueFactory.BuildString(scm.Message);
                        e["UserID"] = DataValueFactory.BuildString(scm.Sender);
                        e["TargetUserID"] = DataValueFactory.BuildString(scm.RoomName);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for SendChatMessage");
                    }
                    server.PutEvent(e);

                    break;
                case "SendVoiceMessageType":
                    SendVoiceMessageType svm = (SendVoiceMessageType)sendingEvent;
                    try
                    {
                        e = SimulationEventFactory.BuildEvent(ref simModelInfo, "PlayVoiceMessage");
                        e["Channel"] = DataValueFactory.BuildString(svm.ChannelName);
                        e["File"] = DataValueFactory.BuildString(svm.FilePath);
                        e["Time"] = DataValueFactory.BuildInteger(svm.Time);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for SendVoiceMessage");
                    }
                    server.PutEvent(e);

                    break;

                case "SendVoiceMessageToUserType":
                    SendVoiceMessageToUserType svmtu = (SendVoiceMessageToUserType)sendingEvent;
                    try
                    {
                        e = SimulationEventFactory.BuildEvent(ref simModelInfo, "PlayVoiceMessageToUser");
                        e["DecisionMakerID"] = DataValueFactory.BuildString(svmtu.DecisionMakerID);
                        e["File"] = DataValueFactory.BuildString(svmtu.FilePath);
                        e["Time"] = DataValueFactory.BuildInteger(svmtu.Time);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for SendVoiceMessageToUser");
                    }
                    server.PutEvent(e);

                    break;

                case "SystemMessage":
                    SystemMessage sm = (SystemMessage)sendingEvent;
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "SystemMessage");
                    e["PlayerID"] = DataValueFactory.BuildString(sm.Addressee);
                    e["Message"] = DataValueFactory.BuildString(sm.Message);
                    e["TextColor"] = DataValueFactory.BuildInteger(sm.TextColor);
                    e["DisplayMode"] = DataValueFactory.BuildString(sm.DisplayMode);
                    server.PutEvent(e);
                    break;

                case "ClassificationsType":
                    e = SimulationEventFactory.BuildEvent(ref simModelInfo, "InitializeClassifications");
                    try
                    {
                        e["Time"] = DataValueFactory.BuildInteger(sendingEvent.Time);
                        e["Classifications"] = DataValueFactory.BuildStringList(((ClassificationsType)sendingEvent).classifications);
                    }
                    catch
                    {
                        throw new Exception("Missing a required attribute for ClientSideRangeRingVisibilityType");
                    }
                    server.PutEvent(e);
                    break;
                case "ForkReplayEventType":
                    server.PutEvent(((ForkReplayEventType)sendingEvent).Event);
                    break;
                /******************No valid event entered***************************************/
                /******************Very Basic Event Type Creation*******************************/
                case "RootEventType":
                    throw new Exception("RootEventType events should not be created");

                /******************Base Scenario Event Type Creation****************************/
                case "ScenarioEventType":
                    throw new Exception("ScenarioEventType events should not be created");  
                default:
                    //What should it do in this case? Nothing?
                    Console.Out.Write("In EventCommunicator: Missing event type to send: " + eventType);
                    break;
            }
        }
Esempio n. 9
0
 public PolygonValue GetWholeScreenMinusSomalia()
 {
     if (WholeScreenMinusSomalia == null)
     {
         WholeScreenMinusSomalia = new PolygonValue();
         WholeScreenMinusSomalia.points.Add(new PolygonValue.PolygonPoint(133, 75433));
         WholeScreenMinusSomalia.points.Add(new PolygonValue.PolygonPoint(28933, 102900));
         WholeScreenMinusSomalia.points.Add(new PolygonValue.PolygonPoint(126666, 103300));
         WholeScreenMinusSomalia.points.Add(new PolygonValue.PolygonPoint(126533, 8633));
         WholeScreenMinusSomalia.points.Add(new PolygonValue.PolygonPoint(-133, 8633));
         WholeScreenMinusSomalia.points.Add(new PolygonValue.PolygonPoint(133, 75433));
     }
     return WholeScreenMinusSomalia;
 }
Esempio n. 10
0
 public void FromPolygon(PolygonValue p)
 {
     this.xPoints.Clear();
     this.yPoints.Clear();
     foreach (PolygonValue.PolygonPoint pp in p.points)
     {
         this.AddVertex(new Vec2D(pp.X, pp.Y));
     }
 }
Esempio n. 11
0
 public Polygon2D(PolygonValue value)
 {
     this.FromPolygon(value);
 }
Esempio n. 12
0
        public static Vec2D FindIntersect(PolygonValue poly1, PolygonValue poly2)
        {
            List<Vec2D> intersections = new List<Vec2D>(); //with polys, we might have 2 intersections, should we find the middle of the two?
            List<PolygonValue.PolygonPoint> p2Points = poly2.points;
            Vec2D intersect = null;
            Polygon2D p2d = new Polygon2D();
            PolygonValue.PolygonPoint p0;
            PolygonValue.PolygonPoint p1;
            p2d.FromPolygon(poly1);
            for (int i = 0; i < p2Points.Count - 1; i++)
            {

                p0 = p2Points[i];
                p1 = p2Points[i + 1];
                intersect = FindIntersect(p2d, new Vec2D(p0.X, p0.Y), new Vec2D(p1.X, p1.Y));
                if (intersect != null)
                    intersections.Add(intersect);
            }
            //then once more from len-1 to 0
            p0 = p2Points[p2Points.Count - 1];
            p1 = p2Points[0];
            intersect = FindIntersect(p2d, new Vec2D(p0.X, p0.Y), new Vec2D(p1.X, p1.Y));
            //intersect = FindIntersect(poly1, p2Points[p2Points.Count - 1], p2Points[0]);
            if (intersect != null)
                intersections.Add(intersect);

            if (intersections.Count > 0)
                return AverageVectors(intersections);

            return null;
        }