Exemple #1
0
        public void onInit(BaseGameScreen parent)
        {
            this.parent = parent;

            aboutBackground = resourceManager.GetResource<Texture2D>(Shared.Resources.BackgroundPause);

            controlManager = new UIControlManager(Game, DefaultGestureHandlingFactory.Instance);
            Global.GestureManager.AddDispatcher(controlManager);

            btnReplay = new Button(Game, services.SpriteBatch, resourceManager.GetResource<Texture2D>(Shared.Resources.BtnReplay), resourceManager.GetResource<Texture2D>(Shared.Resources.BtnOver));
            btnReplay.Canvas.Bound.Position = new Vector2(199.0f, 229.0f);
            btnReplay.FitSizeByImage();

            btnResume = new Button(Game, services.SpriteBatch, resourceManager.GetResource<Texture2D>(Shared.Resources.BtnResume), resourceManager.GetResource<Texture2D>(Shared.Resources.BtnOver));
            btnResume.Canvas.Bound.Position = new Vector2(348.0f, 229.0f);
            btnResume.FitSizeByImage();

            btnMenu = new Button(Game, services.SpriteBatch, resourceManager.GetResource<Texture2D>(Shared.Resources.BtnMenu), resourceManager.GetResource<Texture2D>(Shared.Resources.BtnOver));
            btnMenu.Canvas.Bound.Position = new Vector2(505.0f, 229.0f);
            btnMenu.FitSizeByImage();

            btnReplay.OnPressed += new ButtonEventHandler(btnReplay_OnPressed);
            btnResume.OnPressed += new ButtonEventHandler(btnResume_OnPressed);
            btnMenu.OnPressed += new ButtonEventHandler(btnMenu_OnPressed);

            controlManager.Add(btnReplay);
            controlManager.Add(btnResume);
            controlManager.Add(btnMenu);
        }
Exemple #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            Performance.Push("Game loop");
            soundManager.Update(gameTime);
            Platform.Input.UpdateInput(gameTime);

            if (nextGameScreen != null)
            {
                if (currentGameScreen != null)
                {
                    currentGameScreen.Close();
                }

                currentGameScreen = nextGameScreen;
                if (currentGameScreen != null)
                {
                    currentGameScreen.InitUI();
                }

                nextGameScreen = null;
            }

            if (currentGameScreen != null)
            {
                currentGameScreen.Update(gameTime);
            }

            base.Update(gameTime);
            Performance.Pop();
        }
Exemple #3
0
        public MainGame(IAssetProvider setAssetProvider)
        {
            AssetProvider       = setAssetProvider;
            MainGame.WinWarGame = this;

            Log.Severity = LogSeverity.Fatal;
            Log.Type     = LogType.Performance;

            this.IsMouseVisible = false;

            this.IsFixedTimeStep = false;

            backgroundClearColor = new Color(0x7F, 0x00, 0x00);

            currentGameScreen = null;
            nextGameScreen    = null;

            _graphics = new GraphicsDeviceManager(this);
            _graphics.PreferredBackBufferWidth  = 320 * 3;
            _graphics.PreferredBackBufferHeight = 200 * 3;
            _graphics.ApplyChanges();

            Content.RootDirectory = "Assets";

#if IOS
            MouseCursor.IsVisible = false;
#endif
        }
Exemple #4
0
 void StartClient()
 {
     client = new Client.Client(this, spriteBatch, gameConfigName, this.gameType);
     Components.Add(client);
     activeScreen.Hide();
     activeScreen = client;
     activeScreen.Show();
 }
Exemple #5
0
 private void HandleActionScreen()
 {
     if (CheckKey(Keys.F1))
     {
         //activeScreen.Hide();
         activeScreen.Enabled = false;
         activeScreen         = popUpScreen;
         activeScreen.Show();
     }
 }
