void InitLoadingScreen() { var splashScreen = new BorderImage { Texture = ResourceCache.GetTexture2D(AssetsCoordinates.Backgrounds.LoadingGameScreen.ResourcePath), ImageRect = AssetsCoordinates.Backgrounds.LoadingGameScreen.ImageRect, Size = new IntVector2(ScreenInfo.SetX(1920), ScreenInfo.SetY(1080)), Position = new IntVector2(ScreenInfo.SetX(0), ScreenInfo.SetY(0)) }; UI.Root.AddChild(splashScreen); Engine.RunFrame(); }
public static Text CreateText(UIElement parent, ScreenInfoRatio screenInfo, Font font, int fontSize, int xPos, int yPos, HorizontalAlignment hAlign, VerticalAlignment vAlign) { var text = new Text(); parent.AddChild(text); text.SetAlignment(hAlign, vAlign); text.SetPosition(screenInfo.SetX(xPos), screenInfo.SetY(yPos)); text.SetFont(font, screenInfo.SetX(fontSize)); text.SetColor(Color.Black); return(text); }
public static Button CreateButton(UIElement parent, ScreenInfoRatio screenInfo, int posX, int posY, int width, int height, HorizontalAlignment hAlign, VerticalAlignment vAlign) { Button button = new Button(); parent.AddChild(button); button.SetStyleAuto(null); button.SetPosition(screenInfo.SetX(posX), screenInfo.SetY(posY)); button.SetAlignment(hAlign, vAlign); button.SetSize(screenInfo.SetX(width), screenInfo.SetY(height)); button.SetColor(Color.White); return(button); }
void CreateInfoText() { var infoText = root.CreateWindow(); infoText.SetSize(dim.SetX(1920), dim.SetY(200)); infoText.SetPosition(dim.SetX(0), dim.SetY(160)); infoText.SetColor(Color.Transparent); /* * var text = new Text(); * text.SetFont(GameInstance.ResourceCache.GetFont(GameInstance.defaultFont), 20); * text.SetPosition(dim.SetX(20), dim.SetY(15)); * text.Value = "Use SmartRoadSense to collect road data and unlock new levels!"; * text.UseDerivedOpacity = false; * infoText.AddChild(text); * * * var smallText = new Text(); * smallText.SetFont(GameInstance.ResourceCache.GetFont(GameInstance.defaultFont), 8); * smallText.SetPosition(dim.SetX(20), dim.SetY(67)); * smallText.Value = "*This feature will be available starting from the next app release. Stay tuned for updates!"; * smallText.UseDerivedOpacity = false; * infoText.AddChild(smallText); */ }
void CreateProfileBar() { var generic_bts = cache.GetTexture2D("Textures/Generic/generic_btn.png"); var cont_base = cache.GetTexture2D("Textures/Garage/cont_base.png"); var profiles = cache.GetTexture2D("Textures/Generic/profiles.png"); var garage_bts = cache.GetTexture2D("Textures/Garage/garage_bts.png"); // Buttons container (root element) cont_profile = root.CreateSprite(); cont_profile.Texture = cont_base; cont_profile.SetSize((int)(dim.XScreenRatio * 1200), (int)(dim.YScreenRatio * 600)); cont_profile.SetPosition((int)(dim.XScreenRatio * 10), (int)(dim.YScreenRatio * 160)); cont_profile.ImageRect = new IntRect(0, 0, 56, 56); // Continue var continueBtn = new Button(); root.AddChild(continueBtn); continueBtn.SetStyleAuto(null); continueBtn.SetPosition(dim.SetX(0), dim.SetY(-30)); continueBtn.HorizontalAlignment = HorizontalAlignment.Center; continueBtn.VerticalAlignment = VerticalAlignment.Bottom; continueBtn.SetSize(dim.SetX(300), dim.SetY(100)); continueBtn.Texture = generic_bts; continueBtn.ImageRect = new IntRect(260, 0, 520, 110); Text continueText = new Text(); continueBtn.AddChild(continueText); continueText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); continueText.SetPosition(0, 0); continueText.SetFont(font, dim.XScreenRatio * 35); continueText.Value = "Continue"; continueBtn.Pressed += (PressedEventArgs args) => { System.Diagnostics.Debug.WriteLine("Pressed"); if (CharacterManager.Instance.User == null) { // Creating new user System.Diagnostics.Debug.WriteLine("Creating new user"); CharacterManager.Instance.User = new UserInfo { Experience = 0, PortraitId = counter, Username = _nameText, Wallet = 0 }; } else { // Update user data System.Diagnostics.Debug.WriteLine("Updating user"); var user = CharacterManager.Instance.User; user.PortraitId = counter; user.Username = _nameText; CharacterManager.Instance.User = user; } if (_isUserProfile) { GameInstance.LaunchScene(GameScenesEnumeration.USER_PROFILE); } else { GameInstance.LaunchScene(GameScenesEnumeration.MENU); } }; Window nameContainer = new Window(); cont_profile.AddChild(nameContainer); nameContainer.SetStyleAuto(null); nameContainer.SetPosition((int)(dim.XScreenRatio * 100), (int)(dim.YScreenRatio * 50)); nameContainer.SetSize((int)(dim.XScreenRatio * 650), (int)(dim.YScreenRatio * 100)); nameContainer.Texture = generic_bts; nameContainer.ImageRect = new IntRect(0, 288, 1012, 402); continueBtn.Visible = !string.IsNullOrEmpty(_nameText); var enterTextString = "Rudy Reckless"; if (_isUserProfile) { enterTextString = CharacterManager.Instance.User.Username; } lineEdit = new LineEdit { Name = "nameEdit", Position = new IntVector2(dim.SetX(0), dim.SetY(0)), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Size = new IntVector2(dim.SetX(640), dim.SetY(90)) }; lineEdit.SetColor(Color.Transparent); lineEdit.Text = enterTextString; lineEdit.TextElement.SetFont(font, dim.SetX(35)); lineEdit.TextElement.VerticalAlignment = VerticalAlignment.Center; lineEdit.TextElement.HorizontalAlignment = HorizontalAlignment.Center; nameContainer.AddChild(lineEdit); continueBtn.Visible = true; lineEdit.Focused += (FocusedEventArgs args) => { _nameText = enterTextString; System.Diagnostics.Debug.WriteLine("Focused line edit"); }; /* * lineEdit.TextChanged += (TextChangedEventArgs args) => { * if(args.Text.Equals(enterTextString) || args.Text.Contains("Enter n")) { * lineEdit.Text = string.Empty; * _nameText = string.Empty; * continueBtn.Visible = false; * return; * } * if(args.Text.Length < 3) { * continueBtn.Visible = false; * return; * } * continueBtn.Visible = true; * _nameText = args.Text; * }; */ //male male = new Button(); cont_profile.AddChild(male); male.SetStyleAuto(null); male.SetPosition((int)(dim.XScreenRatio * 800), (int)(dim.YScreenRatio * 50)); male.SetSize((int)(dim.XScreenRatio * 300), (int)(dim.YScreenRatio * 100)); male.Texture = generic_bts; male.ImageRect = new IntRect(0, 0, 260, 110); Text buttonmale = new Text(); male.AddChild(buttonmale); buttonmale.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); buttonmale.SetPosition(0, 0); buttonmale.SetFont(font, dim.XScreenRatio * 30); buttonmale.Value = "MALE"; male.Pressed += args => { counter = 0; ScrollImage(); }; //female female = new Button(); cont_profile.AddChild(female); female.SetStyleAuto(null); female.SetPosition((int)(dim.XScreenRatio * 1120), (int)(dim.YScreenRatio * 50)); female.SetSize((int)(dim.XScreenRatio * 300), (int)(dim.YScreenRatio * 100)); female.Texture = generic_bts; female.ImageRect = new IntRect(0, 0, 260, 110); Text buttonfemale = new Text(); female.AddChild(buttonfemale); buttonfemale.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); buttonfemale.SetPosition(0, 0); buttonfemale.SetFont(font, dim.XScreenRatio * 30); buttonfemale.Value = "FEMALE"; female.Pressed += args => { counter = 12; ScrollImage(); }; //other other = new Button(); cont_profile.AddChild(other); other.SetStyleAuto(null); other.SetPosition((int)(dim.XScreenRatio * 1440), (int)(dim.YScreenRatio * 50)); other.SetSize((int)(dim.XScreenRatio * 300), (int)(dim.YScreenRatio * 100)); other.Texture = generic_bts; other.ImageRect = new IntRect(0, 0, 260, 110); Text buttonother = new Text(); other.AddChild(buttonother); buttonother.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); buttonother.SetPosition(0, 0); buttonother.SetFont(font, dim.XScreenRatio * 30); buttonother.Value = "OTHER"; other.Pressed += args => { counter = 24; ScrollImage(); }; // Buttons container (root element) cont_img = root.CreateSprite(); cont_img.Texture = cont_base; cont_img.SetSize((int)(dim.XScreenRatio * 1200), (int)(dim.YScreenRatio * 800)); cont_img.SetPosition((int)(dim.XScreenRatio * 10), (int)(dim.YScreenRatio * 250)); cont_img.ImageRect = new IntRect(0, 0, 56, 56); p_prev_img = new Button(); cont_profile.AddChild(p_prev_img); p_prev_img.SetStyleAuto(null); p_prev_img.Opacity = 0.25f; p_prev_img.SetPosition((int)(dim.XScreenRatio * -400), (int)(dim.YScreenRatio * 300)); p_prev_img.SetSize((int)(dim.XScreenRatio * 450), (int)(dim.YScreenRatio * 450)); p_prev_img.Texture = profiles; p_prev_img.ImageRect = new IntRect(0, 0, 250, 250); prev_img = new Button(); cont_profile.AddChild(prev_img); prev_img.SetStyleAuto(null); prev_img.Opacity = 0.5f; prev_img.SetPosition((int)(dim.XScreenRatio * 100), (int)(dim.YScreenRatio * 250)); prev_img.SetSize((int)(dim.XScreenRatio * 500), (int)(dim.YScreenRatio * 500)); prev_img.Texture = profiles; prev_img.ImageRect = new IntRect(0, 0, 250, 250); prev_img.Pressed += args => { if (counter <= 0) { counter = 44; } else { counter = counter - 1; } ScrollImage(); }; sel_img = new Button(); cont_profile.AddChild(sel_img); sel_img.SetStyleAuto(null); sel_img.SetPosition((int)(dim.XScreenRatio * 650), (int)(dim.YScreenRatio * 220)); sel_img.SetSize((int)(dim.XScreenRatio * 550), (int)(dim.YScreenRatio * 550)); sel_img.Texture = profiles; sel_img.ImageRect = new IntRect(250, 0, 500, 250); next_img = new Button(); cont_profile.AddChild(next_img); next_img.Opacity = 0.5f; next_img.SetStyleAuto(null); next_img.SetPosition((int)(dim.XScreenRatio * 1250), (int)(dim.YScreenRatio * 250)); next_img.SetSize((int)(dim.XScreenRatio * 500), (int)(dim.YScreenRatio * 500)); next_img.Texture = profiles; next_img.ImageRect = new IntRect(500, 0, 750, 250); next_img.Pressed += args => { if (counter == 44) { //next_img.Enabled = false; counter = 0; } else { next_img.Enabled = true; counter = counter + 1; } ScrollImage(); }; n_next_img = new Button(); cont_profile.AddChild(n_next_img); n_next_img.SetStyleAuto(null); n_next_img.Opacity = 0.25f; n_next_img.SetPosition((int)(dim.XScreenRatio * 1800), (int)(dim.YScreenRatio * 300)); n_next_img.SetSize((int)(dim.XScreenRatio * 450), (int)(dim.YScreenRatio * 450)); n_next_img.Texture = profiles; n_next_img.ImageRect = new IntRect(0, 0, 250, 250); //slider imageSlider = new Slider(); cont_profile.AddChild(imageSlider); imageSlider.SetStyleAuto(null); imageSlider.SetPosition(GameInstance.ScreenInfo.SetX(400), GameInstance.ScreenInfo.SetY(160)); imageSlider.SetSize(GameInstance.ScreenInfo.SetX(1100), GameInstance.ScreenInfo.SetY(55)); imageSlider.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); imageSlider.ImageRect = AssetsCoordinates.Generic.Boxes.VolumeBarWhite; imageSlider.Opacity = 0.2f; imageSlider.Range = 44; var knobM = imageSlider.Knob; knobM.SetFixedSize(GameInstance.ScreenInfo.SetX(100), GameInstance.ScreenInfo.SetY(55)); knobM.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); knobM.ImageRect = AssetsCoordinates.Generic.Boxes.VolumeBarWhite; knobM.UseDerivedOpacity = false; imageSlider.Value = counter; imageSlider.SliderChanged += (SliderChangedEventArgs args) => { counter = (int)args.Value; ScrollImage(); System.Diagnostics.Debug.WriteLine("VALORE = " + (int)args.Value); }; }
void CreateScene() { container = root.CreateSprite(); container.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); container.ImageRect = AssetsCoordinates.Generic.Boxes.ContainerTrasparent; container.SetSize((int)(dim.XScreenRatio * 1200), (int)(dim.YScreenRatio * 1400)); container.SetPosition((int)(dim.XScreenRatio * 0), (int)(dim.YScreenRatio * 0)); Sprite LevelInd = new Sprite(); container.AddChild(LevelInd); LevelInd.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); LevelInd.ImageRect = AssetsCoordinates.Generic.Boxes.LevelBlueBox; LevelInd.SetSize((int)(dim.XScreenRatio * 140), (int)(dim.YScreenRatio * 140)); LevelInd.SetPosition((int)(dim.XScreenRatio * 220), (int)(dim.YScreenRatio * 220)); //STATIC TEXT Text level = new Text(); LevelInd.AddChild(level); level.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top); level.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(10)); level.SetFont(font, dim.XScreenRatio * 20); level.Value = "RACE"; // CURRENT RACE NUMBER Text levelnumber = new Text(); LevelInd.AddChild(levelnumber); levelnumber.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); levelnumber.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(15)); levelnumber.SetFont(font, dim.XScreenRatio * 50); if (_postLevelData != null && _postLevelData.TrackData != null) { levelnumber.Value = _postLevelData.TrackData.IdTrack.ToString(); } Sprite LevelIcon = new Sprite(); container.AddChild(LevelIcon); LevelIcon.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); LevelIcon.ImageRect = AssetsCoordinates.Generic.Boxes.IconBeach; LevelIcon.SetSize((int)(dim.XScreenRatio * 1200), (int)(dim.YScreenRatio * 140)); LevelIcon.SetPosition((int)(dim.XScreenRatio * 410), (int)(dim.YScreenRatio * 220)); Sprite ResultsContainer = new Sprite(); container.AddChild(ResultsContainer); ResultsContainer.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); ResultsContainer.ImageRect = AssetsCoordinates.Generic.Boxes.ContainerTrasparent; ResultsContainer.SetSize((int)(dim.XScreenRatio * 1200), (int)(dim.YScreenRatio * 1200)); ResultsContainer.SetPosition((int)(dim.XScreenRatio * 220), (int)(dim.YScreenRatio * 250)); // CURRENT TIME Sprite TimeIcon = new Sprite(); ResultsContainer.AddChild(TimeIcon); TimeIcon.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); TimeIcon.ImageRect = AssetsCoordinates.Generic.Boxes.TimeIconBar; TimeIcon.SetSize((int)(dim.XScreenRatio * 800), (int)(dim.YScreenRatio * 100)); TimeIcon.SetPosition((int)(dim.XScreenRatio * 350), (int)(dim.YScreenRatio * 120)); // Title Text Time = new Text(); TimeIcon.AddChild(Time); Time.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Center); Time.SetPosition(GameInstance.ScreenInfo.SetX(100), GameInstance.ScreenInfo.SetY(0)); Time.SetFont(font, dim.XScreenRatio * 30); Time.Value = "Time:"; // Time value Text TimeTot = new Text(); TimeIcon.AddChild(TimeTot); TimeTot.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center); TimeTot.SetPosition(GameInstance.ScreenInfo.SetX(-30), GameInstance.ScreenInfo.SetY(0)); TimeTot.SetFont(font, dim.XScreenRatio * 30); if (_postLevelData != null && _postLevelData.TrackData != null) { TimeTot.Value = TimeSpan.FromMilliseconds(_postLevelData.Time).MillisRepresentation(); } // BEST TIME Sprite BestIcon = new Sprite(); ResultsContainer.AddChild(BestIcon); BestIcon.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); BestIcon.ImageRect = AssetsCoordinates.Generic.Boxes.BestIconBar; BestIcon.SetSize((int)(dim.XScreenRatio * 800), (int)(dim.YScreenRatio * 100)); BestIcon.SetPosition((int)(dim.XScreenRatio * 350), (int)(dim.YScreenRatio * 230)); // Title Text Best = new Text(); BestIcon.AddChild(Best); Best.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Center); Best.SetPosition(GameInstance.ScreenInfo.SetX(100), GameInstance.ScreenInfo.SetY(0)); Best.SetFont(font, dim.XScreenRatio * 30); Best.Value = "Best:"; // Value Text BestTot = new Text(); BestIcon.AddChild(BestTot); BestTot.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center); BestTot.SetPosition(GameInstance.ScreenInfo.SetX(-30), GameInstance.ScreenInfo.SetY(0)); BestTot.SetFont(font, dim.XScreenRatio * 30); if (_postLevelData != null && _postLevelData.TrackData != null) { BestTot.Value = TimeSpan.FromMilliseconds(_postLevelData.TrackData.BestTime).MillisRepresentation(); } // COMPONENTS Sprite ComponentsIcon = new Sprite(); ResultsContainer.AddChild(ComponentsIcon); ComponentsIcon.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); ComponentsIcon.ImageRect = AssetsCoordinates.Generic.Boxes.ComponentsIconBar; ComponentsIcon.SetSize((int)(dim.XScreenRatio * 800), (int)(dim.YScreenRatio * 100)); ComponentsIcon.SetPosition((int)(dim.XScreenRatio * 350), (int)(dim.YScreenRatio * 340)); // Title Text components = new Text(); ComponentsIcon.AddChild(components); components.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Center); components.SetPosition(GameInstance.ScreenInfo.SetX(100), GameInstance.ScreenInfo.SetY(0)); components.SetFont(font, dim.XScreenRatio * 30); components.Value = "Components:"; // Value Text ComponentsTot = new Text(); ComponentsIcon.AddChild(ComponentsTot); ComponentsTot.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center); ComponentsTot.SetPosition(GameInstance.ScreenInfo.SetX(-30), GameInstance.ScreenInfo.SetY(0)); ComponentsTot.SetFont(font, dim.XScreenRatio * 30); if (_postLevelData != null && _postLevelData.TrackData != null) { ComponentsTot.Value = "x" + _postLevelData.Components; } // COINS Sprite CoinsIcon = new Sprite(); ResultsContainer.AddChild(CoinsIcon); CoinsIcon.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); CoinsIcon.ImageRect = AssetsCoordinates.Generic.Boxes.CoinsIconBar; CoinsIcon.SetSize((int)(dim.XScreenRatio * 800), (int)(dim.YScreenRatio * 100)); CoinsIcon.SetPosition((int)(dim.XScreenRatio * 350), (int)(dim.YScreenRatio * 450)); // Title Text Coins = new Text(); CoinsIcon.AddChild(Coins); Coins.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Center); Coins.SetPosition(GameInstance.ScreenInfo.SetX(100), GameInstance.ScreenInfo.SetY(0)); Coins.SetFont(font, dim.XScreenRatio * 30); Coins.Value = "Coins:"; // Value Text CoinsTot = new Text(); CoinsIcon.AddChild(CoinsTot); CoinsTot.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center); CoinsTot.SetPosition(GameInstance.ScreenInfo.SetX(-30), GameInstance.ScreenInfo.SetY(0)); CoinsTot.SetFont(font, dim.XScreenRatio * 30); if (_postLevelData != null && _postLevelData.TrackData != null) { CoinsTot.Value = "x" + _postLevelData.Coins; } // POINTS Sprite PointsIcon = new Sprite(); ResultsContainer.AddChild(PointsIcon); PointsIcon.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); PointsIcon.ImageRect = AssetsCoordinates.Generic.Boxes.PointsIconBar; PointsIcon.SetSize((int)(dim.XScreenRatio * 800), (int)(dim.YScreenRatio * 100)); PointsIcon.SetPosition((int)(dim.XScreenRatio * 350), (int)(dim.YScreenRatio * 560)); // Title Text Points = new Text(); PointsIcon.AddChild(Points); Points.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Center); Points.SetPosition(GameInstance.ScreenInfo.SetX(100), GameInstance.ScreenInfo.SetY(0)); Points.SetFont(font, dim.XScreenRatio * 30); Points.Value = "Points:"; // Value Text PointsTot = new Text(); PointsIcon.AddChild(PointsTot); PointsTot.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center); PointsTot.SetPosition(GameInstance.ScreenInfo.SetX(-30), GameInstance.ScreenInfo.SetY(0)); PointsTot.SetFont(font, dim.XScreenRatio * 30); if (_postLevelData != null && _postLevelData.TrackData != null) { PointsTot.Value = _postLevelData.Points.ToString(); } // CHARACTER LEVEL Sprite RankRadBox1 = new Sprite(); container.AddChild(RankRadBox1); RankRadBox1.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); RankRadBox1.ImageRect = AssetsCoordinates.Generic.Boxes.RankRedBox; RankRadBox1.SetSize((int)(dim.XScreenRatio * 140), (int)(dim.YScreenRatio * 140)); RankRadBox1.SetPosition((int)(dim.XScreenRatio * 220), (int)(dim.YScreenRatio * 920)); // Title Text rank1 = new Text(); RankRadBox1.AddChild(rank1); rank1.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top); rank1.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(10)); rank1.SetFont(font, dim.XScreenRatio * 20); rank1.Value = "LEVEL"; // Value Text ranknumber = new Text(); RankRadBox1.AddChild(ranknumber); ranknumber.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); ranknumber.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(15)); ranknumber.SetFont(font, dim.XScreenRatio * 50); ranknumber.Value = CharacterManager.Instance.User.Level.ToString(); var buttons = cache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); double totPoints = CharacterLevelData.PointsToNextLevel(); double currPoints = CharacterLevelData.CurrentLevelPoints(); double currX = currPoints / totPoints * 100; double totX = dim.SetX(400); int x = 1773; // punto d'inizio "left" dell'immagine del bottone int y = (int)Math.Round(x + currX / 100 * totX); int size = y - x; System.Diagnostics.Debug.WriteLine("Size value = " + size + " Tot points = " + totPoints + " currPoints = " + currPoints + " X = " + x + " Y = " + y); // LEVEL BASE BOX Sprite RankIncrease = new Sprite(); container.AddChild(RankIncrease); RankIncrease.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); RankIncrease.ImageRect = AssetsCoordinates.Generic.Boxes.RankIncreaseBar; RankIncrease.SetSize((int)(dim.XScreenRatio * 1000), (int)(dim.YScreenRatio * 140)); RankIncrease.SetPosition((int)(dim.XScreenRatio * 410), (int)(dim.YScreenRatio * 920)); Sprite LevelCompleted = new Sprite(); RankIncrease.AddChild(LevelCompleted); LevelCompleted.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); LevelCompleted.ImageRect = AssetsCoordinates.Generic.Boxes.RaceCompleted; // readonly static public IntRect RaceCompleted = new IntRect(1773, 977, 2370, 1049); LevelCompleted.ImageRect = new IntRect(x, 977, y, 1049); LevelCompleted.SetSize(dim.SetX(size), dim.SetY(140)); LevelCompleted.SetPosition(0, 0); // LEVEL CURRENT POINTS BOX Sprite RankRadBox2 = new Sprite(); container.AddChild(RankRadBox2); RankRadBox2.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); RankRadBox2.ImageRect = AssetsCoordinates.Generic.Boxes.RankRedBox; RankRadBox2.SetSize((int)(dim.XScreenRatio * 140), (int)(dim.YScreenRatio * 140)); RankRadBox2.SetPosition((int)(dim.XScreenRatio * 1470), (int)(dim.YScreenRatio * 920)); // CHARACTER NEXT LEVEL Text rank2 = new Text(); RankRadBox2.AddChild(rank2); rank2.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top); rank2.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(10)); rank2.SetFont(font, dim.XScreenRatio * 20); rank2.Value = "LEVEL"; // Value Text ranknumber2 = new Text(); RankRadBox2.AddChild(ranknumber2); ranknumber2.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); ranknumber2.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(15)); ranknumber2.SetFont(font, dim.XScreenRatio * 50); ranknumber2.Value = (CharacterManager.Instance.User.Level + 1).ToString(); }
void CreateTopBar() { _blackBar = _root.CreateSprite(); _root.AddChild(_blackBar); _blackBar.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.TopBar.ResourcePath); _blackBar.Opacity = 0.5f; _blackBar.SetPosition(0, (int)(_dim.YScreenRatio * 30)); _blackBar.SetSize((int)(_dim.XScreenRatio * 2000), (int)(_dim.YScreenRatio * 140)); _blackBar.ImageRect = AssetsCoordinates.Generic.TopBar.Rectangle; btnBack = new Button(); _blackBar.AddChild(btnBack); btnBack.UseDerivedOpacity = false; btnBack.SetStyleAuto(null); btnBack.SetPosition(_dim.SetX(10), _dim.SetY(0)); btnBack.HorizontalAlignment = HorizontalAlignment.Left; btnBack.VerticalAlignment = VerticalAlignment.Center; btnBack.SetSize(_dim.SetX(120), _dim.SetY(120)); btnBack.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); btnBack.ImageRect = AssetsCoordinates.Generic.Icons.BntBack; btnBack.Pressed += args => { GameInstance.LaunchScene(GameScenesEnumeration.MENU); }; if (VehicleManager.Instance.UnlockedVehicles.VehicleModel.Count == 0) { #if __ANDROID__ btnBack.Visible = false; #else btnBack.Visible = true; #endif } //COINS Button coins = new Button(); _blackBar.AddChild(coins); coins.UseDerivedOpacity = false; coins.SetStyleAuto(null); coins.SetPosition(_dim.SetX(150), _dim.SetY(0)); coins.HorizontalAlignment = HorizontalAlignment.Left; coins.VerticalAlignment = VerticalAlignment.Center; coins.SetSize(_dim.SetX(70), _dim.SetY(70)); coins.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); coins.ImageRect = AssetsCoordinates.Generic.Icons.IconCoin; coins.UseDerivedOpacity = false; //Wallet text _wallet = new Text(); coins.AddChild(_wallet); _wallet.SetPosition((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 10)); _wallet.SetFont(_font, _dim.XScreenRatio * 30); _wallet.Value = string.Format($"{CharacterManager.Instance.Wallet}"); // SCREEN TITLE Button screen_title = new Button(); _root.AddChild(screen_title); screen_title.SetStyleAuto(null); screen_title.SetPosition((int)(_dim.XScreenRatio * 1500), (int)(_dim.YScreenRatio * 50)); screen_title.SetSize((int)(_dim.XScreenRatio * 400), (int)(_dim.YScreenRatio * 100)); screen_title.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); screen_title.ImageRect = AssetsCoordinates.Generic.Boxes.BoxTitle; screen_title.Enabled = false; Text buttonTitleText = new Text(); screen_title.AddChild(buttonTitleText); buttonTitleText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); buttonTitleText.SetPosition(0, 0); buttonTitleText.SetFont(_font, _dim.XScreenRatio * 30); buttonTitleText.Value = "VEHICLE SELECT"; _screenInfo = new Text(); _root.AddChild(_screenInfo); _screenInfo.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top); _screenInfo.SetPosition(_dim.SetX(0), _dim.SetY(220)); _screenInfo.SetFont(_font, _dim.SetX(40)); _screenInfo.SetColor(Color.White); if (VehicleManager.Instance.UnlockedVehicles == null || VehicleManager.Instance.UnlockedVehicles.VehicleModel.Count == 0) { _screenInfo.Value = "Please select a free starting vehicle."; } else { _screenInfo.Value = ""; } }