Exemple #1
0
    public void RestoreInputsPrefs()
    {
        Dictionary <KeyConfig, List <string> > keyBindsRefsSave = new Dictionary <KeyConfig, List <string> >();

        if (PlayerPrefs.GetString("InputsPrefs") != "")
        {
            var jsonBindsRefs = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(PlayerPrefs.GetString("InputsPrefs"));

            try{
                foreach (var kb in jsonBindsRefs)
                {
                    keyBindsRefsSave.Add(KeyConfig.FromString(kb.Key), kb.Value);
                }
            }catch {
                PlayerPrefs.SetString("InputsPrefs", "");
                RestoreInputsPrefs();
            }
        }
        else
        {
            keyBindsRefsSave = KeyBindRefs.DefaultBindsRefs;
        }

        _keyBinds = keyBindsRefsSave;

        var d = this.BindingsChanged;

        if (d != null)
        {
            d(this, EventArgs.Empty);
        }
    }
Exemple #2
0
        void LoadRegisteredKeys()
        {
            if (Settings.Default.RegisteredKeys == "")
            {
                return;
            }

            for (int i = 0; i < keysets.Count; i++)
            {
                UnregisterHotKey(this.Handle, i);
            }
            keysets = new Dictionary <int, string>();
            foreach (string elementset in Settings.Default.RegisteredKeys.Split(';'))
            {
                Console.WriteLine(elementset);
                if (elementset == "")
                {
                    return;
                }
                string[] split = elementset.Split('|');
                Console.WriteLine("test: '" + split[0] + "'");
                KeyConfig conf = new KeyConfig(Int32.Parse(split[0]));
                keysets.Add(conf.keycode, split[1]);
                lbKeys.Items.Add(conf.ToString("- " + split[1]));
                RegisterHotKey(this.Handle, keysets.Count - 1, conf.modifiers, (int)conf.key);
            }
        }
 // Use this for initialization
 void Start()
 {
     curtain = GameObject.Find ("Curtain").GetComponent<Curtain> ();
     soundManager = GameObject.Find ("Sounds").GetComponent<SoundManager> ();
     keyConfig = KeyConfig.Current;
     isFinished = false;
 }
Exemple #4
0
        protected void OnNewDataReady(int scanCode, int timeStamp)
        {
            var handler = KeyPressed;

            if (handler == null || _disposed)
            {
                return;
            }
            if (_keys.ContainsKey(scanCode))
            {
                var key = _keys[scanCode];
                if ((key.Type == KeyType.No || key.Type == KeyType.Yes) &&
                    key.Type == _lastKey.Type &&
                    DateTime.Now - _lastKeyTime < TimeSpan.FromMilliseconds(200))
                {
                    return;
                }
                _lastKey     = key;
                _lastKeyTime = DateTime.Now;
                Logger.LogInfo(Message.KeyboardKeyPressed, scanCode, key.Type, key.Value, timeStamp);
                handler(this, new KeyEventArgs(scanCode, key.Type, key.Value, timeStamp));
            }
            else
            {
                Logger.LogInfo(Message.KeyboardKeyPressed, scanCode, KeyType.Unknown, 0, timeStamp);
                handler(this, new KeyEventArgs(scanCode, KeyType.Unknown, 0, timeStamp));
            }
        }
Exemple #5
0
        public void CreateMenuItem_CanExecuteChangeRaised_ItemUpdated()
        {
            // Arrange
            bool canExecute         = false;
            var  mockHotkeysService = new Mock <IHotkeysService> ();

            App.Current.HotkeysService = mockHotkeysService.Object;
            Command testcommand = new Command(exec => { }, can => { return(canExecute); });

            KeyConfig hotkey = new KeyConfig {
                Key = new HotKey()
            };

            mockHotkeysService.Setup(s => s.GetByName("TEST")).Returns(hotkey);

            MenuItem testItem = testcommand.CreateMenuItem("test text", null, "TEST");

            canExecute = true;

            // Act
            Assert.IsFalse(testItem.Sensitive);
            testcommand.EmitCanExecuteChanged();

            // Assert
            Assert.IsTrue(testItem.Sensitive);
        }
 // Use this for initialization
 void Start()
 {
     curtain = GameObject.Find ("Curtain").GetComponent<Curtain> ();
     soundManager = GameObject.Find ("Sounds").GetComponent<SoundManager> ();
     GameObject.Find ("MaoudamasiiLink").GetComponent<Button> ().onClick.AddListener(() => {
         Application.OpenURL("http://maoudamashii.jokersounds.com/");
     });
     GameObject.Find ("JapaneseSushiLink").GetComponent<Button> ().onClick.AddListener(() => {
         Application.OpenURL("https://www.assetstore.unity3d.com/jp/#!/content/37401");
     });
     GameObject.Find ("NebulaLink").GetComponent<Button> ().onClick.AddListener(() => {
         Application.OpenURL("https://www.assetstore.unity3d.com/jp/#!/content/2967");
     });
     GameObject.Find ("ToonySkiesLink").GetComponent<Button> ().onClick.AddListener(() => {
         Application.OpenURL("https://www.assetstore.unity3d.com/jp/#!/content/11020");
     });
     GameObject.Find ("FurnitureLink").GetComponent<Button> ().onClick.AddListener(() => {
         Application.OpenURL("https://www.assetstore.unity3d.com/jp/#!/content/11859");
     });
     GameObject.Find ("HorseLink").GetComponent<Button> ().onClick.AddListener(() => {
         Application.OpenURL("https://www.assetstore.unity3d.com/jp/#!/content/16687");
     });
     GameObject.Find ("AkibaLink").GetComponent<Button> ().onClick.AddListener(() => {
         Application.OpenURL("https://www.assetstore.unity3d.com/jp/#!/content/20359");
     });
     GameObject.Find ("UnityLink").GetComponent<Button> ().onClick.AddListener(() => {
         Application.OpenURL("http://unity3d.com/");
     });
     GameObject.Find ("MyLink").GetComponent<Button> ().onClick.AddListener(() => {
         Application.OpenURL("https://twitter.com/ye_ey");
     });
     keyConfig = KeyConfig.Current;
     isFinished = false;
 }
 // Use this for initialization
 void Start()
 {
     curtain = GameObject.Find ("Curtain").GetComponent<Curtain> ();
     isSelected = false;
     maxStageIndex = SaveData.GetAvailableStage () - 1;
     stageNameText = GameObject.Find ("StageName").GetComponent<Text> ();
     stageNumberText = GameObject.Find ("StageNumber").GetComponent<Text> ();
     bestTimeText = GameObject.Find ("BestTime").GetComponent<Text> ();
     rightText = GameObject.Find ("Right").GetComponent<Text> ();
     leftText = GameObject.Find ("Left").GetComponent<Text> ();
     newStageNoticeText = GameObject.Find ("NewStageNotice").GetComponent<Text> ();
     soundManager = GameObject.Find ("Sounds").GetComponent<SoundManager> ();
     keyConfig = KeyConfig.Current;
     mainCamera = GameObject.Find("Main Camera");
     skyboxes = new Material[] { GalaxySkybox, NightSkybox, GalaxySkybox, PinkSkybox, BlueSkybox };
     stages = new Stage[] { new Stage1(), new Stage2(), new Stage3(), new Stage4(), new Stage5() };
     courses = new Mesh[] {
         stages [0].CreateFloorsFactory ().CreateFloorList (null).Mesh,
         stages [1].CreateFloorsFactory ().CreateFloorList (null).Mesh,
         stages [2].CreateFloorsFactory ().CreateFloorList (null).Mesh,
         stages [3].CreateFloorsFactory ().CreateFloorList (null).Mesh,
         stages [4].CreateFloorsFactory ().CreateFloorList (null).Mesh
     };
     if (UserInterface.IsAvailableStageInclemented) {
         stageIndex = SaveData.GetAvailableStage () - 1;
         newStageNoticeText.enabled = true;
     } else {
         stageIndex = 0;
         newStageNoticeText.enabled = false;
     }
     isSelected = false;
     isReturn = false;
     changeStage();
 }
