Esempio n. 1
0
    public void SetOpen(bool open)
    {
        GatedInput.SetBlock(GatedInput.Blocker.Console, open);

        panel.gameObject.SetActive(open);
        if (open)
        {
            input_field.ActivateInputField();
        }
    }
Esempio n. 2
0
    public void Tick(ChatSystemClient chatSystem)
    {
        // Handle outgoing messages
        foreach (var l in m_ChatLinesToSend)
        {
            if (chatSystem != null)
            {
                chatSystem.SendMessage(l);
            }
            else
            {
                AddLine(l);
            }
        }
        m_ChatLinesToSend.Clear();

        // Handle incoming messages
        if (chatSystem != null)
        {
            while (chatSystem.incomingMessages.Count > 0)
            {
                var message = chatSystem.incomingMessages.Dequeue();
                AddLine(message);
            }
        }

        if (m_MoveToEnd)
        {
            field.MoveTextEnd(true);
            m_MoveToEnd = false;
        }
        if (!m_IsOpen && GatedInput.GetKeyDown(activationKey))
        {
            field.textComponent.enabled = true;
            field.interactable          = true;

            field.ActivateInputField();
            m_MoveToEnd = true;

            m_IsOpen = true;
            GatedInput.SetBlock(GatedInput.Blocker.Chat, true);

            FadeBackgrounds(1.0f, 0.2f);

            foreach (var line in m_Lines)
            {
                line.Show();
            }
        }
        else if (m_IsOpen && !field.isFocused)
        {
            m_IsOpen = false;
            GatedInput.SetBlock(GatedInput.Blocker.Chat, false);
            field.interactable = false;

            FadeBackgrounds(0.0f, 0.7f);

            foreach (var line in m_Lines)
            {
                line.changeTime = Time.time;
            }
        }
        else if (m_IsOpen && Input.GetKeyDown(KeyCode.Tab))
        {
            var text = field.text;
            for (int i = 0, l = messagePrefixes.Length; i < l; ++i)
            {
                var prefixMatch = text.PrefixMatch(messagePrefixes[i]);
                if (prefixMatch > 1)
                {
                    var oldCaretReverse = field.text.Length - field.caretPosition;
                    defaultPrefix       = messagePrefixes[(i + 1) % l];
                    field.text          = defaultPrefix + text.Substring(prefixMatch);
                    field.caretPosition = field.text.Length - oldCaretReverse;
                    break;
                }
            }
        }

        if (!m_IsOpen)
        {
            // Fade out old lines
            foreach (var line in m_Lines)
            {
                if (Time.time - line.changeTime > 4.0f)
                {
                    line.Hide();
                }
            }
            field.textComponent.enabled = false;
        }
    }
