Exemple #1
0
        public VERGEGame()
            : base()
        {
            System.Diagnostics.StackTrace stack = new System.Diagnostics.StackTrace();
            stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();

            // the assembly/namespace to search for script classes defaults to the one
            // from which this constructor was called.
            Type sourcetype = stack.GetFrame(1).GetMethod().DeclaringType;
            main_assembly = sourcetype.Assembly;
            main_namespace = sourcetype.Namespace;
            game_input_handler = () => { return true; }; // unless overriden, always pass control to the map handler

            VERGEGame.game = this;
            Default_Handlers.game = this;
            followers = new FollowerChain(null);

            // Set up timing
            this.IsFixedTimeStep = false;

            tick_length = 10; // In milliseconds. VERGE standard is 100 ticks per second
            _last_tick_time = 0;
            _tick = 0;

            // Set up graphics
            graphics = new GraphicsDeviceManager(this);

            // Uncomment this line to remove fps throttling:
            graphics.SynchronizeWithVerticalRetrace = false;

            camera = null;
            hook_render = null;
            system_font = null;
            MapContent = new ContentManager(Services, "Content");
            Content.RootDirectory = "Content";

            // Set up input
            input = new InputManager();
            initialize_buttons();

            // Initialize other variables
            global = new ScriptBank();
            map = null;
            player = null;
            player_controllable_stack = new Stack<bool>();
            player_controllable = PLAYER_CONTROLLABLE_DEFAULT;
            player_tile_obstruction = true;
            default_entity_handler = Default_Handlers.omnibus_vergestyle_handler;
            entities_paused = false;
            entities_paused_stack = new Stack<bool>();
            action_queue = new Queue<Action>();
        }
Exemple #2
0
        // time_elapsed is a count of the ticks since the InputManager last updated (generally 1).
        public void Update(InputManager manager, int time_elapsed)
        {
            bool down_now;
            if (_locked) return;

            _pressed = _released = false;

            // Determine current state of semantic button (it's down if anything mapped to the button is down)

            if( manager.gp_state.IsConnected && input.gamepad_buttons.Any( manager.gp_state.IsButtonDown ) ) {
                down_now = true;
            } else if( input.keys.Any( manager.kb_state.IsKeyDown ) ) {
                down_now = true;
            }  else {
                // TODO: other input types here
                down_now = false;
            }

            if (down_now != _down) {
                _down = down_now;
                if( down_now ) {
                    _pressed = true;
                } else {
                    if( !_released ) {
                        unpress();
                    }
                    _released = true;
                }
            }

            if( down_now || _released ) {
                ticks_held += time_elapsed;
            } else {
                ticks_held = 0;
            }
        }