Esempio n. 1
0
        public override int GetHashCode()
        {
            int hashCode = 1784892452;

            if (BannerEnabled != null)
            {
                hashCode += BannerEnabled.GetHashCode();
            }

            if (BannerText != null)
            {
                hashCode += BannerText.GetHashCode();
            }

            if (BannerCtaText != null)
            {
                hashCode += BannerCtaText.GetHashCode();
            }

            if (BannerCtaUrl != null)
            {
                hashCode += BannerCtaUrl.GetHashCode();
            }

            if (Errors != null)
            {
                hashCode += Errors.GetHashCode();
            }

            return(hashCode);
        }
Esempio n. 2
0
        private void UpdatePlayfieldSize()
        {
            // Size of player wrt size of playfield, putting ourselves low on the screen.
            this.screenRect.X      = 0;
            this.screenRect.Y      = 0;
            this.screenRect.Width  = this.playfield.ActualWidth;
            this.screenRect.Height = this.playfield.ActualHeight;

            BannerText.UpdateBounds(this.screenRect);

            this.playerBounds.X      = 0;
            this.playerBounds.Width  = this.playfield.ActualWidth;
            this.playerBounds.Y      = this.playfield.ActualHeight * 0.2;
            this.playerBounds.Height = this.playfield.ActualHeight * 0.75;

            foreach (var player in this.players)
            {
                player.Value.SetBounds(this.playerBounds);
            }

            Rect fallingBounds = this.playerBounds;

            fallingBounds.Y      = 0;
            fallingBounds.Height = playfield.ActualHeight;
            if (this.myFallingThings != null)
            {
                this.myFallingThings.SetBoundaries(fallingBounds);
            }
        }
Esempio n. 3
0
 protected override void InternalRun(string[] args)
 {
     if (args.Contains("/service-run", StringComparer.OrdinalIgnoreCase))
     {
         Directory.SetCurrentDirectory(AppContext.BaseDirectory);
         Core.Log.LibDebug("Starting...");
         Core.Log.InfoBasic("Current Directory: {0}", Directory.GetCurrentDirectory());
         InitAction?.Invoke();
         if (!string.IsNullOrWhiteSpace(BannerText))
         {
             var bannerText = BannerText.Split("\r\n");
             foreach (var line in bannerText)
             {
                 Core.Log.InfoBasic(line);
             }
         }
         Core.Log.InfoBasic("*** RUNNING AS WINDOWS SERVICE ***");
         ShowFullHeader();
         try
         {
             var win32Service = new Win32Service(ServiceName, Service);
             var serviceHost  = new Win32ServiceHost(win32Service);
             serviceHost.Run();
         }
         catch (Exception ex)
         {
             Core.Log.Write(ex);
         }
     }
     else
     {
         base.InternalRun(args);
     }
 }
Esempio n. 4
0
        private void CheckPlayers()
        {
            foreach (var player in this.players)
            {
                if (!player.Value.IsAlive)
                {
                    // Player left scene since we aren't tracking it anymore, so remove from dictionary
                    this.players.Remove(player.Value.GetId());
                    SetStatus(StatusKeySkeleton, StatusSkeletonGone);
                    break;
                }
            }

            // Count alive players
            int alive = this.players.Count(player => player.Value.IsAlive);

            if (alive != this.playersAlive)
            {
                if ((this.playersAlive == 0) && (this.mySpeechRecognizer != null))
                {
                    BannerText.NewBanner(
                        Properties.Resources.Vocabulary,
                        this.screenRect,
                        true,
                        System.Windows.Media.Color.FromArgb(200, 255, 255, 255));
                }

                this.playersAlive = alive;
            }
        }
