Exemplo n.º 1
0
        private void btnStartStop_Click(object sender, RoutedEventArgs e)
        {
            if (SimulationRunning)
            {
                StopSimulation();
            }
            else
            {
                btnStartStop.Content = "Stop Simulation";

                comboBox.SelectedItem = InteractItem;
                comboBox.IsEnabled    = false;

                Simulation = new WirelessNetworkSimulation(Network);
                Simulation.LedStateChanged += Simulation_LedStateChanged;
                SimulatorNodes.Clear();
                foreach (var n in Simulation.SimulationNodes)
                {
                    SimulatorNodes[n.NetworkNode] = n;
                }
                Simulation.StartSimulation();
                NetworkControl.SetSimulation(Simulation, SimulatorNodes);
                LastTick = DateTime.Now;
                SimulationTimer.Change(TickRateMs, TickRateMs);
            }
            SimulationRunning = !SimulationRunning;
        }
        /// <summary>
        /// Event raised on mouse down in the NetworkView.
        /// </summary>
        private void networkControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            NetworkControl.Focus();
            Keyboard.Focus(NetworkControl);

            _mouseButtonDown = e.ChangedButton;
            _origZoomAndPanControlMouseDownPoint = e.GetPosition(ZoomAndPanControl);
            _origContentMouseDownPoint           = e.GetPosition(NetworkControl);

            if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 &&
                (e.ChangedButton == MouseButton.Left ||
                 e.ChangedButton == MouseButton.Right))
            {
                // Shift + left- or right-down initiates zooming mode.
                _mouseHandlingMode = MouseHandlingMode.Zooming;
            }
            else if (_mouseButtonDown == MouseButton.Left &&
                     (Keyboard.Modifiers & ModifierKeys.Control) == 0)
            {
                //
                // Initiate panning, when control is not held down.
                // When control is held down left dragging is used for drag selection.
                // After panning has been initiated the user must drag further than the threshold value to actually start drag panning.
                //
                _mouseHandlingMode = MouseHandlingMode.Panning;
            }

            if (_mouseHandlingMode != MouseHandlingMode.None)
            {
                // Capture the mouse so that we eventually receive the mouse up event.
                NetworkControl.CaptureMouse();
                e.Handled = true;
            }
        }
Exemplo n.º 3
0
        private void mnuSetBackground_Click(object sender, RoutedEventArgs e)
        {
            string filename = FileDialog.GetOpenFilename("Open background image...", "png", "Image File");

            if (filename != null)
            {
                try
                {
                    BitmapImage img = new BitmapImage(new Uri(filename));

                    RealizedNetworkImage ri = new RealizedNetworkImage();
                    ri.Bitmap               = img;
                    ri.FullFilename         = filename;
                    ri.SourceImage          = new WirelessNetworkImage();
                    ri.SourceImage.Scale    = 1.0 / 39;
                    ri.SourceImage.Filename = filename;


                    NetworkControl.Images.Clear();
                    NetworkControl.Images.Add(ri);

                    Network.Images.Clear();
                    Network.Images.Add(ri.SourceImage);

                    NetworkControl.Redraw();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception while trying to load image.\n" + ex.ToString());
                }
            }
        }
Exemplo n.º 4
0
    void Update()
    {
        if (InputJoystick.Direction.magnitude > 0.01f)
        {
            movementDir = new Vector3(InputJoystick.Direction.x, 0, InputJoystick.Direction.y);

            NetworkControl.SendPlaneDirection(movementDir);
        }

        selfTransform.forward = Vector3.Lerp(selfTransform.forward, movementDir, turningSpeed * Time.fixedDeltaTime);

        selfTransform.position = Vector3.Lerp(selfTransform.position, selfTransform.position + selfTransform.forward, Time.fixedDeltaTime);

        //Quaternion deltaRotation = transform.rotation * Quaternion.Inverse (lastRotation);
        //deltaRotation.ToAngleAxis(out magnitude, out axis);

        //lastRotation = transform.rotation;

        //float angVel = -AngularVelocity.y;

        //selfTransform.position += selfTransform.forward * speed * Time.deltaTime;

        //selfTransform.rotation = Quaternion.Lerp(selfTransform.rotation, Quaternion.LookRotation(movementDir, selfTransform.up), angularTransition * Time.fixedDeltaTime);
        //selfTransform.rotation = Quaternion.Lerp(selfTransform.rotation, Quaternion.Euler(new Vector3(selfTransform.rotation.eulerAngles.x, selfTransform.rotation.eulerAngles.y, Mathf.Clamp(angVel * inclineOffset, - maxSideRotation, maxSideRotation))), inclineTransition * Time.fixedDeltaTime);

        //selfTransform.position = new Vector3(selfTransform.position.x, 0, selfTransform.position.z);
    }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new window displaying an empty spreadsheet
        /// </summary>
        public Form1(NetworkControl NetC, string filename)
        {
            this.NC = NetC;

            NC.Update += ServerUpdate;

            InitializeComponent();

            // the name of the form
            this.Text = filename;

            // highlights
            this.ActiveControl = textBoxCellContents;

            // set up listener for panel selection changed
            spreadsheetPanel1.SelectionChanged += OnSelectionChanged;

            // set initial selection to A1, 1
            spreadsheetPanel1.SetSelection(0, 0);

            // call the method to update selection
            OnSelectionChanged(spreadsheetPanel1);

            // set the name of the window to the filename
            Text = filename;
        }
