Ejemplo n.º 1
0
        /// <summary>
        /// initializes this screen.
        /// </summary>
        public override void InitializeScreen()
        {
            base.InitializeScreen();

            FrameworkCore.Viewer.ClearColor = Color.Black;

            NextScreen        = new VersusReadyScreen();
            TransitionOffTime = TimeSpan.FromSeconds(8.0f);

            FrameworkCore.RenderContext.ClearColor = Color.Black;

            //  initializes for world everything.
            InitWorld();

            //  initializes for camera for this stage.
            InitCamera();

            //  Load Hud
            CreateHud();

            for (int i = 0; i < GameLevel.PlayerCountInLevel; i++)
            {
                GamePlayer gamePlayer = GameLevel.GetPlayerInLevel(i);

                //  Update selected weapon image in the Hud
                SetCurrentWeaponHud(i, gamePlayer.CurrentWeapon.WeaponType);
            }

            //  Play a background music
            soundBGM = GameSound.Play(SoundTrack.FirstStage);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Moves to selected menu.
        /// </summary>
        /// <param name="inputIndex">an index of the input</param>
        /// <param name="verticalEntryIndex">
        /// a vertical index of selected entry
        /// </param>
        /// <param name="horizontalEntryIndex">
        /// a horizontal index of selected entry
        /// </param>
        public override void OnSelectedEntry(int inputIndex,
                                             int verticalEntryIndex,
                                             int horizontalEntryIndex)
        {
            //  It prevents more than one input.
            if (inputIndex != 0)
            {
                return;
            }

            if (ScreenState == ScreenState.Active)
            {
                //  If selected a start button, jump to the first stage screen
                if (verticalEntryIndex == 0)
                {
                    NextScreen            = new LoadingScreen();
                    NextScreen.NextScreen = new FirstStageScreen();

                    TransitionOffTime = TimeSpan.FromSeconds(1.0f);
                    ExitScreen();
                }
                //  If selected a versus button, jump to the versus ready screen
                else if (verticalEntryIndex == 1)
                {
                    NextScreen = new VersusReadyScreen();

                    TransitionOffTime = TimeSpan.FromSeconds(1.0f);
                    ExitScreen();
                }
                //  If selected a exit button, exit the program
                else if (verticalEntryIndex == 2)
                {
                    // Allows the default game to exit on Xbox 360 and Windows
                    MessageBoxScreen messageBox =
                        new MessageBoxScreen("Are you sure you want to exit?");

                    //  Register message box handle method
                    messageBox.Accepted += RobotGameGame.ExitAccepted;

                    GameScreenManager.AddScreen(messageBox, true);
                }

                //  Play the select sound
                GameSound.Play(SoundTrack.MenuClose);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// checks the winning condition of the versus play.
        /// Any player who has destroyed the other as many as the kill point wins.
        /// </summary>
        protected override void CheckMission(GameTime gameTime)
        {
            if (isFinishedVersus == false)
            {
                for (int i = 0; i < GameLevel.PlayerCountInLevel; i++)
                {
                    GamePlayer player = GameLevel.GetPlayerInLevel(i);

                    //  Whoever wins the set points first, the versus mode will end.
                    if (RobotGameGame.VersusGameInfo.killPoint <= player.KillPoint)
                    {
                        isFinishedVersus = true;
                    }
                }
            }

            if (isFinishedVersus)
            {
                //  Visible mission result image
                if (missionResultElapsedTime > MissionResultVisibleTime)
                {
                    this.spriteObjHudVersusWin.Visible  = true;
                    this.spriteObjHudVersusLose.Visible = true;
                }
                else
                {
                    if (missionResultElapsedTime < MissionResultVisibleTime)
                    {
                        missionResultElapsedTime +=
                            (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }

                    this.spriteObjHudVersusWin.Visible  = false;
                    this.spriteObjHudVersusLose.Visible = false;
                }

                if (GameSound.IsPlaying(soundBGM))
                {
                    float scaleFactor = 1.0f;
                    if (GameLevel.Info.GamePlayType == GamePlayTypeId.Versus)
                    {
                        scaleFactor = 0.8f;
                    }

                    //  Scale the image size and position for screen resolution
                    Vector2 sizeScale =
                        new Vector2((float)FrameworkCore.ViewWidth * scaleFactor /
                                    (float)ViewerWidth.Width1080,
                                    (float)FrameworkCore.ViewHeight * scaleFactor /
                                    (float)ViewerHeight.Height1080);

                    for (int i = 0; i < GameLevel.PlayerCountInLevel; i++)
                    {
                        GamePlayer player = GameLevel.GetPlayerInLevel(i);

                        //  Player sound and action stop
                        player.MissionEnd();

                        //  Win!!
                        if (RobotGameGame.VersusGameInfo.killPoint <= player.KillPoint)
                        {
                            int scaledWidth =
                                (int)((float)imageWinWidth * sizeScale.X);
                            int scaledHeight =
                                (int)((float)imageWinHeight * sizeScale.Y);

                            int posX = (int)((FrameworkCore.ViewWidth / 2) -
                                             (scaledWidth / 2));

                            int posY = (int)((FrameworkCore.ViewHeight / 2) -
                                             (scaledHeight / 2));

                            if (player.PlayerIndex == PlayerIndex.One)
                            {
                                posY -= FrameworkCore.ViewHeight / 4;
                            }
                            else if (player.PlayerIndex == PlayerIndex.Two)
                            {
                                posY += FrameworkCore.ViewHeight / 4;
                            }

                            this.spriteObjHudVersusWin.ScreenRectangle = new Rectangle(
                                posX, posY,
                                scaledWidth, scaledHeight);
                        }
                        //  Lose!!
                        else
                        {
                            int scaledWidth =
                                (int)((float)imageLoseWidth * sizeScale.X);
                            int scaledHeight =
                                (int)((float)imageLoseHeight * sizeScale.Y);

                            int posX = (int)((FrameworkCore.ViewWidth / 2) -
                                             (scaledWidth / 2));

                            int posY = (int)((FrameworkCore.ViewHeight / 2) -
                                             (scaledHeight / 2));

                            if (player.PlayerIndex == PlayerIndex.One)
                            {
                                posY -= FrameworkCore.ViewHeight / 4;
                            }
                            else if (player.PlayerIndex == PlayerIndex.Two)
                            {
                                posY += FrameworkCore.ViewHeight / 4;
                            }

                            this.spriteObjHudVersusLose.ScreenRectangle = new Rectangle(
                                posX, posY,
                                scaledWidth, scaledHeight);
                        }
                    }

                    //  Stop background music
                    GameSound.Stop(soundBGM);

                    //  Play success music
                    GameSound.Play(SoundTrack.MissionClear);

                    //  Invisible all of the Hud
                    SetVisibleHud(false);

                    //  Go to main menu
                    NextScreen        = new VersusReadyScreen();
                    TransitionOffTime = TimeSpan.FromSeconds(8.0f);
                    ExitScreen();
                }
            }
            else
            {
                // Respawns a destroyed player in the game.
                for (int i = 0; i < GameLevel.PlayerCountInLevel; i++)
                {
                    GamePlayer player = GameLevel.GetPlayerInLevel(i);

                    if (player.IsFinishedDead)
                    {
                        int otherSidePlayerIndex = -1;

                        if (i == 0)
                        {
                            otherSidePlayerIndex = 1;
                        }
                        else if (i == 1)
                        {
                            otherSidePlayerIndex = 0;
                        }

                        GamePlayer otherSidePlayer =
                            GameLevel.GetPlayerInLevel(otherSidePlayerIndex);

                        //  Find the farthest positions for enemy positions.
                        RespawnInLevel respawn = GameLevel.FindRespawnMostFar(
                            otherSidePlayer.WorldTransform.Translation);

                        //  Set to respawn position
                        player.SpawnPoint = Matrix.CreateRotationY(
                            MathHelper.ToRadians(respawn.SpawnAngle)) *
                                            Matrix.CreateTranslation(respawn.SpawnPoint);

                        //  Reset the player info
                        player.Reset(true);
                    }
                }
            }
        }