Exemplo n.º 1
0
    static public LocalPlayerControl CreateLocalPlayer(int id, float x, float y, float z)
    {
        try
        {
            Vector3 pos = new Vector3(x, y, z);
            //pos.y = Utility.GetTerrainY(pos);
            Quaternion rotation = Quaternion.Euler(new Vector3(0, 0, 0));

            GameObject logicObj = GameObject.Instantiate(Resources.Load("Prefab/Player/Alice/Alice")) as GameObject;
            logicObj.name = "123456";
            if (null != logicObj)
            {
                GameObject modelObj = logicObj.transform.GetChild(0).gameObject;

                LocalPlayerControl.Instance = logicObj.AddComponent <LocalPlayerControl>();

                NavMeshAgent navMeshAgent = logicObj.AddComponent <NavMeshAgent>();
                navMeshAgent.radius           = 0.5f;
                navMeshAgent.height           = 1.6f;
                navMeshAgent.baseOffset       = -0.1f;
                navMeshAgent.speed            = 1;
                navMeshAgent.angularSpeed     = 0;
                navMeshAgent.acceleration     = 100;
                navMeshAgent.stoppingDistance = 0.05f;
                LocalPlayerControl.Instance.m_navMeshAgent = navMeshAgent;

                HumanoidAvatar humanAvatar = modelObj.AddComponent <HumanoidAvatar>();
                humanAvatar.humanoidControl = LocalPlayerControl.Instance;
                LocalPlayerControl.Instance.m_humanoidAvatar = humanAvatar;

                KeyboardControl control = logicObj.AddComponent <KeyboardControl>();

                //ÉèÖÃLayer
                //logicObj.layer = LayerMask.NameToLayer("Model");

                LocalPlayerControl.Instance.SetPosition(pos);
                LocalPlayerControl.Instance.SetRotation(rotation);
                //Utility.AdjustYAxis(LocalPlayerControl.Instance);

                LocalPlayerControl.Instance.Initialize();

                return(LocalPlayerControl.Instance);
            }
            else
            {
                LogManager.Log("Player Load Error: ", LogType.Error);
                return(null);
            }
        }
        catch (UnityException uex)
        {
            LogManager.Log(uex.ToString(), LogType.Fatal);
            return(null);
        }
        catch (Exception ex)
        {
            LogManager.Log(ex.ToString(), LogType.Fatal);
            return(null);
        }
    }
Exemplo n.º 2
0
        private void KeyboardControl_IsTitleFoundChanged(object sender, SimpleMvvmToolkit.NotificationEventArgs e)
        {
            Debug.WriteLine("Keyboard event : IsTitleFoundChanged");
            KeyboardControl keyboardControl = sender as KeyboardControl;

            if (keyboardControl == null || this.CurrentViewModel == null || this.CurrentViewModel.SelectedMedia == null)
            {
                return;
            }

            if (keyboardControl.IsFound)
            {
                this.CurrentViewModel.CurrentMediaTitleFound();


                if (AppSettings.Instance.SoundOnOffSetting)
                {
                    // Load the SoundEffect
                    var         info   = App.GetResourceStream(new Uri("Resources/Sounds/success.wav", UriKind.Relative));
                    SoundEffect effect = SoundEffect.FromStream(info.Stream);
                    // Tell the XNA Libraries to continue to run
                    FrameworkDispatcher.Update();
                    // Play the Sound
                    effect.Play();
                }
            }

            //this.CurrentViewModel.SelectedMedia.IsCompleted = keyboardControl.IsFound;
            //this.CurrentViewModel.ProposerTitre();
        }
        public void InitLanguageCombo_Errors()
        {
            DummyKeyboardAdaptor.DummyInstalledKeyboards = new List <IKeyboardDescription>(new []
            {
                new KeyboardDescription(1033, "English (United States)", null),
                new KeyboardDescription(1031, "German (Germany)", null)
            });
            DummyKeyboardAdaptor.DummyErrorKeyboards = new List <IKeyboardErrorDescription>(new []
            {
                new KeyboardErrorDescription(1111)
            });
            KeyboardController.Manager.SetKeyboardAdaptors(new [] { new DummyKeyboardAdaptor() });
            using (var sut = new KeyboardControl())
            {
                var ws = new DummyWritingSystem("en-US", 1033);
                // this fills the combo boxes
                sut.WritingSystem = ws;

                var combo = (ComboBox)sut.Controls["m_langIdComboBox"];
                CollectionAssert.AreEqual(DummyKeyboardAdaptor.DummyInstalledKeyboards, combo.Items);
                Assert.AreEqual(2, combo.Items.Count);

                Assert.AreEqual(1, m_MsgBox.Count);
                Assert.AreEqual("The following system locales are invalid, so will be omitted from " +
                                "the list of System Languages for keyboard input: 1111", m_MsgBox.Text);
                Assert.AreEqual("Error", m_MsgBox.Caption);
            }
        }
