Beispiel #1
0
        public LevelEndScreen() : base("data/Next level screen.png")
        {
            _nextLevelSprite = new Sprite("data/Next Level Text.png", true, false);
            AddChild(_nextLevelSprite);
            _nextLevelSprite.SetXY(1225, 743);
            _nextLevelSprite.SetOrigin(_nextLevelSprite.width * 0.5f, _nextLevelSprite.height * 0.5f);

            //Wait some time to enable input
            CoroutineManager.StartCoroutine(WaitSomeTime(), this);

            //Animate Text
            SpriteTweener.TweenScalePingPong(_nextLevelSprite, 1, 1.05f, 300);
        }
Beispiel #2
0
        public StartScreen() : base("data/Startscreen Bg.png")
        {
            //1260 207

            _startText = new Sprite("data/Start Screen - pressstart.png", true, false);
            AddChild(_startText);
            _startText.SetOrigin(_startText.width * 0.5f, _startText.height * 0.5f);
            _startText.SetXY(1260, 207);


            float mScale = _startText.scale;

            SpriteTweener.TweenScalePingPong(_startText, mScale, mScale * 1.02f, 300);

            SoundManager.Instance.PlayMusic(0);
        }
        private IEnumerator EndLevelByLost()
        {
            Console.WriteLine($"{this}: EndLevelByLost");

            _level.IsLevelEndingByLost = true;

            //Send all drones away
            _level.DronesesManager.EndLevelAllDrones();

            //Stop all hunters
            _level.HuntersManager.EndLevelAllHunters();

            //Cry 3 times
            CoroutineManager.StartCoroutine(Cry3Times(), this);

            if (_isLevelEndingTimesUp)
            {
                //PingPong scale Thermometer
                float mScale = HUD.Instance.Thermometer.scale;
                SpriteTweener.TweenScalePingPong(HUD.Instance.Thermometer, mScale, mScale * 1.10f, 300);
            }

            yield return(new WaitForMilliSeconds(3 * 1200));

            var gameOverScreen = new GameOverScreen();

            HudScreenFader.instance.FadeInOut(MyGame.ThisInstance.Camera, 1400,
                                              () =>
            {
                MyGame.ThisInstance.UnLoadCurrentLevel();

                SoundManager.Instance.DisableAllSounds();

                _level.RemoveChild(MyGame.ThisInstance.Camera);
                HudScreenFader.instance.parent = MyGame.ThisInstance;
                HudScreenFader.instance.SetXY(0, 0);
                MyGame.ThisInstance.AddChildAt(gameOverScreen, HudScreenFader.instance.Index - 1);
            },
                                              null, CenterMode.Center);
        }
        public GameOverScreen() : base("data/GameOver Screen.png")
        {
            _buttonPressed = true;

            _scoreTitle = new HudTextBoard("Score Board", 0, 0, 500, 500, FONT_SIZE, CenterMode.Center,
                                           CenterMode.Center);
            AddChild(_scoreTitle);
            _scoreTitle.SetClearColor(Color.FromArgb(0, 1, 1, 1));
            ((IHasColor)_scoreTitle).MainColor = GlobalVars.DarkBlue;

            _scoreTitle.EasyDraw.TextFont(FONT_PATH, FONT_SIZE);
            _scoreTitle.SetText("Score Board");
            _scoreTitle.x = SCOREBOARD_X + 60;
            _scoreTitle.y = 100;

            _scoreTitle.EasyDraw.TextFont(FONT_PATH, FONT_SIZE);

            var playerScoreData = new PlayerScoreData()
            {
                name  = "you",
                score = MyGame.ThisInstance.TotalScore
            };

            var scorePointsList = new List <PlayerScoreData>(MyGame.ThisInstance.ScoreBoardList)
            {
                playerScoreData
            };

            scorePointsList = scorePointsList.OrderByDescending(ps => ps.score).ToList();

            int pad = 0;

            if (scorePointsList.Count > 0)
            {
                pad = scorePointsList[0].score.ToString().Length;
            }

            var first10Scores = scorePointsList.Take(10).ToList();

            _scoreBoardTexts = new List <HudTextBoard>();
            for (int i = 0; i < first10Scores.Count; i++)
            {
                var scoreData = scorePointsList[i];

                var format = "{0,2}\t{1}\t{2," + pad + "}";

                var text = string.Format(format, i + 1, scoreData.name.ToUpper().Substring(0, 3),
                                         scoreData.score); //$"{scoreData.name.ToUpper().Substring(0, 3)} {$"{scoreData.score:10}"}";

                var hudScoreText = new HudTextBoard(text, 0, 0, 1000, 200, FONT_SIZE, CenterMode.Min, CenterMode.Min);
                AddChild(hudScoreText);
                hudScoreText.SetClearColor(Color.FromArgb(0, 1, 1, 1));

                ((IHasColor)hudScoreText).MainColor =
                    (scoreData.name == "you") ? GlobalVars.DimGreen : GlobalVars.DarkBlue;

                hudScoreText.EasyDraw.TextFont(FONT_PATH, FONT_SIZE);

                hudScoreText.SetText(text);

                if (scoreData.name == "you")
                {
                    hudScoreText.EasyDraw.SetOrigin(hudScoreText.EasyDraw.width * 0.5f,
                                                    hudScoreText.EasyDraw.height * 0.5f);

                    hudScoreText.x = SCOREBOARD_X + hudScoreText.EasyDraw.width * 0.5f;
                    hudScoreText.y = 210 + i * 40 + hudScoreText.EasyDraw.height * 0.5f;

                    //Anim score
                    float mScale = hudScoreText.EasyDraw.scale;
                    SpriteTweener.TweenScalePingPong(hudScoreText.EasyDraw, mScale, mScale * 1.02f, 200);
                }
                else
                {
                    hudScoreText.x = SCOREBOARD_X;
                    hudScoreText.y = 200 + i * 40;
                }
            }

            //Get player position, if greater than 10, put it at the end
            var playerPos = scorePointsList.Select(ps => ps.name).ToList().IndexOf("you");

            if (playerPos > 9)
            {
                var format = "{0,2}\t{1}\t{2," + pad + "}";

                var text = string.Format(format, playerPos + 1, playerScoreData.name.ToUpper().Substring(0, 3),
                                         playerScoreData.score);

                var hudScoreText = new HudTextBoard(text, 0, 0, 1000, 200, FONT_SIZE, CenterMode.Min, CenterMode.Min);
                AddChild(hudScoreText);
                hudScoreText.SetClearColor(Color.FromArgb(0, 1, 1, 1));

                ((IHasColor)hudScoreText).MainColor = GlobalVars.DimGreen;

                hudScoreText.EasyDraw.TextFont(FONT_PATH, FONT_SIZE);

                hudScoreText.SetText(text);

                hudScoreText.EasyDraw.SetOrigin(hudScoreText.EasyDraw.width * 0.5f,
                                                hudScoreText.EasyDraw.height * 0.5f);

                hudScoreText.x = SCOREBOARD_X + hudScoreText.EasyDraw.width * 0.5f;
                hudScoreText.y = 200 + 30 + first10Scores.Count * 40 + hudScoreText.EasyDraw.height * 0.5f;

                //Anim score
                float mScale = hudScoreText.EasyDraw.scale;
                SpriteTweener.TweenScalePingPong(hudScoreText.EasyDraw, mScale, mScale * 1.02f, 200);
            }

            MyGame.ThisInstance.SaveScoreBoard();

            CoroutineManager.StartCoroutine(WaitSomeTimeToEnableInput(), this);
        }