Пример #1
0
        public override void Update(GameTime gameTime)
        {
            //"Chief, let's see if we can find a way to open this door." - Cortana
            if (!HasInputScore)
            {
                if (TheLastSliceGame.Instance.IsUserLoggedIn() && !HasLoggedOut)
                {
                    TheLastSliceGame.Instance.GameService.Logout();
                    HasLoggedOut = true;
                }

                if (gameTime.TotalGameTime.TotalMilliseconds > CursorTimerMS.TotalMilliseconds)
                {
                    ShowCursor    = !ShowCursor;
                    CursorTimerMS = TimeSpan.FromMilliseconds(gameTime.TotalGameTime.TotalMilliseconds + 500);
                }

                if (!String.IsNullOrEmpty(Initials) && Initials.Count() <= 3 && TheLastSliceGame.InputManager.IsInputPressed(Keys.Back))
                {
                    Initials = Initials.Remove(Initials.Length - 1);
                }

                if (Initials.Count() < 3)
                {
                    Vector2 vector = Name.MeasureString(Initials);
                    foreach (Keys key in ValidKeys)
                    {
                        if (TheLastSliceGame.InputManager.IsInputPressed(key))
                        {
                            Initials += key.ToString();
                            break;
                        }
                    }
                }
                else
                {
                    if (CustomWinStrings.Count() == 0 && TheLastSliceGame.InputManager.IsInputPressed(Keys.Enter))
                    {
                        TheLastSliceGame.Instance.GameWinAsync();
                        HasInputScore = true;
                    }
                }
            }
            else
            {
                if (TheLastSliceGame.Instance.IsUserLoggedIn() && !Posted)
                {
                    TheLastSliceGame.Instance.PostScoreAsync(LastPlayerScore.ToString(), Initials);
                    Posted = true;
                    TheLastSliceGame.Instance.AppInsights.PostScoreSuccess();
                }
            }

            ArrowLeft.Update(gameTime);
            ArrowRight.Update(gameTime);
            Menu.Update(gameTime);
        }
Пример #2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            TheLastSliceGame.Instance.IsMouseVisible = false;
            if (CustomWinStrings.Count > 0)
            {
                if (TheLastSliceGame.Instance.GameService.IsSuccessStatusCode)
                {
                    DrawStrings(spriteBatch, CustomWinStrings.ToArray(), YouWin, 150, 40);
                }
                else
                {
                    YouWinString[0]  = CustomWinStrings[0].Replace("\"", "") + "#" + TryAgain;
                    Posted           = false;
                    Initials         = "";
                    HasInputScore    = false;
                    CustomWinStrings = new List <String>();
                }
            }
            else
            {
                DrawStrings(spriteBatch, YouWinString, YouWin, 50, 40);

                // spriteBatch.DrawString(Text, "Score: " + LastPlayerScore, new Vector2(TheLastSliceGame.GameWidth / 2 - 60, 140), ColorYellow);

                DrawStrings(spriteBatch, EnterNameString, YouWin, 200, 40);
                if (!HasInputScore && Initials.Count() >= 3)
                {
                    ArrowLeft.Draw(spriteBatch);
                    ArrowRight.Draw(spriteBatch);
                    Menu.Draw(spriteBatch);
                }
                if (HasInputScore && !TheLastSliceGame.Instance.IsUserLoggedIn())
                {
                    DrawStrings(spriteBatch, LoginString, YouWin, 500, 40);
                }

                int xPos = TheLastSliceGame.Instance.GameWidth / 2 - 110;
                for (int i = 0; i < Initials.Count(); i++)
                {
                    spriteBatch.DrawString(Name, Initials.ElementAt(i).ToString(), new Vector2(xPos, 340), Color.White);
                    if (i < 2)
                    {
                        xPos += 88;
                    }
                }

                if (ShowCursor)
                {
                    spriteBatch.DrawString(Name, "_", new Vector2(xPos, 350), Color.White);
                }
            }
        }