Example #1
0
        private void SendOutScenarioInfo(string playerID, string terminalID)
        {
            SimulationEvent e = SimulationEventFactory.BuildEvent(ref simModelInfo, "HandshakeInitializeGUI");

            e["PlayerID"] = DataValueFactory.BuildString(playerID);
            //e["TerminalID"] = DataValueFactory.BuildString(dmToTerminalMap[playerID]);
            e["TerminalID"]               = DataValueFactory.BuildString(terminalID);
            e["ScenarioInfo"]             = DataValueFactory.BuildString("BASIC SCENARIO INFO **PLACEHOLDER**");
            e["ScenarioName"]             = DataValueFactory.BuildString(scenarioName);
            e["ScenarioDescription"]      = DataValueFactory.BuildString(scenarioDescription);
            e["MapName"]                  = DataValueFactory.BuildString(mapName);
            e["UTMNorthing"]              = DataValueFactory.BuildDouble(northing);
            e["UTMEasting"]               = DataValueFactory.BuildDouble(easting);
            e["HorizontalPixelsPerMeter"] = DataValueFactory.BuildDouble(horizMetersPerPixel);
            e["VerticalPixelsPerMeter"]   = DataValueFactory.BuildDouble(vertMetersPerPixel);
            e["PlayerBrief"]              = DataValueFactory.BuildString(allDMs[playerID].briefing);
            e["IconLibrary"]              = DataValueFactory.BuildString(iconLibrary);
            e["VoiceChatEnabled"]         = DataValueFactory.BuildBoolean(voiceChatEnabled);
            e["VoiceChatServerName"]      = DataValueFactory.BuildString(voiceChatServerName);
            e["VoiceChatServerPort"]      = DataValueFactory.BuildInteger(voiceChatServerPort);
            e["VoiceChatUserPassword"]    = DataValueFactory.BuildString(voiceChatPassword);
            e["IsObserver"]               = DataValueFactory.BuildBoolean(allDMs[playerID].isObserver);
            e["IsForkReplay"]             = DataValueFactory.BuildBoolean(isForkReplay);
            e["DefaultDisplayLabels"]     = DataValueFactory.BuildString(displayLabels);
            e["DefaultDisplayTags"]       = DataValueFactory.BuildString(displayTags);

            server.PutEvent(e);
        }
Example #2
0
        private void btnOpenVoice_Click(object sender, EventArgs e)
        {
            if (null == lbxDecisionMakers.SelectedItem)
            {
                MessageBox.Show("Please select an owner for the voice channel.");
                return;
            }
            if ((null == lbxVoiceMembers.SelectedItems) || (lbxVoiceMembers.SelectedItems.Count < 2))
            {
                MessageBox.Show("Please select at least two members for the voice channel.");
                return;
            }
            if ("" == txtOpenVoiceName.Text)
            {
                MessageBox.Show("Please provide a name for the voice channel.");
                return;
            }
            SimulationEvent openVoice = SimulationEventFactory.BuildEvent(ref simModelInfo, "RequestVoiceChannelCreate");

            openVoice["ChannelName"] = DataValueFactory.BuildString(txtOpenVoiceName.Text);
            openVoice["SenderDM_ID"] = DataValueFactory.BuildString((string)lbxDecisionMakers.SelectedItem);
            StringListValue voiceMembers = new StringListValue();

            for (int i = 0; i < lbxVoiceMembers.SelectedItems.Count; i++)
            {
                voiceMembers.strings.Add((string)lbxVoiceMembers.SelectedItems[i]);
            }
            openVoice["MembershipList"] = DataValueFactory.BuildFromDataValue(voiceMembers);
            EventListener.Network.PutEvent(openVoice);
        }
