コード例 #1
0
        public HUD()
        {
            //Font
            PFC = new PrivateFontCollection();
            PFC.AddFontFile(@"kenyan_coffee_rg.ttf");
            _ownFontClock = new Font(PFC.Families[0], 32);
            _ownFontText  = new Font(PFC.Families[0], 32);

            //Proximity information
            _rectProximityInfo       = new EasyDraw(1920, 1080, addCollider: false);
            _rectProximityInfo.alpha = 0.9f;
            _rectProximityInfo.color = 0x262626;
            AddChild(_rectProximityInfo);

            _proximityInfo       = new EasyDraw(1920, 1080, addCollider: false);
            _proximityInfo.color = 0x56b25d;
            _proximityInfo.TextFont(_ownFontText);

            _textOnceAdded = false;

            //Clock Background
            _clockBackground = new Sprite("timeBackground.png");
            _clockBackground.SetXY(5, 15);
            AddChild(_clockBackground);

            //Clock
            _clock       = new EasyDraw(1920, 1080, addCollider: false);
            _clock.color = 0x56b25d;
            _clock.TextFont(_ownFontClock);
            AddChild(_clock);

            //Shopping list
            _shoppingList       = new Sprite("List.png");
            _shoppingList.scale = 0.65f;
            _shoppingList.SetXY(_shoppingList.width / 2.5f, 300);
            _shoppingList.SetOrigin(_shoppingList.width / 2, _shoppingList.height / 2);
            AddChild(_shoppingList);

            //Settings button
            _settingsButton = new Sprite("settingsButton.png");
            _settingsButton.SetXY(225, 13);
            AddChild(_settingsButton);

            //Chatbox
            _chatBox = new Sprite("chatBox.png");
            _chatBox.SetOrigin(_chatBox.width / 2, _chatBox.height / 2);
            _chatBox.SetXY(game.width / 2, game.height - 50);
            AddChild(_chatBox);

            //Sound
            _backgroundMusic     = new Sound("backgroundSounds.mp3", true, true);
            _backgroundSC        = _backgroundMusic.Play();
            _backgroundSC.Volume = 0.35f;

            //Tutorial
            tutorial = new Sprite("Tutorial.png");
            tutorial.SetOrigin(tutorial.width / 2, tutorial.height / 2);
            tutorial.SetXY(game.width / 2, game.height / 2);
            AddChild(tutorial);
        }
コード例 #2
0
        public HudTextBoard(string pText, float px, float py, int width, int height, int textSize,
                            CenterMode hor = CenterMode.Min,
                            CenterMode ver = CenterMode.Min)
        {
            this.x     = px;
            this.y     = py;
            this._text = pText;

            _easyDraw = new EasyDraw(width, height, false);
            _easyDraw.TextFont("data/Gaiatype.ttf", 12);

            if (!string.IsNullOrEmpty(pText))
            {
                _easyDraw.TextSize(textSize);
                _easyDraw.TextDimensions(_text, out var w, out var h);
                var wr = Mathf.Round(w);
                var hr = Mathf.Round(h);

                if (wr <= 0)
                {
                    wr = 10;
                }

                if (hr <= 0)
                {
                    hr = 10;
                }

                _easyDraw = new EasyDraw(wr, hr, false);
            }
            _easyDraw.TextFont("data/Gaiatype.ttf", 12);
            _easyDraw.TextSize(textSize);
            _easyDraw.TextAlign(hor, ver);

            AddChild(_easyDraw);

            if (hor == CenterMode.Center)
            {
                _textX = _easyDraw.width * 0.5f;
            }
            else if (hor == CenterMode.Max)
            {
                _textX = _easyDraw.width;
            }

            if (ver == CenterMode.Center)
            {
                _textY = _easyDraw.height * 0.5f;
            }
            else if (ver == CenterMode.Max)
            {
                _textY = _easyDraw.height;
            }


            SetText(_text);
        }
コード例 #3
0
ファイル: HudScore.cs プロジェクト: vlab22/Team23_GXPEngine
        public HudScore(string filename) : base(filename, false, false)
        {
            //Hud score text
            //"VAGRundschriftD"
            _scoreLabelEasyDraw = new EasyDraw(350, 40, false);
            AddChild(_scoreLabelEasyDraw);

            //78 115
            _scoreLabelEasyDraw.SetXY(60, 70);
            _scoreLabelEasyDraw.Clear(Color.FromArgb(1, 1, 1, 1));
            _scoreLabelEasyDraw.TextFont($"data/VAGRundschriftD.ttf", 32);
            _scoreLabelEasyDraw.Fill(Color.White);
            _scoreLabelEasyDraw.TextAlign(CenterMode.Min, CenterMode.Min);
            _scoreLabelEasyDraw.Text($"{_score:00000000000000}", 0, 0); //"00000000000000" 14 digits
        }
