Exemplo n.º 1
0
        private void LoadConfiguration(Config config)
        {
            UpTextBox.Text = config.KeyboardUp.ToString();
            DownTextBox.Text = config.KeyboardDown.ToString();
            LeftTextBox.Text = config.KeyboardLeft.ToString();
            RightTextBox.Text = config.KeyboardRight.ToString();
            FrontTextBox.Text = config.KeyboardFront.ToString();
            BackTextBox.Text = config.KeyboardBack.ToString();
            TiltLeftTextBox.Text = config.KeyboardTiltLeft.ToString();
            TiltRightTextBox.Text = config.KeyboardTiltRight.ToString();
            FireTextBox.Text = config.KeyboardTiltRight.ToString();

            MouseLeft.SelectedIndex = config.MouseLeft;
            MouseRight.SelectedIndex = config.MouseRight;
            MouseUp.SelectedIndex = config.MouseUp;
            MouseDown.SelectedIndex = config.MouseDown;
            MouseFront.SelectedIndex = config.MouseFront;
            MouseBack.SelectedIndex = config.MouseLeft;
            MouseTiltLeft.SelectedIndex = config.MouseTiltLeft;
            MouseTiltRight.SelectedIndex = config.MouseTiltRight;
            MouseFire.SelectedIndex = config.MouseFire;

            SpeechLeft.Text = config.SpeechLeft;
            SpeechRight.Text = config.SpeechRight;
            SpeechUp.Text = config.SpeechUp;
            SpeechDown.Text = config.SpeechDown;
            SpeechFront.Text = config.SpeechFront;
            SpeechBack.Text = config.SpeechLeft;
            SpeechTiltLeft.Text = config.SpeechTiltLeft;
            SpeechTiltRight.Text = config.SpeechTiltRight;
            SpeechFire.Text = config.SpeechFire;

            PlayerEndpoint.Text = config.PlayerEndpoint;
            EnemyEndpoint.Text = config.EnemyEndpoint;
        }
Exemplo n.º 2
0
        public Configuration()
        {
            this.InitializeComponent();

            config = new Config();
            LoadConfiguration(config);
        }
Exemplo n.º 3
0
        private void SaveConfiguration(Config config)
        {
            config.KeyboardLeft = (Key) Enum.Parse(typeof(Key), LeftTextBox.Text);
            config.KeyboardRight = (Key) Enum.Parse(typeof(Key), RightTextBox.Text);
            config.KeyboardUp = (Key )Enum.Parse(typeof(Key), UpTextBox.Text);
            config.KeyboardDown = (Key) Enum.Parse(typeof(Key), DownTextBox.Text);
            config.KeyboardFront = (Key) Enum.Parse(typeof(Key), FrontTextBox.Text);
            config.KeyboardBack = (Key) Enum.Parse(typeof(Key), BackTextBox.Text);
            config.KeyboardTiltLeft = (Key)Enum.Parse(typeof(Key), TiltLeftTextBox.Text);
            config.KeyboardTiltRight = (Key)Enum.Parse(typeof(Key), TiltRightTextBox.Text);
            config.KeyboardFire = (Key)Enum.Parse(typeof(Key), FireTextBox.Text);

            config.MouseLeft = MouseLeft.SelectedIndex;
            config.MouseRight = MouseRight.SelectedIndex;
            config.MouseUp = MouseUp.SelectedIndex;
            config.MouseDown = MouseDown.SelectedIndex;
            config.MouseFront = MouseFront.SelectedIndex;
            config.MouseBack = MouseBack.SelectedIndex;
            config.MouseTiltLeft = MouseTiltLeft.SelectedIndex;
            config.MouseTiltRight = MouseTiltRight.SelectedIndex;
            config.MouseFire = MouseFire.SelectedIndex;

            config.SpeechLeft = SpeechLeft.Text;
            config.SpeechRight = SpeechRight.Text;
            config.SpeechUp = SpeechUp.Text;
            config.SpeechDown = SpeechDown.Text;
            config.SpeechFront = SpeechFront.Text;
            config.SpeechBack = SpeechBack.Text;
            config.SpeechTiltLeft = SpeechTiltLeft.Text;
            config.SpeechTiltRight = SpeechTiltRight.Text;
            config.SpeechFire = SpeechFire.Text;

            config.PlayerEndpoint = PlayerEndpoint.Text;
            config.EnemyEndpoint = EnemyEndpoint.Text;

            config.Save();
        }
Exemplo n.º 4
0
        void StartNetwork()
        {
            Config config = new Config();
            ServiceHost service = new ServiceHost(NetworkInput.Instance);
            service.AddServiceEndpoint(
                typeof(XnaSpace.Input.INetworkInputService),
                new NetTcpBinding(),
                config.PlayerEndpoint);
            service.Open();
            Binding binding = new NetTcpBinding();
            EndpointAddress endpointAddress = new EndpointAddress(config.EnemyEndpoint);
            NetworkClient client = new NetworkClient(binding, endpointAddress);
            int tries = 50;

            while (0 != tries)
            {
                try
                {
                    client.Open();
                    break;
                }
                catch (Exception)
                {
                    Thread.Sleep(1000);
                }
                --tries;
            }

            using (Space game = new Space(client))
            {
                game.Run();
            }
            try
            {
                client.Close();
                service.Close();
            }
            catch (Exception)
            {
            }
        }