void UpdateY() { position.Y += currentSpeed; if (position.Y + Size.Y > GameData.LEFT_TOP_Y + GameData.BORDER_WIDTH) { if (index > 0) { SAMusicManager.PlaySoundEffect("Sound/Collide"); } Clean(); Fly(); } else { if (position.Y < GameData.LEFT_TOP_Y) { position.Y = GameData.LEFT_TOP_Y; } currentSpeed += GRAVITY; if (currentSpeed > MAX_DOWN_SPEED) { currentSpeed = MAX_DOWN_SPEED; } } }
public void Update(Bird bird) { if (IfCollide(bird.rectangle)) { if (bird.index > 0) { SAMusicManager.PlaySoundEffect("Sound/Collide"); } bird.Clean(); } MoveLeft(GameData.MOVESPEED); if (CanRelease()) { SAMusicManager.PlaySoundEffect("Sound/Coin"); bird.Add(); Reset(); } }
public void Fly() { this.currentSpeed = -JUMP_SPEED; SAMusicManager.PlaySoundEffect("Sound/Jump"); }
protected override void Update(GameTime gameTime) { // 允许游戏退出 if (ifWin == false) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } } else { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { SAMusicManager.PlaySoundEffect("Sound/Coin"); ifWin = false; bird.Clean(); } } while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); if (gesture.GestureType == GestureType.Tap) { Rectangle temp = new Rectangle((int)(gesture.Position.X), (int)(gesture.Position.Y), 1, 1); if (ifWin == false) { if (soundOn.IfCollide(temp)) { SAMusicManager.IfPlaySound = !SAMusicManager.IfPlaySound; } else { bird.Fly(); } } else { if (buttons[0].Intersects(temp)) { SAMusicManager.PlaySoundEffect("Sound/Coin"); ifWin = false; bird.Clean(); } else if (buttons[1].Intersects(temp)) { SAMusicManager.PlaySoundEffect("Sound/Coin"); GameData.RateGame(); ifWin = false; bird.Clean(); } } } } if (ifWin == false) { bird.Update(); // TODO: 在此处添加更新逻辑 foreach (Block b in blocks) { b.Update(bird); } if (bird.IfWin) { ifWin = true; SAMusicManager.PlaySoundEffect("Sound/win"); } } base.Update(gameTime); }