Exemplo n.º 1
0
        /// <summary>
        /// Add a new key to the manager
        /// </summary>
        /// <param name="key">The key to add</param>
        /// <returns>The task</returns>
        public static async Task AddKeyAsync(Key key)
        {
            // Lock the method
            using (await AsyncLock.LockAsync())
            {
                // Check if it's the following key in any of the available codes
                if (Codes.All(x => x.Key.Length <= CurrentInput.Count || x.Key[CurrentInput.Count] != key))
                {
                    if (CurrentInput.Any())
                    {
                        CurrentInput.Clear();
                        RL.Logger?.LogDebugSource("The secret code inputs were reset due to an invalid key being pressed");
                    }

                    return;
                }

                // Add the key to the list
                CurrentInput.Add(key);

                // Attempt to get a completed code
                var task = Codes.FindItem(x => x.Key.SequenceEqual(CurrentInput)).Value;

                if (task == null)
                {
                    return;
                }

                CurrentInput.Clear();
                RL.Logger?.LogDebugSource("The secret code inputs were reset due to a valid code having been entered");

                // Run the task
                await task();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs the initialisation of the state of the game being interpreted. Usually called whenever
        /// the game starts or restarts.
        /// </summary>
        public void Init()
        {
            ClearVars();
            Vars[Defines.MACHINE_TYPE] = 0;  // IBM PC
            Vars[Defines.MONITOR_TYPE] = 3;  // EGA
            Vars[Defines.INPUTLEN]     = Defines.MAXINPUT + 1;
            Vars[Defines.NUM_VOICES]   = 3;

            // The game would usually set this, but no harm doing it here (2 = NORMAL).
            Vars[Defines.ANIMATION_INT] = 2;

            // Set to the maximum memory amount as recognised by AGI.
            Vars[Defines.MEMLEFT] = 255;

            ClearFlags();
            Flags[Defines.HAS_NOISE] = true;
            Flags[Defines.INITLOGS]  = true;
            Flags[Defines.SOUNDON]   = true;

            // Set the text attribute to default (black on white), and display the input line.
            ForegroundColour = 15;
            BackgroundColour = 0;

            Horizon     = Defines.HORIZON;
            UserControl = true;
            Blocking    = false;

            ClearVisualPixels();
            GraphicsMode   = true;
            AcceptInput    = false;
            ShowStatusLine = false;
            CurrentLogNum  = 0;
            CurrentInput.Clear();
            LastInput  = "";
            SimpleName = "";
            KeyToControllerMap.Clear();
            MenuEnabled = true;
            HoldKey     = false;

            foreach (AnimatedObject aniObj in AnimatedObjects)
            {
                aniObj.Reset(true);
            }

            StoppedObjectList.Clear();
            UpdateObjectList.Clear();

            this.Objects = new Objects(game.Objects);
        }
Exemplo n.º 3
0
 // it may be useful to store the current input, maybe...
 public void UpdateInput(T input)
 {
     CurrentInput.Clear();
     input.ForEach(e => CurrentInput.Add(e));
 }