Inheritance: Urho.Component
Ejemplo n.º 1
0
        public async Task ShowTopScores(StartMenu startMenu)
        {
            if (GameScoreService.Current != null)
            {
                startMenu.TopPlayersText = previousTopScores ?? "";
                var topScores = await GameScoreService.Current.GetTopScoresAsync();

                var text = "\n\nTOP PLAYERS\n\n";
                foreach (var score in topScores)
                {
                    text = text + score.Address.Substring(0, 15) + "...  " + score.Score + "\n";
                }
                startMenu.TopPlayersText = text;
                previousTopScores        = text;

                game.HsCoins = await GameScoreService.Current.GetUserTopScore();
            }
        }
Ejemplo n.º 2
0
 private async void Game_NewStartMenu(StartMenu newStartMenu)
 {
     newStartMenu.ShowSettingsClicked += StartMenu_ShowSettingsClicked;
     await ShowTopScores(newStartMenu).ContinueWith(HandleError);
 }
Ejemplo n.º 3
0
 private void Game_RemovedStartMenu(StartMenu startMenu)
 {
     startMenu.ShowSettingsClicked -= StartMenu_ShowSettingsClicked;
 }
Ejemplo n.º 4
0
        async void CreateScene()
        {
            scene = new Scene();
            scene.CreateComponent <Octree>();

            var physics = scene.CreateComponent <PhysicsWorld>();

            physics.SetGravity(new Vector3(0, 0, 0));

            // Camera
            var cameraNode = scene.CreateChild();

            cameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
            cameraNode.CreateComponent <Camera>();
            Viewport = new Viewport(Context, scene, cameraNode.GetComponent <Camera>(), null);

            if (Platform != Platforms.Android && Platform != Platforms.iOS)
            {
                RenderPath effectRenderPath = Viewport.RenderPath.Clone();
                var        fxaaRp           = ResourceCache.GetXmlFile(Assets.PostProcess.FXAA3);
                effectRenderPath.Append(fxaaRp);
                Viewport.RenderPath = effectRenderPath;
            }
            Renderer.SetViewport(0, Viewport);

            var zoneNode = scene.CreateChild();
            var zone     = zoneNode.CreateComponent <Zone>();

            zone.SetBoundingBox(new BoundingBox(-300.0f, 300.0f));
            zone.AmbientColor = new Color(1f, 1f, 1f);

            // UI
            coinsText = new Text();
            coinsText.HorizontalAlignment = HorizontalAlignment.Right;
            coinsText.SetFont(ResourceCache.GetFont(Assets.Fonts.Font), Graphics.Width / 20);
            UI.Root.AddChild(coinsText);


            hsCoinsText = new Text();
            hsCoinsText.HorizontalAlignment = HorizontalAlignment.Left;
            hsCoinsText.SetFont(ResourceCache.GetFont(Assets.Fonts.Font), Graphics.Width / 20);
            UI.Root.AddChild(hsCoinsText);
            Input.SetMouseVisible(true, false);

            // Background
            var background = new Background();

            scene.AddComponent(background);
            background.Start();

            // Lights:
            var lightNode = scene.CreateChild();

            lightNode.Position = new Vector3(0, -5, -40);
            lightNode.AddComponent(new Light {
                Range = 120, Brightness = 0.8f
            });

            // Game logic cycle
            bool firstCycle = true;

            while (true)
            {
                //
                StartMenu = scene.CreateComponent <StartMenu>();
                NewStartMenu?.Invoke(StartMenu);
                if (!firstCycle)
                {
                    FinishedGame?.Invoke(Coins);
                }
                await StartMenu.ShowStartMenu(!firstCycle);                 //wait for "start"

                StartMenu.Remove();
                RemovedStartMenu?.Invoke(StartMenu);

                await StartGame();

                firstCycle = false;
            }
        }