Пример #1
0
        protected override void Initialize()
        {
            base.Initialize();

            _hololensService     = WaveServices.GetService <HololensService>();
            _spatialInputManager = WaveServices.GetService <SpatialInputService>();
        }
        /// <summary>
        /// Initialize stereoscopic camera controller
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.headTrack = WaveServices.GetService <HeadTrackSensor>();

            this.leftLookAtEntity  = this.Owner.FindChild("leftLookAt");
            this.rightLookAtEntity = this.Owner.FindChild("rightLookAt");
            this.leftEyeEntity     = this.Owner.FindChild("leftEye");
            this.rightEyeEntity    = this.Owner.FindChild("rightEye");

            this.leftEye  = this.leftEyeEntity.FindComponent <Camera3D>();
            this.rightEye = this.rightEyeEntity.FindComponent <Camera3D>();

            this.leftLookAtTransform  = this.leftLookAtEntity.FindComponent <Transform3D>();
            this.rightLookAtTransform = this.rightLookAtEntity.FindComponent <Transform3D>();
            this.leftEyeTransform     = this.leftEyeEntity.FindComponent <Transform3D>();
            this.rightEyeTransform    = this.rightEyeEntity.FindComponent <Transform3D>();

            // Left eye
            this.leftEye.Viewport    = new Viewport(0, 0, 0.5f, 1);
            this.leftEye.FieldOfView = this.FieldOfView;
            this.leftEye.NearPlane   = this.NearPlane;
            this.leftEye.FarPlane    = this.FarPlane;

            // Right eye
            this.rightEye.Viewport    = new Viewport(0.5f, 0, 0.5f, 1);
            this.rightEye.FieldOfView = this.FieldOfView;
            this.rightEye.NearPlane   = this.NearPlane;
            this.rightEye.FarPlane    = this.FarPlane;

            this.isInitialized = true;
            this.RefreshCameraCalibration();
        }
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.LevelSelectionScene);

            this.navigationManager = WaveServices.GetService <NavigationManager>();
            this.storageService    = WaveServices.GetService <StorageService>();
        }
Пример #4
0
        protected override void CreateScene()
        {
            WaveServices.ScreenContextManager.SetDiagnosticsActive(true);

            this.Load(WaveContent.Scenes.MyScene);

            var kinectService = WaveServices.GetService <KinectService>();

            Texture2D texture = kinectService.ColorTexture;

            Entity sprite = new Entity()
                            .AddComponent(new Transform2D()
            {
                XScale = (float)this.VirtualScreenManager.VirtualWidth / (float)texture.Width,
                YScale = (float)this.VirtualScreenManager.VirtualHeight / (float)texture.Height,
            })
                            .AddComponent(new Sprite(texture))
                            .AddComponent(new SpriteRenderer(DefaultLayers.Opaque));

            EntityManager.Add(sprite);

            TextBlock label = new TextBlock()
            {
                Text              = string.Format("Kinect sensor is available: {0} ", kinectService.IsAvailable.ToString()),
                Margin            = new Thickness(20, 20, 20, 20),
                VerticalAlignment = VerticalAlignment.Bottom,
            };

            EntityManager.Add(label);
        }
Пример #5
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.InitialScene);

            var animationService = WaveServices.GetService <AnimationService>();

            var gui = this.EntityManager.Find <Entity>("GUI");

            this.maxScore      = gui.FindChild("maxscore").FindComponent <TextComponent>();
            this.currentScore  = gui.FindChild("currentscore").FindComponent <TextComponent>();
            this.loadingEntity = gui.FindChild("loading");

            var tapToPlayEntity = gui.FindChild("taptoplay");
            var tapToPlay       = tapToPlayEntity.FindComponent <TouchGestures>();

            tapToPlay.TouchTap += this.TapToPlayTouchTap;

            animationService.CreatePulseAnimation(tapToPlayEntity, 350).Run();

            var player = this.EntityManager.Find("sceneEntity.player");

            animationService.CreateIdleAnimation(player, 175).Run();

            WaveServices.GetService <AudioService>().Play(Audio.Music.MrJellyRolls_mp3, 0.3f);
        }