Exemple #6
0
        public ShipService(ComponentStore components, BaseGameScreen gameScreen)
        {
            _components = components;
            _gameScreen = gameScreen;

            var keyboardService = _components.GetSingle <KeyboardService>();

            keyboardService.RegisterKeyListener(new KeyboardService.KeyCombination(Keys.Up, KeyboardService.KeyEventType.Down, Keys.Down, KeyboardService.KeyEventType.Up), Accelerate);
            keyboardService.RegisterKeyListener(new KeyboardService.KeyCombination(Keys.Up, KeyboardService.KeyEventType.Up, Keys.Down, KeyboardService.KeyEventType.Down), Decelerate);
            keyboardService.RegisterKeyListener(new KeyboardService.KeyCombination(Keys.Left, KeyboardService.KeyEventType.Down), Left);
            keyboardService.RegisterKeyListener(new KeyboardService.KeyCombination(Keys.Right, KeyboardService.KeyEventType.Down), Right);
            keyboardService.RegisterKeyListener(new KeyboardService.KeyCombination(Keys.LeftControl, KeyboardService.KeyEventType.Pressed), Fire);
        }
Exemple #7
0
 private void HandleHostGameScreenButtons(Control sender)
 {
     if (sender.Name == "Start")
     {
         gameType = Client.Client.GameType.hosted;
         StartServer(gameType);
     }
     if (sender.Name == "BackButton")
     {
         activeScreen.Hide();
         activeScreen = networkScreen;
         activeScreen.Show();
     }
 }
        public void setState(GameState newState)
        {
            bool skip = (current == GameState.Gameplay && newState == GameState.Cutscene) ||
                        (current == GameState.Cutscene && newState == GameState.Gameplay);

            current = newState;
            switch (current)
            {
            case GameState.CharacterSelection:
                screen = new CharacterSelectionScreen();
                break;

            case GameState.Cutscene:
                screen = new CutsceneScreen();
                break;

            case GameState.Gameplay:
                screen = new GameplayScreen();
                break;

            case GameState.JoinScreen:
                screen = new JoinScreen();
                break;

            case GameState.Multiplayer:
                screen = new MultiplayerScreen();
                break;

            case GameState.RootMenu:
                screen = new MainScreen();
                break;

            case GameState.WorldMap:
                screen = new WorldMapScreen();
                break;

            case GameState.MapEditor:
                screen = new MapEditorScreen();
                break;

            case GameState.WorldEditor:
                screen = new WorldEditorScreen();
                break;
            }
            if (!skip)
            {
                Game.instance.network.sendGameStateUpdate();
            }
        }
Exemple #9
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont  = Content.Load <SpriteFont>("font");
            formFont    = Content.Load <SpriteFont>("FormFont");

            popUpTexture        = Content.Load <Texture2D>("quitscreen");
            actionScreentexture = Content.Load <Texture2D>("greenmetal");
            blankBlackTexture   = Content.Load <Texture2D>("black");

            //initialize and start the screens
            startScreen = new StartScreen(this, spriteBatch, formFont);
            Components.Add(startScreen);
            startScreen.ButtonClicked += new StartScreen.ClickEvent(HandleStartScreenButtons);
            startScreen.Hide();

            networkScreen = new NetworkGameSelectScreen(this, spriteBatch, spriteFont, blankBlackTexture);
            Components.Add(networkScreen);
            networkScreen.ButtonClicked += new NetworkGameSelectScreen.ClickEvent(HandleNetworkSelectScreenButtons);
            networkScreen.Hide();

            joinGameScreen = new JoinNetworkGameScreen(this, spriteBatch, formFont, blankBlackTexture);
            Components.Add(joinGameScreen);
            joinGameScreen.ButtonClicked += new JoinNetworkGameScreen.ClickEvent(HandleJoinGameScreenButtons);
            joinGameScreen.Hide();

            hostGameScreen = new HostNetworkGameScreen(this, spriteBatch, formFont, blankBlackTexture);
            Components.Add(hostGameScreen);
            hostGameScreen.ButtonClicked += new HostNetworkGameScreen.ClickEvent(HandleHostGameScreenButtons);
            hostGameScreen.Hide();

            actionScreen = new ActionScreen(this, spriteBatch, actionScreentexture);
            Components.Add(actionScreen);
            actionScreen.Hide();

            popUpScreen = new PopUpScreen(this, spriteBatch, spriteFont, popUpTexture);
            Components.Add(popUpScreen);
            popUpScreen.Hide();



            activeScreen = startScreen;
            //activeScreen = joinGameScreen;
            activeScreen.Show();

            IsMouseVisible = true;
        }
