コード例 #1
0
 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();
             }
         }
     }
 }
コード例 #2
0
        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());
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
        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
        }
コード例 #5
0
 public void WaitRunGame()
 {
     component.GetActionComponent().StartAction("changeSprite");
     if (SEKeyboardManager.CheckKeyDown(Keys.Space))
     {
         Jump();
         FlappyBirdProperties.SetBirdFlyStatus(true);
         FlappyBirdProperties.SetGameWaitingStatus(false);
         FlappyBirdProperties.GetTextLabel().SetEnable(false);
     }
 }
コード例 #6
0
        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);
        }
コード例 #7
0
 public override void Reload()
 {
     FlappyBirdProperties.Reload();
     bird.Reload();
     obstacleManager.Reload();
 }
コード例 #8
0
        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);
        }