Beispiel #1
0
        private PlayerHud()
        {
            HudSprite          = new Sprite(new Texture(ResourcesManager.resourcesPath + "playerHud.png"));
            eq                 = new Sprite(new Texture(ResourcesManager.resourcesPath + "equipped.png"));
            neq                = new Sprite(new Texture(ResourcesManager.resourcesPath + "notEquipped.png"));
            HudSprite.Position = new Vector2f(1279, 72);


            ShipImg         = new Sprite();
            PlayerNameLabel = new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), "", 30, new Vector2i(267, 27));
            PlayerNameLabel.setPosition(new Vector2f(HudSprite.Position.X + 16, HudSprite.Position.Y + 9));
            PlayerMoneyLabel = new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), "0 cr", 30, new Vector2i(267, 38));
            PlayerMoneyLabel.setPosition(new Vector2f(HudSprite.Position.X + 16, HudSprite.Position.Y + 224));
            HealthLabel = new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), (0 * 100).ToString() + "%", 24, new Vector2i(64, 25));
            HealthLabel.setPosition(new Vector2f(HudSprite.Position.X + 217, HudSprite.Position.Y + 732));
            DmgProgressbar = new OurProgressbar(new Texture(ResourcesManager.resourcesPath + "DamageProgressBarSprite.png"), new Vector2f(193, 23));
            DmgProgressbar.setPosition(new Vector2f(HudSprite.Position.X + 21, HudSprite.Position.Y + 733));
        }
