Exemplo n.º 1
0
        public HudPointsPopUp() : base("+100", 0, 0, 50, 50, 18, CenterMode.Center, CenterMode.Center)
        {
            EasyDraw.TextFont("data/Chantal W00 Medium.ttf", 18);

            _shadowText = new HudTextBoard("+100", -1, -1, 50, 50, 18, CenterMode.Center, CenterMode.Center);
            _shadowText.EasyDraw.TextFont("data/Chantal W00 Medium.ttf", 18);
            _shadowText.SetClearColor(Color.FromArgb(0, 1, 1, 1));
            ((IHasColor)_shadowText).MainColor = GlobalVars.Skim;

            AddChild(_shadowText);

            _clearColor = Color.FromArgb(0, 1, 1, 1);
            ((IHasColor)this).MainColor = Color.DimGray;

            visible = false;
        }
Exemplo n.º 2
0
        private IEnumerator MoveTextBoarToPosition(int lapPosition, HudTextBoard textBoard)
        {
            float xPos   = game.width - textBoard.Width;
            float yPos   = 50;
            float toYPos = yPos + (lapPosition - 1) * 32;
            float fromY  = textBoard.y;

            textBoard.x = xPos;
            float time     = 0;
            float duration = 800;

            do
            {
                textBoard.y = Easing.Ease(Easing.Equation.CubicEaseOut, time, fromY, toYPos, duration);

                yield return(null);

                time += Time.deltaTime;
            } while (time < duration);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public HUD(Camera camera, GameObject player)
        {
            Instance = this;

            _mapData = TiledMapParserExtended.MapParser.ReadMap("HUD.tmx");

            var objectsDepth0 = _mapData.ObjectGroups.FirstOrDefault(og => og.Name == "Depth 0");

            //Hud Score set
            var hudData       = objectsDepth0.Objects.FirstOrDefault(o => o.Name == "Score Bg");
            var hudScoreImage = _mapData.TileSets.FirstOrDefault(ts => ts.FirstGId == hudData.GID).Image.FileName;

            _hudScore = new HudScore(hudScoreImage);
            AddChild(_hudScore);

            _hudScore.SetScaleXY(hudData.Width / _hudScore.width, hudData.Height / _hudScore.height);
            _hudScore.SetXY(hudData.X, hudData.Y - hudData.Height);

            //Pizza life set
            var pizzasHudData = objectsDepth0.Objects.Where(o => o.Name.Trim().StartsWith("Hud Pizza"))
                                .OrderBy(o => o.Name)
                                .ToArray();

            var pizzaHudBitmapMap = new Dictionary <string, Bitmap>();

            var pizzaLostImageFileName = _mapData.TileSets.FirstOrDefault(ts => ts.Name == "Pizza Lost").Image.FileName;

            pizzaHudBitmapMap.Add(pizzaLostImageFileName, new Bitmap(pizzaLostImageFileName));

            _pizzaLives     = new Sprite[pizzasHudData.Length];
            _pizzaLostLives = new Sprite[pizzasHudData.Length];

            for (int i = 0; i < pizzasHudData.Length; i++)
            {
                var pizzaHudData = pizzasHudData[i];

                var imageFile = _mapData.TileSets.FirstOrDefault(ts => ts.FirstGId == pizzaHudData.GID).Image.FileName;

                Bitmap bitMap;

                if (!pizzaHudBitmapMap.ContainsKey(imageFile))
                {
                    bitMap = new Bitmap(imageFile);
                    pizzaHudBitmapMap.Add(imageFile, bitMap);
                }
                else
                {
                    bitMap = pizzaHudBitmapMap[imageFile];
                }

                var pizzaHud = new Sprite(bitMap, false);
                AddChild(pizzaHud);

                int pizzaHudOriginalW = pizzaHud.width;
                int pizzaHudOriginalH = pizzaHud.height;

                pizzaHud.SetScaleXY(pizzaHudData.Width / pizzaHudOriginalW, pizzaHudData.Height / pizzaHudOriginalH);
                pizzaHud.SetXY(pizzaHudData.X, pizzaHudData.Y - pizzaHudData.Height);

                _pizzaLives[i] = pizzaHud;

                var pizzaLostHud = new Sprite(pizzaHudBitmapMap[pizzaLostImageFileName], false);
                AddChild(pizzaLostHud);

                pizzaLostHud.SetScaleXY(pizzaHudData.Width / pizzaHudOriginalW,
                                        pizzaHudData.Height / pizzaHudOriginalH);
                pizzaLostHud.SetXY(pizzaHudData.X, pizzaHudData.Y - pizzaHudData.Height);

                pizzaLostHud.SetActive(false);

                _pizzaLostLives[i] = pizzaLostHud;
            }

            _hudPointsPopUp = new HudPointsPopUp();
            AddChild(_hudPointsPopUp);
            _hudPointsPopUp.Target = player;

            _camera = camera;
            _camera.AddChild(this);

            this.x = -MyGame.HALF_SCREEN_WIDTH;
            this.y = -MyGame.HALF_SCREEN_HEIGHT;

            var centerText = $@"<= and => arrows to flap wings
Turn is weird flapping one wing while the other is static";

            _centerTextBoard = new HudTextBoard(centerText, 312, 32, 20, CenterMode.Center, CenterMode.Center);
            _centerTextBoard.SetText(centerText);
            _centerTextBoard.visible = false;
            _centerTextBoard.Centralize();
            _centerTextBoard.y = Game.main.height - _centerTextBoard.Height;

            AddChild(_centerTextBoard);

            _slider00 = new HudSlider(200, 22);
            AddChild(_slider00);

            _slider00.x = 50;
            _slider00.y = 50;

            _slider00.OnValueChanged += ChangeDroneWaitingSpeed;

            _slider01 = new HudSlider(200, 22);
            AddChild(_slider01);

            _slider01.x = 50;
            _slider01.y = 50 + 34;

            //_slider01.OnValueChanged += ChangeDroneDetectRange;

            //_slider01.OnValueChanged += DebugChangeThermometerValue;

            _slider01.OnValueChanged += ChangeDroneFrameSpeed;

            _hudThermometer = new HudThermometer();
            AddChild(_hudThermometer);

            _hudThermometer.SetXY(game.width - (1920 - 1731), 85);
            _hudThermometer.SetOriginToCenter();

            _hudArrowToObjective = new HudArrowToObjective();
            AddChild(_hudArrowToObjective);

            _hudArrowToObjective.SetScaleXY(0.4f, 0.4f);
            _hudArrowToObjective.SetXY(game.width * 0.5f, game.height * 0.5f);
            _hudArrowToObjective.SetActive(false);

            _debugTimer   = new HudTextBoard(60, 60, 12);
            _debugTimer.x = game.width - 60;
            _debugTimer.y = 60;
            AddChild(_debugTimer);
        }