Example #3
0
        /// <summary>
        /// This method will send out a ViewProInitializeObject event to a specific client.
        /// This event will have that player add this object to their playfield.  Once the
        /// object is in the playfield, it is able to be interacted with.
        /// </summary>
        /// <param name="targetPlayerID">Unique ID of the player recieving this event.</param>
        /// <param name="objectID">Unique ID of the object being revealed.</param>
        /// <param name="location">Location at which to display this object.</param>
        /// <param name="iconName">Icon file name used to display to user.</param>
        /// <param name="ownerID">Unique ID of the owner of the object.</param>
        private void SendViewProInitializeObject(string targetPlayerID, string objectID, LocationValue location, string iconName, string ownerID, bool isWeapon)
        {
            if (!activeDMs.Contains(targetPlayerID))
            {
                return;
            }
            if (!location.exists)
            {
                return;
            }

            SimulationEvent initEvent = SimulationEventFactory.BuildEvent(ref simModel, "ViewProInitializeObject");

            initEvent["Time"]         = DataValueFactory.BuildInteger(currentTick);
            initEvent["TargetPlayer"] = DataValueFactory.BuildString(targetPlayerID);
            initEvent["ObjectID"]     = DataValueFactory.BuildString(objectID);
            initEvent["Location"]     = location;
            initEvent["OwnerID"]      = DataValueFactory.BuildString(ownerID);
            initEvent["IsWeapon"]     = DataValueFactory.BuildBoolean(isWeapon);
            initEvent["LabelColor"]   = DataValueFactory.BuildInteger(dmColorMapping[ownerID]);

            String classification = GetClassificationForDM(objectID, targetPlayerID);
            String overrideIcon   = GetClassificationBasedIcon(objectID, classification);

            initEvent["CurrentClassification"] = DataValueFactory.BuildString(classification);
            if (overrideIcon != String.Empty)
            {
                initEvent["IconName"] = DataValueFactory.BuildString(overrideIcon);
            }
            else
            {
                initEvent["IconName"] = DataValueFactory.BuildString(iconName);
            }
            distClient.PutEvent(initEvent);
        }
Example #4
0
        /// <summary>
        /// This event is broadcast out to each client.  That client will attempt to put the object in motion, but will only
        /// succeed if the object already exists in its playfield.
        /// </summary>
        /// <param name="objectID"></param>
        /// <param name="ownerID"></param>
        /// <param name="location"></param>
        /// <param name="desLocation"></param>
        /// <param name="maxSpeed"></param>
        /// <param name="throttle"></param>
        /// <param name="time"></param>
        /// <param name="iconName"></param>
        /// <param name="isWeapon"></param>
        private void SendViewProMotionUpdate(string objectID, string ownerID, LocationValue location, LocationValue desLocation, double maxSpeed, double throttle, string iconName, bool isWeapon, double activeRegionSpeedMultiplier)
        {
            SimulationEvent vpmu = null;

            vpmu = SimulationEventFactory.BuildEvent(ref simModel, "ViewProMotionUpdate");

            vpmu["ObjectID"]            = DataValueFactory.BuildString(objectID);
            vpmu["OwnerID"]             = DataValueFactory.BuildString(ownerID);
            vpmu["Location"]            = location;
            vpmu["DestinationLocation"] = desLocation;
            //if (objectID == "Fighter01_Troop_2")
            //{
            //    Console.Out.Write(String.Format("\n{0} is moving at {1}*{2}\n", objectID, maxSpeed, activeRegionSpeedMultiplier));
            //}
            vpmu["MaximumSpeed"] = DataValueFactory.BuildDouble(maxSpeed * activeRegionSpeedMultiplier);
            vpmu["Throttle"]     = DataValueFactory.BuildDouble(throttle);
            vpmu["Time"]         = DataValueFactory.BuildInteger(currentTick);
            vpmu["IconName"]     = DataValueFactory.BuildString(iconName);
            //add label color to the mix
            vpmu["LabelColor"] = DataValueFactory.BuildInteger(dmColorMapping[ownerID]);
            vpmu["IsWeapon"]   = DataValueFactory.BuildBoolean(isWeapon);
            distClient.PutEvent(vpmu);
            if (!movingObjects.Contains(objectID) &&
                !DataValueFactory.CompareDataValues(location, desLocation))
            {
                movingObjects.Add(objectID);
            }
        }
Example #5
0
        public override SimulationEvent ToSimulationEvent(ref SimulationModelInfo simModel)
        {
            SimulationEvent          ev         = SimulationEventFactory.BuildEvent(ref simModel, EVENTTYPE);
            AttributeCollectionValue attributes = new AttributeCollectionValue();

            attributes.attributes.Add("Location", this.Location);
            attributes.attributes.Add("State", DataValueFactory.BuildString(this.State));

            if (ObjectType != null && ObjectType != String.Empty)
            {
                attributes.attributes.Add("ClassName", DataValueFactory.BuildString(ObjectType));
            }
            if (OwnerID != null && OwnerID != String.Empty)
            {
                attributes.attributes.Add("OwnerID", DataValueFactory.BuildString(OwnerID));
            }

            if (StartupParameters != null)
            {
                foreach (String s in StartupParameters.Keys)
                {
                    attributes.attributes.Add(s, StartupParameters[s]);
                }
            }


            //do stuff
            ((StringValue)ev["ObjectID"]).value = this.ObjectID;
            ev["Attributes"] = attributes;



            return(ev);
        }
