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; }
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 ); } ); }
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--; } }
/// <summary> /// Creates a new PlayScreen. /// </summary> /// <param name="game">Game the PlayScreen should be associated with.</param> /// <param name="playCube">PlayableCube the screen should display.</param> public PlayScreen( CubeGame game, PlayableCube playCube ) : base(game, playCube) { MediaPlayer.Volume = mVolume; //MediaPlayer.Play(mSong); MediaPlayer.IsRepeating = true; /*Random rand = new Random(); for ( int i = 0 ; i < 10 ; ++i ) { PlayableCube cube = new PlayableCube( Game, this ); cube.Position = new Vector3( (float) (rand.NextDouble() - 0.5) * 10, (float) (rand.NextDouble() - 0.5) * 10, (float) (rand.NextDouble() - 0.5) * 10 ); cube.Enabled = false; Components.Add( cube ); }*/ }
/// <summary> /// Generates a PlayableCube object from the current EditableCube's state. /// </summary> /// <returns>A playable copy of the cube.</returns> internal PlayableCube GeneratePlayableCube() { PlayableCube cube = new PlayableCube( Game ); var editFaces = Faces.GetEnumerator(); var playFaces = cube.Faces.GetEnumerator(); while ( editFaces.MoveNext() && playFaces.MoveNext() ) playFaces.Current.CopySolids( editFaces.Current ); cube.StartPosition = this.StartPosition; cube.NextLevel = this.NextLevel; cube.EnemyPositions = this.EnemyPositions; return cube; }
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; }
public Face( PlayableCube cube, CubeFaceType type, Vector3 normal, Vector3 up, Direction orientation ) : base(cube, type, normal, up, orientation) { }
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 */ }