Exemplo n.º 6
0
        public void LeaveLobby()
        {
            SendChatMessage(SteamFriends.GetPersonaName() + " Lefted the Lobby", false);
            NetworkControl.SendPacketsSafely(new P2PPackage(null, P2PPackageType.LeftLobby), false);
            NetworkControl.PlayerList.Clear();
            SteamMatchmaking.LeaveLobby(lobby);
            lobby = new CSteamID();

            foreach (var t in NetworkControl.instance.OnlineObjects)
            {
                if (t == null)
                {
                    continue;
                }
                Destroy(t.gameObject);
            }

            NetworkControl.instance.OnlineObjects.Clear();
            if (events.lobby_leaved != null)
            {
                events.lobby_leaved.Invoke();
            }
            Destroy(gameObject);
            if (scenes.CurrentScene != scenes.LobbyScene)
            {
                SceneManager.LoadScene(scenes.LobbyScene);
                scenes.CurrentScene = scenes.LobbyScene;
            }
        }
Exemplo n.º 7
0
        void MoveHighlightNode(Point p)
        {
            if (Network != null)
            {
                WirelessNetworkNode selNode = null;
                Point  selPoint             = new Point();
                double minDistance          = double.PositiveInfinity;
                foreach (var node in Network.Nodes)
                {
                    Point  np       = new Point(node.X, node.Y);
                    double dsquared = (p - np).LengthSquared;
                    if (dsquared < minDistance)
                    {
                        selNode     = node;
                        selPoint    = np;
                        minDistance = dsquared;
                    }
                }
                double snapDistance = 20; // pixels
                snapDistance = Math.Pow(NetworkControl.ScreenToLocal(snapDistance), 2);

                if (minDistance < snapDistance)
                {
                    SelectedNode = selNode;
                    p            = selPoint;
                }
                else
                {
                    SelectedNode = null;
                }
            }
            NetworkControl.SetUserCursor(p);
        }
        public void Update()
        {
            if (animator == null)
            {
                return;
            }
            if (!identity.IsLocalSpawned)
            {
                return;
            }
            CurrentTime -= Time.deltaTime;
            if (!(CurrentTime <= 0))
            {
                return;
            }
            CurrentTime = 1f / UpdatesPerSecond;
            NetworkControl.SendPacketsQuicklly(new P2PPackage(GetParamter(), P2PPackageType.AnimatorParamter, identity), false);
            int   num;
            float num2;

            if (!CheckAnimStateChanged(out num, out num2))
            {
                return;
            }
            var msg = new MyAniationMessage(animator);

            NetworkControl.SendPacketsQuicklly(new P2PPackage(msg, P2PPackageType.AnimatorState, identity), false);
        }
Exemplo n.º 9
0
    public void JoinGame()
    {
        NetworkControl nc = GameObject.FindGameObjectWithTag("NetworkControl").GetComponent <NetworkControl>();

        nc.networkAddress = IpInput.text;
        nc.networkPort    = int.Parse(PortInput.text);
        nc.StartClient();
    }
Exemplo n.º 10
0
 void DeleteMouseDown(Point p)
 {
     if (SelectedNode != null)
     {
         Network.Nodes.Remove(SelectedNode);
         NetworkControl.Redraw();
     }
 }