Example #6
0
        private void RevealObject(SimulationEvent e)
        {
            String objectID             = ((StringValue)e["ObjectID"]).value;
            SimulationObjectProxy proxy = objectProxies[objectID];

            //initialize values for times to -1
            proxy["DetectTime"].SetDataValue(DataValueFactory.BuildInteger(-1));
            proxy["IdentifyTime"].SetDataValue(DataValueFactory.BuildInteger(-1));
            proxy["TrackingTime"].SetDataValue(DataValueFactory.BuildInteger(-1));
            proxy["DestroyedTime"].SetDataValue(DataValueFactory.BuildInteger(-1));
            proxy["HostileActionTime"].SetDataValue(DataValueFactory.BuildInteger(-1));
            proxy["GroundTruthIFF"].SetDataValue(DataValueFactory.BuildString("Unknown"));
            proxy["UserClassifiedIFF"].SetDataValue(DataValueFactory.BuildString("Unknown"));
            proxy["RevealTime"].SetDataValue(DataValueFactory.BuildInteger(time));
            proxy["TrackedBy"].SetDataValue(DataValueFactory.BuildString(""));

            if (((AttributeCollectionValue)e["Attributes"]).attributes.ContainsKey("DefaultClassification"))
            {
                //has IFF on
                String iff = ((StringValue)((AttributeCollectionValue)e["Attributes"]).attributes["DefaultClassification"]).value;
                proxy["GroundTruthIFF"].SetDataValue(DataValueFactory.BuildString(iff));
                proxy["UserClassifiedIFF"].SetDataValue(DataValueFactory.BuildString(iff));
            }
            else
            {
                String owner = ((StringValue)proxy["OwnerID"].GetDataValue()).value;
                if (owner.ToLower().Contains("pirate"))
                {
                    proxy["GroundTruthIFF"].SetDataValue(DataValueFactory.BuildString("Suspect"));
                }
            }
            proxy["IsInSeaLane"].SetDataValue(DataValueFactory.BuildBoolean(false));
            proxy["IsGoingTowardsPort"].SetDataValue(DataValueFactory.BuildBoolean(false));
        }
Example #7
0
        private void ClickHandler(SimulationEvent e)
        {
            String objectID = ((StringValue)e["ObjectID"]).value;
            String dmID     = ((StringValue)e["UserID"]).value;

            if (objectID == string.Empty)
            {
                return;//weird edge case
            }
            if (objectProxies.Count == 0)
            {
                return; //another weird edge case
            }
            SimulationObjectProxy proxy = objectProxies[objectID];

            //AD: TODO Need to only set this if the target object's Item belongs to the clicking DM
            //TODO": add attributes for onCourse, onLocation, booleans for if the objects are in the correct regions and moving towards the correct regions

            if (DMAssignedAsset(dmID, objectID) || IndividualDMIsLoggedIn)
            {
                if (((IntegerValue)proxy["DetectTime"].GetDataValue()).value != -1)
                {
                    return;
                }
                else
                {
                    proxy["DetectTime"].SetDataValue(DataValueFactory.BuildInteger(time));
                    proxy["DetectedBy"].SetDataValue(DataValueFactory.BuildString(((StringValue)e["UserID"]).value));
                }
            }
        }
