Exemple #1
0
        private void Start()
        {
            InputDispatcher dispatcher = FindObjectOfType <InputDispatcher>();

            dispatcher.AddKeyDownHandler(KeyCode.W, keyCode => startMovement(MovementDirection.North));
            dispatcher.AddKeyDownHandler(KeyCode.D, keyCode => startMovement(MovementDirection.East));
            dispatcher.AddKeyDownHandler(KeyCode.S, keyCode => startMovement(MovementDirection.South));
            dispatcher.AddKeyDownHandler(KeyCode.A, keyCode => startMovement(MovementDirection.West));
            dispatcher.AddKeyUpHandler(KeyCode.W, keyCode => stopMovement(MovementDirection.North));
            dispatcher.AddKeyUpHandler(KeyCode.D, keyCode => stopMovement(MovementDirection.East));
            dispatcher.AddKeyUpHandler(KeyCode.S, keyCode => stopMovement(MovementDirection.South));
            dispatcher.AddKeyUpHandler(KeyCode.A, keyCode => stopMovement(MovementDirection.West));
        }
Exemple #2
0
        private void Awake()
        {
            // Listen for Escape key ('Back' on Android) that suspends the game on Android
            // or ends it on any other platform
                        #if UNITY_ANDROID
            inputDispatcher.AddKeyUpHandler(KeyCode.Escape,
                                            keyCode => {
                AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer")
                                             .GetStatic <AndroidJavaObject>("currentActivity");
                activity.Call <bool>("moveTaskToBack", true);
            });
                        #else
            inputDispatcher.AddKeyDownHandler(KeyCode.Escape,
                                              keyCode => Application.Quit());
                        #endif

            cardStorage     = new CardStorage(defaultCharacterSprite, loadRemoteCollectionFirst);
            progressStorage = new ProgressStorage(cardStorage);

            GameStartOverlay.FadeOutCallback = StartGameplayLoop;
        }