示例#1
0
文件: GameScene.cs 项目: wbgl/Samples
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.GameScene);

            this.matchmakingClientService = WaveServices.GetService <MatchmakingClientService>();
            this.matchmakingClientService.StateChanged += this.MatchmakingClientService_StateChanged;
        }
示例#2
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 };
        }
示例#3
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();
            }
        }
示例#4
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");
        }
示例#5
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);
        }
示例#6
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;
        }
示例#7
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
        }
示例#8
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);
        }
示例#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
        /// <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>();
        }
示例#11
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;
                }
            }
        }
示例#12
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>();
        }
        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>();
        }
        /// <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
        }
示例#17
0
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.audioService = WaveServices.GetService <AudioService>();
            this.hadHorn      = false;
        }
示例#18
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);
        }
        protected override void CreateScene()
        {
            EntityManager.Add(CreateEntity.Background());

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

            CreateUI();
        }
示例#20
0
        public SelectPlayerScene()
        {
            this.networkService = WaveServices.GetService <NetworkService>();
            this.networkService.MessageReceivedFromClient += this.HostMessageReceived;
            this.networkService.MessageReceivedFromHost   += this.ClientMessageReceived;

            this.assignedPlayerSprites = new Dictionary <int, string>();
        }
示例#21
0
        private async void Play_Click(object sender, EventArgs e)
        {
            var logIn = await WaveServices.GetService <SocialService>().Login();

            if (!logIn)
            {
                return;
            }
示例#22
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);
        }
示例#23
0
文件: MainScene.cs 项目: wbgl/Samples
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

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

            this.CreateUi();
        }
示例#24
0
        protected override void CreateScene()
        {
            EntityManager.Add(CreateEntity.Background());

            CreateUI();

            WaveServices.GetService <AnalyticsService>().TagEvent("Page opened", "Page", "Options");
        }
示例#25
0
        protected override void Start()
        {
            base.Start();
            var keyboardService = WaveServices.GetService <KeyboardActionsService>();

            keyboardService?.SetScene(this);
            this.EntityManager.FindFirstComponentOfType <Components.EnginesComponent>().ApplyInitialForce();
        }
示例#26
0
        private void InitializeSoundbank()
        {
            SoundBank soundBank = new SoundBank(Assets);

            WaveServices.SoundPlayer.RegisterSoundBank(soundBank);

            soundBank.Add(WaveServices.GetService <SoundService>().Sound["buttonClick"]);
        }
示例#27
0
        protected override void DefaultValues()
        {
            base.DefaultValues();

            this.maxRotation  = MathHelper.ToRadians(20);
            this.inputManager = WaveServices.Input;
            this.timerFactory = WaveServices.TimerFactory;
            this.soundManager = WaveServices.GetService <SoundManager>();
        }
示例#28
0
        protected override void Start()
        {
            base.Start();

            var scoreService = WaveServices.GetService <ScoreService>();

            this.maxScore.Text     = scoreService.MaxScore.ToString();
            this.currentScore.Text = scoreService.CurrentScore.ToString();
        }
示例#29
0
        public void DoNavigation()
        {
            var navService = WaveServices.GetService <NavigationService>();

            if (navService != null)
            {
                navService.Navigate(this.NavigationCommand);
            }
        }
示例#30
0
        protected override void Initialize()
        {
            base.Initialize();

            this.hololensService     = WaveServices.GetService <HololensService>();
            this.spatialInputManager = WaveServices.GetService <SpatialInputService>();

            this.PlaceEntity();
        }