Example #8
0
        public static void Tick(int tick)
        {
            if (tick > nextEventAt + 2000)
            {
                nextEventAt = tick + 1000 * (randInt(13, 37));
                simModel    = modelReader.readModel("C:\\Program Files\\Aptima\\DDD 4.0\\Client\\SimulationModel.xml");
            }
            else if (Math.Truncate(tick / 1000.0) == Math.Truncate(nextEventAt / 1000.0))
            {// do something now
                // first update nextEventTime
                nextEventAt += 1000 * randInt(3, 20);
                if (allUnits.Keys.Count > 0)
                {
                    string[] keyArray = new string[allUnits.Keys.Count];
                    allUnits.Keys.CopyTo(keyArray, 0);
                    string          unitToUse = keyArray[randInt(keyArray.Length)];
                    SimulationEvent simEvent;
                    switch (randInt(2))
                    {
                    case 0:    //move a unit
                        Location whereToGo = allUnits[unitToUse].newLocation();
                        Console.WriteLine("Moving " + unitToUse + " from (" + allUnits[unitToUse].position.X + "," + allUnits[unitToUse].position.Y + ") to (" + whereToGo.X.ToString() + "," + whereToGo.Y.ToString() + ")");


                        // Generate a moveObject request
                        simEvent                        = SimulationEventFactory.BuildEvent(ref simModel, "MoveObjectRequest");
                        simEvent["UserID"]              = DataValueFactory.BuildString("red dm");
                        simEvent["ObjectID"]            = DataValueFactory.BuildString(unitToUse);
                        simEvent["DestinationLocation"] = DataValueFactory.BuildLocation((double)whereToGo.X, (double)whereToGo.Y, 0.0, true);
                        simEvent["Throttle"]            = DataValueFactory.BuildDouble(randInt(75, 101) / 100.0);
                        simEvent["Time"]                = DataValueFactory.BuildInteger(tick + 3000);// '+3000" is not magic -- just a clumsy attempt to avoid a race condition
                        EventGetter.Network.PutEvent(simEvent);
                        break;

                    case 1:     //attack a unit

                        string myTarget = Target.GetRandom();
                        if ("" != myTarget)
                        {
                            Console.WriteLine("Using " + unitToUse + " to attack " + myTarget);


                            //generate an attack request
                            simEvent           = SimulationEventFactory.BuildEvent(ref simModel, "AttackObjectRequest");
                            simEvent["UserID"] = DataValueFactory.BuildString("red dm");

                            simEvent["ObjectID"]       = DataValueFactory.BuildString(unitToUse);
                            simEvent["TargetObjectID"] = DataValueFactory.BuildString(myTarget);
                            simEvent["CapabilityName"] = DataValueFactory.BuildString("Missile");
                            simEvent["Time"]           = DataValueFactory.BuildInteger(tick + 3000);// '+3000" is not magic -- just a clumsy attempt to avoid a race condition
                            EventGetter.Network.PutEvent(simEvent);
                        }

                        break;
                    }
                }
            }
        }
Example #9
0
        private void SendStateChangeEvent(string objectID, string newStateName)
        {
            SimulationEvent stateChange = SimulationEventFactory.BuildEvent(ref simModel, "StateChange");

            stateChange["ObjectID"] = DataValueFactory.BuildString(objectID);
            stateChange["NewState"] = DataValueFactory.BuildString(newStateName);

            distClient.PutEvent(stateChange);
        }
Example #10
0
        private void SendSystemErrorMessage(string text, string playerID)
        {
            SimulationEvent e = SimulationEventFactory.BuildEvent(ref simModelInfo, "SystemMessage");

            e["Message"]   = DataValueFactory.BuildString(text);
            e["TextColor"] = DataValueFactory.BuildInteger(-65536);//(System.Drawing.Color.Red.ToArgb());
            e["PlayerID"]  = DataValueFactory.BuildString(playerID);
            server.PutEvent(e);
        }
Example #11
0
        private void ResetObjectMovement(string objectID, double throttle, LocationValue destination)
        {
            SimulationEvent moveObject = SimulationEventFactory.BuildEvent(ref simModel, "MoveObject");

            moveObject["ObjectID"]            = DataValueFactory.BuildString(objectID);
            moveObject["DestinationLocation"] = destination;
            moveObject["Throttle"]            = DataValueFactory.BuildDouble(throttle);

            distClient.PutEvent(moveObject);
        }
Example #12
0
        private void SendSelfDefenseAttackStarted(string attacker, string target)
        {
            SimulationEvent send = SimulationEventFactory.BuildEvent(ref simModel, "SelfDefenseAttackStarted");

            send["AttackerObjectID"] = DataValueFactory.BuildString(attacker);
            send["TargetObjectID"]   = DataValueFactory.BuildString(target);
            send["Time"]             = DataValueFactory.BuildInteger(time);

            distClient.PutEvent(send);
        }