Exemple #10
0
 private void HandlePopUpScreen()
 {
     if (CheckKey(Keys.Enter))
     {
         if (popUpScreen.SelectedIndex == 0)
         {
             activeScreen.Hide();
             actionScreen.Hide();
             activeScreen = startScreen;
             activeScreen.Show();
         }
         if (popUpScreen.SelectedIndex == 1)
         {
             activeScreen.Hide();
             activeScreen = actionScreen;
             activeScreen.Show();
         }
     }
 }
Exemple #11
0
        private void HandleStartScreenButtons(Control sender)
        {
            if (sender.Name == "StartGame")
            {
                gameType = Client.Client.GameType.local;
                StartServer(gameType);
            }
            if (sender.Name == "NetworkGame")
            {
                activeScreen.Hide();
                activeScreen = networkScreen;
                activeScreen.Show();
            }
            if (sender.Name == "QuitGame")
            {
                this.Exit();
            }

            /* if (CheckKey(Keys.Enter))
             * {
             *   if (startScreen.SelectedIndex == 0) //start
             *   {
             *       gameType = Client.Client.GameType.local;
             *       StartServer(gameType);
             *       //activeScreen.Hide();
             *       //activeScreen = actionScreen;
             *       //activeScreen.Show();
             *   }
             *
             *   if (startScreen.SelectedIndex == 1) //Multiplayer game
             *   {
             *       activeScreen.Hide();
             *       activeScreen = networkScreen;
             *       activeScreen.Show();
             *   }
             *
             *   if (startScreen.SelectedIndex == 2) //quit
             *   {
             *       this.Exit();
             *   }
             * }*/
        }
Exemple #12
0
 private void HandleJoinGameScreenButtons(Control sender)
 {
     if (sender.Name == "ScanLan")
     {
         //TODO: Only start client if local game is found
         gameType = Client.Client.GameType.scanLan;
         StartClient();
         Console.WriteLine("SCAN LAN!");
     }
     if (sender.Name == "Connect") //Join a network game by address
     {
         gameType = Client.Client.GameType.hosted;
         Console.WriteLine("Connect to {0}:{1}", joinGameScreen.Address, joinGameScreen.Port);
     }
     if (sender.Name == "BackButton")
     {
         activeScreen.Hide();
         activeScreen = networkScreen;
         activeScreen.Show();
     }
 }
Exemple #13
0
 private void HandleNetworkSelectScreenButtons(Control sender)
 {
     if (sender.Name == "HostGame")
     {
         gameType = Client.Client.GameType.hosted;
         activeScreen.Hide();
         activeScreen = hostGameScreen;
         activeScreen.Show();
     }
     if (sender.Name == "JoinGame")
     {
         //load join screen
         activeScreen.Hide();
         activeScreen = joinGameScreen;
         activeScreen.Show();
     }
     if (sender.Name == "BackButton")
     {
         //go back to startScreen
         activeScreen.Hide();
         activeScreen = startScreen;
         activeScreen.Show();
     }
 }
 public void DrawPlayer(BaseGameScreen screen, PlayerData playerData, Vector2 coord, int spriteNum, float spriteRotation = 0, float spriteScale = 1f, SpriteEffects spriteEffect = SpriteEffects.None)
 {
     /*Draw(pdata.body, coord, (int)state, spriteRotation, spriteScale);
     Draw(pdata.faces, coord, (int)state, spriteRotation, spriteScale);
     if(pdata.accessories != null) {
         Draw(pdata.accessories, coord, (int)state, spriteRotation, spriteScale);
     }
     if(pdata.hats != null) {
         Draw(pdata.hats, coord - spriteScale * new Vector2(0, 32), 0, spriteRotation, spriteScale);
     }*/
     int len = Helpers.TextureLen(typeof(TextureData.PlayerStates));
     Draw(screen.textureList[playerData.profile], coord, spriteNum + len * playerData.color, spriteEffect, spriteRotation: spriteRotation, spriteScale: spriteScale);
 }
 private BaseScreen SetGameScreen(BaseGameScreen.GameType gameType, object[] data = null) {
   GameObject tempGameObject;
   BaseScreen tempScreen;
   switch(gameType) {
     default:
       tempScreen = null;
     break;
   }
   CurrentGameScreen = tempScreen as BaseGameScreen;
   return tempScreen;
 }
 public TextBanner(BaseGameScreen screen, string text)
 {
     this.text = text;
     this.screen = screen;
 }
 public StateManager()
 {
     screen = new MainScreen();
 }