Пример #6
0
        public override void Initialize(IApplication application)
        {
            base.Initialize(application);

            // Load storage game data
            GameStorage gameStorage;

            if (WaveServices.Storage.Exists <GameStorage>())
            {
                gameStorage = WaveServices.Storage.Read <GameStorage>();
            }
            else
            {
                gameStorage = new GameStorage();
            }

            Catalog.RegisterItem <GameStorage>(gameStorage);

            // Register the SoundManager service
            WaveServices.RegisterService <SoundManager>(new SoundManager());

            // Play background music
            WaveServices.MusicPlayer.Play(new MusicInfo(WaveContent.Assets.Audio.bg_music_mp3));
            WaveServices.MusicPlayer.IsRepeat = true;

            // GameBackContext is visible always at the background.
            // For this reason the behavior is set to Draw and Update when the scene is in background.
            var backContext = new ScreenContext("GameBackContext", new GameScene());

            backContext.Behavior = ScreenContextBehaviors.DrawInBackground | ScreenContextBehaviors.UpdateInBackground;

            //On init show the Main menu
            WaveServices.ScreenContextManager.Push(backContext);
            WaveServices.ScreenContextManager.Push(new ScreenContext("MenuContext", new MenuScene()));
        }
Пример #7
0
        /// <summary>
        /// Resolves the dependencies needed for this instance to work.
        /// </summary>
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.kinectService = WaveServices.GetService <KinectService>();

            this.colorFactorX = 1;
            this.colorFactorY = 1;
            this.depthFactorX = 1;
            this.depthFactorY = 1;

            ////if (this.kinectService != null)
            ////{
            ////    if (WaveServices.ViewportManager != null && WaveServices.ViewportManager.IsActivated)
            ////    {
            ////        this.colorFactorX = (float)WaveServices.ViewportManager.VirtualWidth / (float)this.kinectService.ColorTexture.Width;
            ////        this.colorFactorY = (float)WaveServices.ViewportManager.VirtualHeight / (float)this.kinectService.ColorTexture.Height;
            ////        this.depthFactorX = (float)WaveServices.ViewportManager.VirtualWidth / (float)this.kinectService.DepthTexture.Width;
            ////        this.depthFactorY = (float)WaveServices.ViewportManager.VirtualHeight / (float)this.kinectService.DepthTexture.Height;
            ////    }
            ////    else
            ////    {
            ////        this.colorFactorX = (float)WaveServices.Platform.ScreenWidth / (float)this.kinectService.ColorTexture.Width;
            ////        this.colorFactorY = (float)WaveServices.Platform.ScreenHeight / (float)this.kinectService.ColorTexture.Height;
            ////        this.depthFactorX = (float)WaveServices.Platform.ScreenWidth / (float)this.kinectService.DepthTexture.Width;
            ////        this.depthFactorY = (float)WaveServices.Platform.ScreenHeight / (float)this.kinectService.DepthTexture.Height;
            ////    }
            ////}

            this.DrawPoints2DProjected = new List <Vector2>();
            this.DrawPoints3D          = new List <Vector3>();
            this.DrawLines             = new List <Line>();
            this.DrawOrientations      = new List <Line>();
        }
Пример #8
0
        /// <summary>
        /// Allows to execute custom logic during the initialization of this instance.
        /// </summary>
        /// <exception cref="System.Exception">Invalid configure rendering</exception>
        protected override void Initialize()
        {
            base.Initialize();

            this.mixedRealityService = WaveServices.GetService <MixedRealityService>();
            this.spatialInputService = WaveServices.GetService <SpatialInputService>();
        }