Example #13
0
        private void SendTrackRemovedEvent(String dmID, String objectID)
        {
            SimulationEvent ev = new SimulationEvent();

            ev.eventType = "SEAMATE_TrackRemoved";
            ev.parameters.Add("UserID", DataValueFactory.BuildString(dmID));
            ev.parameters.Add("ObjectID", DataValueFactory.BuildString(objectID));
            ev.parameters.Add("Time", DataValueFactory.BuildInteger(time));

            DDDConnection.SendSimEvent(ev);
        }
Example #14
0
        private void TrackRemoved(SimulationEvent e)
        {
            if (objectProxies.Count == 0)
            {
                return; //another weird edge case
            }
            String objectID             = ((StringValue)e["ObjectID"]).value;
            SimulationObjectProxy proxy = objectProxies[objectID];

            proxy["TrackedBy"].SetDataValue(DataValueFactory.BuildString(""));
        }
Example #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="playerID"></param>
        /// <param name="message"></param>
        private void SendSystemMessageToPlayer(string playerID, string message)
        {
            //might be nice to send out a confirmation of player X's joining to the server
            //and selection of a DM.  The msg would be a text chat?
            SimulationEvent e = SimulationEventFactory.BuildEvent(ref simModelInfo, "SystemMessage");

            e["Message"]   = DataValueFactory.BuildString(message);
            e["PlayerID"]  = DataValueFactory.BuildString(playerID);
            e["TextColor"] = DataValueFactory.BuildInteger(System.Drawing.Color.Red.ToArgb());
            server.PutEvent(e);
        }
Example #16
0
        private void SendLoginEvent(String userID, String dmID, String teamID)
        {
            SimulationEvent ev = new SimulationEvent();

            ev.eventType = "SEAMATE_ExperimenterLogin";
            ev.parameters.Add("IndividualID", DataValueFactory.BuildString(userID));
            ev.parameters.Add("TeamID", DataValueFactory.BuildString(teamID));
            ev.parameters.Add("DM_ID", DataValueFactory.BuildString(dmID));
            ev.parameters.Add("Time", DataValueFactory.BuildInteger(time));

            DDDConnection.SendSimEvent(ev);
        }
Example #17
0
        private void SendViewProActiveRegionUpdate(string objectID, bool isVisible, int displayColor, Polygon3D poly)
        {
            SimulationEvent vpmu = null;

            vpmu = SimulationEventFactory.BuildEvent(ref simModel, "ViewProActiveRegionUpdate");

            vpmu["ObjectID"]     = DataValueFactory.BuildString(objectID);
            vpmu["IsVisible"]    = DataValueFactory.BuildBoolean(isVisible);
            vpmu["DisplayColor"] = DataValueFactory.BuildInteger(displayColor);
            vpmu["Shape"]        = poly.Footprint.GetPolygonValue();

            distClient.PutEvent(vpmu);
        }
Example #18
0
        private void EngramValue(SimulationEvent e)
        {
            SimulationObjectProxy obProx;
            string engramName     = ((StringValue)e["EngramName"]).value;
            string engramValue    = ((StringValue)e["EngramValue"]).value;
            string engramDataType = ((StringValue)e["EngramDataType"]).value;
            string objectID       = string.Empty;

            objectID = ((StringValue)e["SpecificUnit"]).value;
            if (objectID != string.Empty)
            {
                obProx = objectProxies[objectID];
                if (!StateDB.physicalObjects.ContainsKey(objectID))
                {
                    return;
                }
                EmitterValue          em  = (EmitterValue)obProx["Emitters"].GetDataValue();
                CustomAttributesValue cus = (CustomAttributesValue)obProx["CustomAttributes"].GetDataValue();
                if (em.attIsEngram.ContainsKey(engramName))
                {
                    cus.attributes[engramName] = DataValueFactory.BuildString(engramValue);
                    obProx["CustomAttributes"].SetDataValue(cus);
                }
                //Add the qualified engram name to the collection.
                //Does not need to be the same qualified name as the scencon uses.
                StateDB.UpdateEngrams(String.Format("{0}|{1}", objectID, engramName), engramValue, engramDataType);

                return;
            }
            else
            {
                StateDB.UpdateEngrams(engramName, engramValue, engramDataType);

                foreach (string id in objectProxies.Keys)
                {
                    obProx = objectProxies[id];
                    if (!StateDB.physicalObjects.ContainsKey(id))
                    {
                        continue;
                    }
                    EmitterValue          em  = (EmitterValue)obProx["Emitters"].GetDataValue();
                    CustomAttributesValue cus = (CustomAttributesValue)obProx["CustomAttributes"].GetDataValue();
                    if (em.attIsEngram.ContainsKey(engramName))
                    {
                        cus.attributes[engramName] = DataValueFactory.BuildString(engramValue);
                        obProx["CustomAttributes"].SetDataValue(cus);
                    }
                }
                return;
            }
        }