Exemplo n.º 4
0
        public void btnKeyControlChangeUnless_Click(Object sender, EventArgs e)
        {
            if (lstKeyboardControls.SelectedIndex < 0)
            {
                return;
            }

            var capture = new frmKeyboardControl();

            if (capture.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (capture.Results.Count == 0)
            {
                return;
            }
            var keyOption = lstKeyboardControls_Items[lstKeyboardControls.SelectedIndex];
            var previous  = (KeyboardControl)(ChangedKeyControls.GetValue(keyOption));

            var unlessKeys = new Keys[capture.Results.Count];

            for (var i = 0; i <= capture.Results.Count - 1; i++)
            {
                unlessKeys[i] = capture.Results[i];
            }
            var copy = new KeyboardControl(previous.Keys, unlessKeys);

            ChangedKeyControls.SetChanges(keyOption, new Change <KeyboardControl>(copy));
            UpdateKeyboardControl(keyOption.GroupLink.ArrayPosition);
        }
 public void Setup()
 {
     m_MsgBox = new RememberingMessageBox();
     MessageBoxUtils.Manager.SetMessageBoxAdapter(m_MsgBox);
     KeyboardController.Manager.Reset();
     KeyboardControl.ResetErrorMessages();
     DummyKeyboardAdaptor.Reset();
 }
Exemplo n.º 6
0
    protected void Start()
    {
        kc = GetComponent <KeyboardControl>();
        mc = GetComponent <MouseControl>();

        kc.enabled = !startWithMouseControls;
        mc.enabled = startWithMouseControls;
    }
Exemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     if (this.keyboard == null)
     {
         this.keyboard = GameObject.FindWithTag("Keyboard");
     }
     this.controller = this.keyboard.GetComponent <KeyboardControl> ();
 }
Exemplo n.º 8
0
    protected void Start()
    {
        kc = GetComponent<KeyboardControl>();
        mc = GetComponent<MouseControl>();

        kc.enabled = !startWithMouseControls;
        mc.enabled = startWithMouseControls;
    }
Exemplo n.º 9
0
        public Form4()
        {
            InitializeComponent();

            virtualKeyboard          = new KeyboardControl();
            virtualKeyboard.Location = new Point(10, 200);
            virtualKeyboard.Visible  = false;
            virtualKeyboard.Text     = "Touch Keyboard";

            this.Controls.Add(virtualKeyboard);
        }
Exemplo n.º 10
0
    private void init()
    {
        blood              = 1;
        Max_blood          = 10;
        KeyboardController = Instantiate((GameObject)Resources.Load("Prefab\\KeyboardController"));
        kbc = KeyboardController.GetComponent <KeyboardControl>();
        Instantiate((GameObject)Resources.Load("player\\Show_Object"));
        Get_Map = Instantiate((GameObject)Resources.Load("Product\\Get_Map"));
        GameObject obj = Instantiate((GameObject)Resources.Load("player\\player"));

        obj.transform.position = new Vector2(0, 50);
        GameObject tp = Instantiate((GameObject)Resources.Load("player\\Reback_Point"));

        Reback_Point          = tp;
        tp.transform.position = obj.transform.position;
        player = obj;
        camera = GameObject.Find("Main Camera");
    }
        public void InitLanguageCombo_AllOk()
        {
            DummyKeyboardAdaptor.DummyInstalledKeyboards = new List <IKeyboardDescription>(new []
            {
                new KeyboardDescription(1033, "English (United States)", null),
                new KeyboardDescription(1031, "German (Germany)", null)
            });
            KeyboardController.Manager.SetKeyboardAdaptors(new [] { new DummyKeyboardAdaptor() });

            using (var sut = new KeyboardControl())
            {
                var ws = new DummyWritingSystem("en-US", 1033);
                // this fills the combo boxes
                sut.WritingSystem = ws;

                var combo = (ComboBox)sut.Controls["m_langIdComboBox"];
                CollectionAssert.AreEqual(DummyKeyboardAdaptor.DummyInstalledKeyboards, combo.Items);
                Assert.AreEqual(2, combo.Items.Count);
                Assert.AreEqual(0, m_MsgBox.Count);
            }
        }
        public void InitLanguageCombo()
        {
            using (var sut = new KeyboardControl())
            {
                var ws = new DummyWritingSystem("en-US", 1033);
                // this fills the combo boxes
                sut.WritingSystem = ws;

                var  combo = (ComboBox)sut.Controls["m_langIdComboBox"];
                bool found = false;
                foreach (IKeyboardDescription item in combo.Items)
                {
                    Console.WriteLine("{0}: {1}", item.Id, item.Name);
                    if (item.Id == 1033)
                    {
                        found = true;
                    }
                }

                Assert.IsTrue(found,
                              "keyboard layout combobox did not contain the 'English (United States)' keyboard");
            }
        }
