Esempio n. 1
0
    public virtual void Start()
    {
        charInput    = GetComponent <CharInput>();
        controller   = GetComponent <CharacterController>();
        animator     = GetComponent <Animator> ();
        rbody        = GetComponent <Rigidbody>();
        arm          = transform.Find("Armature").Find("Bone").Find("Bone.007");
        forearm      = arm.Find("Bone.008");
        hand         = forearm.Find("Bone.009");
        cameraT      = charInput.cameraT;
        spells       = new String[] { "FlameSpell", "DeathSpell", "BaseBoltSpell", "BaseBoltHeavySpell", "FireBoltCharge", "FreezeSpell" };
        timeSinceUse = new float[spells.Length];
        for (int i = 0; i < timeSinceUse.Length; i++)
        {
            timeSinceUse[i] = 5000;
        }
        spell = (GameObject)Resources.Load("Prefabs/" + spells[spellIndex]);
        spell.GetComponent <Spell>().PreStartStuff();
        shield = (GameObject)Resources.Load("Prefabs/DefaultShield");
        health = totalHealth;

        layermasknum     = ~((1 << (gameObject.layer)) | (1 << (gameObject.layer + 3)));
        Cursor.lockState = CursorLockMode.Locked;
        //animator.speed = 0.5f;
    }
Esempio n. 2
0
        public ClientForm()
        {
            InitializeComponent();
            UserInput.SetCueBanner("Username");
            PassInput.SetCueBanner("Password");
            PicInput.SetCueBanner("PIC");
            CharInput.SetCueBanner("Character");
            PacketInput.SetCueBanner("Enter packet to send...");
            DelayInput.SetCueBanner("Delay");
            InitializeProgress();

            client = new Client(this);
            PacketView.SetInput(PacketInput);
            RushView.SetClient(client);

            FmFunctions = new FreeMarketForm(this);

#if DEBUG
            /*Use this for testing account
            *  username.Text           = "";
            *  password.Text           = "";
            *  pic.Text                = "";
            *  character.Text          = "";
            *  world.SelectedIndex     = 0;
            *  channel.SelectedIndex   = 0;*/
#endif
            InitializeAccount();
        }
Esempio n. 3
0
 private void Start()
 {
     target = GameObject.Find("Player").transform;
     m_LastTargetPosition = target.position;
     m_OffsetZ            = (transform.position - target.position).z;
     transform.parent     = null;
     charInput            = GameObject.Find("Player").GetComponent <CharInput>();
 }
Esempio n. 4
0
        public void CharInput_Works()
        {
            CharInput ti = new CharInput();

            ti.Add('1');
            ti.Add('c');
            ti.Add('2');
            Assert.IsTrue(ti.GetValue() == "1c2", "CharInput value doesn't match expected");
        }
Esempio n. 5
0
        private void PushChar(char c)
        {
            if (!ConsumeInput)
            {
                Text = Text.Insert(Cursor, c.ToString());
                Cursor++;
            }

            CharInput.SetResult(c);
            CharInput = new TaskCompletionSource <char>();
        }
Esempio n. 6
0
 public override string ToString()
 {
     if (IsCharGroup)
     {
         throw new NotImplementedException();
     }
     else
     {
         return(CharInput.ToString());
     }
 }
Esempio n. 7
0
    public virtual void Start()
    {
        charInput  = GetComponent <CharInput>();
        controller = GetComponent <CharacterController>();
        animator   = GetComponent <Animator> ();
        rbody      = GetComponent <Rigidbody>();
        arm        = transform.Find("Armature").Find("Bone").Find("Bone.007");
        forearm    = arm.Find("Bone.008");
        hand       = forearm.Find("Bone.009");
        cameraT    = charInput.cameraT;
        spells     = new String[] { "FreezeSpell", "DeathSpell", "FireBoltCharge", "BaseBoltSpell", "BaseBoltHeavySpell" };
        spell      = (GameObject)Resources.Load("Prefabs/" + spells[spellIndex]);
        crosshair  = GameObject.Find("Canvas").transform.Find("Crosshair");
        health     = totalHealth;

        //animator.speed = 0.5f;
    }