Пример #9
0
        private void TapToPlayTouchTap(object sender, GestureEventArgs e)
        {
            if (count == 0)
            {
                count++;

                GameScene gameScene = null;

                ScreenTransition transition = new CoverTransition(TimeSpan.FromMilliseconds(500), CoverTransition.EffectOptions.FromTop);
                transition.EaseFunction = new CubicEase()
                {
                    EasingMode = EasingMode.EaseInOut
                };

                this.loadingEntity.IsVisible = true;
                var animationService = WaveServices.GetService <AnimationService>();
                animationService.CreatePulseAnimation(this.loadingEntity, 1000).Run();

#if MAC
                gameScene = new GameScene();
                gameScene.Initialize(WaveServices.GraphicsDevice);
                WaveServices.ScreenContextManager.To(new ScreenContext(gameScene), transition);
#else
                WaveBackgroundTask.Run(() =>
                {
                    gameScene = new GameScene();
                    gameScene.Initialize(WaveServices.GraphicsDevice);
                })
                .ContinueWith((t) =>
                {
                    WaveServices.ScreenContextManager.To(new ScreenContext(gameScene), transition);
                });
#endif
            }
        }
Пример #10
0
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.audioService = WaveServices.GetService <AudioService>();
            this.hadHorn      = false;
        }
Пример #11
0
        override void CreateScene()
        {
            this.Load(WaveContent.Scenes.GameOverScene);
            this.EntityManager.Find("defaultCamera2D").FindComponent <Camera2D>().CenterScreen();

            this.gameStorage = Catalog.GetItem <GameStorage>();
            this.gameScene   = WaveServices.ScreenContextManager.FindContextByName("GamePlay")
                               .FindScene <GamePlayScene>();

            if (this.gameStorage.BestScore < this.gameScene.CurrentScore)
            {
                // Update best score
                this.gameStorage.BestScore = this.gameScene.CurrentScore;

                // Save storage game data
                GameStorage gameStorage = Catalog.GetItem <GameStorage>();
                WaveServices.Storage.Write <GameStorage>(gameStorage);

#if ANDROID
                await WaveServices.GetService <SocialService>().AddNewScore(LeaderboardCode, this.gameScene.CurrentScore);

                await WaveServices.GetService <SocialService>().ShowLeaderboard(LeaderboardCode);
#endif
            }

            this.CreateUI();

            // Music Volume
            WaveServices.MusicPlayer.Volume = 0.2f;
        }
Пример #12
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

            WaveServices.RegisterService(new SpatialInputService());
            WaveServices.RegisterService(new KeywordRecognizerService());
        }
        /// <summary>
        /// Resolves the dependencies needed for this instance to work.
        /// </summary>
        protected override void ResolveDependencies()
        {
            // Register Noesis service
            NoesisService svc = WaveServices.GetService <NoesisService>();

            if (svc == null)
            {
                WaveServices.RegisterService(new NoesisService());
            }

            base.ResolveDependencies();

            this.camera = this.Owner.FindComponent <Camera>(false);

#if OPENGL
            if (this.usingOpenGL)
            {
                GL.GetInteger(GetPName.MaxTextureImageUnits, out this.maxTextureUnits);
            }
#endif

#if ANDROID
            var activityManager = (ActivityManager)(Game.Current.Application as Activity).GetSystemService(Android.Content.Context.ActivityService);
            var version         = activityManager.DeviceConfigurationInfo.GlEsVersion;

            this.disableSamplers = !version.StartsWith("2");
#elif OPENGL
            this.disableSamplers = true;
#endif
        }
Пример #14
0
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();
            this.firstUpdate = true;

            this.animationService = WaveServices.GetService <AnimationService>();
            this.audioService     = WaveServices.GetService <AudioService>();

            var gui = this.EntityManager.Find <Entity>("GUI");

            this.scoreControl = gui.FindChild("currentscore").FindComponent <TextComponent>();

            var gameController = this.EntityManager.Find("GameController");

            this.terrainGeneratorBehavior = gameController.FindComponent <TerrainGeneratorBehavior>();

            this.leftOrientation  = Quaternion.CreateFromYawPitchRoll(MathHelper.PiOver2, 0f, 0f);
            this.rightOrientation = Quaternion.CreateFromYawPitchRoll(-MathHelper.PiOver2, 0f, 0f);
            this.upOrientation    = Quaternion.CreateFromYawPitchRoll(0f, 0f, 0f);
            this.downOrientation  = Quaternion.CreateFromYawPitchRoll(MathHelper.Pi, 0f, 0f);

            this.desiredOrientation = upOrientation;
            this.currentOrientation = this.desiredOrientation;

            this.desiredScale = Vector3.One;
            this.currentScale = this.desiredScale;

            this.jumpSounds = new Audio.Sfx[] { Audio.Sfx.jump1_wav, Audio.Sfx.jump2_wav, Audio.Sfx.jump3_wav };
        }