Exemplo n.º 11
0
        private void NetworkControl_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            const double ZoomPower = 1.002;

            Point  screen = e.GetPosition(NetworkControl);
            double zoom   = Math.Pow(ZoomPower, e.Delta);

            NetworkControl.DoZoom(screen, zoom);
        }
Exemplo n.º 12
0
        private void NetworkControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point p = e.GetPosition(NetworkControl);

            p = NetworkControl.ScreenToLocal(p);

            ActionContext c = GetActionContext();

            c?.MouseDown?.Invoke(p);
        }
Exemplo n.º 13
0
        private void NetworkControl_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = e.GetPosition(NetworkControl);

            p = NetworkControl.ScreenToLocal(p);

            ActionContext c = GetActionContext();

            c?.MouseMove?.Invoke(p);
        }
Exemplo n.º 14
0
        private void boxRange_TextChanged(object sender, TextChangedEventArgs e)
        {
            double newRange;

            if (Network != null && double.TryParse(boxRange.Text, out newRange))
            {
                Network.BaseTransmitRange = newRange;
                NetworkControl.Redraw();
            }
        }
    public void StartServer()
    {
        Control        ctrl    = GameObject.FindGameObjectWithTag("Control").GetComponent <Control>();
        NetworkControl netCtrl = GameObject.FindGameObjectWithTag("NetworkControl").GetComponent <NetworkControl>();

        netCtrl.networkAddress = netCtrl.networkAddress;
        netCtrl.networkPort    = int.Parse(PortInput.text);
        ctrl.isDedicatedServer = DedicatedServerToggle.isOn;
        netCtrl.StartHost();
    }
Exemplo n.º 16
0
 private void OnLobbyJoined(LobbyEnter_t pCallbacks, bool bIOFailure)
 {
     NetworkControl.CreateConnections(lobby);
     if (events.lobby_just_joined != null)
     {
         events.lobby_just_joined.Invoke();
     }
     SendChatMessage(SteamFriends.GetPersonaName() + " Joined the Lobby", false);
     NetworkControl.instance.CheckJoinedLobby();
 }
Exemplo n.º 17
0
        void MoveMouseMove(Point p)
        {
            MoveHighlightNode(p);

            if (panning)
            {
                NetworkControl.DoScrollLocal(p - lastMove);
                //lastMove = p;
            }
        }
Exemplo n.º 18
0
        public void Networkbutton_Click(object sender, RoutedEventArgs e)
        {
            ListBoxItem item = new ListBoxItem();

            EditorLD.Items.Add(item);
#pragma warning disable CS0436 // Тип конфликтует с импортированным типом
            NetworkControl item1 = new NetworkControl();
#pragma warning restore CS0436 // Тип конфликтует с импортированным типом
            EditorLD.Items.Add(item1);
        }
 private async void NetworkInformation_NetworkStatusChanged(object sender)
 {
     Log.Enter();
     if (!connected)
     {
         await OOBENetworkPageDispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
         {
             NetworkControl.SetupDirectConnection();
         });
     }
     Log.Leave();
 }
Exemplo n.º 20
0
        private void StopSimulation()
        {
            if (SimulationRunning)
            {
                btnStartStop.Content = "Start Simulation";
                SimulationTimer.Change(Timeout.Infinite, Timeout.Infinite);
                Simulation = null;
                NetworkControl.StopSimulation();

                comboBox.IsEnabled = true;
            }
        }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
        /// <summary>
        /// Event raised on mouse up in the NetworkView.
        /// </summary>
        private void networkControl_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (_mouseHandlingMode != MouseHandlingMode.None)
            {
                if (_mouseHandlingMode == MouseHandlingMode.Panning)
                {
                    //
                    // Panning was initiated but dragging was abandoned before the mouse
                    // cursor was dragged further than the threshold distance.
                    // This means that this basically just a regular left mouse click.
                    // Because it was a mouse click in empty space we need to clear the current selection.
                    //
                }
                else if (_mouseHandlingMode == MouseHandlingMode.Zooming)
                {
                    if (_mouseButtonDown == MouseButton.Left)
                    {
                        // Shift + left-click zooms in on the content.
                        ZoomIn(_origContentMouseDownPoint);
                    }
                    else if (_mouseButtonDown == MouseButton.Right)
                    {
                        // Shift + left-click zooms out from the content.
                        ZoomOut(_origContentMouseDownPoint);
                    }
                }
                else if (_mouseHandlingMode == MouseHandlingMode.DragZooming)
                {
                    // When drag-zooming has finished we zoom in on the rectangle that was highlighted by the user.
                    ApplyDragZoomRect();
                }

                //
                // Reenable clearing of selection when empty space is clicked.
                // This is disabled when drag panning is in progress.
                //
                NetworkControl.IsClearSelectionOnEmptySpaceClickEnabled = true;

                //
                // Reset the override cursor.
                // This is set to a special cursor while drag panning is in progress.
                //
                Mouse.OverrideCursor = null;

                NetworkControl.ReleaseMouseCapture();
                _mouseHandlingMode = MouseHandlingMode.None;
                e.Handled          = true;
            }
        }