Beispiel #2
0
        //inicjalizacja, dodawanie komponentów do listy komponentów
        public override void initialize(RenderWindow window)
        {
            if (!initialized)
            {
                panelList = new List <Panel>();
                PlayerHud.Instance().PlayerInfo = PlayerManager.Instance;
                PlayerHud.Instance().ShipImg = new Sprite(new Texture(PlayerManager.Instance.ShipInfo.ShipTexture));
                PlayerHud.Instance().ShipImg.Position = new Vector2f(1428 - PlayerHud.Instance().ShipImg.Texture.Size.X / 2, 200 - PlayerHud.Instance().ShipImg.Texture.Size.Y / 2);
                PlayerHud.Instance().update();

                OurLabel pnlInfo = new OurLabel(new Texture(ResourcesManager.resourcesPath + "infoPanel.png"), "", 0, new Vector2i(1114, 452));
                pnlInfo.setPosition(new Vector2f(83, 171));
                componentList.Add(pnlInfo);

                #region workbenchPanel
                Panel workbenchPanel = new Panel();
                workbenchPanel.PanelName = "Warsztat";
                string[] statsPaths =
                {
                    "btnRepairSprite.png",
                    "btnSpeedSprite.png",
                    "btnArmorSprite.png",
                    "btnAccuracySprite.png",
                    "btnFireRateSprite.png",
                    "btnFireDmgSprite.png"
                };
                int[] statsArgs = { -1, 0, 1, 2, 3, 4 };

                for (int i = 0; i < statsPaths.Length; i++)
                {
                    OurButton button = new OurButton(new Texture(ResourcesManager.resourcesPath + statsPaths[i]), new Vector2i(200, 199), "", 0);
                    button.componentID = "btnStat" + i;
                    button.ArgToPass   = statsArgs[i];
                    workbenchPanel.panelBtnList.Add(button);
                }

                foreach (OurButton button in workbenchPanel.panelBtnList)
                {
                    button.Visible        = false;
                    button.Active         = false;
                    button.MouseHovered  += OnStatBtnMouseHovered;
                    button.MouseReleased += OnStatBtnMouseReleased;
                    componentList.Add(button);
                }
                for (int i = 0; i < 5; i++)
                {
                    workbenchPanel.panelBtnList[i].Visible = true;
                    workbenchPanel.panelBtnList[i].Active  = true;
                    workbenchPanel.panelBtnList[i].setPosition(new Vector2f(80 + 230 * i, 647));
                }
                for (int i = 0; i < 6; i++)
                {
                    workbenchPanel.panelLblList.Add(new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), PlayerManager.Instance.upgradeCost((stats)(i - 1)).ToString() + " cr", 28));

                    workbenchPanel.panelLblList[i].setPosition(new Vector2f(workbenchPanel.panelBtnList[i].Position.X + 35, workbenchPanel.panelBtnList[i].Position.Y + 165));
                    workbenchPanel.panelLblList[i].Visible = false;
                    componentList.Add(workbenchPanel.panelLblList[i]);
                }
                for (int i = 0; i < 5; i++)
                {
                    workbenchPanel.panelLblList[i].Visible = true;
                }

                workbenchInfo = readPanelInfo("workbenchInfo.xml");
                OurLabel workbenchDisplayedInfo = new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), "", 32);
                workbenchDisplayedInfo.TextAlign   = align.left;
                workbenchDisplayedInfo.componentID = "workbenchDisplayedInfo";
                workbenchDisplayedInfo.setPosition(new Vector2f(250, 300));
                componentList.Add(workbenchDisplayedInfo);
                workbenchPanel.panelInfoLblList.Add(workbenchDisplayedInfo);

                panelList.Add(workbenchPanel);
                #endregion

                #region shipshopPanel
                Panel shipshopPanel = new Panel();
                shipshopPanel.PanelName = "Salon";
                string[] shipsPaths =
                {
                    "ship1BtnSprite.png",
                    "ship2BtnSprite.png",
                    "ship3BtnSprite.png",
                    "ship4BtnSprite.png",
                    "ship5BtnSprite.png"
                };

                for (int i = 0; i < shipsPaths.Length; i++)
                {
                    OurButton button = new OurButton(new Texture(ResourcesManager.resourcesPath + shipsPaths[i]), new Vector2i(200, 199), "", 0);
                    button.componentID = "btnShip" + i;
                    button.ArgToPass   = i;
                    shipshopPanel.panelBtnList.Add(button);
                }
                foreach (OurButton button in shipshopPanel.panelBtnList)
                {
                    button.Visible        = false;
                    button.Active         = false;
                    button.MouseHovered  += OnShipMouseHovered;
                    button.MouseReleased += OnShipBtnMouseReleased;
                    componentList.Add(button);
                }


                for (int i = 0; i < 5; i++)
                {
                    shipshopPanel.panelBtnList[i].Visible = true;
                    shipshopPanel.panelBtnList[i].Active  = true;
                    shipshopPanel.panelBtnList[i].setPosition(new Vector2f(80 + 230 * i, 647));
                }
                for (int i = 0; i < 5; i++)
                {
                    shipshopPanel.panelLblList.Add(new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), "", 28));
                    shipshopPanel.panelLblList[i].Text = PlayerManager.Instance.ShipPrefabs[i].Price + " cr";
                    shipshopPanel.panelLblList[i].setPosition(new Vector2f(shipshopPanel.panelBtnList[i].Position.X + 100, shipshopPanel.panelBtnList[i].Position.Y + 180));
                    shipshopPanel.panelLblList[i].Visible = false;
                    componentList.Add(shipshopPanel.panelLblList[i]);
                }

                OurLabel ShipshopDisplayedInfo = new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), "", 30);
                ShipshopDisplayedInfo.componentID = "ShipShopDisplayedInfo";
                ShipshopDisplayedInfo.Text        = "";
                ShipshopDisplayedInfo.setPosition(new Vector2f(470, 400));
                componentList.Add(ShipshopDisplayedInfo);
                shipshopPanel.panelInfoLblList.Add(ShipshopDisplayedInfo);

                OurLabel shipImg = new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), "", 0, new Vector2i(160, 117));
                shipImg.componentID = "ShipShopShipImg";
                shipImg.setPosition(new Vector2f(900, 330));
                componentList.Add(shipImg);
                shipshopPanel.panelInfoLblList.Add(shipImg);

                panelList.Add(shipshopPanel);
                #endregion

                #region powerupsPanel

                Panel powerupsPanel = new Panel();

                powerupsPanel.PanelName = "Sklep";
                string[] pupsPaths =
                {
                    "btnRocketSprite.png",
                    "btnLaserSprite.png",
                    "btnBombSprite.png",
                    "btnWaveSprite.png",
                    "btnShieldSprite.png"
                };
                for (int i = 0; i < pupsPaths.Length; i++)
                {
                    OurButton button = new OurButton(new Texture(ResourcesManager.resourcesPath + pupsPaths[i]), new Vector2i(200, 199), "", 0);
                    button.componentID = "btnPUp" + i;
                    button.ArgToPass   = i;
                    powerupsPanel.panelBtnList.Add(button);
                }

                foreach (OurButton button in powerupsPanel.panelBtnList)
                {
                    button.Visible        = false;
                    button.Active         = false;
                    button.MouseHovered  += OnPowerupMouseHovered;
                    button.MouseReleased += OnPowerupBtnMouseReleased;
                    componentList.Add(button);
                }
                for (int i = 0; i < 5; i++)
                {
                    powerupsPanel.panelBtnList[i].Visible = true;
                    powerupsPanel.panelBtnList[i].Active  = true;
                    powerupsPanel.panelBtnList[i].setPosition(new Vector2f(80 + 230 * i, 647));
                }

                for (int i = 0; i < 5; i++)
                {
                    powerupsPanel.panelLblList.Add(new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), "", 28));
                    powerupsPanel.panelLblList[i].Text = PlayerManager.Instance.powerupCost((powerups)i) + " cr";
                    powerupsPanel.panelLblList[i].setPosition(new Vector2f(powerupsPanel.panelBtnList[i].Position.X + 100, powerupsPanel.panelBtnList[i].Position.Y + 180));
                    powerupsPanel.panelLblList[i].Visible = false;
                    componentList.Add(powerupsPanel.panelLblList[i]);
                }

                powerupInfo = readPanelInfo("powerupInfo.xml");
                OurLabel powerupDisplayedInfo = new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), "", 32);
                powerupDisplayedInfo.TextAlign   = align.left;
                powerupDisplayedInfo.componentID = "powerupDisplayedInfo";
                powerupDisplayedInfo.setPosition(new Vector2f(250, 300));
                componentList.Add(powerupDisplayedInfo);
                powerupsPanel.panelInfoLblList.Add(powerupDisplayedInfo);

                OurLabel currentPowerups = new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), "", 32);
                currentPowerups.componentID = "currentPowerups";
                currentPowerups.TextAlign   = align.left;
                currentPowerups.Text        = "Posiadasz: ";
                currentPowerups.setPosition(new Vector2f(250, 520));
                componentList.Add(currentPowerups);

                powerupsPanel.panelInfoLblList.Add(currentPowerups);


                panelList.Add(powerupsPanel);
                #endregion

                activePanel = workbenchPanel;
                ChangePanel(workbenchPanel);


                #region SomeButtons
                OurLabel pnlName = new OurLabel(new Texture(ResourcesManager.resourcesPath + "blank.png"), workbenchPanel.PanelName, 60);
                pnlName.setPosition(new Vector2f(640 - pnlName.Size.X / 2, 210));
                pnlName.TextColor   = new Color(225, 57, 6);
                pnlName.componentID = "panelName";
                componentList.Add(pnlName);


                OurButton btnMission = new OurButton(new Texture(ResourcesManager.resourcesPath + "btnMission.png"), new Vector2i(300, 99), "", 0);
                btnMission.setPosition(new Vector2f(633, 21));
                btnMission.MouseReleased += OnBtnMissionMouseReleased;
                btnMission.componentID    = "mission";

                componentList.Add(btnMission);

                OurButton btnLeftScroll = new OurButton(new Texture(ResourcesManager.resourcesPath + "btnLeftSprite.png"), new Vector2i(40, 199), "", 0);
                btnLeftScroll.setPosition(new Vector2f(28, 647));
                btnLeftScroll.componentID    = "left";
                btnLeftScroll.MouseReleased += OnBtnLeftScrollMouseReleased;
                componentList.Add(btnLeftScroll);

                OurButton btnRightScroll = new OurButton(new Texture(ResourcesManager.resourcesPath + "btnRightSprite.png"), new Vector2i(40, 199), "", 0);
                btnRightScroll.componentID = "right";
                btnRightScroll.setPosition(new Vector2f(1212, 647));
                btnRightScroll.MouseReleased += OnBtnRightScrollMouseReleased;
                componentList.Add(btnRightScroll);



                OurButton btnScrollPanelLeft = new OurButton(new Texture(ResourcesManager.resourcesPath + "btnLeftPanelSprite.png"), new Vector2i(40, 449), "", 0);
                btnScrollPanelLeft.setPosition(new Vector2f(28, 171));
                btnScrollPanelLeft.MouseReleased += OnScrollPanelLeftMouseReleased;
                componentList.Add(btnScrollPanelLeft);

                OurButton btnScrollPanelRight = new OurButton(new Texture(ResourcesManager.resourcesPath + "btnRightPanelSprite.png"), new Vector2i(40, 449), "", 0);
                btnScrollPanelRight.setPosition(new Vector2f(1212, 171));
                btnScrollPanelRight.MouseReleased += OnScrollPanelRightMouseReleased;
                componentList.Add(btnScrollPanelRight);
                #endregion

                //cursor
                cursor = Cursor.Instance(new Texture(ResourcesManager.resourcesPath + "cursor.png"), new Vector2f(1f, 1f));

                initialized = true;
            }
        }
