Ejemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            for (int i = 0; i < Global.HighScores.Length; i++)
            {
                SpriteLabel scoreLabel = SpriteCollection[String.Format("scoreLabel{0}", i)].Cast <SpriteLabel>();
                scoreLabel.Text      = String.Format("{0} :{1}", Global.HighScores[i].Minutes.ToString("D2"), Global.HighScores[i].Seconds.ToString("D2"));
                scoreLabel.Origin    = new Vector2(scoreLabel.Width / 2, scoreLabel.Height / 2);
                scoreLabel.IsVisible = Global.HighScores[i] != TimeSpan.Zero;


                HighScoreControl scoreTypeLabel = SpriteCollection[String.Format("scoreTypeLabel{0}", i)].Cast <HighScoreControl>();
                scoreTypeLabel.Control = Global.HighScoresType[i];
                if (scoreTypeLabel.Control != ControlTypes.NoControl)
                {
                    //origin needs to be calculated based on original size of the image so setting scale back to 1 just for origin recalculation
                    scoreTypeLabel.Scale  = Vector2.One;
                    scoreTypeLabel.Origin = new Vector2(scoreTypeLabel.Width / 2, scoreTypeLabel.Height / 2);
                    scoreTypeLabel.X      = RenderTarget.Width / 2;
                    scoreTypeLabel.Scale  = new Vector2(.85f);
                }

                SpriteLabel scoreDateLabel = SpriteCollection[String.Format("scoreDateLabel{0}", i)].Cast <SpriteLabel>();
                scoreDateLabel.Text      = Global.HighScoreDates[i].ToShortDateString();
                scoreDateLabel.Origin    = new Vector2(scoreDateLabel.Width / 2, scoreDateLabel.Height / 2);
                scoreDateLabel.IsVisible = Global.HighScores[i] != TimeSpan.Zero;
            }

            if (Global.MusicEnabled && MediaPlayer.State != MediaState.Playing)
            {
                MediaPlayer.Play(Global.BackgroundSong);
            }

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        public override void Load(ContentManager content)
        {
            Sprite bg = new Sprite("Background", content.Load <Texture2D>("Backgrounds/Game Screen 6"), Vector2.Zero, Color.White);

            SpriteCollection.Add(bg);

            Sprite homeButton = new Sprite("homeButton", content.Load <Texture2D>("Screen Images/Home Icon"), new Vector2(0, 1500), Color.White);

            homeButton.Origin = new Vector2(homeButton.Width / 2, homeButton.Height / 2);
            homeButton.X      = RenderTarget.Width / 2;
            SpriteCollection.Add(homeButton);


            Sprite title = new Sprite("title", content.Load <Texture2D>("Screen Images/ScoreTitle"), new Vector2(RenderTarget.Width / 2, 182), Color.White);

            title.Origin = new Vector2(title.Width / 2, 0);
            SpriteCollection.Add(title);

            SpriteLabel timeTitle = new SpriteLabel("timeTitle", content.Load <SpriteFont>("Fonts/dnk48"), "Time:", new Vector2(58, 286), Color.White);
            SpriteLabel typeTitle = new SpriteLabel("typeTitle", content.Load <SpriteFont>("Fonts/dnk48"), "Type:", new Vector2(449, 286), Color.White);
            SpriteLabel dateTitle = new SpriteLabel("dateTitle", content.Load <SpriteFont>("Fonts/dnk48"), "Date:", new Vector2(836, 286), Color.White);

            SpriteCollection.Add(timeTitle);
            SpriteCollection.Add(typeTitle);
            SpriteCollection.Add(dateTitle);

            SpriteLabel highScoreLabel = new SpriteLabel("highScoreLabel", content.Load <SpriteFont>("Fonts/dnk48"), String.Empty, new Vector2(RenderTarget.Width / 2, 350), Color.Black);

            SpriteCollection.Add(highScoreLabel);

            int y          = 441;
            int difference = 200;

            for (int i = 0; i < Global.HighScores.Length; i++)
            {
                SpriteLabel scoreLabel = new SpriteLabel(String.Format("scoreLabel{0}", i), content.Load <SpriteFont>("Fonts/dnk48"), String.Empty, new Vector2(timeTitle.X + timeTitle.Width / 2.4f, y), Color.White);
                SpriteCollection.Add(scoreLabel);

                HighScoreControl scoreTypeLabel = new HighScoreControl(String.Format("scoreTypeLabel{0}", i), ControlTypes.NoControl, scoreLabel.Position);
                scoreTypeLabel.X = typeTitle.X + typeTitle.Width / 2.4f;
                SpriteCollection.Add(scoreTypeLabel);

                SpriteLabel scoreDateLabel = new SpriteLabel(String.Format("scoreDateLabel{0}", i), content.Load <SpriteFont>("Fonts/dnk48"), String.Empty, scoreLabel.Position, Color.White);
                scoreDateLabel.X = dateTitle.X + dateTitle.Width / 2.4f;
                SpriteCollection.Add(scoreDateLabel);


                y += difference;
            }

#if WINDOWS
            homeButton.MouseClick += homeButton_MouseClick;
#else
            TouchManager touchManger = TouchManager.Instance;
            touchManger.GestureOccured += touchManger_GestureOccured;
#endif

            clickSound = content.Load <SoundEffect>("Sounds/Effects/RD click Sound");
        }