Example #19
0
        private void TrackAdded(SimulationEvent e)
        {
            if (objectProxies.Count == 0)
            {
                return; //another weird edge case
            }
            String objectID             = ((StringValue)e["ObjectID"]).value;
            SimulationObjectProxy proxy = objectProxies[objectID];

            string id = ((StringValue)e["UserID"]).value;

            proxy["TrackedBy"].SetDataValue(DataValueFactory.BuildString(id));
            proxy["TrackingTime"].SetDataValue(DataValueFactory.BuildInteger(time));
        }
Example #20
0
        public static void PublishCPE(String dmId, double findFixCpe, double trackTargetCpe)
        {
            SimulationEvent cpe = new SimulationEvent();

            cpe.eventType = "SEAMATE_UpdateCPE";
            cpe.parameters.Add("DM_ID", DataValueFactory.BuildString(dmId));
            cpe.parameters.Add("FF_CPE", DataValueFactory.BuildDouble(findFixCpe));
            cpe.parameters.Add("TT_CPE", DataValueFactory.BuildDouble(trackTargetCpe));

            if (_client == null)
            {
                throw new Exception("DDD Network Client not connected; You need to call Connect successfully before sending events.");
            }
            _client.PutEvent(cpe);
        }
Example #21
0
        private void AttackObject(SimulationEvent e)
        {
            String objectID                   = ((StringValue)e["ObjectID"]).value;
            SimulationObjectProxy proxy       = objectProxies[objectID];
            String targetID                   = ((StringValue)e["TargetObjectID"]).value;
            SimulationObjectProxy targetProxy = objectProxies[targetID];

            // It's a sea vessel if it's not a BAMS or Firescout
            String className = ((StringValue)proxy["ClassName"].GetDataValue()).value;

            if (className != "BAMS" && className != "Firescout")
            {
                proxy["HostileActionTime"].SetDataValue(DataValueFactory.BuildInteger(time));
                proxy["GroundTruthIFF"].SetDataValue(DataValueFactory.BuildString("Hostile"));
            }
        }
Example #22
0
        /// <summary>
        /// Sends out a ClientRemoveObject event for a specified object to a specified user.
        /// </summary>
        /// <param name="objectID"></param>
        /// <param name="playerID"></param>
        private void SendRemoveObjectEvent(string objectID, string playerID)
        {
            if (!activeDMs.Contains(playerID))
            {
                return;
            }

            SimulationEvent e = SimulationEventFactory.BuildEvent(ref simModel, "ClientRemoveObject");

            e["TargetPlayer"] = DataValueFactory.BuildString(playerID);
            e["ObjectID"]     = DataValueFactory.BuildString(objectID);
            e["Time"]         = DataValueFactory.BuildInteger(currentTick);
            dmViews[playerID].RemoveObject(objectID);

            distClient.PutEvent(e);
        }
Example #23
0
        public void CreateVoiceChannel(SimulationEvent e)
        {
            string roomName = ((StringValue)e["ChannelName"]).value;

            if (listOfVoiceChannelCreates.ContainsKey(roomName))
            {
                return;
            }

            List <string> members = ((StringListValue)e["MembershipList"]).strings;

            SimulationEvent ev = SimulationEventFactory.BuildEvent(ref simModelInfo, "CreateVoiceChannel");

            ev["ChannelName"] = DataValueFactory.BuildString(roomName);
            ((StringListValue)ev["MembershipList"]).strings = members;

            listOfVoiceChannelCreates.Add(roomName, ev);
        }