Exemplo n.º 23
0
        private void ShowGenomeNetwork(NeatGenome genome)
        {
            NetworkControl networkControl = new NetworkControl();

            networkControl.Dock = DockStyle.Fill;
            panelNetWorkViewer.Controls.Clear();
            panelNetWorkViewer.Controls.Add(networkControl);

            /* create network model to draw the network */
            NetworkModel      networkModel  = GenomeDecoder.DecodeToNetworkModel(genome);
            GridLayoutManager layoutManager = new GridLayoutManager();

            layoutManager.Layout(networkModel, networkControl.Size);
            networkControl.NetworkModel = networkModel;
        }
Exemplo n.º 24
0
    // Use this for initialization
    void Start()
    {
        NetworkTransport.Init();
        servers = new List <PlayerInfo>();

        IPAddress  ip      = IPAddress.Parse("224.5.6.7");
        IPEndPoint localEP = new IPEndPoint(NetworkControl.LocalIPAddress(), multicastPort);

        listener = new UdpClient();
        listener.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
        listener.Client.Bind(localEP);
        listener.JoinMulticastGroup(ip);
        receive_byte_array = new byte[1024];
        receiveThread      = new Thread(ReceiveData);
        serverList         = new List <PlayerInfo>();
        receiveThread.Start();
    }
 void Update()
 {
     if (IsLocalObject)
     {
         CurrentTime -= Time.deltaTime;
         if (CurrentTime <= 0)
         {
             CurrentTime = 1 / 9;
             NetworkControl.SendPackets(
                 new P2PPackage(new Lib.M_Vector3(transform.position), P2PPackageType.SyncTransform,
                                identity),
                 EP2PSend.k_EP2PSendUnreliable, false);
         }
     }
     if (!IsLocalObject)
     {
         transform.position = Vector3.Lerp(transform.position, TargetPosition, 1f);
     }
 }
        public OOBENetwork()
        {
            this.InitializeComponent();
            OOBENetworkPageDispatcher = Window.Current.Dispatcher;

            NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged;
            NetworkControl.NetworkConnected         += NetworkGrid_NetworkConnected;


            this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;

            this.DataContext = LanguageManager.GetInstance();

            this.Loaded += async(sender, e) =>
            {
                await OOBENetworkPageDispatcher.RunAsync(CoreDispatcherPriority.Low, async() => {
                    NetworkControl.SetupDirectConnection();
                    await NetworkControl.RefreshWifiListViewItemsAsync(true);
                });
            };
        }
Exemplo n.º 27
0
        public OOBENetworkPage()
        {
            InitializeComponent();
            _oobeNetworkPageDispatcher = Window.Current.Dispatcher;

            NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged;

            _rootFrame = Window.Current.Content as Frame;

            NavigationCacheMode = NavigationCacheMode.Enabled;

            DataContext = LanguageManager.GetInstance();

            Loaded += async(sender, e) =>
            {
                await _oobeNetworkPageDispatcher.RunAsync(CoreDispatcherPriority.Low, async() => {
                    DirectConnectControl.SetUpDirectConnection();
                    await NetworkControl.RefreshWiFiListViewItemsAsync(true);
                });
            };
        }
Exemplo n.º 28
0
        void AddMouseDown(Point p)
        {
            ActionContext c = GetActionContext();

            if (c?.AddNodeType != null)
            {
                // Verify that we are not adding too close to another node.
                if (SelectedNode != null)
                {
                    return;
                }

                Network.Nodes.Add(new WirelessNetworkNode()
                {
                    NodeType = c.AddNodeType.FullName,
                    X        = p.X,
                    Y        = p.Y
                });

                NetworkControl.Redraw();
            }
        }
Exemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        gameIndex           = SceneManager.GetActiveScene().buildIndex;
        CharacterHighlights = new List <GameObject>();
        difficultyHighlight = null;
        turnHighlight       = null;

        GameObject net = GameObject.FindGameObjectWithTag("network");

        if (net)
        {
            netController = net.GetComponent <NetworkControl>();
            netController.SetCharacterSelect(this);
            if (netController.isClient)
            {
                //player1 is black
                PlayerPrefs.SetInt("player1", 1);
            }
            else
            {
                //player1 is white
                PlayerPrefs.SetInt("player1", 0);
            }
        }

        waitPanel = GameObject.FindGameObjectWithTag("waitPanel");
        if (waitPanel)
        {
            waitPanel.SetActive(false);
        }

        timeoutPanel = GameObject.FindGameObjectWithTag("timeoutPanel");
        if (timeoutPanel)
        {
            timeoutPanel.SetActive(false);
        }
    }
Exemplo n.º 30
0
    public void EmoteClicked(int emote)
    {
        //deactivate emote buttons
        emoteButtons.SetActive(false);
        ToggleOpen panelManager = GameObject.FindGameObjectWithTag("panelManager").GetComponent <ToggleOpen>();

        panelManager.SelectedPanel = null;

        //get the emote text
        emoteText = emotePanel.transform.GetChild(0).GetComponent <Text>();

        PlayEmoteAudio(emote);
        StartCoroutine(AnimateLocalEmotePanel(emote));

        int gameIndex = SceneManager.GetActiveScene().buildIndex;

        if (gameIndex == 7)
        {
            //send the emote over the network
            netController = GameObject.FindGameObjectWithTag("network").GetComponent <NetworkControl>();
            string tosend = "emote|" + emote;
            netController.Send(tosend);
        }
    }
Exemplo n.º 31
0
    // Use this for initialization
    void Start()
    {
        // The total of drones should be divisible by the number of spawn locations;
        if (drone_number % spawn_locations.Length == 0)
        {
            drones_per_location = drone_number / spawn_locations.Length;
        }
        else
        {
            Debug.LogError("Number of Drones is not devisable by amount of spawn locations");
        }

        destination = new Transform[spawn_locations.Length];
        //Find the corresponding destination locations
        // In case we have a checkpoint, the destination becomes that checkpoint,
        //  Else we will just use end position
        if (checkpoint == null)
        {
            GameObject[] candidates = GameObject.FindGameObjectsWithTag("Mothership");
            if (candidates.Length > 1)
            {
                DroneSpawn s;
                // Check for both objects if it is the mothership we want
                if (candidates[0].transform == this.transform)
                {
                    s = candidates[1].GetComponent<DroneSpawn>();
                }
                else
                {
                    s = candidates[0].GetComponent<DroneSpawn>();
                }

                Transform[] temp_spawn = s.spawn_locations;

                // Copy the spawn locations on the opposing mothership
                // as the destination of our mothership
                for (int i = 0; i < temp_spawn.Length; i++)
                {
                    destination[temp_spawn.Length - 1 - i] = temp_spawn[i];
                }

            }
            else
            {
                Debug.LogError("No Destination Mothership in scene");
            }
        }
        else
        {
            for (int i = 0; i < destination.Length; i++)
                {
                    destination[i] = checkpoint.transform;
                }
        }
        // Start the spawn calls in startTime seconds
        InvokeRepeating("SpawnDrones", startTime, repeatTime);

        ///
        /// Network Code Below
        ///
        if (!GlobalSettings.SinglePlayer)
        {
            this.networkControl = GameObject.Find("NetworkControl").GetComponent<NetworkControl>();
            this.guidGenerator = this.networkControl.GetComponent<GUIDGenerator>();
            this.ownObjectSync = this.GetComponent<ObjectSync>();
            this.objectTables = GameObject.Find("PlayerObjectTable").GetComponent<PlayerObjectTable>();
        }
        ///
        /// End Network Code
        ///
    }
Exemplo n.º 32
0
	void Start()
	{
		nc = GameObject.Find("Scripts").GetComponent<NetworkControl>();
	}