Пример #1
0
    private void Update()
    {
        // Camera Rotation
        if (Input.GetKey(KeybindManager.GetKeyByName(KeybindManager.KeyName.camera_left)))
        {
            _cameraCurrentCircleAngle += _cameraCircleAngleStep;
        }
        if (Input.GetKey(KeybindManager.GetKeyByName(KeybindManager.KeyName.camera_right)))
        {
            _cameraCurrentCircleAngle -= _cameraCircleAngleStep;
        }

        // Camera Distance
        _cameraDistanceAttitude -= Input.mouseScrollDelta.y * _cameraAttitudeSensetivity;
        if (_cameraDistanceAttitude > 1)
        {
            _cameraDistanceAttitude = 1;
        }
        else if (_cameraDistanceAttitude < 0.3f)
        {
            _cameraDistanceAttitude = 0.3f;
        }

        _camera.position = _trackedObject.position + CalculateCurve();
        _camera.LookAt(_trackedObject.position + _trackedObjectBias);
    }
Пример #2
0
 /// <summary>
 /// Load the Keybind Manager and retrieves current keybinds
 /// </summary>
 private void Start()
 {
     Time.timeScale  = 1;
     input           = transform.GetComponent <KeybindManager>();
     player1Keybinds = input.GetPlayerKeybinds(KeybindManager.PlayerOption.Player_1);
     player2Keybinds = input.GetPlayerKeybinds(KeybindManager.PlayerOption.Player_2);
 }
Пример #3
0
    // Use this for initialization
    void Awake()
    {
        if (instance == null || instance.Equals(null))
        {
            instance          = this;
            acceptDuringState = new Dictionary <PauseManager.State, Dictionary <InputAction, System.Action> >();
            foreach (PauseManager.State state in System.Enum.GetValues(typeof(PauseManager.State)))
            {
                acceptDuringState[state] = new Dictionary <InputAction, System.Action>();
                foreach (InputAction action in System.Enum.GetValues(typeof(InputAction)))
                {
                    acceptDuringState[state].Add(action, null);
                }
            }

            acceptAlways = new Dictionary <InputAction, System.Action>();
            foreach (InputAction action in System.Enum.GetValues(typeof(InputAction)))
            {
                acceptAlways.Add(action, null);
            }
            LoadBindingsFromFile("Keybindings.txt");
        }
        else
        {
            Destroy(this);
        }
    }
Пример #4
0
 private void ProfileModelOnOnProfileUpdatedEvent(object sender, EventArgs e)
 {
     foreach (var keybindModel in _keybindModels)
     {
         KeybindManager.AddOrUpdate(keybindModel);
     }
 }
Пример #5
0
        private void RegisterToggle(LayerModel layerModel, int index)
        {
            Action downAction = null;
            Action upAction   = null;

            switch (ToggleType)
            {
            case ToggleType.EnableHeldDown:
                layerModel.RenderAllowed = false;
                downAction = () => layerModel.RenderAllowed = true;
                upAction   = () => layerModel.RenderAllowed = false;
                break;

            case ToggleType.DisableHeldDown:
                downAction = () => layerModel.RenderAllowed = false;
                upAction   = () => layerModel.RenderAllowed = true;
                break;
            }

            // Either bind HotKey or mouse buttons depending on what isn't null
            if (HotKey != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", HotKey, PressType.Down, downAction);
                _upKeybind   = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-up", HotKey, PressType.Up, upAction);
            }
            else if (MouseButtons != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", MouseButtons.Value, PressType.Down, downAction);
                _upKeybind   = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-up", MouseButtons.Value, PressType.Up, upAction);
            }
            KeybindManager.AddOrUpdate(_downKeybind);
            KeybindManager.AddOrUpdate(_upKeybind);
            return;
        }