Exemple #8
0
    //    public void SetKeyDownBind(string keyId, Action act)
    //    {
    //        if (keyId == null)
    //            Debug.LogError("keyId can't be null in SetKeyDownBind");
    //
    //        if(_ActionBinds [keyId].GetType() == typeof(KeyActionConfig))
    //        {
    //            KeyActionConfig kac = (KeyActionConfig)_ActionBinds [keyId];
    //            kac.KeyDownAction = act;
    //        }
    //    }
    //
    //    public void SetKeyUpBind(string keyId, Action act)
    //    {
    //        if (keyId == null)
    //            Debug.LogError("keyId can't be null in SetKeyUpBind");
    //
    //        if(_ActionBinds [keyId].GetType() == typeof(KeyActionConfig))
    //        {
    //            KeyActionConfig kac = (KeyActionConfig)_ActionBinds [keyId];
    //            kac.KeyUpAction = act;
    //        }
    //    }

    public void ChangeBind(KeyConfig currentInput, string keyId, KeyConfig newInput)
    {
        if (keyId == null)
        {
            Debug.LogError("keyId can't be null in ChangeBind");
        }

        _keyBinds [currentInput].Remove(keyId);

        if (_keyBinds.ContainsKey(newInput))
        {
            _keyBinds [newInput].Add(keyId);
        }
        else
        {
            _keyBinds.Add(newInput, new List <string>()
            {
                keyId
            });
        }

        if (_keyBinds [currentInput].Count <= 0)
        {
            _keyBinds.Remove(currentInput);
        }

        var d = this.BindingsChanged;

        if (d != null)
        {
            d(this, EventArgs.Empty);
        }
    }
Exemple #9
0
 public GameScreen(GraphicsDeviceManager g, ContentManager c, SpriteFont f) : base(g, c, f)
 {
     //initialize GameDraw
     GameDraw.Initialize(g, c, f);
     GameDraw.drawAdjObjects = true;
     KeyConfig.Initialize();
     StopDrawing = false;
 }
Exemple #10
0
        void ApplyConfig(KeyConfig kconfig)
        {
            var keyconfig = App.Current.Config.KeyConfigs.FirstOrDefault((k) => k.Name == kconfig.Name);

            if (keyconfig != null)
            {
                kconfig.Key = keyconfig.Key;
            }
        }
Exemple #11
0
 /// <summary>
 /// Register the specified keyConfig.
 /// </summary>
 /// <param name="keyConfig">Key config.</param>
 public void Register(KeyConfig keyConfig)
 {
     if (keyConfigs.Contains(keyConfig))
     {
         throw new InvalidOperationException("A KeyConfig with the same name is already registered");
     }
     keyConfigs.Add(keyConfig);
     ApplyConfig(keyConfig);
 }
Exemple #12
0
 static public void Set()
 {
     if (!FileManager.Instance.LoadFile <KeyConfig>(ref instance, filename))
     {
         instance = new KeyConfig();
     }
     instance.prevTapTime = new float[System.Enum.GetNames(typeof(Key)).Length];
     instance.curKey      = new int[System.Enum.GetNames(typeof(Key)).Length];
 }
Exemple #13
0
    public void RemoveBind(KeyConfig input, string keyId)
    {
        if (keyId == null || !_keyBinds.ContainsKey(input))
        {
            Debug.LogError("keyId and input can't be null in RemoveBind");
        }

        _keyBinds [input].Remove(keyId);
    }
        private void logKeyConfig(KeyConfig key, bool isDown)
        {
            var updown    = isDown ? "Down" : "Up  ";
            var leftright = key.isLeft ? "Left " : "Right";
            var facehand  = key.actionType == KeyActionTypes.Face ? "Face" : "Hand";
            var type      = key.type == KeyTypes.Controller ? "Controller" : key.type == KeyTypes.Keyboard ? "Keyboard  " : "Mouse     ";

            System.Diagnostics.Debug.WriteLine($"Key{updown} {facehand} {leftright} {type} {key.keyCode} {key.keyIndex}");
        }
        public TouchSliderEmulator(MemoryManipulator memoryManipulator, KeyConfig keyConfig)
        {
            MemoryManipulator = memoryManipulator;
            KeyConfig         = keyConfig;

            for (int i = 0; i < sliderStopwatched.Length; i++)
            {
                sliderStopwatched[i] = new Stopwatch();
            }
        }
        private async void ControllerAction_KeyDown(object sender, OVRKeyEventArgs e)
        {
            //win.KeyDownEvent{ value = win, new KeyEventArgs((EVRButtonId)e.ButtonId, e.Axis.x, e.Axis.y, e.IsLeft));

            var config = new KeyConfig();

            config.type       = KeyTypes.Controller;
            config.actionType = KeyActionTypes.Hand;
            config.keyCode    = -2;
            config.keyName    = e.Name;
            config.isLeft     = e.IsLeft;
            bool isStick = e.Name.Contains("Stick");

            config.keyIndex = e.IsAxis == false ? -1 : NearestPointIndex(e.IsLeft, e.Axis.x, e.Axis.y, isStick);
            config.isTouch  = e.IsTouch;
            if (e.IsAxis)
            {
                if (config.keyIndex < 0)
                {
                    return;
                }
                if (e.IsLeft)
                {
                    if (isStick)
                    {
                        lastStickLeftAxisPoint = config.keyIndex;
                    }
                    else
                    {
                        lastTouchpadLeftAxisPoint = config.keyIndex;
                    }
                }
                else
                {
                    if (isStick)
                    {
                        lastStickRightAxisPoint = config.keyIndex;
                    }
                    else
                    {
                        lastTouchpadRightAxisPoint = config.keyIndex;
                    }
                }
            }
            if (doKeyConfig || doKeySend)
            {
                await controlWPFWindow.server.SendCommandAsync(new PipeCommands.KeyDown {
                    Config = config
                });
            }
            if (!doKeyConfig)
            {
                CheckKey(config, true);
            }
        }
Exemple #17
0
 public void SetKeyConfig(KeyConfig keyConfig)
 {
     byte[] msg =
     {
         (byte)hid_pkt_req.HID_PKT_REQ_CONFIG_KEY_SET,
         (byte)keyConfig.Action,
         keyConfig.Param1,
         keyConfig.Param2
     };
     _MessageQueue.Enqueue(msg);
 }
