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 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); }