示例#1
0
        public bool Accept(AgendaContext context, Activation activation)
        {
            var keys = activation.GetState <ChangeKeys>(KeyName);

            if (keys == null)
            {
                keys = new ChangeKeys();
                activation.SetState(KeyName, keys);
                activation.OnRuleFiring += OnRuleFiring;
            }

            keys.New = _keySelectors.Select(selector => selector.Invoke(context, activation)).ToList();
            bool accept = true;

            if (keys.Current != null)
            {
                accept = false;
                for (int i = 0; i < keys.Current.Count; i++)
                {
                    if (!Equals(keys.Current[i], keys.New[i]))
                    {
                        accept = true;
                        break;
                    }
                }
            }

            return(accept);
        }
示例#2
0
        public bool Accept(AgendaContext context, Activation activation)
        {
            bool initial = false;

            if (!_changeKeys.TryGetValue(activation, out var keys))
            {
                initial = true;
                keys    = new ChangeKeys(_keySelectors.Count);
                _changeKeys[activation] = keys;
            }

            for (int i = 0; i < _keySelectors.Count; i++)
            {
                keys.New[i] = _keySelectors[i].Invoke(context, activation);
            }
            bool accept = true;

            if (!initial)
            {
                accept = false;
                for (int i = 0; i < keys.Current.Length; i++)
                {
                    if (!Equals(keys.Current[i], keys.New[i]))
                    {
                        accept = true;
                        break;
                    }
                }
            }

            return(accept);
        }
示例#3
0
    // Use this for initialization
    void Start()
    {
        controllers     = Input.GetJoystickNames();
        controllerCount = new List <int>();
        for (int i = 0; i < controllers.Length; i++)
        {
            if (controllers[i] != "")
            {
                controllerCount.Add(i);
            }
        }

        if (PlayerPrefs.GetInt("Keyboard") == 0)
        {
            QWERTYLine.SetActive(true);
            AZERTYLine.SetActive(false);
        }
        else if (PlayerPrefs.GetInt("Keyboard") == 1)
        {
            QWERTYLine.SetActive(false);
            AZERTYLine.SetActive(true);
        }

        // check slider values
        musicSlider.GetComponent <Slider> ().value = PlayerPrefs.GetFloat("MusicVolume");
        sfxSlider.GetComponent <Slider> ().value   = PlayerPrefs.GetFloat("SFXVolume");

        // check tool tip value
        if (PlayerPrefs.GetInt("ToolTips") == 0)
        {
            toolTipsText.GetComponent <Text>().text = "off";
        }
        else
        {
            toolTipsText.GetComponent <Text>().text = "on";
        }

        // Set the default input system for the player 1
        if (PlayerPrefs.GetInt("Input1") >= 0 && controllerCount.Contains(PlayerPrefs.GetInt("Input1")))
        {
            GeneralData.inputPlayer1 = ProfilsID.XBoxGamepad;
            Profile.Models[1]        = GeneralData.controller1ProfileModel;
            Keyboard1Line.gameObject.SetActive(false);
            Controller1Line.gameObject.SetActive(true);
        }
        else if (PlayerPrefs.GetInt("Input1") == -1 || controllerCount.Contains(PlayerPrefs.GetInt("Input1")))
        {
            GeneralData.inputPlayer1 = ProfilsID.Keyboard1;
            Profile.Models[1]        = GeneralData.Keyboard1ProfileModel;
            Keyboard1Line.gameObject.SetActive(true);
            Controller1Line.gameObject.SetActive(false);
        }

        // Set the default input system for the player 2
        if (PlayerPrefs.GetInt("Input2") >= 0 && controllerCount.Contains(PlayerPrefs.GetInt("Input2")))
        {
            GeneralData.inputPlayer2 = ProfilsID.XBoxGamepad;
            Profile.Models[2]        = GeneralData.controller2ProfileModel;
            Keyboard2Line.gameObject.SetActive(false);
            Controller2Line.gameObject.SetActive(true);
        }
        else if (PlayerPrefs.GetInt("Input2") == -1 || controllerCount.Contains(PlayerPrefs.GetInt("Input2")))
        {
            GeneralData.inputPlayer2 = ProfilsID.Keyboard2;
            Profile.Models[2]        = GeneralData.Keyboard2ProfileModel;
            Keyboard2Line.gameObject.SetActive(true);
            Controller2Line.gameObject.SetActive(false);
        }

        ChangeKeys.InitKeys(new GameObject[] { forwardKey, backwardsKey, leftKey, rightKey, swordAttackKey, skill1Key, skill2Key, skill3Key, skill4Key, pauseKey,
                                               interactKey, changeTorchKey, submitKey, cameraRightKey, cameraLeftKey });
    }