Ejemplo n.º 3
0
        public void UpdateHighScores(string title)
        {
            var scores = _engine.GetScores(0, 10);

            _highScoreLists.Clear();
            foreach (var table in scores)
            {
                var newList = new HighScoreControl(table.Name, table.Scores);
                _highScoreLists.Add(newList);
            }

            HighScoreControl.DataContext = _highScoreLists.Where(x => x.Title == title).First();
        }
Ejemplo n.º 4
0
        public override void Load(Microsoft.Xna.Framework.Content.ContentManager content)
        {
            _content = content;
            loadingDropingObjects(content);
            loadingBackgrounds(content);
            loadingSongs(content);



            FallingItem.FallingSpeed = startingSpeed;
            startingDifficultyTime   = new TimeSpan(0, 0, 3);
            elapsedArrowTime         = TimeSpan.Zero;
            difficultyTime           = startingDifficultyTime;

            arrowFadeTime = new TimeSpan(0, 0, 0, 5);

            //SpriteLabel tutorialText = new SpriteLabel("tutorialText", content.Load<SpriteFont>("Fonts/FS14"), "Press the arrows to move!", Vector2.Zero, Color.Black);
            //tutorialText.Scale = new Vector2(3);
            //tutorialText.Position = new Vector2(RenderTarget.Width / 2 - tutorialText.Width / 2, RenderTarget.Height - tutorialText.Height * 2);
            //tutorialText.IsVisible = Global.Tutorial;

            _columns = new Column[fallingLocation.Length];
            for (int i = 0; i < _columns.Length; i++)
            {
                _columns[i] = new Column(fallingLocation[i].X.ToInt(true), RenderTarget.Height);
            }

            _columns[0].NextColumns.Add(_columns[1]);

            //_columns[1].NextColumns.Add(_columns[0]);
            _columns[1].NextColumns.Add(_columns[2]);

            //_columns[2].NextColumns.Add(_columns[1]);
            _columns[2].NextColumns.Add(_columns[3]);

            _columns[3].NextColumns.Add(_columns[2]);


            backGround = new Sprite("backGround", Global.Backgrounds[Global.CurrentBackgroundIndex], Vector2.Zero, Color.White);


            leftHelpButton          = new Sprite("leftButton", content.Load <Texture2D>("Screen Images/Left Arrow"), Vector2.Zero, Color.White);
            leftHelpButton.Scale    = new Vector2(.8f);
            leftHelpButton.Position = new Vector2(0, RenderTarget.Height - leftHelpButton.Height * 3f);
            leftHelpButton.Color    = Color.Lerp(Color.White, Color.Transparent, .3f);

            //leftHelpButton.Effect = SpriteEffects.FlipHorizontally;

            rightHelpButton          = new Sprite("rightButton", content.Load <Texture2D>("Screen Images/Right Arrow"), Vector2.Zero, Color.White);
            rightHelpButton.Scale    = leftHelpButton.Scale;
            rightHelpButton.Position = new Vector2(RenderTarget.Width - rightHelpButton.Width, leftHelpButton.Y);
            rightHelpButton.Color    = Color.Lerp(Color.White, Color.Transparent, .3f);



            _fpsLabel           = new SpriteLabel("SpeedLabel", content.Load <SpriteFont>("Fonts/dnk24"), String.Empty, Vector2.Zero, Color.Black);
            _fpsLabel.Text      = String.Format("Speed: {0}", FallingItem.FallingSpeed);
            _fpsLabel.Scale     = new Vector2(3);
            _fpsLabel.Y         = RenderTarget.Height - _fpsLabel.Height;
            _fpsLabel.IsVisible = false;

            //death
            Texture2D   firstDeathFrame = content.Load <Texture2D>("Characters/Effects/Death/explosion1");
            SpriteSheet deathSprite     = new SpriteSheet("RedPanda", Vector2.Zero, Color.White, firstDeathFrame);

            for (int i = 2; i < 6; i++)
            {
                Sprite deathFrame = new Sprite("RedPanda", content.Load <Texture2D>(String.Format("Characters/Effects/Death/explosion{0}", i)), Vector2.Zero, Color.White);
                deathSprite.Add(deathFrame);
            }

            foreach (Sprite frame in deathSprite)
            {
                frame.Origin = new Vector2(frame.Width / 2, frame.Height / 3 * 2);
                frame.Scale  = new Vector2(0.8f);
            }
            deathSprite.AnimateTime      = TimeSpan.FromMilliseconds(100);
            deathSprite.AnimationFinish += deathSprite_AnimationFinish;

            playerIndex = 1;

            //ria load
            Sprite idleRiaFrame = new Sprite("RedPanda", content.Load <Texture2D>("Characters/RedPanda/Ria/0"), Vector2.Zero, Color.White);

            idleRiaFrame.Origin = new Vector2(380, idleRiaFrame.Height);


            Texture2D   test            = content.Load <Texture2D>("Characters/RedPanda/Ria/1");
            SpriteSheet movingRiaFrames = new SpriteSheet("RedPanda", Vector2.Zero, Color.White, test);

            for (int i = 2; i < 7; i++)
            {
                Sprite frame = new Sprite("RedPanda", content.Load <Texture2D>(String.Format("Characters/RedPanda/Ria/{0}", i)), Vector2.Zero, Color.White);
                movingRiaFrames.Add(frame);
            }
            movingRiaFrames.Origin = new Vector2(380, test.Height);


            movingRiaFrames.AnimateTime = TimeSpan.FromMilliseconds(25 / (_level + 1));//speed animation up according to level. Kevin

            movingRiaFrames.AnimationFinish += movingRiaFrames_AnimationFinish;

            player = new Character(new ISprite[] { idleRiaFrame, movingRiaFrames, deathSprite });

            player.Position = new Vector2(fallingLocation[playerIndex].X - 1, RenderTarget.Height - 50);

            direction = Direction.None;
            //SpriteCollection.Add(tutorialText);
            SpriteCollection.Add(backGround);
            SpriteCollection.Add(_fpsLabel);

            SpriteCollection.Add(leftHelpButton);
            SpriteCollection.Add(rightHelpButton);

            string leftSwipeFile  = String.Empty;
            string rightSwipeFile = String.Empty;

            XnaAudio.MediaPlayer.Volume = 1;

            SpriteCollection.NameCheck = false;
            SpriteCollection.Add(player);

            foreach (Column column in _columns)
            {
                foreach (FallingItem item in column.Pool)
                {
                    SpriteCollection.Add(item);
                }
            }
            if (Global.Control == ControlTypes.Swipe)
            {
                leftHelpButton.IsVisible  = false;
                rightHelpButton.IsVisible = false;
            }
            else
            {
                leftHelpButton.IsVisible  = true;
                rightHelpButton.IsVisible = true;
            }
            _lastSpwaned   = _columns[0];
            Column.OffSet  = player.BoundingBox.Height + player.BoundingBox.Height / 4;
            leftSwipeFile  = "Sounds/Effects/Air 1 swipe to left";
            rightSwipeFile = "Sounds/Effects/Air 2 swipe to right";
#if !WINDOWS
            TouchManager touch = TouchManager.Instance;
            touch.GestureOccured += touch_GestureOccured;
#endif

            SpriteLabel helperLabel = new SpriteLabel("helperLabel", content.Load <SpriteFont>("Fonts/dnk48"), String.Empty, new Vector2(RenderTarget.Width / 2, RenderTarget.Height / 2), Color.White);

            helperLabel.Y     += 425;
            helperLabel.Origin = new Vector2(helperLabel.Width / 2, helperLabel.Height / 2);
            //helperLabel.Scale = new Vector2(1);
            SpriteCollection.Add(helperLabel);


            timeLabel          = new SpriteLabel("timeLabel", content.Load <SpriteFont>("Fonts/dnk72"), String.Empty, Vector2.Zero, Color.Black);
            timeLabel.Position = new Vector2(RenderTarget.Width / 2, 30);
            //timeLabel.Scale = new Vector2(2);
            SpriteCollection.Add(timeLabel);

            controlLabel       = new HighScoreControl("controlLabel", ControlTypes.Tap, new Vector2(0, 30));
            controlLabel.Scale = new Vector2(0.5f);
            controlLabel.X     = RenderTarget.Width - controlLabel.Width - 30;

            controlLabel.IsVisible = false;
            SpriteCollection.Add(controlLabel);

            deathSound     = content.Load <SoundEffect>("Sounds/Effects/DeathSound"); //content.Load<XnaAudio.Song>("Sounds/DeathSound");
            leftSwipe      = content.Load <SoundEffect>(leftSwipeFile);               //content.Load<XnaAudio.Song>(leftSwipeFile);
            rightSwipe     = content.Load <SoundEffect>(rightSwipeFile);              // content.Load<XnaAudio.Song>(rightSwipeFile);
            highScoreSound = content.Load <SoundEffect>("Sounds/Effects/RD High Score");
            _level         = 0;



            SpriteCollection.IsReadOnly = true;
        }