예제 #1
0
 public void SubPlatformLaunch(string object_id, string parent_id, double xpos, double ypos, double zpos)
 {
     _SubPEvent = SimulationEventFactory.BuildEvent(ref _SimModel, "SubplatformLaunchRequest");
     ((StringValue)(_SubPEvent["UserID"])).value                       = DDD_Global.Instance.PlayerID;
     ((StringValue)(_SubPEvent["ObjectID"])).value                     = object_id;
     ((StringValue)(_SubPEvent["ParentObjectID"])).value               = parent_id;
     ((LocationValue)(_SubPEvent["LaunchDestinationLocation"])).X      = (double)UTM_Mapping.HorizontalPixelsToMeters((float)xpos);
     ((LocationValue)(_SubPEvent["LaunchDestinationLocation"])).Y      = (double)UTM_Mapping.VerticalPixelsToMeters((float)ypos);
     ((LocationValue)(_SubPEvent["LaunchDestinationLocation"])).Z      = zpos;
     ((LocationValue)(_SubPEvent["LaunchDestinationLocation"])).exists = true;
     if (DDD_Global.Instance.IsConnected)
     {
         DDD_Global.Instance.PutEvent(_SubPEvent);
     }
     else
     {
         lock (this)
         {
             if (DemoEvents != null)
             {
                 DemoEvents.Add(_SubPEvent);
             }
         }
     }
 }
예제 #2
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);
        }
예제 #3
0
        public void Start(SimulationModelInfo simModel, ref SimulationEventDistributor distributor, string logName, bool loop)
        {
            try
            {
                playerThread = new Thread(new ThreadStart(EventLoop));
                //nc = new NetworkClient();
                //nc.Connect(hostname, port);
                distClient = new SimulationEventDistributorClient();
                distributor.RegisterClient(ref distClient);
                this.simModel   = simModel;
                time            = 0;
                this.loop       = loop;
                this.logname    = logName;
                updateFrequency = simModel.simulationExecutionModel.updateFrequency;

                SimulationEvent ev = SimulationEventFactory.BuildEvent(ref simModel, "ResetSimulation");
                distClient.PutEvent(ev);
                LoadEvents(logName);

                playerThread.Start();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #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);
            }
        }
예제 #5
0
        public ForkReplayToQueues(String replayName, SimulationModelInfo simModelInfo)
        {
            m_simModelInfo = simModelInfo;

            List <SimulationEvent> events = LoadForkReplayFile(replayName);

            if (events.Count == 0) // this is not a fork replay
            {
                return;
            }

            SimulationEvent start  = SimulationEventFactory.BuildEvent(ref simModelInfo, "ForkReplayStarted");
            SimulationEvent finish = SimulationEventFactory.BuildEvent(ref simModelInfo, "ForkReplayFinished");

            TimerQueueClass.SendBeforeStartup(new ForkReplayEventType(start));

            int lastTime = 1;

            foreach (SimulationEvent ev in events)
            {
                ForkReplayEventType fr = new ForkReplayEventType(ev);
                TimerQueueClass.Add(fr.Time, fr);
                lastTime = fr.Time;
            }
            ForkReplayEventType fr2 = new ForkReplayEventType(finish);

            fr2.Time = lastTime + 1;
            TimerQueueClass.Add(fr2.Time, fr2);
        }
예제 #6
0
        public void DoMove(string user_id, string object_id, double throttle, double xpos, double ypos, double zpos)
        {
            _MoveEvent = SimulationEventFactory.BuildEvent(ref _SimModel, "MoveObjectRequest");

            ((StringValue)(_MoveEvent["UserID"])).value   = user_id;
            ((StringValue)(_MoveEvent["ObjectID"])).value = object_id;
            ((DoubleValue)(_MoveEvent["Throttle"])).value = throttle;

            ((LocationValue)(_MoveEvent["DestinationLocation"])).X      = (double)UTM_Mapping.HorizontalPixelsToMeters((float)xpos);
            ((LocationValue)(_MoveEvent["DestinationLocation"])).Y      = (double)UTM_Mapping.VerticalPixelsToMeters((float)ypos);
            ((LocationValue)(_MoveEvent["DestinationLocation"])).Z      = zpos;
            ((LocationValue)(_MoveEvent["DestinationLocation"])).exists = true;

            if (DDD_Global.Instance.IsConnected)
            {
                DDD_Global.Instance.PutEvent(_MoveEvent);
            }
            else
            {
                lock (this)
                {
                    if (DemoEvents != null)
                    {
                        DemoEvents.Add(_MoveEvent);
                    }
                }
            }
        }
예제 #7
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);
        }
