Пример #1
0
 public Projectile( PlayScreen screen, PlayableCube cube, Vector3 worldPos, Vector3 direction, float rotation )
     : base(cube.Game, screen, cube, worldPos, (Direction) rotation)
 {
     this.Visible = true;
     this.DrawOrder = 1;
     mDirection = direction;
 }
Пример #2
0
        public EndLevelScreen(CubeGame game, string levelName, PlayScreen level)
            : base(game)
        {
            pLevelName = levelName;
            pSaveData = SaveData.Load(pLevelName);

            mLevel = level;
            mTextBox = new TextBox(game, game);

            mTextBox.Visible = false;
            bSendingScore = false;
            bSentScore = false;

            // TODO: Replace Tester with user's name
            // pSaveData.AddScore( pScore, "The World's #1" );
            // pSaveData.Save( pLevelName );
        }
Пример #3
0
        public Player( PlayScreen screen, PlayableCube cube, Vector3 worldPos, float rotation )
            : base(cube.Game, screen, cube, worldPos, (Direction) rotation)
        {
            this.Visible = true;
            this.DrawOrder = 1;

            mModelRotation = new AnimatedVariable<float>( rotation,
                (f0, f1, step) => {
                    var diff = MathHelper.WrapAngle( f1 - f0 );
                    return f0.Tween( f0 + diff, step );
                } );

            mHeadbob = new AnimatedVariable<float>( //Utils.Lerp );
                (f0, f1, step) => {
                    return f0.Tween( f1, step );
                } );
        }
Пример #4
0
        public Enemy( PlayScreen screen, PlayableCube cube, Vector3 worldPos, float rotation )
            : base(cube.Game, screen, cube, worldPos, (Direction) rotation)
        {
            this.Visible = true;
            this.DrawOrder = 1;

            mModelRotation = new AnimatedVariable<float>( rotation,
                (f0, f1, step) => {
                    var diff = MathHelper.WrapAngle( f1 - f0 );
                    return f0.Tween( f0 + diff, step );
                } );

            mMovementDirection = (Direction) rotation;

            sRand = new Random();
            if (sRand.Next() % 2 == 0) {
                mMovementDirection++;
            } else {
                mMovementDirection--;
            }
        }
Пример #5
0
 private void TestLevel()
 {
     PlayableCube playCube = Cube.GeneratePlayableCube();
     //playCube.Load( "CubeLevel" );
     PlayScreen playScreen = new PlayScreen( Game, playCube );
     ScreenManager.PushScreen( playScreen );
 }
Пример #6
0
        public override void Update( GameTime gameTime )
        {
            base.Update( gameTime );
            resetTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;

            // Fade effect for highlighed menu button
            if (isFading)
            {
                cSelected.A -= 3;
                if (cSelected.A == 0) isFading = false;
            }
            else
            {
                cSelected.A += 3;
                if (cSelected.A == 255) isFading = true;
            }

            GamePadState NewPadState = GamePad.GetState(PlayerIndex.One);
            KeyboardState NewKeyState = Keyboard.GetState();
            if (resetTime < 0)
            {
                // Change highlighted button on "up"
                if ((NewKeyState.IsKeyDown(Keys.Up) && OldKeyState.IsKeyUp(Keys.Up))
                    || (NewPadState.IsButtonDown(Buttons.DPadUp) && OldPadState.IsButtonUp(Buttons.DPadUp)))
                {
                    sfxButtonPressed.Play();
                    switch (currentHighlight)
                    {
                        case Highlight.NewGame:
                            break;
                        case Highlight.LoadGame:
                            currentHighlight = Highlight.NewGame;
                            break;
                        //case Highlight.LevelEditor:
                        //    currentHighlight = Highlight.LoadGame;
                        //    break;
                        case Highlight.Controls:
                            //currentHighlight = Highlight.LevelEditor;
                            currentHighlight = Highlight.NewGame;
                            break;
                        case Highlight.Exit:
                            //currentHighlight = Highlight.Controls;
                            currentHighlight = Highlight.Controls;
                            break;
                        default:
                            break;
                    }
                }

                // Level editor is not accessible by normal means:
                // L + E on keyboard, or left and right bumper on the gamepad
                if ((NewKeyState.IsKeyDown(Keys.L) && NewKeyState.IsKeyDown(Keys.E)) || (NewPadState.IsButtonDown(Buttons.LeftShoulder) && NewPadState.IsButtonDown(Buttons.RightShoulder)))
                {
                    ScreenManager.PushScreen(new EditScreen(Game));
                }

                // Change highlighted button on "down"
                if ((NewKeyState.IsKeyDown(Keys.Down) && OldKeyState.IsKeyUp(Keys.Down))
                    || (NewPadState.IsButtonDown(Buttons.DPadDown) && OldPadState.IsButtonUp(Buttons.DPadDown)))
                {
                    sfxButtonPressed.Play();
                    switch (currentHighlight)
                    {
                        case Highlight.NewGame:
                            //currentHighlight = Highlight.LoadGame;
                            currentHighlight = Highlight.Controls;
                            break;
                        case Highlight.LoadGame:
                            //currentHighlight = Highlight.LevelEditor;
                            currentHighlight = Highlight.Controls;
                            break;
                        //case Highlight.LevelEditor:
                        //    currentHighlight = Highlight.Controls;
                        //    break;
                        case Highlight.Controls:
                            currentHighlight = Highlight.Exit;
                            break;
                        case Highlight.Exit:
                            break;
                        default:
                            break;
                    }
                }

                if ((NewKeyState.IsKeyDown(Keys.Enter) && OldKeyState.IsKeyUp(Keys.Enter))
                    || (NewPadState.IsButtonDown(Buttons.A) && OldPadState.IsButtonUp(Buttons.A)))
                {
                    sfxButtonPressed2.Play();
                    switch (currentHighlight)
                    {
                        case Highlight.NewGame:
                            PlayableCube playCube = new PlayableCube(Game);
                            playCube.Load("_level0");
                            //playCube.Load( "enemy" );
                            PlayScreen playScreen = new PlayScreen(Game, playCube);
                            ScreenManager.PushScreen(playScreen);
                            break;
                        case Highlight.LoadGame:
                            Stream saveStream = StorageManager.Instance.OpenWriteFile("CyberCube.sav");
                            // Saving functionality here.

                            Stream loadStream = StorageManager.Instance.OpenReadFile("CyberCube.sav");
                            // Loading functionality here.

                            StorageManager.Instance.Finish();

                            break;
                        //case Highlight.LevelEditor:
                        //    ScreenManager.PushScreen(new EditScreen(Game));
                        //    break;
                        case Highlight.Controls:
                            ScreenManager.PushScreen( new ControlsScreen( Game ) );
                            break;
                        case Highlight.Exit:
                            Game.Exit();
                            break;
                        default:
                            break;
                    }
                }
            }

            OldPadState = NewPadState;
            OldKeyState = NewKeyState;
        }
Пример #7
0
 public PlayableCube( CubeGame game, PlayScreen screen = null )
     : base(game, screen)
 {
     CameraDistance = 3.5f;
 }
Пример #8
0
 private void LoadNextLevelAsync()
 {
     #if XBOX
     //mLoadThread.SetProcessorAffinity( 3 );
     #endif
     if ( Cube.NextLevel == null )
         return;
     PlayableCube playCube = new PlayableCube( Game );
     playCube.Load( Cube.NextLevel );
     mNextPlayScreen = new PlayScreen( Game, playCube );
     /* your code goes here */
 }