Exemple #18
0
        public void onInit(BaseGameScreen parent)
        {
            this.parent = parent;

            aboutBackground = resourceManager.GetResource<Texture2D>(Shared.Resources.BackgroundWin);

            controlManager = new UIControlManager(Game, DefaultGestureHandlingFactory.Instance);
            Global.GestureManager.AddDispatcher(controlManager);

            btnReplay = new Button(Game, services.SpriteBatch, resourceManager.GetResource<Texture2D>(Shared.Resources.BtnReplay), resourceManager.GetResource<Texture2D>(Shared.Resources.BtnOver));
            btnReplay.Canvas.Bound.Position = new Vector2(516f, 352f);
            btnReplay.FitSizeByImage();

            btnMenu = new Button(Game, services.SpriteBatch, resourceManager.GetResource<Texture2D>(Shared.Resources.BtnMenu), resourceManager.GetResource<Texture2D>(Shared.Resources.BtnOver));
            btnMenu.Canvas.Bound.Position = new Vector2(223f, 352f);
            btnMenu.FitSizeByImage();

            btnReplay.OnPressed += new ButtonEventHandler(btnReplay_OnPressed);
            btnMenu.OnPressed += new ButtonEventHandler(btnMenu_OnPressed);

            controlManager.Add(btnReplay);
            controlManager.Add(btnMenu);

            // Exception for Next button, prevent choice next map when next map not available
            if (Convert.ToInt32(Global.CurrentMap) + 1 < Global.NumberOfMap)
            {
                btnNext = new Button(Game, services.SpriteBatch, resourceManager.GetResource<Texture2D>(Shared.Resources.BtnNextGame), resourceManager.GetResource<Texture2D>(Shared.Resources.BtnOver));
                btnNext.Canvas.Bound.Position = new Vector2(370f, 352f);
                btnNext.FitSizeByImage();

                btnNext.OnPressed += new ButtonEventHandler(btnNext_OnPressed);
                controlManager.Add(btnNext);
            }

            String gameType = "";
            if (parent is BasicGameScene)
            {
                gameType = SaveLoadGame.GAME_SCORE_BASIC;
                currentScore = Global.Counter_Scores + Global.TotalCoin * 50 + (1000 - (long)Global.Counter_Time);
            }
            else if(parent is MiniGameLimitBomb)
            {
                gameType = SaveLoadGame.GAME_SCORE_BOMB;
                currentScore = Global.Bomb_Number;
            }
            else
            {
                gameType = SaveLoadGame.GAME_SCORE_TIME;
                currentScore = Global.Counter_Time;
            }

            SaveLoadGame.LoadGameScore(gameType, Convert.ToInt32(Global.CurrentMap), out lastScore);

            if (lastScore <= currentScore)
            {
                SaveLoadGame.SaveGameScore(gameType, Convert.ToInt32(Global.CurrentMap), currentScore);
                newHighScore = resourceManager.GetResource<Texture2D>(Shared.Resources.NewHighScore);
                newHighScorePos = new Vector2(486f, 24f);

                scoreFont = resourceManager.GetResource<SpriteFont>("Score");
                scorePos = new Vector2(300f, 210f);
            }

            SaveLoadGame.SaveLevel(Global.CurrentMode, Convert.ToInt32(Global.CurrentMap) + 1);
        }
Exemple #19
0
 internal void SetNextGameScreen(BaseGameScreen setNextGameScreen)
 {
     nextGameScreen = setNextGameScreen;
 }