예제 #8
0
        public SimulationEvent MoveDoneReceived(SimulationEvent e, SimulationModelInfo model, SimulationEvent theTick)
        {
            //Should receieve a MoveDone event, and create a new move event and send
            //it to the Queue Manager with time ticks + 1.

            SimulationEvent ee = SimulationEventFactory.BuildEvent(ref model, "MoveObject");

            ee.eventType = "MoveObject";

            DataValue myDV = new IntegerValue();

            myDV           = e["ObjectID"];
            ee["ObjectID"] = myDV;

            myDV = new LocationValue();
            ((LocationValue)(myDV)).X = 150;
            ((LocationValue)(myDV)).Y = 150;
            ((LocationValue)(myDV)).Z = 50;
            ee["DestinationLocation"] = myDV;

            myDV = new DoubleValue();
            ((DoubleValue)(myDV)).value = .5;
            ee["Throttle"] = myDV;

            myDV = new IntegerValue();
            ((IntegerValue)(myDV)).value =
                ((IntegerValue)theTick.parameters["Time"]).value + 1000;
            ee["Time"] = myDV;

            return(ee);
        }
예제 #9
0
파일: Form1.cs 프로젝트: vishalbelsare/DDD
        private void clockTimer_Tick(object sender, EventArgs e)
        {
            simulationTime += updateFrequency;
            SimulationEvent tick = SimulationEventFactory.BuildEvent(ref simModel, "TimeTick");

            ((IntegerValue)tick["Time"]).value = simulationTime;
            netClient.PutEvent(tick);

            EventListBoxItem lbi = null;

            if (!manualCheckBox.Checked)
            {
                while (eventsListBox.Items.Count > 0)
                {
                    lbi = (EventListBoxItem)eventsListBox.Items[0];
                    if (((IntegerValue)lbi.simEvent["Time"]).value >= simulationTime &&
                        ((IntegerValue)lbi.simEvent["Time"]).value < (simulationTime + updateFrequency))
                    {
                        eventsListBox.Items.Remove(lbi);
                        netClient.PutEvent(lbi.simEvent);
                    }
                    else
                    {
                        break;
                    }
                }
            }



            FormUpdate();
        }
예제 #10
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);
        }
예제 #11
0
파일: Form1.cs 프로젝트: vishalbelsare/DDD
        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);
        }
예제 #12
0
        public void InitializeGUIDone(SimulationEvent e)
        { //event contains PlayerID
            string playerID;
            string loginType;

            try
            {
                playerID  = ((StringValue)e["PlayerID"]).value;
                loginType = ((StringValue)e["LoginType"]).value;
            }
            catch
            {
                throw new Exception("Player ID does not exist in this event.");
            }
            if (loginType == "FULL")
            {
                //add to DMs ready a true val for the specified dm
                dmsIsReady[playerID]          = true;
                allDMs[playerID].availability = DecisionMaker.Availability.READY;
                Thread.Sleep(100);//delay so client can synch up
                SendSystemMessageToAll(String.Format("SYSTEM: New user ({0}) has joined the simulation.", playerID));
                SimulationEvent player = SimulationEventFactory.BuildEvent(ref simModelInfo, "PlayerControl");
                ((StringValue)player["DecisionMakerID"]).value = playerID;
                ((StringValue)player["ControlledBy"]).value    = "HUMAN";
                server.PutEvent(player);

                SimulationEvent assetTransferEnabled = SimulationEventFactory.BuildEvent(ref simModelInfo, "ClientSideAssetTransferAllowed");
                assetTransferEnabled["EnableAssetTransfer"] = DataValueFactory.BuildBoolean(enableAssetTransfers);
                server.PutEvent(assetTransferEnabled);

                ////The following section is in place for clients that join after a CreateChatRoom
                ////Event  has been sent out.  Without this, new tabbed chat rooms would not open
                ////if the room was created before they joined.
                foreach (SimulationEvent ev in listOfChatRoomCreates.Values)
                {
                    if (((StringListValue)ev["MembershipList"]).strings.Contains(playerID))
                    {
                        server.PutEvent(ev);
                    }
                }

                foreach (SimulationEvent ev in listOfWhiteboardRoomCreates.Values)
                {
                    if (((StringListValue)ev["MembershipList"]).strings.Contains(playerID))
                    {
                        server.PutEvent(ev);
                    }
                }
                ////The following section is in place for clients that join after a CreateVoiceChannel
                ////event is sent out
                foreach (SimulationEvent ev in listOfVoiceChannelCreates.Values)
                {
                    if (((StringListValue)ev["MembershipList"]).strings.Contains(playerID))
                    {
                        server.PutEvent(ev);
                    }
                }
            }
        }