Example #24
0
        private void btnChangeTag_Click(object sender, EventArgs e)
        {
            string chosenText  = "";
            string chosenAsset = "";
            string chosenDM    = "";

            if (null != lbxDecisionMakers.SelectedItem)
            {
                chosenDM = lbxDecisionMakers.SelectedItem.ToString();
            }
            if (null != lbxAssets.SelectedItem)
            {
                chosenAsset = lbxAssets.SelectedItem.ToString();
            }
            if (null != txArg1.Text)
            {
                chosenText = txArg1.Text;
            }
            if ("" == chosenDM)
            {
                MessageBox.Show("Please select a Decision Maker");
                return;
            }
            if ("" == chosenAsset)
            {
                MessageBox.Show("Please select an asset");
                return;
            }
            if ("" == chosenText)
            {
                DialogResult dr = MessageBox.Show("Do you wish to remove the current tag from " + chosenAsset + "?", "", MessageBoxButtons.YesNo);
                if (DialogResult.No == dr)
                {
                    return;
                }
            }

            SimulationEvent chTag = SimulationEventFactory.BuildEvent(ref simModelInfo, "ChangeTagRequest");

            chTag["UnitID"]          = DataValueFactory.BuildString(chosenAsset);
            chTag["DecisionMakerID"] = DataValueFactory.BuildString(chosenDM);
            chTag["Tag"]             = DataValueFactory.BuildString(chosenText);
            EventListener.Network.PutEvent(chTag);
        }
Example #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="playerID"></param>
        /// <param name="message"></param>
        private void SendSystemMessageToAll(string message)
        {
            //might be nice to send out a confirmation of player X's joining to the server
            //and selection of a DM.  The msg would be a text chat?
            SimulationEvent e;


            foreach (string playerID in allDMs.Keys)
            {
                if (allDMs[playerID].availability != DecisionMaker.Availability.AVAILABLE)
                {
                    e              = SimulationEventFactory.BuildEvent(ref simModelInfo, "SystemMessage");
                    e["Message"]   = DataValueFactory.BuildString(message);
                    e["TextColor"] = DataValueFactory.BuildInteger(System.Drawing.Color.Black.ToArgb());
                    e["PlayerID"]  = DataValueFactory.BuildString(playerID);
                    server.PutEvent(e);
                }
            }
        }
Example #26
0
        /// <summary>
        /// This event receives an attack object, sends out the attack, and returns false if the current time
        /// is the same as the attack end time.  This info is used to remove the attack from the attack list if the
        /// time is up.
        /// </summary>
        /// <param name="attack"></param>
        /// <returns></returns>
        private bool SendAttackEvent(Attack attack)
        {
            bool returnBool = true;
            int  endTime    = attack.endTime;

            if (endTime <= currentTick)
            { //attack is over
                returnBool = false;
            }

            SimulationEvent e = SimulationEventFactory.BuildEvent(ref simModel, "ViewProAttackUpdate");

            e["AttackerID"]    = DataValueFactory.BuildString(attack.attacker);
            e["TargetID"]      = DataValueFactory.BuildString(attack.target);
            e["AttackEndTime"] = DataValueFactory.BuildInteger(attack.endTime);
            e["Time"]          = DataValueFactory.BuildInteger(currentTick);
            distClient.PutEvent(e);

            return(returnBool);
        }
Example #27
0
        private void btnCloseChat_Click(object sender, EventArgs e)
        {
            if (null == lbxDecisionMakers.SelectedItem)
            {
                MessageBox.Show("Please select an owner for the chat room.");
                return;
            }

            if (null == lbxCloseChatNames.SelectedItem)
            {
                MessageBox.Show("Please select the name of the room to close.");
                return;
            }

            SimulationEvent closeChat = SimulationEventFactory.BuildEvent(ref simModelInfo, "RequestCloseChatRoom");

            closeChat["RoomName"]    = DataValueFactory.BuildString((string)lbxCloseChatNames.SelectedItem);
            closeChat["SenderDM_ID"] = DataValueFactory.BuildString((string)lbxDecisionMakers.SelectedItem);
            EventListener.Network.PutEvent(closeChat);
        }
