Ejemplo n.º 1
0
        public string JoystickLayoutPatch;// => JoystickLayoutPatches.WithZoomInAndOut;

        //DebugHud _debug;
        protected override void Start()
        {
            InitResourceCache();

            InitUiInfo();

            InitLoadingScreen();

            Task.Run(async() => { await InitTracks(); }).Wait();

            LaunchScene(GameScenesEnumeration.MENU);

            JsonReaderVehicles.GetVehicleConfig();

            CharacterLevelData.PointsToNextLevel();

            VehicleManager.Instance.Init();

#if DEBUG
            // TEST DATA FOR BUYING VEHICLES

            CharacterManager.Instance.Wallet = 100000;

            var newComponentsContainer = new CollectedComponentsContainer {
                CollectedComponentsList = new List <CollectedComponents>()
            };
            var components = VehicleManager.Instance.CollectedComponents;
            foreach (var c in components.CollectedComponentsList)
            {
                var newComponents = new CollectedComponents {
                    VehicleId         = c.VehicleId,
                    VehicleComponents = new Components()
                };
                newComponents.VehicleComponents.Brakes      = true;
                newComponents.VehicleComponents.Performance = true;
                newComponents.VehicleComponents.Suspensions = true;
                newComponents.VehicleComponents.Wheels      = true;
                newComponentsContainer.CollectedComponentsList.Add(newComponents);
            }
            VehicleManager.Instance.CollectedComponents = newComponentsContainer;

            //_debug = Engine.CreateDebugHud();
            //_debug.ToggleAll();
#endif
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        void CreateLevelBar()
        {
            _container           = root.CreateSprite();
            _container.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            _container.ImageRect = AssetsCoordinates.Generic.Boxes.ContainerTrasparent;
            _container.SetSize((int)(dim.XScreenRatio * 800), (int)(dim.YScreenRatio * 400));
            _container.SetPosition(GameInstance.ScreenInfo.SetX(500), GameInstance.ScreenInfo.SetY(30));

            Sprite LevelToComplete = new Sprite();

            _container.AddChild(LevelToComplete);
            LevelToComplete.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            LevelToComplete.ImageRect = AssetsCoordinates.Generic.Boxes.LevelToComplete;
            LevelToComplete.SetSize((int)(dim.XScreenRatio * 400), (int)(dim.YScreenRatio * 100));
            LevelToComplete.SetPosition(GameInstance.ScreenInfo.SetX(350), GameInstance.ScreenInfo.SetY(240));

            //per comodità utilizzo direttamente IntRect e non AssetsCoordinate
            // in questo punto dovrebbe essere creato l'IntRect utilizzando la percentuale di completamento del livello
            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    = 2017; // punto d'inizio "left" dell'immagine del bottone
            int y    = (int)Math.Round(x + currX / 100 * totX);
            int size = y - x;

            Sprite LevelCompleted = new Sprite();

            _container.AddChild(LevelCompleted);
            LevelCompleted.Texture   = buttons;
            LevelCompleted.ImageRect = new IntRect(x, 1410, y, 1471);
            LevelCompleted.SetSize(dim.SetX(size), dim.SetY(100));
            LevelCompleted.SetPosition(dim.SetX(350), dim.SetY(240));
            //LevelCompleted.SetPosition((int)(dim.XScreenRatio * 220), (int)(dim.YScreenRatio * 220));

            // LEVEL INDICATOR
            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(GameInstance.ScreenInfo.SetX(220), GameInstance.ScreenInfo.SetY(220));

            // Title
            Text level = new Text();

            LevelInd.AddChild(level);
            level.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top);
            level.SetPosition(0, GameInstance.ScreenInfo.SetY(10));
            level.SetFont(font, dim.XScreenRatio * 20);
            level.Value = "LEVEL";

            // Value
            Text levelnumber = new Text();

            LevelInd.AddChild(levelnumber);
            levelnumber.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            levelnumber.SetPosition(0, GameInstance.ScreenInfo.SetY(20));
            levelnumber.SetFont(font, dim.XScreenRatio * 50);
            levelnumber.Value = string.Format("{0}", CharacterManager.Instance.User.Level);
        }