예제 #13
0
파일: Utility.cs 프로젝트: xiangnanyue/DDD
        static public SimulationEvent BuildActiveRegionSpeedMultiplierUpdateEvent(ref SimulationModelInfo simModel, int time, string id)
        {
            SimulationEvent sc = SimulationEventFactory.BuildEvent(ref simModel, "ActiveRegionSpeedMultiplierUpdate");

            ((IntegerValue)sc["Time"]).value    = time;
            ((StringValue)sc["ObjectID"]).value = id;
            return(sc);
        }
예제 #14
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;
                    }
                }
            }
        }
예제 #15
0
        private void SocketHandler()
        {
            NetMessage      m = new NetMessage();
            SimulationEvent e = null;

            while (true)
            {
                try
                {
                    m.Receive(ref netStream);
                    switch (m.type)
                    {
                    case NetMessageType.EVENT:
                        try
                        {
                            e = SimulationEventFactory.XMLDeserialize(m.msg);
                            lock (eventQueueLock)
                            {
                                eventQueue.Add(e);
                            }
                        }
                        catch (Exception exc)
                        {
                            ErrorLog.Write(String.Format("NONFATAL Deserialize Error in NetworkClient: {0}", m.msg));
                            ErrorLog.Write(exc.ToString());
                        }
                        break;

                    case NetMessageType.DISCONNECT:
                        System.Console.WriteLine("NetworkClient: recieved Shutdown message from server.  Disconnecting...");
                        Disconnect();
                        return;

                    case NetMessageType.PING:
                        break;

                    case NetMessageType.NONE:

                        System.Console.WriteLine("NetworkClient: Message with no type received.  Disconnecting.");
                        Disconnect();
                        return;

                    default:
                        throw new Exception("NetworkClient: recieved unhandled message");
                    }
                }
                catch (System.IO.IOException)
                {
                    System.Console.WriteLine("NetworkClient: Lost connection with remote server!");
                    netStream.Close();
                    netStream.Dispose();
                    isConnected = false;
                    clientThread.Abort();
                    return;
                }
            }
        }
예제 #16
0
        private void PromptForDM()
        {
            if (this.Dispatcher.Thread == Thread.CurrentThread)
            {
                string selectedDM            = "";
                SimulationModelInfo simModel = DDDConnection.GetSimModel();
                SimulationEvent     ev       = SimulationEventFactory.BuildEvent(ref simModel, "SEAMATE_RequestMyDecisionMaker");
                ((StringValue)ev["TerminalID"]).value   = DDDConnection.TerminalID;
                ((StringValue)ev["ComputerName"]).value = System.Environment.MachineName;

                int attempts = 0;
                while (selectedDM == "" && attempts < 10)
                {
                    DDDConnection.SendSimEvent(ev);
                    // DDDConnection.ProcessEvents();
                    Thread.Sleep(1000);
                    DDDConnection.ProcessEvents();
                    Thread.Sleep(100);
                    List <SimulationEvent> events = DDDConnection.GetEvents();
                    foreach (SimulationEvent e in events)
                    {
                        if (e.eventType == "SEAMATE_ResponseDecisionMaker")
                        {
                            if (((StringValue)e["TerminalID"]).value == DDDConnection.TerminalID)
                            {
                                selectedDM = ((StringValue)e["DM_ID"]).value;
                                break;
                            }
                        }
                    }
                    attempts++;
                }
                if (selectedDM == "")
                {
                    MessageBox.Show("Unable to retrieve your Decision Maker info from the server in 10 seconds.  Make sure you've connected with a DDD Client, and then try re-connecting with the decision aid");
                    return;
                }

                //DDDConnection.RequestPlayers();
                //List<string> decisionMakers = new List<string>();
                //while (decisionMakers.Count == 0)
                //{
                //    decisionMakers = DDDConnection.Players;
                //    DDDConnection.ProcessEvents();
                //}
                //DMSelectorDialog dmDlg = new DMSelectorDialog(decisionMakers);
                //dmDlg.Owner = this;
                //if (!dmDlg.ShowDialog().Value)
                //    return;
                //string selectedDM = dmDlg.SelectedDecisionMaker;
                MyDM = selectedDM;
            }
            else
            {
                this.Dispatcher.Invoke(new NoParams(PromptForDM), DispatcherPriority.Normal);
            }
        }
