public override void Update() { if (FlappyBirdProperties.IsBirdFly()) { base.Update(); } else { if (FlappyBirdProperties.IsGameWaiting()) { bird.WaitRunGame(); } else { if (SEKeyboardManager.CheckKeyDown(Keys.Space)) { Reload(); } bird.GetComponent().GetCircleColliderComponent().SetCenterPosition(bird.GetComponent().GetTransformComponent().GetPosition().X, bird.GetComponent().GetTransformComponent().GetPosition().Y); if (bird.GetComponent().GetTransformComponent().GetPositionY() < FlappyBirdProperties.GetGroundHeigth()) { bird.GetComponent().GetTransformComponent().Rotate(0.02f); bird.GetComponent().GetTransformComponent().MoveDown(); } } } }
public FlappyBirdMainGameScene(string _name) : base(_name) { FlappyBirdProperties.Init(); SEObject background = new SEObject("background"); background.GetComponent().GetSpriteComponent().SetSprite(SEResourcesManager.GetSpriteByName("background-day")); background.GetComponent().GetTransformComponent().SetSize(SEProperties.GetGameWindowWidth(), SEProperties.GetGameWindowHeight()); background.GetComponent().GetSpriteComponent().SetLayerDepth(1.0f); AddChild(background); bird = new Bird(); AddChild(bird); obstacleManager = new ObstacleManager(); AddChild(obstacleManager); Ground ground = new Ground(); AddChild(ground); AddChild(FlappyBirdProperties.GetScoreLabel()); AddChild(FlappyBirdProperties.GetHighScoreLabel()); AddChild(FlappyBirdProperties.GetTextLabel()); }
public override void CustomUpdate() { component.GetCircleColliderComponent().SetCenterPosition(component.GetTransformComponent().GetPosition().X, component.GetTransformComponent().GetPosition().Y); component.GetActionComponent().StartAction("changeSprite"); if (isFalling) { if (component.GetTransformComponent().GetRotateAngle() < 1.5f) { component.GetTransformComponent().Rotate(0.03f); } component.GetTransformComponent().MoveDown(); if (SEKeyboardManager.CheckKeyDown(Keys.Space)) { Jump(); } } else { TimeSpan span = DateTime.Now - timeFalling; if ((span.TotalSeconds) > 0.2f) { component.GetTransformComponent().SetSpeed(fallingSpeed); isFalling = true; } component.GetTransformComponent().MoveUp(); } if ((GetComponent().GetTransformComponent().GetPositionY() > FlappyBirdProperties.GetGroundHeigth()) || (GetComponent().GetTransformComponent().GetPositionY() < 0)) { component.GetAudioSourceComponent().Play(@"FlappyBird\sfx_die"); Collapse(); } }
public void Collapse() { FlappyBirdProperties.SetBirdFlyStatus(false); FlappyBirdProperties.GetTextLabel().GetComponent().GetFontComponent().SetText("Tap on space to reload game"); FlappyBirdProperties.GetTextLabel().SetEnable(true); component.GetTransformComponent().SetSpeed(8); #if DEBUG Console.WriteLine("Collapse"); #endif }
public void WaitRunGame() { component.GetActionComponent().StartAction("changeSprite"); if (SEKeyboardManager.CheckKeyDown(Keys.Space)) { Jump(); FlappyBirdProperties.SetBirdFlyStatus(true); FlappyBirdProperties.SetGameWaitingStatus(false); FlappyBirdProperties.GetTextLabel().SetEnable(false); } }
public bool CheckBirdCollapse(Bird bird) { for (int i = 0; i < childs.Count; ++i) { if ((childs[i].GetChilds()[0].GetComponent().GetTransformComponent().GetPositionX() < bird.GetComponent().GetTransformComponent().GetPositionX()) && (childs[i] as Obstacle).IsActive()) { bird.GetComponent().GetAudioSourceComponent().Play(@"FlappyBird\sfx_point"); FlappyBirdProperties.IncreaseScore(); FlappyBirdProperties.GetScoreLabel().GetComponent().GetFontComponent().SetText(FlappyBirdProperties.GetScore().ToString()); (childs[i] as Obstacle).SetNonActive(); } for (int j = 0; j < childs[i].GetChilds().Count; ++j) { if (bird.GetComponent().GetCircleColliderComponent().Contains(childs[i].GetChilds()[j].GetComponent().GetTransformComponent().GetRectangle())) { bird.GetComponent().GetAudioSourceComponent().Play(@"FlappyBird\sfx_hit"); bird.Collapse(); return(true); } } } return(false); }
public override void Reload() { FlappyBirdProperties.Reload(); bird.Reload(); obstacleManager.Reload(); }
private void CreateNewGroundPart() { SEObject groundPart = new SEObject("ground"); groundPart.GetComponent().GetSpriteComponent().SetSprite(SEResourcesManager.GetSpriteByName("base")); groundPart.GetComponent().GetTransformComponent().SetPosition(xPositionLastPart, FlappyBirdProperties.GetGroundHeigth()); groundPart.GetComponent().GetTransformComponent().SetSize(SEProperties.GetGameWindowWidth(), (int)(SEProperties.GetGameWindowHeight() - FlappyBirdProperties.GetGroundHeigth())); groundPart.GetComponent().GetTransformComponent().SetRectangle(new Rectangle((int)xPositionLastPart, (int)FlappyBirdProperties.GetGroundHeigth(), SEProperties.GetGameWindowWidth(), (int)(SEProperties.GetGameWindowHeight() - FlappyBirdProperties.GetGroundHeigth()))); groundPart.GetComponent().GetSpriteComponent().SetLayerDepth(0.0f); groundPart.GetComponent().GetTransformComponent().SetSpeed(4f); AddChild(groundPart); }