Beispiel #1
0
        public override void Update(GameTime gameTime)
        {
            var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;


            if (ready)
            {
                newFlowerTimer += elapsed;
                textInitTimer  += elapsed;

                if (!shiftMode)
                {
                    if (newFlowerTimer >= newFlowerTimerDuration)
                    {
                        newFlowerTimer = 0;
                        if (flowerPool.Any(r => !r.Active))
                        {
                            var pos = Vector2.Zero;

                            do
                            {
                                pos = new Vector2(MasterRandom.FRandom.Next(32, 1248), MasterRandom.FRandom.Next(32, 688));
                            }while (flowerPool.Any(t => t.Position.X >= (pos.X - 64) && t.Position.X < (pos.X + 64) &&
                                                   t.Position.Y >= (pos.Y - 64) && t.Position.Y < (pos.Y + 64)));

                            flowerPool.First(t => !t.Active).ActivateFlower(pos);
                        }
                    }

                    if (textInitTimer >= textInitTimerDuration)
                    {
                        timer += elapsed;
                        if (timer >= timerDuration && !titleMoveDone)
                        {
                            timer = 0;

                            if (!bounceUp)
                            {
                                titleTextPosition = new Vector2(titleTextPosition.X, titleTextPosition.Y + 7);

                                if (titleTextPosition.Y >= 248)
                                {
                                    bounceUp = true;
                                }
                            }
                            else
                            {
                                titleTextPosition = new Vector2(titleTextPosition.X, titleTextPosition.Y - 3);

                                if (titleTextPosition.Y <= 200)
                                {
                                    titleMoveDone = true;
                                }
                            }
                        }
                    }


                    foreach (var flower in flowerPool)
                    {
                        if (flower.Active)
                        {
                            flower.Update(gameTime);
                        }
                    }

                    foreach (var bee in bees)
                    {
                        bee.Update(gameTime);
                    }

                    if (InputHandler.FingerRaised() && titleMoveDone)
                    {
                        shiftMode = true;

                        for (var i = 0; i < flowerPool.Count; i++)
                        {
                            flowerPool[i].AllStop = true;
                        }

                        for (var i = 0; i < bees.Count; i++)
                        {
                            bees[i].AllStop = true;
                        }


                        ScreenManager.GameReference.ScreenControl(ScreenName, "NewUser");
                    }

                    if (InputHandler.FingerRaised() && titleMoveDone)
                    {
                        shiftMode = true;

                        for (var i = 0; i < flowerPool.Count; i++)
                        {
                            flowerPool[i].AllStop = true;
                        }

                        for (var i = 0; i < bees.Count; i++)
                        {
                            bees[i].AllStop = true;
                        }

                        if (isNewUser)
                        {
                            ScreenManager.GameReference.ScreenControl(ScreenName, "NewUser");
                        }
                    }
                }
                else
                {
                    if (timer >= timerDuration)
                    {
                        timerDuration = 0;

                        foreach (var flower in flowerPool)
                        {
                            if (flower.Active)
                            {
                                flower.Update(gameTime);
                            }
                        }

                        foreach (var bee in bees)
                        {
                            bee.Update(gameTime);
                        }

                        helperNode = new Vector2(helperNode.X, helperNode.Y + 55 * 5 * elapsed);

                        titleTextPosition = new Vector2(titleTextPosition.X, titleTextPosition.Y + 65 * 5 * elapsed);
                    }

                    if (helperNode.Y >= 256 && !startingNextScreen)
                    {
                        ScreenManager.GameReference.ScreenControl(ScreenName, "Begin");
                        Tiling             = null;
                        startingNextScreen = true;
                    }

                    if (helperNode.Y >= 768)
                    {
                        ScreenManager.GameReference.ScreenControl(ScreenName, "Next");
                    }
                }
            }
            else
            {
                initTimer += elapsed;

                if (initTimer > 5)
                {
                    ready = true;
                }
            }
            ControlManager.Update(gameTime);
        }