Esempio n. 3
0
    public static void AccumulateInput(ref UserCommand command, float deltaTime)
    {
        // To accumulate move we store the input with max magnitude and uses that
        Vector2 moveInput = new Vector2(GatedInput.GetAxisRaw("Horizontal"), GatedInput.GetAxisRaw("Vertical"));
        float   angle     = Vector2.Angle(Vector2.up, moveInput);

        if (moveInput.x < 0)
        {
            angle = 360 - angle;
        }
        float magnitude = Mathf.Clamp(moveInput.magnitude, 0, 1);

        if (magnitude > maxMoveMagnitude)
        {
            maxMoveYaw       = angle;
            maxMoveMagnitude = magnitude;
        }
        command.moveYaw       = maxMoveYaw;
        command.moveMagnitude = maxMoveMagnitude;

        float invertY = configInvertY.IntValue > 0 ? -1.0f : 1.0f;

        Vector2 deltaMousePos = new Vector2(0, 0);

        if (deltaTime > 0.0f)
        {
            deltaMousePos += new Vector2(GatedInput.GetAxisRaw("Mouse X"), GatedInput.GetAxisRaw("Mouse Y") * invertY);
        }
        deltaMousePos += deltaTime * (new Vector2(GatedInput.GetAxisRaw("RightStickX") * s_JoystickLookSensitivity.x, -invertY * GatedInput.GetAxisRaw("RightStickY") * s_JoystickLookSensitivity.y));
        deltaMousePos += deltaTime * (new Vector2(
                                          ((GatedInput.GetKey(KeyCode.Keypad4) ? -1.0f : 0.0f) + (GatedInput.GetKey(KeyCode.Keypad6) ? 1.0f : 0.0f)) * s_JoystickLookSensitivity.x,
                                          -invertY * GatedInput.GetAxisRaw("RightStickY") * s_JoystickLookSensitivity.y));

        command.lookYaw += deltaMousePos.x * configMouseSensitivity.FloatValue;
        command.lookYaw  = command.lookYaw % 360;
        while (command.lookYaw < 0.0f)
        {
            command.lookYaw += 360.0f;
        }

        command.lookPitch += deltaMousePos.y * configMouseSensitivity.FloatValue;
        command.lookPitch  = Mathf.Clamp(command.lookPitch, 0, 180);
        command.buttons.Or(UserCommand.Button.Jump, GatedInput.GetKeyDown(KeyCode.Space) || GatedInput.GetKeyDown(KeyCode.Joystick1Button0));
        command.buttons.Or(UserCommand.Button.JumpHold, GatedInput.GetKey(KeyCode.Space) || GatedInput.GetKey(KeyCode.Joystick1Button0));
        command.buttons.Or(UserCommand.Button.SurfaceGrab, GatedInput.GetMouseButton(1) || GatedInput.GetAxisRaw("Left Trigger") > 0.5f);
        command.buttons.Or(UserCommand.Button.Boost, GatedInput.GetKey(KeyCode.B) || GatedInput.GetKey(KeyCode.Joystick1Button4));
        command.buttons.Or(UserCommand.Button.PrimaryFire, (GatedInput.GetMouseButton(0) && GetMousePointerLock()) || GatedInput.GetAxisRaw("Right Trigger") > 0.5f);
        command.buttons.Or(UserCommand.Button.SecondaryFire, GatedInput.GetMouseButton(1) || GatedInput.GetKey(KeyCode.Joystick1Button5));
        command.buttons.Or(UserCommand.Button.Ability1, GatedInput.GetKey(KeyCode.LeftShift) || GatedInput.GetKey(KeyCode.Joystick1Button8));
        command.buttons.Or(UserCommand.Button.Ability2, GatedInput.GetKey(KeyCode.F) || GatedInput.GetAxisRaw("Left Trigger") > 0.5f);
        command.buttons.Or(UserCommand.Button.Ability3, GatedInput.GetKey(KeyCode.Q));
        command.buttons.Or(UserCommand.Button.Reload, GatedInput.GetKey(KeyCode.R) || GatedInput.GetKey(KeyCode.Joystick1Button2));
        command.buttons.Or(UserCommand.Button.Melee, GatedInput.GetKey(KeyCode.V) || GatedInput.GetKey(KeyCode.Joystick1Button1));
        command.buttons.Or(UserCommand.Button.Use, GatedInput.GetKey(KeyCode.E));
        command.buttons.Or(UserCommand.Button.Crouch, GatedInput.GetKey(KeyCode.LeftControl) || GatedInput.GetKey(KeyCode.Joystick1Button9));

        // TODO: if needed bring back after unite demo
        //command.buttons.Or(UserCommand.Button.CameraSideSwitch, GatedInput.GetKey(KeyCode.C));

        command.buttons.Or(UserCommand.Button.Item1,
                           GatedInput.GetKeyDown(KeyCode.Alpha1) || Input.GetAxisRaw("DPadY") == 1);
        command.buttons.Or(UserCommand.Button.Item2,
                           GatedInput.GetKeyDown(KeyCode.Alpha2) || Input.GetAxisRaw("DPadX") == 1);
        command.buttons.Or(UserCommand.Button.Item3,
                           GatedInput.GetKeyDown(KeyCode.Alpha3) || Input.GetAxisRaw("DPadY") == -1);
        command.buttons.Or(UserCommand.Button.Item4,
                           GatedInput.GetKeyDown(KeyCode.Alpha4) || Input.GetAxisRaw("DPadX") == -1);
    }
Esempio n. 4
0
    public void UpdateIngame(ref Player.State playerState)
    {
        // Countdown
        countDownPanel.SetPanelActive(playerState.displayCountDown);
        if (playerState.displayCountDown)
        {
            countDownPanel.levelInfoCounter.Format("{0}", playerState.countDown);
        }

        // Scoreboard
        scoreboardPanel.SetPanelActive(!playerState.displayCountDown && (playerState.displayScoreBoard || GatedInput.GetKey(KeyCode.Tab) || m_ShowScorePanel));

        // Game score panel
        gameScorePanel.SetPanelActive(playerState.displayGameScore);
    }