Пример #15
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.CornflowerBlue;
            //RenderManager.DebugLines = true;

            TextBlock levelText = new TextBlock("levelText")
            {
                Foreground          = Color.Black,
                Text                = "Level " + WaveServices.GetService <LevelInformationService>().Level,
                Margin              = new Thickness(20f),
                HorizontalAlignment = HorizontalAlignment.Left,
            };

            EntityManager.Add(levelText);

            TextBlock toasterPosition = new TextBlock("ToasterPosition")
            {
                Text   = "Klicken Sie auf den Toaster um zu beginnen!",
                Margin = new Thickness(20, 50, 0, 0),
            };

            EntityManager.Add(toasterPosition);

            CreateKitchen();
            CreateLight();
            CreateCamera();
            CreateToaster();
            //CreatePlate();

            WaveServices.GetService <AnalyticsService>().TagEvent("Page opened", "Page", "In-game");
        }
Пример #16
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.GameScene);

            this.matchmakingClientService = WaveServices.GetService <MatchmakingClientService>();
            this.matchmakingClientService.StateChanged += this.MatchmakingClientService_StateChanged;
        }
Пример #17
0
        /// <summary>
        /// Performs further custom initialization for this instance.
        /// </summary>
        /// <remarks>
        /// By default this method does nothing.
        /// </remarks>
        protected override void Initialize()
        {
            base.Initialize();

            this.kinectService = WaveServices.GetService <KinectService>();
            this.outPosition   = new Vector2(-500, -500);
        }
Пример #18
0
        public override void Initialize(IApplication application)
        {
            base.Initialize(application);

#if DEBUG
            if (WaveServices.Storage.Exists <GameStorage>())
            {
                WaveServices.Storage.Delete <GameStorage>();
            }
#endif

            // Load storage game data
            if (WaveServices.Storage.Exists <GameStorage>())
            {
                _gameStorage = WaveServices.Storage.Read <GameStorage>();
            }
            else
            {
                _gameStorage = new GameStorage
                {
                    IsMusicEnabled   = true,
                    AreSoundsEnabled = true,
                    Record           = 0
                };
            }
            Catalog.RegisterItem(_gameStorage);

            WaveServices.RegisterService(new SimpleSoundService());

            StartMusic();

            var screenContext = new ScreenContext(new MainMenuScene(), new PlayersPopupScene(), new RulesScene());
            var transition    = new ColorFadeTransition(Color.White, TimeSpan.FromSeconds(1));
            WaveServices.ScreenContextManager.To(screenContext, transition);
        }
Пример #19
0
        protected override void Initialize()
        {
            base.Initialize();

            this.CurrentEpisode = 0;

            if (WaveServices.Platform.IsEditor ||
                (string.IsNullOrEmpty(this.ShipEntityPath)) ||
                (string.IsNullOrEmpty(this.TerrainEntityPath)))
            {
                return;
            }

            this.randy = WaveServices.Random;

            this.shipComponent = this.Owner.Find(this.ShipEntityPath)?.FindComponent <ShipComponent>();
            this.terrain       = this.Owner.Find(this.TerrainEntityPath)?.FindComponent <TerrainMeshComponent>();

            this.networkService = WaveServices.GetService <Lunar3DNetworkService>();

            if (this.networkService != null)
            {
                this.networkService.ActionReveiced += this.OnActionReceived;
                this.networkService.OnReset        += this.OnReset;
                this.networkService.Updated        += this.OnUpdated;
                this.networkService.Rendered       += this.OnRendered;

                this.Owner.Scene.Pause();
                this.Owner.Scene.IsVisible = false;
            }
            else
            {
                this.Reset();
            }
        }