コード例 #4
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;
        }
コード例 #5
0
        public HunterGameObject(float pX, float pY, float pWidth, float pHeight,
                                float pSightSpeed = 200) : base("data/Hunter.png", 1, 1,
                                                                -1, false, false)
        {
            _scanEnemyRange = pWidth;
            _sightSpeed     = pSightSpeed;

            _hunterBehaviorListeners = new IHunterBehaviorListener[0];

            SetOrigin(0, height);

            x = pX + pWidth * 0.5f;
            y = pY - pHeight * 0.5f;

            SetOrigin(width * 0.5f, height * 0.5f);

            _crossHair = new HunterCrossHairGameObject(this);
            AddChild(_crossHair);
            _crossHair.SetXY(0, 0);
            _crossHair.alpha = 0;

            _hunterFollowRangeCone = new HunterFollowRangeCone(this);
            _hunterFollowRangeCone.SetColor(0.9f, 0.9f, 0);
            _hunterFollowRangeCone.alpha = 0;
            AddChild(_hunterFollowRangeCone);

            _easyDrawDebug = new EasyDraw(200, 80, false);
            _easyDrawDebug.SetOrigin(0, _easyDrawDebug.height * 0.5f);
            //_easyDrawDebug.Clear(Color.Black);
            AddChild(_easyDrawDebug);
            _easyDrawDebug.TextFont("data/Gaiatype.ttf", 8);
            _easyDrawDebug.x = 0;
            _easyDrawDebug.y = -40;

            CoroutineManager.StartCoroutine(WaitForEnemySet(), this);
        }
コード例 #6
0
        public DroneGameObject(float pX, float pY, float pWidth, float pHeight, float pSpeed = 200,
                               float pRotation = 0) : base(
                "data/Drone spritesheet small.png", 2, 2, 4, false, true)
        {
            _id  = ++IdCounter;
            name = $"{this}_{_id}";

            _customColliderBounds = new Rectangle(-27, -24, 53, 50);

            _maxSpeed = pSpeed;

            float originalWidth  = width;
            float originalHeight = height;

            SetOrigin(0, height);

            float lScaleX = pWidth / width;
            float lScaleY = pHeight / height;

            SetScaleXY(lScaleX, lScaleY);

            x = pX; // + width / 2;
            y = pY; // - height + height / 2f;

            SetOrigin(originalWidth / 2f, originalHeight / 2f);

            Turn(pRotation);

            x = pX + Mathf.Cos(rotation.DegToRad()) * width * 0.5f;
            y = pY + Mathf.Sin(rotation.DegToRad()) * width * 0.5f;

            var pos  = new Vector2(x - pX, y - pY);
            var perp = new Vector2(pos.y, -pos.x).Normalized;

            pos = perp * height * 0.5f;

            SetScaleXY(1, 1);

            x += pos.x;
            y += pos.y;

            _startPosition = new Vector2(x, y);

            _ledSprite = new AnimationSprite("data/Drone White Led.png", 1, 1, -1, false, false);
            _ledSprite.SetOrigin(width * 0.5f, height * 0.5f);

            _ledOffSprite = new AnimationSprite("data/Drone Gray Led.png", 1, 1, -1, false, false);
            _ledOffSprite.SetOrigin(width * 0.5f, height * 0.5f);

            _ledSprite.SetColor(0, 1f, 0);

            AddChild(_ledOffSprite);
            AddChild(_ledSprite);

            _droneFollowRangeCone = new DroneFollowRangeCone(this);
            _droneFollowRangeCone.SetColor(0.9f, 0.9f, 0);
            _droneFollowRangeCone.alpha = 0;
            AddChild(_droneFollowRangeCone);

            _easyDrawDebug = new EasyDraw(200, 80, false);
            _easyDrawDebug.SetOrigin(0, _easyDrawDebug.height * 0.5f);
            _easyDrawDebug.Clear(Color.Black);
            AddChild(_easyDrawDebug);
            _easyDrawDebug.TextFont("data/Gaiatype.ttf", 8);
            _easyDrawDebug.x = 0;
            _easyDrawDebug.y = -40;

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