예제 #17
0
파일: Utility.cs 프로젝트: xiangnanyue/DDD
        static public SimulationEvent BuildMoveDoneEvent(ref SimulationModelInfo simModel, int time, string id, string reason)
        {
            SimulationEvent sc = SimulationEventFactory.BuildEvent(ref simModel, "MoveDone");

            ((StringValue)sc["ObjectID"]).value = id;
            ((IntegerValue)sc["Time"]).value    = time;
            ((StringValue)sc["Reason"]).value   = reason;
            return(sc);
        }
예제 #18
0
파일: Utility.cs 프로젝트: xiangnanyue/DDD
        static public SimulationEvent BuildStateChangeEvent(ref SimulationModelInfo simModel, int time, string id, string state)
        {
            SimulationEvent sc = SimulationEventFactory.BuildEvent(ref simModel, "StateChange");

            ((StringValue)sc["ObjectID"]).value = id;
            ((StringValue)sc["NewState"]).value = state;
            ((IntegerValue)sc["Time"]).value    = time;
            return(sc);
        }
예제 #19
0
 public void DisconnectDecisionMaker(string dm_id)
 {
     _AttackEvent = SimulationEventFactory.BuildEvent(ref _SimModel, "DisconnectDecisionMaker");
     ((StringValue)(_AttackEvent["DecisionMakerID"])).value = dm_id;
     if (DDD_Global.Instance.IsConnected)
     {
         DDD_Global.Instance.PutEvent(_AttackEvent);
     }
 }
예제 #20
0
        private void SendDecisionMakerResponseEvent(string terminal, string dmID)
        {
            SimulationEvent ev = SimulationEventFactory.BuildEvent(ref simModel, "SEAMATE_ResponseDecisionMaker");

            ((StringValue)ev["TerminalID"]).value = terminal;
            ((StringValue)ev["DM_ID"]).value      = dmID;

            distributor.PutEvent(ev);
        }
예제 #21
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);
        }
예제 #22
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);
        }
예제 #23
0
 public void sendRequestUnmuteUserEvent(string strChannelName)
 {
     _VoiceClientEventRequest = SimulationEventFactory.BuildEvent(ref _SimModel, "RequestUnmuteUser");
     ((StringValue)(_VoiceClientEventRequest["ChannelName"])).value = strChannelName;
     ((StringValue)(_VoiceClientEventRequest["Speaker"])).value     = DDD_Global.Instance.PlayerID;
     if (DDD_Global.Instance.IsConnected)
     {
         DDD_Global.Instance.PutEvent(_VoiceClientEventRequest);
     }
 }
예제 #24
0
 public void SendServerStateEvent(String messageType, String messageText)
 {
     if (eventClient != null)
     {
         SimulationEvent e = SimulationEventFactory.BuildEvent(ref simEngine.simCore.simModelInfo, "ServerState");
         ((StringValue)e["MessageType"]).value = messageType;
         ((StringValue)e["MessageText"]).value = messageText;
         eventClient.PutEvent(e);
     }
 }
예제 #25
0
파일: Utility.cs 프로젝트: xiangnanyue/DDD
        static public SimulationEvent BuildScoreUpdateEvent(ref SimulationModelInfo simModel, int time, string dm, string scoreName, double scoreValue)
        {
            SimulationEvent sc = SimulationEventFactory.BuildEvent(ref simModel, "ScoreUpdate");

            ((IntegerValue)sc["Time"]).value           = time;
            ((StringValue)sc["DecisionMakerID"]).value = dm;
            ((StringValue)sc["ScoreName"]).value       = scoreName;
            ((DoubleValue)sc["ScoreValue"]).value      = scoreValue;
            return(sc);
        }
예제 #26
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);
        }
예제 #27
0
        private void SendAuthenticationResponse(string termID, string message, bool success)
        {
            SimulationEvent e = SimulationEventFactory.BuildEvent(ref simModelInfo, "AuthenticationResponse");

            ((StringValue)e["TerminalID"]).value = termID;
            ((StringValue)e["Message"]).value    = message;
            ((BooleanValue)e["Success"]).value   = success;

            server.PutEvent(e);
        }
예제 #28
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);
        }
예제 #29
0
        private static void SendTextChat(string userID, string targetUserID, string chatBody, int time)
        {
            SimulationEvent sendingEvent = SimulationEventFactory.BuildEvent(ref simModelInfo, "TextChat");
            DataValue       dv           = new StringValue();

            ((StringValue)sendingEvent["ChatBody"]).value     = chatBody;
            ((StringValue)sendingEvent["UserID"]).value       = userID;
            ((StringValue)sendingEvent["TargetUserID"]).value = targetUserID;
            ((IntegerValue)sendingEvent["Time"]).value        = time;
            server.PutEvent(sendingEvent);
        }
예제 #30
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);
        }