Exemple #18
0
    public override bool Equals(object obj)
    {
        KeyConfig kc = (KeyConfig)obj;

        if (kc.AxisName == null && kc.KeyName == KeyCode.None)
        {
            return(false);
        }

        return(IsAxis == kc.IsAxis && KeyName == kc.KeyName && AxisName == kc.AxisName);
    }
 // Use this for initialization
 void Start()
 {
     curtain = GameObject.Find ("Curtain").GetComponent<Curtain> ();
     soundManager = GameObject.Find ("Sounds").GetComponent<SoundManager> ();
     sushiFactory = GameObject.Find ("SushiFactory").GetComponent<SushiFactory> ();
     cursor = GameObject.Find ("Cursor").GetComponent<Text> ();
     keyConfig = KeyConfig.Current;
     isFinished = false;
     isYes = false;
     isDeleting = false;
     sushi = sushiFactory.Create ((int)SushiType.Toro, Vector3.zero, Quaternion.Euler (new Vector3 (-30f, -30f, 0f)));
 }
Exemple #20
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Pokemon.BaseStatsList.initialize();
            font = Content.Load <SpriteFont>("font");
            KeyConfig.Initialize();
            ScreenHandler.Initialize(graphics, Content, font);

            // TODO: use this.Content to load your game content here
        }
Exemple #21
0
        /// <summary>
        /// Get client secret key from application state. Key is retrieved
        /// from KeyVault in Application_Start via the KeyConfig class
        /// </summary>
        /// <returns>Application secret</returns>
        public static string GetKey()
        {
            var keyObj = HttpContext.Current.Application["ida:ClientSecret"];

            if (null == keyObj)
            {
                KeyConfig.RegisterKeys();
            }
            string key = HttpContext.Current.Application["ida:ClientSecret"].ToString();

            return(key);
        }
Exemple #22
0
        public Camera()
        {
            Reset();

            KeyConfiguration = new KeyConfig()
            {
                MoveForward  = Key.W,
                MoveBackward = Key.S,
                StrafeLeft   = Key.A,
                StrafeRight  = Key.D
            };
        }
 // Use this for initialization
 void Start()
 {
     keyConfig = KeyConfig.Current;
     sushis = new GameObject[14];
     for (int i = 0; i < 14; i++) {
         sushis[i] = GameObject.Find ("" + i);
     }
     selector = GameObject.Find ("Selector").GetComponent<Text> ();
     curtain = GameObject.Find ("Curtain").GetComponent<Curtain> ();
     soundManager = GameObject.Find ("Sounds").GetComponent<SoundManager> ();
     IsSelected = false;
     IsReturn = false;
 }
        private async void ControllerAction_KeyUp(object sender, OVRKeyEventArgs e)
        {
            //win.KeyUpEvent{ value = win, new KeyEventArgs((EVRButtonId)e.ButtonId, e.Axis.x, e.Axis.y, e.IsLeft));
            var config = new KeyConfig();

            config.type       = KeyTypes.Controller;
            config.actionType = KeyActionTypes.Hand;
            config.keyCode    = -2;
            config.keyName    = e.Name;
            config.isLeft     = e.IsLeft;
            bool isStick = e.Name.Contains("Stick");

            config.keyIndex = e.IsAxis == false ? -1 : NearestPointIndex(e.IsLeft, e.Axis.x, e.Axis.y, isStick);
            config.isTouch  = e.IsTouch;
            if (e.IsAxis && config.keyIndex != (isStick ? (e.IsLeft ? lastStickLeftAxisPoint : lastStickRightAxisPoint) : (e.IsLeft ? lastTouchpadLeftAxisPoint : lastTouchpadRightAxisPoint)))
            {//タッチパッド離した瞬間違うポイントだった場合
                var newindex = config.keyIndex;
                config.keyIndex = (isStick ? (e.IsLeft ? lastStickLeftAxisPoint : lastStickRightAxisPoint) : (e.IsLeft ? lastTouchpadLeftAxisPoint : lastTouchpadRightAxisPoint));
                //前のキーを離す
                if (doKeyConfig)
                {
                }                   //  await server.SendCommandAsync(new PipeCommands.KeyUp { Config = config });
                else
                {
                    CheckKey(config, false);
                }
                config.keyIndex = newindex;
                if (config.keyIndex < 0)
                {
                    return;
                }
                //新しいキーを押す
                if (doKeyConfig)
                {
                    await controlWPFWindow.server.SendCommandAsync(new PipeCommands.KeyDown {
                        Config = config
                    });
                }
                else
                {
                    CheckKey(config, true);
                }
            }
            if (doKeyConfig || doKeySend)
            {
            }                                //  await server.SendCommandAsync(new PipeCommands.KeyUp { Config = config });
            if (!doKeyConfig)
            {
                CheckKey(config, false);
            }
        }
        public HandshakeFinishedService(
            ICipherSuitesProvider cipherSuitesProvider,

            CipherSuiteConfig cipherSuiteConfig,
            EndConfig endConfig,
            HandshakeConfig handshakeConfig,
            KeyConfig keyConfig)
        {
            _cipherSuitesProvider = cipherSuitesProvider;
            _cipherSuiteConfig    = cipherSuiteConfig;
            _endConfig            = endConfig;
            _handshakeConfig      = handshakeConfig;
            _keyConfig            = keyConfig;
        }
Exemple #26
0
 void SearchComboBox_Loaded(object sender, RoutedEventArgs e)
 {
     if (DesignerProperties.GetIsInDesignMode(new FrameworkElement())) return;
     if (File.Exists(SaveModelFolder))
     {
         Config = serializer.Deserialize<KeyConfig>(SaveModelFolder);
         this.ItemsSource = Config.LatestSearchList;
     }
     else
     {
         Config = new KeyConfig() { Key = SearchModel, LatestSearchList = new ObservableCollection<string>() };
         this.ItemsSource = Config.LatestSearchList;
     }
     this.Loaded -= SearchComboBox_Loaded;
 }
Exemple #27
0
        /// <summary>
        /// セットアップ(KeyConfigを元に設定をする
        /// </summary>
        public void Init(KeyConfig config)
        {
            if (!config)
            {
                return;
            }

            // キーボード入力の設定
            config.Gets((type, code) => {
                if (code != KeyCode.None)
                {
                    InitKey(type, code);
                }
            });
        }
Exemple #28
0
 void SaveToConfig(KeyConfig kconfig)
 {
     if (!App.Current.Config.KeyConfigs.Contains(kconfig))
     {
         App.Current.Config.KeyConfigs.Add(kconfig);
     }
     else
     {
         var keyConfig = App.Current.Config.KeyConfigs.FirstOrDefault((arg) => arg.Name == kconfig.Name);
         if (keyConfig != null)
         {
             keyConfig = kconfig;
         }
     }
     App.Current.Config.Save();
 }
        private /*async*/ void KeyboardAction_KeyUp(object sender, KeyboardEventArgs e)
        {
            var config = new KeyConfig();

            config.type       = KeyTypes.Keyboard;
            config.actionType = KeyActionTypes.Face;
            config.keyCode    = e.KeyCode;
            config.keyName    = e.KeyName;
            if (doKeyConfig || doKeySend)
            {
            }                                //  await server.SendCommandAsync(new PipeCommands.KeyUp { Config = config });
            if (!doKeyConfig)
            {
                CheckKey(config, false);
            }
        }