Esempio n. 8
0
        private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
        {
            if (nCode == 0)
            {
                EventMsg msg = (EventMsg)Marshal.PtrToStructure(lParam, typeof(EventMsg));
                if (wParam == WM_KEYUP)
                {
                    int vkCode = Marshal.ReadInt32(lParam);

                    Keys key = (Keys)vkCode;

                    if (key == Keys.LShiftKey)
                    {
                        _shift = false;
                        goto END1;
                    }
                }

                if (wParam == WM_KEYDOWN)//WM_KEYDOWN=0x100
                {
                    int vkCode = Marshal.ReadInt32(lParam);

                    Keys key = (Keys)vkCode;

                    if (key == Keys.LShiftKey)
                    {
                        _shift = true;
                        // Console.WriteLine($"modi {(System.Windows.Forms.Keys)vkCode}");
                        goto END1;
                    }

                    TimeSpan ts = DateTime.Now.Subtract(_string.Time);
                    if (ts.TotalMilliseconds > TIME_SHTRESHOLD)
                    {
                        _barcode.Clear();
                    }

                    _string.Time = DateTime.Now;

                    //KeysConverter kc = new KeysConverter();
                    //string keyChar = kc.ConvertToString(key);

                    string keyChar = GetKeyString(key, _shift);
                    Debug.WriteLine($"keyChar='{keyChar}', key='{key.ToString()}'");

                    _barcode.Append(keyChar);

                    // 保护缓冲区
                    if (_barcode.Length > 1000)
                    {
                        _barcode.Clear();
                    }

                    Debug.WriteLine($"msg.message={(msg.message & 0xff)} _barcode:'{_barcode.ToString()}'");

                    if (InputChar != null)
                    {
                        CharInput input = new CharInput {
                            Key     = key,
                            KeyChar = keyChar,
                        };
                        AsyncCallback callback = new AsyncCallback(AsyncBackCharFeed);
                        Delegate[]    delArray = InputChar.GetInvocationList();
                        foreach (Delegate_charFeed del in delArray)
                        {
                            try
                            {
                                del.BeginInvoke(input, callback, del);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }
                    }

                    if ((msg.message & 0xff) == 13 && _barcode.Length > 3)
                    {
                        // 回车
                        _string.Barcode = _barcode.ToString();// barCode.OriginalBarCode;
                        _string.IsValid = true;
                        _barcode.Remove(0, _barcode.Length);

                        Debug.WriteLine($"isValid = true");
                    }
                    else
                    {
                        goto END1;
                    }

                    try
                    {
                        if (InputLine != null
                            // && _string.IsValid
                            )
                        {
                            Debug.WriteLine($"trigger callback");

                            AsyncCallback callback = new AsyncCallback(AsyncBackLineFeed);
                            Delegate[]    delArray = InputLine.GetInvocationList();
                            foreach (Delegate_lineFeed del in delArray)
                            {
                                try
                                {
                                    del.BeginInvoke(_string, callback, del); // 异步调用防止界面卡死
                                }
                                catch (Exception ex)
                                {
                                    throw ex;
                                }
                            }
                            //BarCodeEvent(barCode);//触发事件
                            _string.Barcode = "";
                            //_char.OriginalChrs = "";
                            //_char.OriginalAsciis = "";
                            //_char.OriginalBarCode = "";
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    finally
                    {
                        _string.IsValid = false;
                        _string.Time    = DateTime.Now;
                    }
                }
            }
END1:
            if (Handled == true)
            {
                return(1);
            }
            return(CallNextHookEx(hKeyboardHook, nCode, wParam, lParam));
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            //Data Items
            double       w1, w2, h1, h2, radius, triangle, area = 0, roofarea = 0, reqpaintgal, reqpaintlit;
            double       roofpaintgal = 0, roofpaintlit = 0;
            char         measurement = ' '; char shape = ' '; char repeat = 'y'; char knowarea = 'n';
            double       coverage = 350.00; // For 1 gallon of paint
            const double metresCoverage = 10.75, galtolit = 4.54609, pie = Math.PI;

            //Inputs - ingredients

            do
            {
                Console.WriteLine(" Which is your preferred unit of measurement?");
                Console.Write(" Please enter m for metres, and f for feet  ");
                measurement = CharInput.checktwochars('M', 'F');

                Console.WriteLine(" Do you know the surface area of your room?");
                Console.Write(" Please enter y for yes and n for no  ");
                knowarea = CharInput.checktwochars('Y', 'N');

                if (knowarea == 'n')
                {
                    Console.WriteLine(" Which shape is your room?");
                    Console.WriteLine(" Please enter s for square, r for rectangle, ");
                    Console.Write(" t for triangular or c for circular  ");
                    shape = Convert.ToChar(Console.ReadLine());

                    area = 0;

                    while (area <= 0)
                    {
                        if (shape == 's')
                        {
                            Console.Write(" Please enter the width of the wall   ");
                            w1 = Convert.ToDouble(Console.ReadLine());

                            Console.Write(" Please enter the height the wall  ");
                            h1 = Convert.ToDouble(Console.ReadLine());

                            area = (w1 * h1) * 4;

                            roofarea = area / 4;
                        }
                        else if (shape == 'r')
                        {
                            Console.Write(" Please enter the width of wall one  ");
                            w1 = Convert.ToDouble(Console.ReadLine());

                            Console.Write(" Please enter the height of wall one  ");
                            h1 = Convert.ToDouble(Console.ReadLine());

                            Console.Write(" Please enter the width of wall two  ");
                            w2 = Convert.ToDouble(Console.ReadLine());

                            Console.Write(" Please enter the height of wall two  ");
                            h2 = Convert.ToDouble(Console.ReadLine());

                            area = ((w1 * h1) + (w2 * h2)) * 2;

                            roofarea = w1 * w2;
                        }
                        else if (shape == 't')
                        {
                            Console.Write(" Please enter the width of wall one  ");
                            w1 = Convert.ToDouble(Console.ReadLine());

                            Console.Write(" Please enter the height of wall one  ");
                            h1 = Convert.ToDouble(Console.ReadLine());

                            Console.Write(" Please enter the width of wall two  ");
                            w2 = Convert.ToDouble(Console.ReadLine());

                            Console.Write(" Please enter the height of wall two  ");
                            h2 = Convert.ToDouble(Console.ReadLine());

                            triangle = (w1 * w1) + (w2 * w2);

                            area = (Math.Sqrt(triangle) * h1) + (w1 * h1) + (w2 * h2);

                            roofarea = (w1 * w2) / 2;
                        }
                        else if (shape == 'c')
                        {
                            Console.Write(" Please enter the radius of the room   ");
                            radius = Convert.ToDouble(Console.ReadLine());

                            Console.Write(" Please enter the height the wall  ");
                            h1 = Convert.ToDouble(Console.ReadLine());

                            area = (2 * radius * pie) * h1;

                            roofarea = (radius * radius) * pie;
                        }
                        else
                        {
                            Console.WriteLine(" Sorry but the shape you entered wasn't");
                            Console.WriteLine(" recognized. Please try again");
                            Console.WriteLine(" Remember to enter s for square, r for rectangle, ");
                            Console.Write(" t for triangular or c for circular  ");
                            shape = Convert.ToChar(Console.ReadLine());
                        }
                    }
                }
                else
                {
                    Console.Write(" Please enter the surface area of the room  ");
                    area = Convert.ToDouble(Console.ReadLine());
                }



                //Processes - recipe

                if (measurement == 'm')
                {
                    coverage = coverage / metresCoverage;
                }



                reqpaintgal  = area / coverage;
                roofpaintgal = roofarea / coverage;
                reqpaintlit  = reqpaintgal * galtolit;
                roofpaintlit = roofpaintgal * galtolit;

                //Output

                Console.WriteLine(" Total paint required is: {0:0.00} in gallons", reqpaintgal);
                Console.WriteLine(" and the paint required is: {0:0.00} in litres", reqpaintlit);
                Console.WriteLine(" The roof would need an extra {0:0.00} in gallons", roofpaintgal);
                Console.WriteLine(" and {0:0.00} in litres", roofpaintlit);
                Console.WriteLine(" Would you like to do another calculation?");
                Console.Write(" Enter y for yes and n for no  ");
                repeat = Convert.ToChar(Console.ReadLine());
            } while (repeat == 'y');
        }
Esempio n. 10
0
        private void RegisterWindowCallbacks()
        {
            if (_callbackRegistered)
            {
                return;
            }
            _callbackRegistered = true;

            // [NOTE]
            // Do not register callback to GLFW as lambda or method. (That cannot work)
            // Put delegate on a field and register it to GLFW.

            _posCallback = (wnd, x, y) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                _location = new Vector2i(x, y);
                Move?.Invoke(this, new WindowPositionEventArgs(x, y));
            };
            GLFW.SetWindowPosCallback(_window, _posCallback);

            _sizeCallback = (wnd, width, height) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                GLFW.GetWindowFrameSize(_window, out var left, out var top, out var right, out var bottom);
                _clientSize = new Vector2i(width, height);
                _size       = new Vector2i(_clientSize.X + left + right, _clientSize.Y + top + bottom);
                Resize?.Invoke(this, new ResizeEventArgs(width, height));
            };
            GLFW.SetWindowSizeCallback(_window, _sizeCallback);

            _frameBufferSizeCallback = (wnd, width, height) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                _frameBufferSize = new Vector2i(width, height);
                FrameBufferSizeChanged?.Invoke(this, _frameBufferSize);
            };
            GLFW.SetFramebufferSizeCallback(_window, _frameBufferSizeCallback);

            _closeCallback = wnd =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var cancel = false;
                var e      = new CancelEventArgs(&cancel);
                Closing?.Invoke(this, e);
                if (e.Cancel)
                {
                    GLFW.SetWindowShouldClose(_window, false);
                }
            };
            GLFW.SetWindowCloseCallback(_window, _closeCallback);


            _iconifyCallback = (wnd, minimized) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                Minimized?.Invoke(this, new MinimizedEventArgs(minimized));
            };
            GLFW.SetWindowIconifyCallback(_window, _iconifyCallback);

            _focusCallback = (wnd, focused) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                FocusedChanged?.Invoke(this, new FocusedChangedEventArgs(focused));
            };
            GLFW.SetWindowFocusCallback(_window, _focusCallback);

            _charCallback = (wnd, unicode) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                CharInput?.Invoke(this, new CharInputEventArgs(unicode));
            };
            GLFW.SetCharCallback(_window, _charCallback);

            _keyCallback = (wnd, glfwKey, scanCode, action, glfwMods) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new KeyboardKeyEventArgs(glfwKey, scanCode, glfwMods, action == GlfwInputAction.Repeat);

                if (action == GlfwInputAction.Release)
                {
                    KeyUp?.Invoke(this, e);
                }
                else
                {
                    KeyDown?.Invoke(this, e);
                }
            };
            GLFW.SetKeyCallback(_window, _keyCallback);

            _cursorEnterCallback = (wnd, entered) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                if (entered)
                {
                    MouseEnter?.Invoke(this);
                }
                else
                {
                    MouseLeave?.Invoke(this);
                }
            };
            GLFW.SetCursorEnterCallback(_window, _cursorEnterCallback);

            _mouseButtonCallback = (wnd, button, action, mods) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new MouseButtonEventArgs(button, action, mods);

                if (action == GlfwInputAction.Release)
                {
                    MouseUp?.Invoke(this, e);
                }
                else
                {
                    MouseDown?.Invoke(this, e);
                }
            };
            GLFW.SetMouseButtonCallback(_window, _mouseButtonCallback);

            _cursorPosCallback = (wnd, posX, posY) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new MouseMoveEventArgs(new Vector2((int)posX, (int)posY));
                MouseMove?.Invoke(this, e);
            };
            GLFW.SetCursorPosCallback(_window, _cursorPosCallback);

            _scrollCallback = (wnd, offsetX, offsetY) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new MouseWheelEventArgs((float)offsetX, (float)offsetY);
                MouseWheel?.Invoke(this, e);
            };
            GLFW.SetScrollCallback(_window, _scrollCallback);

            _dropCallback = (wnd, count, paths) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new FileDropEventArgs(count, paths);
                FileDrop?.Invoke(this, e);
            };
            GLFW.SetDropCallback(_window, _dropCallback);

            _joystickCallback = (joystick, state) =>
            {
                var e = new JoystickConnectionEventArgs(joystick, state == GlfwConnectedState.Connected);
                JoystickConnectionChanged?.Invoke(this, e);
            };
            GLFW.SetJoystickCallback(_joystickCallback);

            _monitorCallback = (monitor, state) =>
            {
                var e = new MonitorConnectionEventArgs(monitor, state == GlfwConnectedState.Connected);
                MonitorConnectionChanged?.Invoke(this, e);
            };
            GLFW.SetMonitorCallback(_monitorCallback);

            _refreshCallback = wnd =>
            {
                if (wnd != _window)
                {
                    return;
                }
                Refresh?.Invoke(this);
            };
            GLFW.SetWindowRefreshCallback(_window, _refreshCallback);
        }