Beispiel #3
0
        //inicjalizacja, dodawanie komponentów do listy komponentów
        public override void initialize(RenderWindow window)
        {
            if (!initialized)
            {
                #region Labels
                string   lblWelcomeText = "Witaj na pokladzie Kapitanie!\nNie bylo cie przez dlugi czas\nZanim wyruszymy w podroz\nPrzypomnij nam swoje imie".ToLower();
                OurLabel lblWelcome     = new OurLabel(new Texture(ResourcesManager.resourcesPath + "labelBg2.png"), lblWelcomeText, 30);
                lblWelcome.setPosition(new Vector2f(window.Size.X * 0.45f - lblWelcome.Size.X / 2, window.Size.Y * 0.4f - lblWelcome.Size.Y / 2));
                lblWelcome.Visible     = false;
                lblWelcome.componentID = "label";
                componentList.Add(lblWelcome);
                #endregion

                #region Textboxes
                OurTextbox txbUsername = new OurTextbox(new Texture(ResourcesManager.resourcesPath + "txbSprite.png"), new Vector2f(lblWelcome.Size.X, 0), 30);
                txbUsername.setPosition(new Vector2f(lblWelcome.Position.X, lblWelcome.Position.Y + lblWelcome.Size.Y + 10));
                txbUsername.TextConfirmed += onTxbUserNameTextConfirmed;
                txbUsername.componentID    = "textbox";
                txbUsername.Visible        = false;
                componentList.Add(txbUsername);
                #endregion

                #region Images

                OurImage imgCapral = new OurImage(new Texture(ResourcesManager.resourcesPath + "capral.png"), new Vector2f(230, 230));
                imgCapral.setPosition(new Vector2f(lblWelcome.Position.X + lblWelcome.Size.X + 5, lblWelcome.Position.Y - 20));
                imgCapral.componentID = "capral";
                imgCapral.Visible     = false;
                componentList.Add(imgCapral);

                #endregion

                #region Buttons

                Vector2i buttonSize = new Vector2i(300, 99);
                uint     fontSize   = 40;

                OurButton btnNewGame = new OurButton(new Texture(ResourcesManager.resourcesPath + "buttonSprite.png"), buttonSize, "nowa gra", fontSize);

                btnNewGame.MouseReleased += OnNewGameButtonReleased;

                btnNewGame.setPosition(new Vector2f(window.Size.X * 0.67f + btnNewGame.Size.X / 2, window.Size.Y * 0.30f + btnNewGame.Size.Y / 2));
                componentList.Add(btnNewGame);

                OurButton btnLoadGame = new OurButton(new Texture(ResourcesManager.resourcesPath + "buttonSprite.png"), buttonSize, "wczytaj gre", 35);
                btnLoadGame.setPosition(new Vector2f(window.Size.X * 0.67f + btnNewGame.Size.X / 2, window.Size.Y * 0.45f + btnNewGame.Size.Y / 2));

                btnLoadGame.MouseReleased += OnBtnLoadMouseReleased;

                componentList.Add(btnLoadGame);

                OurButton btnOptions = new OurButton(new Texture(ResourcesManager.resourcesPath + "buttonSprite.png"), buttonSize, "opcje", fontSize);
                btnOptions.setPosition(new Vector2f(window.Size.X * 0.67f + btnNewGame.Size.X / 2, window.Size.Y * 0.6f + btnNewGame.Size.Y / 2));
                componentList.Add(btnOptions);

                OurButton btnExit = new OurButton(new Texture(ResourcesManager.resourcesPath + "buttonSprite.png"), buttonSize, "wyjdz", fontSize);
                btnExit.setPosition(new Vector2f(window.Size.X * 0.67f + btnNewGame.Size.X / 2, window.Size.Y * 0.75f + btnNewGame.Size.Y / 2));

                btnExit.MouseReleased += OnExitButtonReleased;
                componentList.Add(btnExit);
                #endregion


                //cursor
                cursor = Cursor.Instance(new Texture(ResourcesManager.resourcesPath + "cursor.png"), new Vector2f(1f, 1f));

                initialized = true;
            }
        }