Exemple #30
0
        public void TestApplyConfigInRegisterKeys()
        {
            var kconfig = new KeyConfig {
                Name        = "KC1",
                Description = "KeyConfig 1 Description",
                Category    = "Cat1",
                Key         = App.Current.Keyboard.ParseName("z")
            };

            App.Current.Config.KeyConfigs.Add(kconfig);

            hotkeysService.Register(keyConfig1);
            var regKeyConfig = hotkeysService.GetByName("KC1");

            Assert.AreEqual(App.Current.Keyboard.ParseName("z"), regKeyConfig.Key);
            Assert.AreSame(keyConfig1, regKeyConfig);
        }
Exemple #31
0
 private void SetKeyBindImpl(string keyId, KeyConfig keyconfig)
 {
     if (_keyBinds.ContainsKey(keyconfig))
     {
         if (!_keyBinds[keyconfig].Contains(keyId))
         {
             _keyBinds[keyconfig].Add(keyId);
         }
     }
     else
     {
         _keyBinds.Add(keyconfig, new List <string>()
         {
             keyId
         });
     }
 }
Exemple #32
0
        public MasterSecretCalculator(
            ICipherSuitesProvider cipherSuitesProvider,

            RandomConfig randomConfig,
            CipherSuiteConfig cipherSuiteConfig,

            KeyConfig keyConfig,
            AEADCipherConfig aeadConfig,
            BlockCipherConfig blockConfig)
        {
            _cipherSuitesProvider = cipherSuitesProvider;

            _randomConfig      = randomConfig;
            _cipherSuiteConfig = cipherSuiteConfig;

            _keyConfig   = keyConfig;
            _aeadConfig  = aeadConfig;
            _blockConfig = blockConfig;
        }
        private async void KeyboardAction_KeyDown(object sender, KeyboardEventArgs e)
        {
            var config = new KeyConfig();

            config.type       = KeyTypes.Keyboard;
            config.actionType = KeyActionTypes.Face;
            config.keyCode    = e.KeyCode;
            config.keyName    = e.KeyName;
            if (doKeyConfig || doKeySend)
            {
                await controlWPFWindow.server.SendCommandAsync(new PipeCommands.KeyDown {
                    Config = config
                });
            }
            if (!doKeyConfig)
            {
                CheckKey(config, true);
            }
        }
Exemple #34
0
        public void TestGetByCategory()
        {
            var KeyConfigCat1 = new KeyConfig {
                Name        = "KC1-2",
                Description = "KeyConfig 1-2 Description",
                Category    = "Cat1",
                Key         = App.Current.Keyboard.ParseName("y")
            };
            List <KeyConfig> list = new List <KeyConfig> {
                keyConfig1, keyConfig2, KeyConfigCat1
            };

            hotkeysService.Register(list);
            var cat1KeyConfigs = hotkeysService.GetByCategory("Cat1");
            var cat2KeyConfigs = hotkeysService.GetByCategory("Cat2");

            Assert.AreEqual(2, cat1KeyConfigs.Count());
            Assert.AreEqual(1, cat2KeyConfigs.Count());
            Assert.AreSame(cat2KeyConfigs.First(), keyConfig2);
        }
        public GameScreen(GraphicsDeviceManager g, ContentManager c, SpriteFont f) : base(g, c, f)
        {
            //initialize GameDraw
            GameDraw.Initialize(g, c, f);
            GameDraw.drawAdjObjects = true;
            KeyConfig.Initialize();
            StopDrawing = false;
            StartNewGame();

            List <string> optionList = new List <string>();

            optionList.Add("Pokedex");
            optionList.Add(player.name);
            optionList.Add("Pokemon");
            optionList.Add("Save");
            optionList.Add("Bag");
            optionList.Add("Options");
            menu   = new MenuWindow(MENU_POS, optionList, MENU_PADDING);
            inMenu = false;
            Name   = "GameScreen";
        }
 // Use this for initialization
 void Start()
 {
     curtain = GameObject.Find ("Curtain").GetComponent<Curtain> ();
     soundManager = GameObject.Find ("Sounds").GetComponent<SoundManager> ();
     sushiFactory = GameObject.Find ("SushiFactory").GetComponent<SushiFactory> ();
     ogoruButton = GameObject.Find ("KojikiLink").GetComponent<Button> ();
     caption = GameObject.Find ("Caption").GetComponent<Text> ();
     thanks = GameObject.Find ("Thanks").GetComponent<Text> ();
     ogoruButton.onClick.AddListener (() => {
         Application.OpenURL("http://www.amazon.co.jp/gp/registry/wishlist/2BNAH23MYZ5TM/ref=cm_wl_huc_view");
         isThanks = true;
     });
     ogoruButtonRect = GameObject.Find ("KojikiLink").GetComponent<RectTransform> ();
     canvas = GameObject.Find ("Canvas").GetComponent<Canvas> ();
     keyConfig = KeyConfig.Current;
     isFinished = false;
     isJumping = false;
     isThanks = false;
     thanks.enabled = false;
     sushi = sushiFactory.Create ((int)SushiType.Toro, Vector3.zero, Quaternion.Euler (new Vector3 (-30f, -30f, 0f)));
 }