Пример #6
0
        public Form1()
        {
            InitializeComponent();

            player         = AudioPlaybackEngine.Instance;
            keybindManager = new KeybindManager();
            settings       = Settings.LoadSettings();

            timer1.Interval = 400;
            timer1.Tick    += timer1_Tick;

            textBox2.Text = settings.fileFolder;

            player.PlaybackEnded   += OnPlaybackEnded;
            player.PlaybackStarted += OnPlaybackStarted;

            keybindManager.KeyPressed        += KeyPressed;
            keybindManager.KeybindAdded      += KeybindAdded;
            keybindManager.KeybindUpdated    += KeybindUpdated;
            keybindManager.KeybindRemoved    += KeybindRemoved;
            keybindManager.KeybindStopButton += KeybindStopButton;

            keybindManager.RefreshKeybinds();

            PopulateFiles();
            RefreshDevices();
            PopulateKeys();
        }
 private void Update()
 {
     if (Input.GetKey(KeybindManager.GetKeyByName(KeybindManager.KeyName.action_0)))
     {
         ProcessMovement();
     }
 }
        public new void OnActivate()
        {
            base.OnActivate();

            _loopManager.RenderCompleted += LoopManagerOnRenderCompleted;
            KeybindManager.AddOrUpdate(_copyKeybind);
            KeybindManager.AddOrUpdate(_pasteKeybind);
        }
Пример #9
0
        public override void Dispose()
        {
            foreach (var keybindModel in _keybindModels)
            {
                KeybindManager.Remove(keybindModel);
            }

            LuaManager.ProfileModel.OnProfileUpdatedEvent -= ProfileModelOnOnProfileUpdatedEvent;
        }
        public new void OnDeactivate(bool close)
        {
            base.OnDeactivate(close);

            SaveSelectedProfile();
            _loopManager.RenderCompleted -= LoopManagerOnRenderCompleted;
            KeybindManager.Remove(_copyKeybind);
            KeybindManager.Remove(_pasteKeybind);
        }
Пример #11
0
        /// <summary>
        ///     If found, removes a keybind with the given name
        /// </summary>
        /// <param name="name"></param>
        public void RemoveKeybind(string name)
        {
            var existing = _keybindModels.FirstOrDefault(k => k.Name == name);

            if (existing != null)
            {
                _keybindModels.Remove(existing);
            }

            KeybindManager.Remove(name);
        }
Пример #12
0
    static Game()
    {
        GameObject game = SafeFind("_app");

        m_players          = (PlayerManager)SafeComponent(game, "PlayerManager");
        m_keybinds         = (KeybindManager)SafeComponent(game, "KeybindManager");
        m_options          = (OptionManager)SafeComponent(game, "OptionManager");
        m_audio            = (AudioManager)SafeComponent(game, "AudioManager");
        m_leaderNetHandler = (LeaderboardNetworkHandler)SafeComponent(game, "LeaderboardNetworkHandler");
        m_projPool         = (ProjectilePooler)SafeComponent(SafeFind("ProjectilePooler"), "ProjectilePooler");
    }
Пример #13
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != null)
     {
         Destroy(this.gameObject);
     }
 }
Пример #14
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
 }
