Esempio n. 1
0
        public World(int currentLevel)
        {
            _currentLevel = currentLevel;

            Map = new Map(ContentChest.Maps[_currentLevel]);

            WorldObjects = Map.WorldObjects;
            WorldItems   = Map.WorldItems;

            InputManager.OnDownHeld        = () => Player.Move(0, 1);
            InputManager.OnUpHeld          = () => Player.Move(0, -1);
            InputManager.OnLeftHeld        = () => Player.Move(-1, 0);
            InputManager.OnRightHeld       = () => Player.Move(1, 0);
            InputManager.OnDownPressed     = () => Player.Look(0, 1);
            InputManager.OnUpPressed       = () => Player.Look(0, -1);
            InputManager.OnLeftPressed     = () => Player.Look(-1, 0);
            InputManager.OnRightPressed    = () => Player.Look(1, 0);
            InputManager.OnNextSlotPressed = () => UIManager.NextSlot();
            InputManager.OnLastSlotPressed = () => UIManager.LastSlot();
            InputManager.OnInteractPressed = UseItem;
            InputManager.OnPickupPressed   = PickupWorldObject;
            InputManager.OnBackPressed     = ResetWorld;

            Map.RequestNotification = s => RequestNotification?.Invoke(s);

            UIManager = new UIManager();

            SetupPlayer();
            SetupCamera();

            ProgressTimer          = new Timer();
            ProgressTimer.Elapsed += (e, b) => Progress();
            ProgressTimer.Start();
        }
Esempio n. 2
0
        public GameScreen(int level = 1)
        {
            if (!LevelExists(level))
            {
                RequestScreenChange?.Invoke(new GameScreen(level - 1));
                return;
            }

            _world = new World(level)
            {
                RequestNotification    = s => RequestNotification?.Invoke(s),
                RequestTransitionReset = ResetTransition,
                RequestScreenChange    = (screen) => RequestScreenChange?.Invoke(screen)
            };

            Transition.OnTransitionOutEnded = _world.Progress;

            UIManager = _world.UIManager;
        }