Exemple #37
0
        // SRC: https://www.fluxbytes.com/csharp/how-to-register-a-global-hotkey-for-your-application-in-c/
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == 0x0312)
            {
                Keys         key      = (Keys)(((int)m.LParam >> 16) & 0xFFFF);     // The key of the hotkey that was pressed.
                KEYMODIFIERS modifier = (KEYMODIFIERS)((int)m.LParam & 0xFFFF);     // The modifier of the hotkey that was pressed.
                int          id       = m.WParam.ToInt32();                         // The id of the hotkey that was pressed.

                string file = "";
                foreach (int keyset in keysets.Keys)
                {
                    if (KeyConfig.GetOnlyKey(keyset) == (int)key)
                    {
                        file = keysets[keyset];
                    }
                }
                requests.PlayRequest(file);
            }
        }
    bool RemoveKey(Hashtable cfg, JoyCode jc, int jplayer, KeyConfig except)
    {
        ArrayList al = null;
        if( FindKey(cfg, jc, jplayer, out al) ){
            int ijc = (int)jc;

            foreach(KeyConfig e in al){
                if( e == except ) continue;

                e._joyKey = (ijc == e._joyKey && jplayer == e._joyKeyPlayer)? 0 : e._joyKey;
                e._negJoyKey = (ijc == e._negJoyKey && jplayer == e._negJoyKeyPlayer)? 0 : e._negJoyKey;
            }
        }
        return al.Count >= 1 && !(al.Count == 1 && al.Contains(except));
    }
    bool RemoveKey(Hashtable cfg, JoyAnalog ja, int jplayer, KeyConfig except)
    {
        ArrayList al = null;
        if( FindKey(cfg, ja, jplayer, out al) ){

            foreach(KeyConfig e in al){
                if( e == except ) continue;

                e.JoystickAxis = JoyAnalog.None;
            }
        }
        return al.Count >= 1 && !(al.Count == 1 && al.Contains(except));
    }
    bool RemoveMouseKey(Hashtable cfg, int button, KeyConfig except)
    {
        ArrayList al = null;
        if( FindMouseKey(cfg, button, out al) ){

            foreach(KeyConfig e in al){
                if( e == except ) continue;

                e._mouseKey = (e._mouseKey == button)? -1 : e._mouseKey;
                e._negMouseKey = (e._negMouseKey == button)? -1 : e._negMouseKey;
            }
        }
        return al.Count >= 1 && !(al.Count == 1 && al.Contains(except));
    }
    //closes the Editor
    public bool CloseEditor()
    {
        if(!_editorOpen) return false;

        _editorOpen = false;
        _changedConfigs = null;
        _editting = null;
        _scrollPos = Vector2.zero;
        viewPlayerPage = 1;

        return true;
    }
 public ResultState(UserInterface userInterface)
     : base(userInterface)
 {
     keyConfig = KeyConfig.Current;
     userInterface.LastRankNumText.text = "" + userInterface.LastUserRankNum;
     userInterface.LastRankDenomText.text = "/ " + (userInterface.AIs.Length + 1);
     if (userInterface.LastUserRankNum == 1) {
         userInterface.LastRankImage.sprite = userInterface.TokujoSprite;
     } else if (userInterface.LastUserRankNum == 2) {
         userInterface.LastRankImage.sprite = userInterface.JoSprite;
         userInterface.LastRankRect.sizeDelta = new Vector2(75f, 75f);
     } else {
         userInterface.LastRankImage.sprite = userInterface.NamiSprite;
         userInterface.LastRankRect.sizeDelta = new Vector2(75f, 75f);
     }
     float time = userInterface.GoalTime;
     userInterface.GoalTimeText.text = UserInterface.FormatFloatTime (time);
     userInterface.ResultImage.enabled = true;
     userInterface.GoalTimeText.enabled = true;
     userInterface.LastRankNumText.enabled = true;
     userInterface.LastRankDenomText.enabled = true;
     userInterface.LastRankImage.enabled = true;
     userInterface.TweetButton.enabled = true;
     userInterface.TweetButton.image.enabled = true;
     userInterface.TweetButton.GetComponentInChildren<Text> ().enabled = true;
     userInterface.ReturnButton.enabled = true;
     userInterface.ReturnButton.image.enabled = true;
     userInterface.ReturnButton.GetComponentInChildren<Text> ().enabled = true;
     float prevBestTime = SaveData.GetStageBestTime (UserInterface.CurrentStageId);
     if (prevBestTime == -1 || time < prevBestTime) {
         SaveData.SetStageBestTime (UserInterface.CurrentStageId, time);
         UserInterface.HighScoreNoticeText.enabled = true;
     }
     int prevAvailableStageId = SaveData.GetAvailableStage ();
     if (prevAvailableStageId < 5 && prevAvailableStageId == UserInterface.CurrentStageId) {
         SaveData.SetAvailableStage (UserInterface.CurrentStageId + 1);
         UserInterface.IsAvailableStageInclemented = true;
     }
     userInterface.ReturnSelectorText.enabled = true;
 }
    //edit the current key if a keycode was pressed
    bool EditKey( KeyConfig config, EditStates es, KeyCode kc)
    {
        if( ( es == EditStates.VertNegKey || es == EditStates.VertPosKey ) && config._biDirLink == null) return false;

        KeyConfig HorizConfig;
        KeyConfig VertConfig;

        if( config._biDirLink == null || config.Direction == BiDir.Horizontal ){
            HorizConfig = config;
            VertConfig = config._biDirLink;
        }else{
            VertConfig = config;
            HorizConfig = config._biDirLink;
        }

        int ikc = (int) kc;

        //check for dupes in this keyconfig alone
        if(config.isAxis && config._biDirLink != null)
        {
            switch(es){
            case EditStates.VertNegKey:
                if(ikc == HorizConfig._key) return false;
                goto case EditStates.PosKey;
            case EditStates.PosKey:
                if(ikc == VertConfig._key) return false;
                goto case EditStates.VertPosKey;
            case EditStates.VertPosKey:
                if(ikc == HorizConfig._negKey) return false;
                goto case EditStates.NegKey;
            case EditStates.NegKey:
                break;
            }
        }
        else if(config.isAxis)
        {
            switch(es){
            case EditStates.PosKey:
                if(ikc == HorizConfig._negKey) return false;
                goto case EditStates.NegKey;
            case EditStates.NegKey:
                break;
            }
        }

        // SET the correct key
        switch(es){
        case EditStates.PosKey:
            ClearKeys(HorizConfig,es);
            HorizConfig._key = ikc;
            break;
        case EditStates.NegKey:
            ClearKeys(HorizConfig,es);
            HorizConfig._negKey = ikc;
            break;
        case EditStates.VertPosKey:
            ClearKeys(VertConfig,es);
            VertConfig._key = ikc;
            break;
        case EditStates.VertNegKey:
            ClearKeys(VertConfig,es);
            VertConfig._negKey = ikc;
            break;
        }
        return true;
    }
 void Start()
 {
     curtain = GameObject.Find ("Curtain").GetComponent<Curtain> ();
     maxSpeedText = GameObject.Find ("MaxSpeedText").GetComponent<Text> ();
     accelerationText = GameObject.Find ("AccelerationText").GetComponent<Text> ();
     weightText = GameObject.Find ("WeightText").GetComponent<Text> ();
     maxSpeedMeterText = GameObject.Find ("MaxSpeedMeter").GetComponent<Text> ();
     accelerationMeterText = GameObject.Find ("AccelerationMeter").GetComponent<Text> ();
     weightMeterText = GameObject.Find ("WeightMeter").GetComponent<Text> ();
     hideSpecs ();
     soundManager = GameObject.Find ("Sounds").GetComponent<SoundManager> ();
     keyConfig = KeyConfig.Current;
     switchableSushi = GameObject.Find("SwitchableSushi").GetComponent<SwitchableSushi>();
     maxSushi = Enum.GetValues (typeof(SushiType)).Length;
     currentSushi = SushiType.Amaebi;
     switchableSushi.InitializeRenderer ();
     switchableSushi.SwitchSushi (currentSushi);
     message = GameObject.Find ("Message");
     fuda = GameObject.Find ("Fuda");
     fudaSprites = new Sprite[] {
         AmaebiSprite,
         EbiSprite,
         HamachiSprite,
         HokkiSprite,
         IkaSprite,
         IkuraSprite,
         KohadaSprite,
         OotoroSprite,
         MaguroSprite,
         SulmonSprite,
         TakoSprite,
         TamagoSprite,
         UniSprite
     };
     frame = 0;
     hideSprites ();
     initFudaPosition ();
     isSelected = false;
     isReturn = false;
 }
    //clears the key assignments for the editstate es, and whether or not it's for a joystick
    void ClearKeys(KeyConfig kc, EditStates es, bool forjoy = false)
    {
        if(kc == null) return;

        if( !forjoy )
        {
            switch( es ){
            case EditStates.NegKey:
            case EditStates.VertNegKey:
                kc._negKey = 0;
                kc._negMouseKey = -1;
                break;
            case EditStates.PosKey:
            case EditStates.VertPosKey:
                kc._key = 0;
                kc._mouseKey = -1;
                break;
            }
            kc.MouseAxis = MouseAxes.None;
        }
        else
        {
            switch( es ){
            case EditStates.NegKey:
            case EditStates.VertNegKey:
                kc._negJoyKey = 0;
                kc._negJoyKeyPlayer = 0;
                break;
            case EditStates.PosKey:
            case EditStates.VertPosKey:
                kc._joyKey = 0;
                kc._joyKeyPlayer = 0;
                break;
            }
            kc.JoystickAxis = JoyAnalog.None;
            kc._joyAxisPlayer = 0;
        }
    }
    //reassign the keys to what the player presses if the player is editting a config
    void DoEditKeyWork()
    {
        if(_editting == null || !_editorOpen)return;

        //stop editting if escape is pressed
        if( _prevKeyPressed == KeyCode.Escape && (( _edittingState == EditStates.NegKey && _editting.isAxis) || (_edittingState == EditStates.PosKey && !_editting.isAxis)) ) {
            _editting = null;
            return;
        }else if(_prevKeyPressed == KeyCode.Escape){
            return;
        }

        //get the keys that were pressed
        bool keychanged = false;
        bool axischanged = false;

        //if the player is editting the joystick keys
        if(_edittingJoy)
        {
            // Joycode
            int JCPlayer = -1;
            JoyCode JCPressed = ControllerManager.Get().GetKeyPressed(out JCPlayer);

            // Joystick Axis
            int JAPlayer = -1;
            JoyAnalog JAChanged = JoyAnalog.None;

            //check if an analog button was pressed
            for(int i = 1 ; i <= 4 ; i ++){
                ControllerManager.JoyInterface joy = CMRef.GetController(i);
                if(joy == null) continue;

                //check each analog axis
                foreach(JoyAnalog ja in JoyCode.GetValues(typeof(JoyAnalog))){
                    if(joy.GetAnalogValue(ja) != 0){
                        JAChanged = ja;
                        JAPlayer = i;
                        break;
                    }
                }
            }

            //if and analog value was changed
            if( JAChanged != JoyAnalog.None && JAChanged != JoyAnalog.LeftTrigger && JAChanged != JoyAnalog.RightTrigger)
            {
                axischanged = EditKey( _editting, _edittingState, JAChanged, JAPlayer );
            }

            //if a button was pressed
            if( JCPressed != JoyCode.None && !axischanged)
            {
                keychanged = EditKey( _editting, _edittingState, JCPressed, JCPlayer);
            }
            else if( !axischanged )
            {
                return;
            }

        }
        //otherwise if the player is editting the keyboard bindings
        else
        {
            // Keycode
            KeyCode KCPressed = _prevKeyPressed;

            // Mouse Axis
            MouseAxes MAChanged = MouseAxes.None;
            float mX = Mathf.Abs(Input.GetAxis("MouseX"));
            float mY = Mathf.Abs(Input.GetAxis("MouseY"));
            float ms = Mathf.Abs(Input.GetAxis("MouseScrollWheel"));

            //scroll wheel and movement change checks
            if(ms > .2f) MAChanged = MouseAxes.ScrollWheel;
            else if(mX > 3 && mX > mY) MAChanged = MouseAxes.MoveHorizontal;
            else if(mY > 3 && mY > mX) MAChanged = MouseAxes.MoveVertical;

            // Mouse Buttons
            int MPressed = -1;
            for(int i = 0 ; i < 3 ; i ++){
                if(GetMouseButtonDown(i)) MPressed = i;
            }

            // if the mouse axis changed
            if( MAChanged != MouseAxes.None )
            {
                axischanged = EditKey( _editting, _edittingState, MAChanged);
            }
            //if a button was pressed
            else if( MPressed != -1)
            {
                keychanged = EditMouseKey( _editting, _edittingState, MPressed);
            }
            //if a key was pressed
            else if( KCPressed != KeyCode.None )
            {
                keychanged = EditKey( _editting, _edittingState, KCPressed);
            }
            else
            {
                return;
            }

        }

        //if an axis was changed
        if( axischanged ){
            _editting = null;
        //if a key changed
        }else if(keychanged){
            //cycle the editted key forward
            if(_editting.isAxis && _editting._biDirLink != null)
            {

                switch(_edittingState){
                case EditStates.NegKey: //left
                    _edittingState = EditStates.VertPosKey;
                    break;
                case EditStates.VertPosKey: //up
                    _edittingState = EditStates.PosKey;
                    break;
                case EditStates.PosKey: //right
                    _edittingState = EditStates.VertNegKey;
                    break;
                case EditStates.VertNegKey: //down
                    _editting = null;
                    break;
                default:
                    _editting = null;
                    break;
                }

            }
            else if(_editting.isAxis)
            {
                switch(_edittingState){
                case EditStates.NegKey:
                    _edittingState = EditStates.PosKey;
                    break;
                case EditStates.PosKey:
                    _editting = null;
                    break;
                default:
                    _editting = null;
                    break;
                }
            }
            else
            {
                _editting = null;
            }
        }
    }
    //draw the button as a bidirectional axis button
    int DrawBidirAxisButton(int pos, KeyConfig kc, float width)
    {
        if( kc._biDirLink == null ) return 0;

        const int bidiraxisHeight = 1;
        float lineHeight = ConfigButtonHeight;

        GUI.BeginGroup(new Rect(0, lineHeight * pos, width,lineHeight * bidiraxisHeight));

        lineHeight *= bidiraxisHeight;

        float buttonPercent = (1 - DescriptionColumnWidthPercent)/2;

        // Draw description
        GUI.Label( new Rect(0,0,width * DescriptionColumnWidthPercent, lineHeight) , kc.Description);

        // keyboard button
        Rect r = new Rect(width * DescriptionColumnWidthPercent,0, width * buttonPercent, lineHeight);
        if( GUI.Button(r, ""/*, (_editting == kc && !_edittingJoy)?"ActiveKeyConfig":"KeyConfig"*/))
        {
            EditConfig(kc);
        }

        GUI.BeginGroup(r);
        DrawBidirLabels(kc, new Vector2(width *buttonPercent, lineHeight));
        GUI.EndGroup();

        //joystick button
        r = new Rect(width * (1 - buttonPercent),0, width * buttonPercent, lineHeight);
        if( GUI.Button(r, ""/*, (_editting == kc && _edittingJoy)?"ActiveKeyConfig":"KeyConfig"*/))
        {
            EditConfig(kc, true);
        }

        GUI.BeginGroup(r);
        DrawBidirLabels(kc,new Vector2(width *buttonPercent, lineHeight),true);
        GUI.EndGroup();

        GUI.EndGroup();

        return bidiraxisHeight;
    }
    // draw the layout for the bidir labels
    void DrawBidirLabels(KeyConfig kc, Vector2 dim, bool forJoy = false)
    {
        if( kc._biDirLink == null ) return;

        string editKey = "_";

        KeyConfig HorizConfig;
        KeyConfig VertConfig;

        if(kc.Direction == BiDir.Horizontal){
            HorizConfig = kc;
            VertConfig = kc._biDirLink;
        }else{
            VertConfig = kc;
            HorizConfig = kc._biDirLink;
        }

        string analogAxis = "";
        string[] keys = new string[4]; //left up right down

        if( !forJoy ){
            switch(kc.MouseAxis){
            case MouseAxes.MoveHorizontal:
            case MouseAxes.MoveVertical:
                analogAxis = "Mouse";
                break;
            case MouseAxes.ScrollWheel:
                analogAxis = "Scroll Wheel";
                break;
            }

            if(analogAxis == "")
            {
                if( HorizConfig._negMouseKey != -1 ) keys[0] += "Mouse " + HorizConfig._negMouseKey;
                else keys[0] = ((KeyCode) HorizConfig._negKey).ToString();

                if( VertConfig._mouseKey != -1 ) keys[1] += "Mouse " + VertConfig._mouseKey;
                else keys[1] = ((KeyCode) VertConfig._key).ToString();

                if( HorizConfig._mouseKey != -1 ) keys[2] += "Mouse " + HorizConfig._mouseKey;
                else keys[2] = ((KeyCode) HorizConfig._key).ToString();

                if( VertConfig._negMouseKey != -1 ) keys[3] += "Mouse " + VertConfig._negMouseKey;
                keys[3] = ((KeyCode) VertConfig._negKey).ToString();
            }

        }else{
            switch(kc.JoystickAxis){
            case JoyAnalog.DPadHorizontal:
            case JoyAnalog.DPadVertical:
                analogAxis = "D Pad";
                break;
            case JoyAnalog.LeftStickHorizontal:
            case JoyAnalog.LeftStickVertical:
                analogAxis = "Left Stick";
                break;
            case JoyAnalog.RightStickHorizontal:
            case JoyAnalog.RightStickVertical:
                analogAxis = "Right Stick";
                break;
            }

            //analogAxis = GetControllerKeyName(kc.JoystickAxis, kc._joyAxisPlayer); //for custom strings

            if(analogAxis == "")
            {
                /*
                //for custom strings
                keys[0] = GetControllerKeyName((JoyCode)HorizConfig._negJoyKey, HorizConfig._negJoyKeyPlayer);
                keys[1] = GetControllerKeyName((JoyCode)VertConfig._joyKey, VertConfig._joyKeyPlayer);
                keys[2] = GetControllerKeyName((JoyCode)VertConfig._negJoyKey, VertConfig._negJoyKeyPlayer);
                keys[3] = GetControllerKeyName((JoyCode)HorizConfig._joyKey, HorizConfig._joyKeyPlayer);
                */

                keys[0] = "P" + HorizConfig._negJoyKeyPlayer + " " + ((JoyCode)HorizConfig._negJoyKey).ToString();
                keys[1] = "P" + VertConfig._joyKeyPlayer + " " + ((JoyCode)VertConfig._joyKey).ToString();
                keys[2] = "P" + HorizConfig._joyKeyPlayer + " " + ((JoyCode)HorizConfig._joyKey).ToString();
                keys[3] = "P" + VertConfig._negJoyKeyPlayer + " " + ((JoyCode)VertConfig._negJoyKey).ToString();
            }
        }

        GUIStyle centeredLabel = new GUIStyle("label");
        centeredLabel.alignment = TextAnchor.MiddleCenter;

        //change the key to the edit character
        if(_editting == kc && forJoy == _edittingJoy)
        {
            int start = (int) _edittingState;
            for(int i = start ; i < 4 ; i++){
                keys[i] = "";
            }
            keys[start] = editKey;
        }

        if(analogAxis != ""){
            GUI.Label(new Rect(0,0,dim.x,dim.y), analogAxis,centeredLabel);
        }else{

            int padding = ConfigButtonHeight/5;

            centeredLabel.padding = new RectOffset(0,padding,0,0);
            centeredLabel.alignment = TextAnchor.MiddleRight;
            GUI.Label(new Rect(0,0, dim.x/2, dim.y), keys[0],centeredLabel); //left

            centeredLabel.padding = new RectOffset(0,0,0,padding);
            centeredLabel.alignment = TextAnchor.LowerCenter;
            GUI.Label(new Rect(0,0, dim.x, dim.y/2), keys[1],centeredLabel); //top

            centeredLabel.padding = new RectOffset(padding,0,0,0);
            centeredLabel.alignment = TextAnchor.MiddleLeft;
            GUI.Label(new Rect(dim.x/2,0, dim.x/2, dim.y), keys[2],centeredLabel); //right

            centeredLabel.padding = new RectOffset(0,0,padding,0);
            centeredLabel.alignment = TextAnchor.UpperCenter;
            GUI.Label(new Rect(0,dim.y/2, dim.x, dim.y/2), keys[3],centeredLabel); //bottom

        }
    }
    //draw the given keyconfig at the given position. Returns the amount of positions to be jumped
    int DrawKeyConfigButton(int pos, KeyConfig kc, float width)
    {
        if(kc._biDirLink != null) return DrawBidirAxisButton(pos,kc,width);

        float lineHeight = ConfigButtonHeight;

        float buttonPercent = (1 - DescriptionColumnWidthPercent)/2;

        GUIStyle centerLabel = new GUIStyle("KeyConfigLabel");
        centerLabel.alignment = TextAnchor.MiddleCenter;

        GUI.BeginGroup(new Rect(0, lineHeight * pos, width,lineHeight * 2));

        //draw description
        GUI.Label(new Rect(0,0,width * DescriptionColumnWidthPercent, lineHeight), kc.Description);

        //draw keyboard button
        if( GUI.Button(new Rect(width * DescriptionColumnWidthPercent,0, width * buttonPercent, lineHeight), ""/*,(_editting == kc && !_edittingJoy)?"ActiveKeyConfig":"KeyConfig"*/))
        {
            EditConfig(kc);
        }
        // draw label
        GUI.Label(new Rect(width * DescriptionColumnWidthPercent,0, width * buttonPercent, lineHeight), GetButtonString(kc),centerLabel);

        //draw joystick button
        if( GUI.Button(new Rect(width *(1-buttonPercent),0, width * buttonPercent, lineHeight), ""/*,(_editting == kc && _edittingJoy)?"ActiveKeyConfig":"KeyConfig"*/))
        {
            EditConfig(kc, true);
        }
        //draw label
        GUI.Label(new Rect(width *(1-buttonPercent),0, width * buttonPercent, lineHeight), GetButtonString(kc,true),centerLabel);

        GUI.EndGroup();

        return 1;
    }
    //set the given keyconfig to be editted
    bool EditConfig(KeyConfig kc, bool forJoy = false)
    {
        if( _editting != null) return false;

        _editting = kc;
        _edittingJoy = forJoy;

        if( kc.isAxis ) _edittingState = EditStates.NegKey;
        else _edittingState = EditStates.PosKey;

        return true;
    }
    bool RemoveKey(Hashtable cfg, MouseAxes ma, KeyConfig except)
    {
        ArrayList al = null;
        if( FindKey(cfg, ma, out al) ){

            foreach(KeyConfig e in al){
                if( e == except ) continue;

                e.MouseAxis = MouseAxes.None;
            }
        }
        return al.Count >= 1 && !(al.Count == 1 && al.Contains(except));
    }
 public InputControlKeyboard(KeyConfig keyConfig)
 {
     this.keyConfig = keyConfig;
 }
    //removes the key from the table unless it is in "except"
    //TODO: When removing an axis, make sure that it is removed from the bidirlink keyconfig aswell.
    bool RemoveKey(Hashtable cfg, KeyCode kc, KeyConfig except)
    {
        ArrayList al = null;
        if( FindKey(cfg, kc, out al) ){
            int ikc = (int)kc;

            foreach(KeyConfig e in al){
                if( e == except ) continue;

                e._key = (ikc == e._key)? 0 : e._key;
                e._negKey = (ikc == e._negKey)? 0 : e._negKey;
            }
        }
        return al.Count >= 1 && !(al.Count == 1 && al.Contains(except));
    }
    // checks if the config or its bidirectional link are missing any inputs
    bool isMissingJoystickInput( KeyConfig kc )
    {
        for(int i = 0 ; i < 2 ; i ++)
        {
            if( kc == null ) return false;
            if( kc.JoystickAxis == JoyAnalog.None )
            {
                if(kc._joyKey == (int) JoyCode.None || kc._negJoyKey == (int) JoyCode.None)
                {
                    return true;
                }
            }
            kc = kc._biDirLink;
        }

        return false;
    }
 //clears both positive and negative key assignments
 void ClearKeys(KeyConfig kc, bool forjoy = false)
 {
     ClearKeys(kc, EditStates.PosKey, forjoy);
     ClearKeys(kc, EditStates.NegKey, forjoy);
 }
    // Use this for initialization
    void Start()
    {
        Curtain = GameObject.Find ("Curtain").GetComponent<Curtain> ();
        UserInterface.IsAvailableStageInclemented = false;
        SoundManager = GetComponent<SoundManager>();
        Player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Car> ();
        GameObject[] aiGameObjects = GameObject.FindGameObjectsWithTag ("AI");
        AIs = new Car[aiGameObjects.Length];
        for (int i = 0; i < AIs.Length; i++) {
            AIs [i] = aiGameObjects [i].GetComponent<Car> ();
        }
        state = new ReadyState (this);

        initDrivingStateUI ();
        initResultUI ();
        hideDrivingStateUI ();
        hideResultUI ();
        keyConfig = KeyConfig.Current;
    }
    // checks if the config or its bidirectional link are missing any inputs
    bool isMissingKeyboardInput( KeyConfig kc )
    {
        for(int i = 0 ; i < 2 ; i ++)
        {
            if( kc == null ) return false;
            if( kc.MouseAxis == MouseAxes.None )
            {
                if( (kc._key == (int) KeyCode.None && kc._mouseKey == -1) || (kc._negKey == (int) KeyCode.None && kc._negMouseKey == -1) )
                {
                    return true;
                }
            }
        }

        return false;
    }
    // load the configs for the editor
    public bool LoadEditorConfig()
    {
        if(!PlayerPrefs.HasKey( SAVE_EDIT_PREF_NAME ))
        {
            Debug.Log("An editor configuration has not been saved before");
            return false;
        }

        string setupstring = "";

        setupstring = PlayerPrefs.GetString( SAVE_EDIT_PREF_NAME );

        string[] configsetups = setupstring.Split( CONFIG_SEPERATOR );

        //subtract by one because one extra config seperator is always added to the end
        defaultKeys = new KeyConfig[ configsetups.Length - 1 ];
        int count = 0;

        if( configsetups.Length <= 1 ) return false;

        foreach( string s in configsetups )
        {
            int i = count;
            count ++;

            if( i >= defaultKeys.Length ) continue;

            defaultKeys[i] = new KeyConfig();

            string[] param = s.Split( KEY_SEPERATOR );
            if( param.Length != 18 )
            {
                Debug.LogWarning( "Config number " + i + " was not stored properly, skipping" );
                continue;
            }

            defaultKeys[i].Name = param[0];						// 0 : name

            defaultKeys[i].PlayerNum = int.Parse(param[1]);		// 1 : player number
            defaultKeys[i].Tab = param[2];						// 2 : tab
            defaultKeys[i].Description = param[3];				// 3 : description

            defaultKeys[i].Key = param[4];						// 4 : keyboard key
            defaultKeys[i].MouseButton = param[5];				// 5 : mouse button
            defaultKeys[i].JoystickButton = param[6];			// 6 : joystick button

            defaultKeys[i].isAxis = bool.Parse(param[7]);						// 7 : is an axis

            defaultKeys[i].NegativeKey = param[8];								// 8 : negative keyboard key
            defaultKeys[i].NegativeMouseButton = param[9];						// 9 : negative mouse button
            defaultKeys[i].NegativeJoystickButton = param[10];					// 10 : negative joystick button

            defaultKeys[i].MouseAxis = (MouseAxes) int.Parse(param[11]);		// 11 : mouse axis
            defaultKeys[i].JoystickAxis = (JoyAnalog) int.Parse(param[12]);		// 12 : joystick axis

            defaultKeys[i].Gravity = int.Parse( param[13] );					// 13 : gravity
            defaultKeys[i].Sensitivity = int.Parse( param[14] );				// 14 : sensitivity

            defaultKeys[i].IsBidirectional = bool.Parse( param[15] );			// 15 : is bidirectional
            defaultKeys[i].BiDirectionalLinkName = param[16];					// 16 : bidirectional link name
            defaultKeys[i].Direction = (BiDir) int.Parse(param[17]);			// 17 : bidirectional direction
        }

        return true;
    }