Пример #15
0
        /// <summary>
        ///     Sets a keybind to call the provided function
        /// </summary>
        /// <param name="name">Name of the keybind</param>
        /// <param name="hotKey">Hotkey in string format, per example: ALT+CTRL+SHIFT+D</param>
        /// <param name="pressType">The key type, either key up or key down</param>
        /// <param name="function">LUA function to call</param>
        /// <param name="args">Optional arguments for the passed function</param>
        public void SetKeybind(string name, string hotKey, PressType pressType, DynValue function, params DynValue[] args)
        {
            if (pressType != PressType.Down && pressType != PressType.Up)
            {
                throw new ScriptRuntimeException("Key type must either be Down or Up.");
            }

            var modifierKeys = ModifierKeys.None;
            var key          = Key.System;
            var hotKeyParts  = hotKey.Split('+').Select(p => p.Trim());

            foreach (var hotKeyPart in hotKeyParts)
            {
                if (hotKeyPart == "ALT")
                {
                    modifierKeys |= ModifierKeys.Alt;
                }
                else if (hotKeyPart == "CTRL")
                {
                    modifierKeys |= ModifierKeys.Control;
                }
                else if (hotKeyPart == "SHIFT")
                {
                    modifierKeys |= ModifierKeys.Shift;
                }
                else
                {
                    Enum.TryParse(hotKeyPart, true, out key);
                }
            }

            if (key == Key.System)
            {
                throw new ScriptRuntimeException($"Hotkey '{hotKey}' couldn't be parsed.");
            }

            var hk    = new HotKey(key, modifierKeys);
            var model = args != null
                ? new KeybindModel("LUA-" + name, hk, pressType, () => LuaManager.Call(function, args))
                : new KeybindModel("LUA-" + name, hk, pressType, () => LuaManager.Call(function));

            KeybindManager.AddOrUpdate(model);

            var existing = _keybindModels.FirstOrDefault(k => k.Name == model.Name);

            if (existing != null)
            {
                _keybindModels.Remove(existing);
            }

            _keybindModels.Add(model);
        }
Пример #16
0
 public void Unregister()
 {
     if (_downKeybind != null)
     {
         KeybindManager.Remove(_downKeybind);
         _downKeybind = null;
     }
     if (_upKeybind != null)
     {
         KeybindManager.Remove(_upKeybind);
         _upKeybind = null;
     }
 }
Пример #17
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        LoadKeybinds();
    }
Пример #18
0
    /// <summary>
    /// Listen's to the players input
    /// </summary>
    private void GetInput()
    {
        Direction = Vector2.zero;

        ///THIS IS USED FOR DEBUGGING ONLY
        if (Input.GetKeyDown(KeyCode.I))
        {
            health.MyCurrentValue -= 10;
            mana.MyCurrentValue   -= 10;
        }
        if (Input.GetKeyDown(KeyCode.O))
        {
            health.MyCurrentValue += 10;
            mana.MyCurrentValue   += 10;
        }

        if (Input.GetKey(KeybindManager.GetKeyCode(KeyBinderKeys.UP)))//Moves up
        {
            Direction += Vector2.up;
            exitIndex  = 0;
        }
        if (Input.GetKey(KeybindManager.GetKeyCode(KeyBinderKeys.LEFT))) //Moves left
        {
            Direction += Vector2.left;
            exitIndex  = 3;
        }
        if (Input.GetKey(KeybindManager.GetKeyCode(KeyBinderKeys.DOWN))) //Moves down
        {
            Direction += Vector2.down;
            exitIndex  = 2;
        }
        if (Input.GetKey(KeybindManager.GetKeyCode(KeyBinderKeys.RIGHT))) //Moves right
        {
            Direction += Vector2.right;
            exitIndex  = 1;
        }
        if (IsMoving)
        {
            StopAttack();
        }

        foreach (string action in KeybindManager.MyInstance.MyActionbinds.Keys)
        {
            if (Input.GetKeyDown(KeybindManager.MyInstance.MyActionbinds[action]))
            {
                UIManager.MyInstance.ClickActionButton(action);
            }
        }
    }
Пример #19
0
        private void RegisterEvent(LayerModel layerModel, int index)
        {
            Action action = () =>
            {
                layerModel.EventProperties.TriggerEvent(layerModel);
            };

            // Either bind HotKey or mouse buttons depending on what isn't null
            if (HotKey != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", HotKey, PressType.Down, action);
            }
            else if (MouseButtons != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", MouseButtons.Value, PressType.Down, action);
            }
            KeybindManager.AddOrUpdate(_downKeybind);
        }