Пример #20
0
        public void ShootBullet(bool player, float initX, float initY, float velocityX, float velocityY)
        {
            Entity bullet          = player ? this.Bullets[BulletIndex] : this.EnemyBullets[EnemyBulletIndex];
            var    bulletTransform = bullet.FindComponent <Transform2D>();

            bulletTransform.X = initX;
            bulletTransform.Y = initY;

            var bulletBehavior = bullet.FindComponent <BulletBehavior>();

            bulletBehavior.SpeedX = velocityX;
            bulletBehavior.SpeedY = velocityY;

            bullet.Enabled = true;

            if (player)
            {
                switch (WaveServices.Random.Next(0, 3))
                {
                case 0:
                    WaveServices.GetService <SoundManager>().PlaySound(SoundManager.SOUNDS.Blast0);
                    break;

                case 1:
                    WaveServices.GetService <SoundManager>().PlaySound(SoundManager.SOUNDS.Blast1);
                    break;

                case 2:
                    WaveServices.GetService <SoundManager>().PlaySound(SoundManager.SOUNDS.Blast2);
                    break;
                }
            }
        }
Пример #21
0
        private void BackToInitial()
        {
            WaveServices.GetService <ScoreService>().RegisterScore(this.currentScore);

            InitialScene intialScene = null;

            ScreenTransition transition = new CoverTransition(TimeSpan.FromMilliseconds(500), CoverTransition.EffectOptions.FromTop);

            transition.EaseFunction = new CubicEase()
            {
                EasingMode = EasingMode.EaseInOut
            };

#if MAC
            intialScene = new InitialScene();
            intialScene.Initialize(WaveServices.GraphicsDevice);
            WaveServices.ScreenContextManager.To(new ScreenContext(intialScene), transition);
#else
            WaveBackgroundTask.Run(() =>
            {
                intialScene = new InitialScene();
                intialScene.Initialize(WaveServices.GraphicsDevice);
            })
            .ContinueWith((t) =>
            {
                WaveServices.ScreenContextManager.To(new ScreenContext(intialScene), transition);
            });
#endif
        }
Пример #22
0
        protected override void CreateScene()
        {
            EntityManager.Add(CreateEntity.Background());

            CreateUI();

            WaveServices.GetService <AnalyticsService>().TagEvent("Page opened", "Page", "Options");
        }
Пример #23
0
        private void InitializeSoundbank()
        {
            SoundBank soundBank = new SoundBank(Assets);

            WaveServices.SoundPlayer.RegisterSoundBank(soundBank);

            soundBank.Add(WaveServices.GetService <SoundService>().Sound["buttonClick"]);
        }
        protected override void CreateScene()
        {
            EntityManager.Add(CreateEntity.Background());

            _achievements = WaveServices.GetService <AchievementService>().Achievements;

            CreateUI();
        }
Пример #25
0
        public GameScene(int playerSpriteIndex)
        {
            this.playerSpriteIndex = playerSpriteIndex;

            this.networkService = WaveServices.GetService <NetworkService>();
            //Register the scene to use the synchronization components. This scene sync the entities in the scenes with the same sceneId in other clients.
            this.networkManager = this.networkService.RegisterScene(this, GameSceneIdentifier);
        }
Пример #26
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

            this.matchmakingClientService = WaveServices.GetService <MatchmakingClientService>();

            this.CreateUi();
        }
Пример #27
0
        protected override void Start()
        {
            base.Start();
            var keyboardService = WaveServices.GetService <KeyboardActionsService>();

            keyboardService?.SetScene(this);
            this.EntityManager.FindFirstComponentOfType <Components.EnginesComponent>().ApplyInitialForce();
        }
Пример #28
0
        public SelectPlayerScene()
        {
            this.networkService = WaveServices.GetService <NetworkService>();
            this.networkService.MessageReceivedFromClient += this.HostMessageReceived;
            this.networkService.MessageReceivedFromHost   += this.ClientMessageReceived;

            this.assignedPlayerSprites = new Dictionary <int, string>();
        }
Пример #29
0
        private async void Play_Click(object sender, EventArgs e)
        {
            var logIn = await WaveServices.GetService <SocialService>().Login();

            if (!logIn)
            {
                return;
            }
Пример #30
0
        private void InitializeAndRegisterSocialService()
        {
            var socialService = new SocialService();

            socialService.Initialize(null);

            WaveServices.RegisterService(socialService);
        }