Exemple #59
0
 // Use this for initialization
 void Start()
 {
     keyConfig = KeyConfig.Current;
     soundManager = GameObject.Find ("UserInterface").GetComponent<SoundManager> ();
     courseFactory = GameObject.Find ("Course").GetComponent<CourseFactory> ();
     courseFactory.CreateCourse ();
     if (!IsObj) {
         lastIntersectedFloor = courseFactory.Floor;
     }
     if (IsSushi) {
         switchableSushi = GetComponentInChildren<SwitchableSushi> ();
         switchableSushi.InitializeRenderer ();
         if (IsAI) {
             int maxSushi = Enum.GetValues (typeof(SushiType)).Length;
             int sushiType = UnityEngine.Random.Range (0, maxSushi);
             switchableSushi.SwitchSushi ((SushiType)sushiType);
         } else {
             switchableSushi.SwitchSushi (Global.CurrentSushiType);
             SushiSpec spec = SushiSpecProvider.Provide (Global.CurrentSushiType);
             maxSpeed = spec.MaxSpeed;
             acceleration = spec.Acceleration;
             speedDecrFactor = spec.Weight;
         }
     }
     floatingEffect = GameObject.Find("FloatingEffect").GetComponent<ParticleSystem> ();
     floatingEffect.enableEmission = false;
 }
        //clones the config - does NOT clone link to the bidirectional axis partner
        public KeyConfig Clone()
        {
            KeyConfig k = new KeyConfig();

            k.PlayerNum = PlayerNum;
            k.Name = Name;
            k.Description = Description;
            k.Key = Key;
            k.isAxis = isAxis;
            k.NegativeKey = NegativeKey;
            k.Gravity = Gravity;
            k.Sensitivity = Sensitivity;
            k._value = _value;
            k._key = _key;
            k._negKey = _negKey;

            k._mouseKey = _mouseKey;
            k._negMouseKey = _negMouseKey;
            /* New */
             			k.JoystickButton = JoystickButton;

            k.MouseAxis = MouseAxis;
            k.JoystickAxis = JoystickAxis;

            k.IsBidirectional = IsBidirectional;
            k.BiDirectionalLinkName = BiDirectionalLinkName;
            k.Direction = Direction;

            /* Converted Values */
            k._key = _key;
            k._joyKey = _joyKey;
            k._negKey = _negKey;
            k._negJoyKey = _negJoyKey;

            k._joyKeyPlayer = _joyKeyPlayer;
            k._negJoyKeyPlayer = _negJoyKeyPlayer;
            k._joyAxisPlayer = _joyAxisPlayer;

            return k;
        }