Esempio n. 5
0
        private void HandleGameTimer(int param)
        {
            // Every so often, notify what our actual framerate is
            if ((this.frameCount % 100) == 0)
            {
                this.myFallingThings.SetFramerate(1000.0 / this.actualFrameTime);
            }

            // Advance animations, and do hit testing.
            for (int i = 0; i < NumIntraFrames; ++i)
            {
                foreach (var pair in this.players)
                {
                    HitType hit = this.myFallingThings.LookForHits(pair.Value.Segments, pair.Value.GetId());
                    if ((hit & HitType.Squeezed) != 0)
                    {
                        this.squeezeSound.Play();
                    }
                    else if ((hit & HitType.Popped) != 0)
                    {
                        this.popSound.Play();
                    }
                    else if ((hit & HitType.Hand) != 0)
                    {
                        this.hitSound.Play();
                    }
                }

                this.myFallingThings.AdvanceFrame();
            }

            // Draw new Wpf scene by adding all objects to canvas
            playfield.Children.Clear();
            this.myFallingThings.DrawFrame(this.playfield.Children);
            foreach (var player in this.players)
            {
                player.Value.Draw(playfield.Children);
            }

            BannerText.Draw(playfield.Children);
            FlyingText.Draw(playfield.Children);

            this.CheckPlayers();
        }
Esempio n. 6
0
        private void HandleGameTimer(int param)
        {
            // Every so often, notify what our actual framerate is
            if ((frameCount % 100) == 0)
            {
                myFallingThings.SetFramerate(1000.0 / actualFrameTime);
            }

            // Advance animations, and do hit testing.
            for (int i = 0; i < NumIntraFrames; ++i)
            {
                foreach (var pair in players)
                {
                    HitType hit = myFallingThings.LookForHits(pair.Value.Segments, pair.Value.GetId());
                    if ((hit & HitType.Correct) != 0)
                    {
                        squeezeSound.Play();
                        FlyingText.NewFlyingText(screenRect.Width / 30, new Point(screenRect.Width / 2, screenRect.Height / 2), "YES!");
                    }
                    else if ((hit & HitType.Incorrect) != 0)
                    {
                        popSound.Play();
                        FlyingText.NewFlyingText(screenRect.Width / 30, new Point(screenRect.Width / 2, screenRect.Height / 2), "Wrong :(");
                    }
                }

                myFallingThings.AdvanceFrame();
            }



            // Draw new Wpf scene by adding all objects to canvas
            playfield.Children.Clear();
            myFallingThings.DrawFrame(playfield.Children);
            foreach (var player in players)
            {
                player.Value.Draw(playfield.Children);
            }

            BannerText.Draw(playfield.Children);
            FlyingText.Draw(playfield.Children);

            this.CheckPlayers();
        }
Esempio n. 7
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is RetrieveObsMigrationProfileResponse other &&
                   ((BannerEnabled == null && other.BannerEnabled == null) || (BannerEnabled?.Equals(other.BannerEnabled) == true)) &&
                   ((BannerText == null && other.BannerText == null) || (BannerText?.Equals(other.BannerText) == true)) &&
                   ((BannerCtaText == null && other.BannerCtaText == null) || (BannerCtaText?.Equals(other.BannerCtaText) == true)) &&
                   ((BannerCtaUrl == null && other.BannerCtaUrl == null) || (BannerCtaUrl?.Equals(other.BannerCtaUrl) == true)) &&
                   ((Errors == null && other.Errors == null) || (Errors?.Equals(other.Errors) == true)));
        }
Esempio n. 8
0
        private void CheckPlayers()
        {
            foreach (var player in this.players)
            {
                if (!player.Value.IsAlive)
                {
                    // Player left scene since we aren't tracking it anymore, so remove from dictionary
                    this.players.Remove(player.Value.GetId());
                    break;
                }
            }

            // Count alive players
            int alive = this.players.Count(player => player.Value.IsAlive);

            if (alive != this.playersAlive)
            {
                if (alive == 2)
                {
                    this.myFallingThings.SetGameMode(GameMode.TwoPlayer);
                }
                else if (alive == 1)
                {
                    this.myFallingThings.SetGameMode(GameMode.Solo);
                }
                else if (alive == 0)
                {
                    this.myFallingThings.SetGameMode(GameMode.Off);
                }

                if ((this.playersAlive == 0) && (this.mySpeechRecognizer != null))
                {
                    BannerText.NewBanner(
                        Properties.Resources.Vocabulary,
                        this.screenRect,
                        true,
                        System.Windows.Media.Color.FromArgb(200, 255, 255, 255));
                }

                this.playersAlive = alive;
            }
        }