Пример #20
0
        private void RegisterRegular(LayerModel layerModel, int index)
        {
            // Bind Enable, Disable or Toggle
            Action action = null;

            switch (ToggleType)
            {
            case ToggleType.Enable:
                // Apply RenderAllowed only if this is the first keybind
                if (index == 0)
                {
                    layerModel.RenderAllowed = false;
                }
                action = () => layerModel.RenderAllowed = true;
                break;

            case ToggleType.Disable:
                // Apply RenderAllowed only if this is the first keybind
                if (index == 0)
                {
                    layerModel.RenderAllowed = false;
                }
                action = () => layerModel.RenderAllowed = false;
                break;

            case ToggleType.Toggle:
                action = () => layerModel.RenderAllowed = !layerModel.RenderAllowed;
                break;
            }

            // Either bind HotKey or mouse buttons depending on what isn't null
            if (HotKey != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", HotKey, PressType.Down, action);
            }
            else if (MouseButtons != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", MouseButtons.Value, PressType.Down, action);
            }
            KeybindManager.AddOrUpdate(_downKeybind);
        }
Пример #21
0
    public void AcceptInput(KeybindManager.InputAction action)
    {
        if (!KeybindManager.IsRowHit(action) || PauseManager.currentState != PauseManager.State.Gameplay)
        {
            return;
        }

        int         row         = KeybindManager.GetRow(action);
        NoteType    nType       = KeybindManager.GetType(action);
        ClosebyNote closestNote = null;

        foreach (ClosebyNote note in notesInWindow)
        {
            if (note.note.lane == row &&
                note.note.type == nType &&
                (closestNote == null || Mathf.Abs(note.timing) < Mathf.Abs(closestNote.timing)))
            {
                closestNote = note;
            }
        }
        if (closestNote == null)
        {
            HitsoundManager.instance.PlaySound(SoundType.Normal, false);
            return;
        }
        ScoreManager.instance.totalAccuracy += closestNote.timing;
        ScoreManager.instance.notesHit      += 1;
        Window last = timingWindows[0];

        for (int i = 1; i < timingWindows.Count; ++i)
        {
            if (Mathf.Abs(closestNote.timing) > Mathf.Abs(timingWindows[i].msDelay))
            {
                TriggerWindow(last, closestNote);
                return;
            }
            last = timingWindows[i];
        }
        TriggerWindow(last, closestNote);
        return;
    }
Пример #22
0
    void Awake()
    {
        /*if (Km == null)
         * {
         *  DontDestroyOnLoad(gameObject);
         *  Km = this;
         * }
         * else if (Km != this)
         * {
         *  Destroy(gameObject);
         * }*/
        Km = this;
        //PlayerPrefs.DeleteAll();

        tl = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("topLeftKey", "Keypad7"));
        ml = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("middleLeftKey", "Keypad4"));
        bl = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("bottomLeftKey", "Keypad1"));
        tc = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("topCenterKey", "Keypad8"));
        bc = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("bottomCenterKey", "Keypad2"));
        tr = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("topRightKey", "Keypad9"));
        mr = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("middleRightKey", "Keypad6"));
        br = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("bottomRightKey", "Keypad3"));
    }
Пример #23
0
 // Update is called once per frame
 void PausableUpdate()
 {
     upImage.enabled     = KeybindManager.GetDown(KeybindManager.GetRowHitAction(lane, NoteType.UpHit));
     normalImage.enabled = KeybindManager.GetDown(KeybindManager.GetRowHitAction(lane, NoteType.Hit));
     downImage.enabled   = KeybindManager.GetDown(KeybindManager.GetRowHitAction(lane, NoteType.DownHit));
 }
Пример #24
0
 void OnDestroy()
 {
     KeybindManager.acceptDuringState[PauseManager.State.Gameplay][KeybindManager.GetRowHitAction(lane, NoteType.DownHit)] -= TriggerDown;
     KeybindManager.acceptDuringState[PauseManager.State.Gameplay][KeybindManager.GetRowHitAction(lane, NoteType.Hit)]     -= TriggerMid;
     KeybindManager.acceptDuringState[PauseManager.State.Gameplay][KeybindManager.GetRowHitAction(lane, NoteType.UpHit)]   -= TriggerUp;
 }