Exemplo n.º 13
0
        private void keyboardControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (this.CurrentViewModel == null)
            {
                return;
            }

            KeyboardControl keyboard = sender as KeyboardControl;

            if (keyboard == null)
            {
                return;
            }

            Media dataContext = keyboard.DataContext as Media;

            if (dataContext == null)
            {
                return;
            }

            keyboard.InitializeState(dataContext.Title, dataContext.IsCompleted, Constants.QUIZZ_APP_HELP_LIMIT);
        }
Exemplo n.º 14
0
        public void AddChar(char c, KeyboardControl t)
        {
            switch (t)
            {
                case KeyboardControl.Char:
                    Text = Text + c;
                    break;

                case KeyboardControl.SpaceBar:
                    Text = Text + '\u0020';
                    break;

                case KeyboardControl.NumericKeypad:
                    break;

                case KeyboardControl.Back:
                    break;

                case KeyboardControl.Backspace:
                    if (Text.Length > 1)
                    {
                        Text = Text.Substring(0, Text.Length - 1);
                    }
                    else if (Text.Length == 1)
                    {
                        Text = string.Empty;
                    }
                    break;

                case KeyboardControl.Enter:
                    break;

                case KeyboardControl.AlphaKeypad:
                    break;
            }
        }
Exemplo n.º 15
0
 public void Init()
 {
     isDead = true;
     control = GetComponent<KeyboardControl>();
     sprite = GetComponent<tk2dSprite>();
     stream = GetComponentInChildren<Stream>();
     rayCasters = gameObject.GetComponentsInChildren<RayCaster>();
     Static.Events.MiddlePointReached += MiddlePointReached;
     Static.Events.CriticalPointReached += CriticalPointReached;
     Static.Events.CriticalPointExited += CriticalPointExited;
     Static.Events.DeathZoneReached += DeathZoneReached;
     Static.Events.CameraUpdateComplete += UpdatePosition;
 }
Exemplo n.º 16
0
 // opcode 102 - change keyboard control
 /**
    * @see <a href="XChangeKeyboardControl.html">XChangeKeyboardControl</a>
    */
 public void change_keyboard_control(KeyboardControl control)
 {
     display.send_request (new Request.ValueList (
       display, 102, 2, 0, control));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Starts forwarding keyboard events to the specified WPF control.
 /// </summary>
 /// <param name="control">The control to forward input to.</param>
 /// <param name="releaseOnEnter">If true, keyboard capture will cease when the enter key is pressed,
 /// otherwise, <see cref="KeyboardCapture" /> has to be explicitly set to false.</param>
 public void StartKeyboardCapture(System.Windows.Controls.Control control, bool releaseOnEnter = true)
 {
     KeyboardCapture  = true;
     _keyboardControl = new WpfKeyboardControl(control, releaseOnEnter);
 }
Exemplo n.º 18
0
 public void SetController(KeyboardControl cont)
 {
     _inputController = cont;
     _inputController.RegisterObject(this, type);
 }
Exemplo n.º 19
0
        // opcode 102 - change keyboard control

        /**
         * @see <a href="XChangeKeyboardControl.html">XChangeKeyboardControl</a>
         */
        public void change_keyboard_control(KeyboardControl control)
        {
            display.send_request(new Request.ValueList(
                                     display, 102, 2, 0, control));
        }
Exemplo n.º 20
0
        protected void OnCharPressed(char c, KeyboardControl e)
        {
            if (this.AutoConnectFocusedTextbox)
            {
                foreach (var t in Parent.UICanvas)
                {
                    Textbox txt = t as Textbox;

                    if (txt != null && txt.Focused)
                    {
                        txt.AddChar(c, e);
                        break;
                    }
                }
            }

            if (OnCharPressedEvent != null)
            {
                OnCharPressedEvent(this, c, e);
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// Starts forwarding keyboard events to the specified WinForms control.
 /// </summary>
 /// <param name="control">THe control to forward input to.</param>
 /// <param name="releaseOnEnter">If true, keyboard capture will cease when the enter key is pressed,
 /// otherwise, <see cref="KeyboardCapture" /> has to be explicitly set to false.</param>
 public void StartKeyboardCapture(Control control, bool releaseOnEnter = true)
 {
     KeyboardCapture  = true;
     _keyboardControl = new WinFormsKeyboardControl(control, releaseOnEnter);
 }
Exemplo n.º 22
0
        /// <summary>
        /// Initializes the KeyboardController, blocks user input, and sets
        /// the focus on the specified control.
        /// </summary>
        /// <param name="control">The ControlTester to use the keyboard on.</param>
        public void UseOn(ReflectionTester control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            Control c = control.TheObject as Control;
            FormsAssert.IsTrue(c != null, "Keyboard control requires tester of Control");
            sendKeys = sendKeysFactory.Create(c.Handle);

            keyboardControl = new KeyboardControl(control);

            if (!restoreUserInput)
            {
                //if this next line returns false, I used to throw an exception...
                Win32.BlockInput(true);
                restoreUserInput = true;
            }
        }