Esempio n. 1
0
        public TitleScreenState()
        {
            SoundFactory.Instance.StopCreditsSong();
            SoundFactory.Instance.StopDungeonSong();
            SoundFactory.Instance.StopBossSong();
            SoundFactory.Instance.PlayTitleSong();
            sprite            = ScreenSpriteFactory.Instance.TitleScreen();
            enter             = ScreenSpriteFactory.Instance.PressEnter();
            sprite.FrameDelay = GameData.Instance.GameStateDataConstants.TitleScreenFrameDelay;
            LoZGame.Instance.GameObjects.Clear();
            LoZGame.Instance.Players.Clear();

            LoZGame.Instance.Link = new Link(new Vector2(
                                                 (float)(BlockSpriteFactory.Instance.HorizontalOffset + GameData.Instance.GameStateDataConstants.HorizontalHalfDungeon),
                                                 (float)(BlockSpriteFactory.Instance.TopOffset + GameData.Instance.GameStateDataConstants.VerticalHalfDungeon)));

            LoZGame.Instance.Players.Add(LoZGame.Instance.Link);

            KeyboardCommandLoader keyboardLoader = new KeyboardCommandLoader(LoZGame.Instance.Players[0]);
            MouseCommandLoader    mouseLoader    = new MouseCommandLoader();

            if (LoZGame.Instance.Controllers.Count == 0)
            {
                LoZGame.Instance.Controllers.Add(new KeyboardController(keyboardLoader));
                LoZGame.Instance.Controllers.Add(new MouseController(mouseLoader));
            }
            else
            {
                for (int i = 0; i < LoZGame.Instance.Controllers.Count; i++)
                {
                    if (LoZGame.Instance.Controllers[i] is KeyboardController)
                    {
                        LoZGame.Instance.Controllers[i] = new KeyboardController(keyboardLoader);
                    }
                    else if (LoZGame.Instance.Controllers[i] is MouseController)
                    {
                        LoZGame.Instance.Controllers[i] = new MouseController(mouseLoader);
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyboardController"/> class.
 /// </summary>
 /// <param name="allCommands">Contains all commands for the controller to execute.</param>
 public KeyboardController(KeyboardCommandLoader allCommands)
 {
     this.allCommands         = allCommands;
     oldState                 = Keyboard.GetState();
     playerDict               = allCommands.GetPlayerDict;
     inventoryDict            = allCommands.GetInventoryDict;
     optionsDict              = allCommands.GetOptionsDict;
     profilesDict             = allCommands.GetProfilesDict;
     purchaseConfirmationDict = allCommands.GetPurchaseConfirmationDict;
     resetConfirmationDict    = allCommands.GetResetConfirmationDict;
     quitConfirmationDict     = allCommands.GetQuitConfirmationDict;
     playerCommands           = new Stack <KeyValuePair <Keys, ICommand> >();
     playerKeys               = new List <Keys>
     {
         Keys.W, Keys.Up, Keys.A, Keys.Left, Keys.S, Keys.Down, Keys.D, Keys.Right,
         Keys.Z, Keys.Space, Keys.N,
     };
     oneUseKeys = new List <Keys>
     {
         Keys.Z, Keys.Space, Keys.N,
     };
 }