Example #28
0
        private void ObjectSelected(SimulationEvent ev)
        {
            if (((StringValue)ev["UserID"]).value != MyDM)
            {
                return;
            }
            String objectID = ((StringValue)ev["ObjectID"]).value;

            _mostRecentlyClickedObject = objectID;
            DDDObj d = GetFromAllObjects(objectID);

            if (d == null)
            {
                return;
            }
            String tag = "unknown";

            if (d.Name != String.Empty)
            {
                tag = d.Name;
            }
            SimulationEvent evnt = new SimulationEvent();

            evnt.eventType = "UpdateTag";
            evnt.parameters.Add("Time", DataValueFactory.BuildInteger(time));
            evnt.parameters.Add("UnitID", DataValueFactory.BuildString(objectID));
            evnt.parameters.Add("Tag", DataValueFactory.BuildString(tag));
            List <String> dms = new List <string>();

            if (MyDM.Contains("Individ"))
            {
                dms.Add(MyDM);
            }
            else
            {
                dms.Add("BAMS DM");
                dms.Add("Firescout DM");
            }
            evnt.parameters.Add("TeamMembers", DataValueFactory.BuildStringList(dms));
            DDDConnection.SendSimEvent(evnt);//.SendObjectAttributeUpdateEvent(objectID, "InitialTag", DataValueFactory.BuildString(tag));
        }
Example #29
0
        private void btnTransfer_Click(object sender, EventArgs e)
        {
            string chosenAsset = "";
            string chosenDM    = "";
            string receivingDM = "";

            if (null != lbxDecisionMakers.SelectedItem)
            {
                chosenDM = lbxDecisionMakers.SelectedItem.ToString();
            }
            if (null != lbxAssets.SelectedItem)
            {
                chosenAsset = lbxAssets.SelectedItem.ToString();
            }
            if (null != lbxTransferReceiver.SelectedItem)
            {
                receivingDM = lbxTransferReceiver.SelectedItem.ToString();
            }
            if ("" == chosenDM)
            {
                MessageBox.Show("Please select a Decision Maker to cause the transfer");
                return;
            }
            if ("" == chosenAsset)
            {
                MessageBox.Show("Please select an asset");
                return;
            }
            if ("" == receivingDM)
            {
                MessageBox.Show("Please select a Decision MAker to receive the asset");

                return;
            }
            SimulationEvent xfer = SimulationEventFactory.BuildEvent(ref simModelInfo, "TransferObjectRequest");

            xfer["ObjectID"]    = DataValueFactory.BuildString(chosenAsset);
            xfer["UserID"]      = DataValueFactory.BuildString(chosenDM);
            xfer["RecipientID"] = DataValueFactory.BuildString(receivingDM);
            EventListener.Network.PutEvent(xfer);
        }
Example #30
0
        private RangeRingLevels selectedRangeRingLevel = RangeRingLevels.FULL; //DEFAULT
        #endregion

        #region sensory methods

        /// <summary>
        /// This method will run through each object and determine what those objects can sense.
        /// </summary>
        private void CalculateSensoryAlgorithm()
        {
            //objectProxies = bbClient.GetObjectProxies();
            Dictionary <string, Dictionary <string, AttributeCollectionValue> > allObjectsViews        = new Dictionary <string, Dictionary <string, AttributeCollectionValue> >();
            Dictionary <string, Dictionary <string, AttributeCollectionValue> > allSensorNetworksViews = new Dictionary <string, Dictionary <string, AttributeCollectionValue> >();
            Dictionary <string, Dictionary <string, AttributeCollectionValue> > allDMsViews            = new Dictionary <string, Dictionary <string, AttributeCollectionValue> >();

            //each object senses each other object, and the allObjectsViews is populated and returned.
            SenseAllObjects(ref allObjectsViews);

            //each sensor network goes through the views of objects contained within that network, and
            //creates its best view for all its members.
            RetrieveSensorNetworkView(ref allSensorNetworksViews, ref allObjectsViews);

            //Go through each sensor network, and create the best DM view for each active DM.
            RetrieveAllDMViews(ref allDMsViews, ref allSensorNetworksViews);

            //Send out view pro updates.
            List <string> recentlyDiscoveredObjects = new List <string>();
            bool          sendAttUpdate             = true;

            foreach (string dm in dmOwnedObjects.Keys)
            {
                if (!allDMsViews.ContainsKey(dm))
                {
                    continue;
                }
                CompareNewDMViewWithPrevious(dm, allDMsViews[dm], ref recentlyDiscoveredObjects);
            }
            foreach (string obj in recentlyDiscoveredObjects)
            {
                if (!movingObjects.Contains(obj))
                {
                    continue;
                }
                AttributeCollectionValue atts = new AttributeCollectionValue();
                atts.attributes.Add("ObjectID", DataValueFactory.BuildString(obj));
                SendViewProMotionUpdate(atts);
            }
        }