public FloorDisplay(int left, int width, int floor, int friendRank, int globalRank, double bestTime, double parTime) { m_iLeft = left; m_iWidth = width; m_iFloor = floor; m_iRank_Friends = friendRank; m_iRank_Global = globalRank; m_dfBestTime = bestTime; int halfWidth = width >> 1; int quarterWidth = halfWidth >> 1; int textGap = 10; int textLeft = left + quarterWidth - textGap; int textMid = left + halfWidth; int textRight = textMid + textGap + quarterWidth; m_BestTimeLabel = new UILabel("Best Time", textLeft, 0, Color.LightYellow, Assets.HelpFont, UILabel.XMode.Center); m_FriendRankLabel = new UILabel("Friends Rank", textMid, 0, Color.LightYellow, Assets.HelpFont, UILabel.XMode.Center); m_GlobalRankLabel = new UILabel("Global Rank", textRight, 0, Color.LightYellow, Assets.HelpFont, UILabel.XMode.Center); m_BestTimeDisplay = new UILabel(m_dfBestTime == 0 ? "- -" : Happiness.TimeString(m_dfBestTime), textLeft, 0, (bestTime <= parTime) ? Color.Green : Color.Red, Assets.HelpFont, UILabel.XMode.Center); m_FriendRankDisplay = new UILabel(m_iRank_Friends.ToString("n0"), textMid, 0, Color.White, Assets.HelpFont, UILabel.XMode.Center); m_GlobalRankDisplay = new UILabel(m_iRank_Global.ToString("n0"), textRight, 0, Color.White, Assets.HelpFont, UILabel.XMode.Center); m_iTextLineSpace = 20; m_fHeight = (Assets.HelpFont.MeasureString("qQ").Y * 2);// + m_iTextLineSpace; m_FloorDisplay = new UILabel(floor.ToString(), left + 4, 0, Color.Goldenrod, Assets.DialogFont, UILabel.XMode.Left); }
public void Draw(Renderer sb) { if (!m_bHidden) { Happiness.ShadowString(sb, m_Font, m_szText, m_vPosition, m_Color); } }
public void Draw(Renderer sb) { // Draw frame & background sb.Draw(Assets.TransparentBox, m_Rect, Color.DarkGray); sb.Draw(Assets.TransparentBox, m_Rect, Color.DarkGray); sb.Draw(Assets.TransparentBox, m_Rect, Color.DarkGray); // Draw the title Happiness.ShadowString(sb, Assets.MenuFont, m_szTitleText, m_vTitlePosition, Color.Goldenrod); if (m_szStatusText != null) { Happiness.ShadowString(sb, Assets.HelpFont, m_szStatusText, m_vStatusPosition, Color.Red); } switch (m_Mode) { case Mode.SignInButtons: foreach (UIButton button in m_SignInButtons) { button.Draw(sb); } break; case Mode.EmailInput: DrawEmailInput(sb); break; } }
public void SavePuzzle() { string saveName = Happiness.PuzzleSaveName(m_Puzzle.m_iSize, m_iPuzzleIndex); FileStream fs = File.Open(saveName, FileMode.Create); BinaryWriter bw = new BinaryWriter(fs); bw.Write(ElapsedTime); bw.Write(m_iHintCount); bw.Write(m_iMegaHintCount); bw.Write(m_History.Count); foreach (Action a in m_History) { a.Save(bw, m_Puzzle.m_iSize); } for (int iRow = 0; iRow < m_Puzzle.m_iSize; iRow++) { for (int iCol = 0; iCol < m_Puzzle.m_iSize; iCol++) { for (int iIcon = 0; iIcon < m_Puzzle.m_iSize; iIcon++) { bw.Write(m_Puzzle.m_Rows[iRow].m_Cells[iCol].m_bValues[iIcon]); } } } bw.Close(); }
public void LoadPuzzle() { string saveName = Happiness.PuzzleSaveName(m_Puzzle.m_iSize, m_iPuzzleIndex); if (File.Exists(saveName)) { FileStream fs = File.OpenRead(saveName); BinaryReader br = new BinaryReader(fs); double elapsed = br.ReadDouble(); m_PuzzleStart = m_PuzzleStart.AddSeconds(-elapsed); m_iHintCount = br.ReadInt32(); m_iMegaHintCount = br.ReadInt32(); int historyCount = br.ReadInt32(); m_History = new List <Action>(); for (int i = 0; i < historyCount; i++) { m_History.Add(Action.Load(br, m_Puzzle.m_iSize)); } for (int iRow = 0; iRow < m_Puzzle.m_iSize; iRow++) { for (int iCol = 0; iCol < m_Puzzle.m_iSize; iCol++) { for (int iIcon = 0; iIcon < m_Puzzle.m_iSize; iIcon++) { m_Puzzle.m_Rows[iRow].m_Cells[iCol].m_bValues[iIcon] = br.ReadBoolean(); } m_Puzzle.m_Rows[iRow].m_Cells[iCol].m_iFinalIcon = m_Puzzle.m_Rows[iRow].m_Cells[iCol].GetRemainingIcon(); } } br.Close(); } }
public override void Draw(SpriteBatch spriteBatch) { // Draw background spriteBatch.Draw(Assets.Background, new Rectangle(0, 0, Game.ScreenWidth, Game.ScreenHeight), Color.White); // Draw Logo spriteBatch.Draw(Assets.Logo, m_LogoRectangle, Color.White); // Draw Credits Happiness.ShadowString(spriteBatch, Assets.MenuFont, m_szCreditLine, m_vCreditPosition, Color.Goldenrod); Happiness.ShadowString(spriteBatch, Assets.DialogFont, m_szMusicCreditLine, m_vMusicCreditPosition, Color.LightGray); Happiness.ShadowString(spriteBatch, Assets.DialogFont, m_szArtistCreditLine, m_vArtistCreditPosition, Color.LightGray); // Show sign in dialog if (m_SignInDialog != null) { m_SignInDialog.Draw(spriteBatch); } if (m_szWaitText != null) { Assets.WaitIcon.Draw(spriteBatch, m_WaitRect, Color.White); Happiness.ShadowString(spriteBatch, Assets.HelpFont, m_szWaitText, Happiness.CenterText(m_WaitTextCenter, m_szWaitText, Assets.HelpFont), Color.White); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var g = new Happiness(); SetContentView((View)g.Services.GetService(typeof(View))); g.Run(); }
public void SavePuzzle() { string saveName = Happiness.PuzzleSaveName(m_Puzzle.m_iSize, m_iPuzzleIndex); MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); bw.Write(ElapsedTime); bw.Write(m_iHintCount); bw.Write(m_iMegaHintCount); bw.Write(m_History.Count); foreach (Action a in m_History) { a.Save(bw, m_Puzzle.m_iSize); } for (int iRow = 0; iRow < m_Puzzle.m_iSize; iRow++) { for (int iCol = 0; iCol < m_Puzzle.m_iSize; iCol++) { for (int iIcon = 0; iIcon < m_Puzzle.m_iSize; iIcon++) { bw.Write(m_Puzzle.m_Rows[iRow].m_Cells[iCol].m_bValues[iIcon]); } } } FileManager.Instance.WriteAllBytes(saveName, ms.ToArray()); bw.Dispose(); }
void DrawEmailInput(Renderer sb) { // Draw email field m_Email.Draw(sb); Happiness.ShadowString(sb, Assets.HelpFont, m_szEmailText, m_vEmailLabelPosition, Color.LightGray); // Draw password field m_Password.Draw(sb); Happiness.ShadowString(sb, Assets.HelpFont, m_szPasswordText, m_vPasswordLabelPosition, Color.LightGray); // Draw confirm password field if (m_bEmailCreate) { m_Password2.Draw(sb); Happiness.ShadowString(sb, Assets.HelpFont, m_szPasswordText2, m_vPassword2LabelPosition, Color.LightGray); } Happiness.ShadowString(sb, Assets.DialogFont, m_szAccountStatusText, m_vAccountStatusPosition, Color.Goldenrod); m_AccountStatusButton.Draw(sb); foreach (UIButton b in m_DialogButtons) { b.Draw(sb); } }
public void Draw(SpriteBatch sb) { if (!m_bHidden) { Happiness.ShadowString(sb, m_Font, m_szText, m_vPosition, m_Color); } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Happiness game = new Happiness()) { Happiness.Game = game; game.Run(); } }
public GameScene(Happiness hgame) : base(hgame) { // Init Input InputController.IC.OnDragBegin += M_Input_OnDragBegin; InputController.IC.OnDrag += M_Input_OnDrag; InputController.IC.OnDragEnd += M_Input_OnDragEnd; InputController.IC.OnClick += M_Input_OnClick; InputController.IC.OnKeyUp += M_Input_OnKeyUp; }
void DeleteSavedPuzzle() { string saveName = Happiness.PuzzleSaveName(m_Puzzle.m_iSize, m_iPuzzleIndex); if (File.Exists(saveName)) { File.Delete(saveName); } }
public GameScene(Happiness hgame) : base(hgame) { // Init Input InputController.IC.OnDragBegin += M_Input_OnDragBegin; InputController.IC.OnDrag += M_Input_OnDrag; InputController.IC.OnDragEnd += M_Input_OnDragEnd; InputController.IC.OnClick += M_Input_OnClick; }
public FloorSelectDialog(int tower, int screenWidth, int screenHeight, Happiness game) { m_Game = game; m_iTower = tower; int iCenterX = screenWidth >> 1; int iCenterY = screenHeight >> 1; m_FloorScrollPosition = 0; m_iSelectedFloor = -1; // Frame rect int width = (int)(Constants.FloorSelectDialog_Width * screenWidth); int height = (int)(Constants.FloorSelectDialog_Height * screenHeight); m_Rect = new Rectangle(iCenterX - (width >> 1), iCenterY - (height >> 1), width, height); // Title int iTopMargin = (int)(Constants.FloorSelectDialog_MarginTopBottom * screenHeight); string title = string.Format("{0} x {0}", tower + 3); m_Title = new UILabel(title, iCenterX, m_Rect.Top + iTopMargin, Color.Goldenrod, Assets.MenuFont, UILabel.XMode.Center); // Buttons m_iLeftRightMargin = (int)(Constants.FloorSelectDialog_MarginLeftRight * screenWidth); int navButtonTop = m_Rect.Top + iTopMargin; int navButtonWidth = (int)(Constants.FloorSelectDialog_NavButtonWidth * screenWidth); int navButtonHeight = (int)(Constants.FloorSelectDialog_NavButtonHeight * screenHeight); int lbButtonWidth = (int)(Constants.FloorSelectDialog_LBButtonWidth * screenWidth); int lbButtonHeight = (int)(Constants.FloorSelectDialog_LBButtonHeight * screenHeight); m_Buttons = new UIButton[3]; m_Buttons[0] = new UIButton(0, "<", Assets.MenuFont, new Rectangle(m_Rect.Left + m_iLeftRightMargin, navButtonTop, navButtonWidth, navButtonHeight), Assets.ScrollBar); m_Buttons[1] = new UIButton(1, ">", Assets.MenuFont, new Rectangle(m_Rect.Right - (m_iLeftRightMargin + navButtonWidth), navButtonTop, navButtonWidth, navButtonHeight), Assets.ScrollBar); m_Buttons[2] = new UIButton(2, "Leaderboard", Assets.DialogFont, new Rectangle(m_Rect.Right - (m_iLeftRightMargin + lbButtonWidth), m_Rect.Bottom - (iTopMargin + lbButtonHeight), lbButtonWidth, lbButtonHeight), Assets.ScrollBar); m_Buttons[1].Enabled = false; m_Buttons[2].Enabled = false; // Floors int floorScrollWidth = (int)(Constants.FloorSelectDialog_FloorScrollWidth * screenWidth); int floorScrollTop = m_Title.PositionY + m_Title.Height + (iTopMargin >> 1); int floorScrollBottom = m_Rect.Bottom - iTopMargin; int floorScrollHeight = floorScrollBottom - floorScrollTop; int waitIconSize = (int)(Constants.FloorSelectDialog_WaitIconSize * screenHeight); int halfWaitIconSize = waitIconSize >> 1; m_FloorScrollRect = new Rectangle(iCenterX - (floorScrollWidth >> 1), floorScrollTop, floorScrollWidth, floorScrollHeight); m_FloorWaitRectangle = new Rectangle(iCenterX - halfWaitIconSize, iCenterY - halfWaitIconSize, waitIconSize, waitIconSize); m_FloorDataFetchText = new UILabel("Fetching Data...", iCenterX, m_FloorWaitRectangle.Bottom, Color.White, Assets.DialogFont, UILabel.XMode.Center); m_ScrollFrame = new UIFrame(5, m_FloorScrollRect); // Request the data from the server NetworkManager.Net.RequestTowerData(tower, true); m_iFloorSelectTutorialWidth = (int)(Constants.FloorSelectDialog_FloorSelectTutorialWidth * screenWidth); int floorPlayTutorialWidth = (int)(Constants.FloorSelectDialog_PlayTutorialWidth * screenWidth); m_Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.FloorPlay, new Vector2(m_Buttons[1].Rect.Left, m_Buttons[1].Rect.Bottom), (float)-Math.PI / 4, new Rectangle(m_FloorScrollRect.Right + m_iLeftRightMargin, m_Buttons[1].Rect.Bottom + m_Game.Tutorial.ArrowWidth, floorPlayTutorialWidth, 0), "Press this button to play the selected floor.", TutorialSystem.TutorialPiece.None, m_Buttons[1].Rect); }
public void Draw(SpriteBatch sb) { sb.Draw(Assets.CheckBox, new Rectangle(m_Rect.Left, m_Rect.Top, m_iCheckboxSize, m_iCheckboxSize), m_bEnabled ? Color.White : Color.Gray); if (m_bChecked) { sb.Draw(Assets.Check, new Rectangle(m_Rect.Left, m_Rect.Top, m_iCheckboxSize, m_iCheckboxSize), m_bEnabled ? Color.White : Color.Gray); } Happiness.ShadowString(sb, Assets.HelpFont, m_szText, m_TextLocation, m_bEnabled ? m_TextColor : m_TextDisabledColor); }
public void Update(Happiness theGame, GameTime time, PlayerIndex Primary) { UpdateMouse(); UpdateTouch(); if (OnKeyDown != null || OnKeyUp != null || OnKeyRepeat != null) { UpdateKeyboard(); } }
public MainMenu(Happiness game) { m_Game = game; m_aNewGameBoxes = new Rectangle[6]; m_iSelection = 0; m_bNewGameDialog = true; m_iPuzzleNumber = 0; // 0 - 67,108,863 m_iSize = 6; // 3 - 9 m_iDifficulty = 0; // 0 - 3 }
public void Draw(Renderer sb) { // Draw the icon sb.Draw(m_Icon, m_Rect, m_bLocked ? Color.DarkGray : Color.White); if (m_bLocked) { sb.Draw(Assets.NotOverlay, m_Rect, Color.White); } Happiness.ShadowString(sb, Assets.DialogFont, m_szSize, m_vSizePosition, Color.Goldenrod); Happiness.ShadowString(sb, Assets.DialogFont, m_szFloor, m_vFloorPosition, Color.White); }
private void DrawClock(SpriteBatch sb) { if (GameScene.ClockRunning) { m_dfSeconds = GameScene.ElapsedTime; } double seconds = m_dfSeconds; string timeString = Happiness.TimeString(seconds); Vector2 size = Assets.DialogFont.MeasureString(timeString); sb.DrawString(Assets.DialogFont, timeString, new Vector2(m_Rect.Right - (size.X + 5), (m_Rect.Top + (m_Rect.Height >> 1)) - (size.Y * 0.5f)), Color.White); }
public virtual void Draw(SpriteBatch sb) { // Draw Bar sb.Draw(m_BarTexture, m_BarRect, Color.White); // Draw cursor float barWidth = m_BarRect.Width; float xdelta = m_BarRect.Left + (Percentage * barWidth); m_CursorRect.X = (int)xdelta - (m_CursorRect.Width >> 1); sb.Draw(m_CursorTexture, m_CursorRect, Color.White); // Draw text if (m_szText != null) { Happiness.ShadowString(sb, m_Font, m_szText, m_vTextPosition, Color.White); } }
public void SetInstructions(Rectangle rect, string text, bool okButton) { m_Lines = Happiness.FormatLines(rect.Width - (m_iTextMarginLeftRight * 2), text, Assets.HelpFont); int buttonHeight = okButton ? m_iButtonHeight + m_iTextMarginTopBottom : 0; int autoHeight = ((m_Lines.Length + 1) * m_iTextLineHeight) + buttonHeight; m_InstructionRect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height == 0 ? autoHeight : rect.Height); m_InstructionFrame = new UIFrame(1, m_InstructionRect); if (okButton) { m_OKButton = new UIButton(0, "OK", Assets.HelpFont, new Rectangle(m_InstructionRect.Left + (m_InstructionRect.Width >> 1) - (m_iButtonWidth >> 1), m_InstructionRect.Bottom - (m_iButtonHeight + m_iTextMarginTopBottom), m_iButtonWidth, m_iButtonHeight), Assets.ScrollBar); } else { m_OKButton = null; } }
public HubScene(Happiness game) : base(game) { InputController.IC.OnClick += IC_OnClick; InputController.IC.OnDragBegin += IC_OnDragBegin; InputController.IC.OnDrag += IC_OnDrag; NetworkManager nm = NetworkManager.Net; // Setup Towers int centerX = Game.ScreenWidth >> 1; int centerY = Game.ScreenHeight >> 1; int towerSize = (int)(Constants.HubScene_TowerSize * Game.ScreenHeight); int towerTop = (int)(Constants.HubScene_TowerAreaTop * Game.ScreenHeight); int leftX = centerX - towerSize - towerSize; int midX = centerX - (towerSize >> 1); int rightX = centerX + towerSize; m_Towers = new Tower[6]; m_Towers[0] = new Tower(3, nm.GameData.TowerFloors[0], new Rectangle(leftX, towerTop, towerSize, towerSize), Assets.Towers[0]); m_Towers[1] = new Tower(4, nm.GameData.TowerFloors[1], new Rectangle(midX, towerTop, towerSize, towerSize), Assets.Towers[1]); m_Towers[2] = new Tower(5, nm.GameData.TowerFloors[2], new Rectangle(rightX, towerTop, towerSize, towerSize), Assets.Towers[2]); m_Towers[3] = new Tower(6, nm.GameData.TowerFloors[3], new Rectangle(leftX, centerY, towerSize, towerSize), Assets.Towers[3]); m_Towers[4] = new Tower(7, nm.GameData.TowerFloors[4], new Rectangle(midX, centerY, towerSize, towerSize), Assets.Towers[0]); m_Towers[5] = new Tower(8, nm.GameData.TowerFloors[5], new Rectangle(rightX, centerY, towerSize, towerSize), Assets.Towers[0]); // Level/Exp display int expBarWidth = (int)(Constants.HubScene_ExpBarWidth * Game.ScreenWidth); int expBarHeight = (int)(Constants.HubScene_ExpBarHeight * Game.ScreenHeight); int expBarLeft = (int)(Constants.HubScene_MarginLeftRight * Game.ScreenWidth); int levelY = (int)(Constants.HubScene_MarginTopBottom * Game.ScreenHeight); GameDataArgs gd = NetworkManager.Net.GameData; game.Tutorial.Load(gd.Tutorial); m_LevelLabel = new UILabel("Level: ", expBarLeft, levelY, Color.Goldenrod, Assets.HelpFont, UILabel.XMode.Left); m_Level = new UILabel(gd.Level.ToString(), expBarLeft + m_LevelLabel.Width, levelY, Color.White, Assets.HelpFont, UILabel.XMode.Left); m_ExpBar = new UIProgressBar(new Rectangle(expBarLeft, levelY + m_Level.Height, expBarWidth, expBarHeight)); m_ExpBar.ProgressColor = Color.Yellow; m_ExpBar.Progress = (float)gd.Exp / Balance.ExpForNextLevel(gd.Level); int tutorialWidth = (int)(Constants.HubScene_TutorialWidth * Game.ScreenWidth); Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.ClickTower, new Vector2(leftX, towerTop + (towerSize >> 1)), 0, new Rectangle(leftX - (tutorialWidth + 5), towerTop + (towerSize >> 1) + (Game.Tutorial.ArrowHeight >> 1), tutorialWidth, 0), "Tap the 3x3 tower to get started.", TutorialSystem.TutorialPiece.None, m_Towers[0].Rect); Game.Tutorial.TriggerPiece(TutorialSystem.TutorialPiece.ClickTower); }
public void Draw(Renderer sb) { // Draw frame sb.Draw(Assets.TransparentBox, m_Rect, Color.SteelBlue); sb.Draw(Assets.TransparentBox, m_Rect, Color.SteelBlue); sb.Draw(Assets.TransparentBox, m_Rect, Color.SteelBlue); sb.Draw(Assets.TransparentBox, m_Rect, Color.SteelBlue); // Draw text Happiness.ShadowString(sb, Assets.DialogFont, m_szTitle, m_vTitlePosition, Color.Goldenrod); Happiness.ShadowString(sb, Assets.HelpFont, m_szSecondaryText, m_vSecondaryPosition, Color.LightGray); // Draw input field m_Input.Draw(sb); // Draw buttons foreach (UIButton b in m_Buttons) { b.Draw(sb); } }
public void Draw(SpriteBatch sb, SpriteFont font, Vector2 position, Color color) { Vector2 fontSize = font.MeasureString("qQ"); int iconSize = (int)fontSize.Y; float fX = position.X; float fY = position.Y; foreach (PieceInfo piece in m_Pieces) { if (piece.m_Str != null) { Happiness.ShadowString(sb, font, piece.m_Str, new Vector2(fX, fY), color); fX += font.MeasureString(piece.m_Str).X; } if (piece.m_Icon != null) { sb.Draw(piece.m_Icon, new Rectangle((int)fX, (int)fY, iconSize, iconSize), Color.White); fX += iconSize; } } }
public void Draw(SpriteBatch sb) { // Draw the box sb.Draw(Assets.TransGray, m_InputRect, m_bEnabled ? Color.White : Color.Gray); // Draw the text Happiness.ShadowString(sb, Assets.HelpFont, m_bMaskedText ? m_szMaskedText : m_szInputText, new Vector2(m_InputRect.Left + 4, m_InputRect.Top), m_bEnabled ? Color.White : Color.Gray); // Draw the cursor if (m_bShowCursor && m_bFocused && m_bEnabled) { Vector2 textSize = Assets.HelpFont.MeasureString(m_bMaskedText ? m_szMaskedText : m_szInputText); int cursorLeft = m_InputRect.Left + 4 + (int)textSize.X; sb.Draw(Assets.GoldBarVertical, new Rectangle(cursorLeft, m_InputRect.Top + 2, 2, m_InputRect.Height - 4), Color.White); } // Draw outline if (m_bFocused && m_bEnabled) { m_FocusFrame.Draw(sb); } }
public StartupScene(Happiness game) : base(game) { //LoadStartupDetails(); m_GIV = GameInfoValidator.Instance; m_GIV.BeginLoadFromDisk(); game.SoundManager.PlayMainMenuMusic(); game.SoundManager.PlaySound(SoundManager.SEInst.Happiness); InputController.IC.OnClick += IC_OnClick; InputController.IC.OnKeyUp += IC_OnKeyUp; int logoSize = (int)(Constants.Startup_LogoSize * game.ScreenHeight); m_LogoRectangle = new Rectangle(0, 0, logoSize, logoSize); m_szCreditLine = "A logic puzzle game by Ron O'Hara"; m_szMusicCreditLine = "Muisc by Ronald Jenkees (www.ronaldjenkees.com)"; m_szArtistCreditLine = "Artwork by: <your name here!> (Artist Wanted)"; int creditX = (int)(Constants.Startup_CreditX * game.ScreenWidth); int creditY = (int)(Constants.Startup_CreditY * game.ScreenHeight); int musicY = (int)(Constants.Startup_MusicCreditY * game.ScreenHeight); m_vCreditPosition.X = creditX; m_vCreditPosition.Y = game.ScreenHeight - creditY; m_vMusicCreditPosition.Y = game.ScreenHeight - musicY; m_vMusicCreditPosition.X = creditX + 20; m_vArtistCreditPosition.X = game.ScreenWidth / 2; m_vArtistCreditPosition.Y = game.ScreenHeight - musicY; int waitIconSize = (int)(Constants.Startup_WaitIconSize * game.ScreenWidth); m_WaitRect = new Rectangle((Game.ScreenWidth / 2) - (waitIconSize / 2), (Game.ScreenHeight / 2) - (waitIconSize / 2), waitIconSize, waitIconSize); m_WaitTextCenter = new Point(Game.ScreenWidth / 2, m_WaitRect.Bottom + 10); m_szWaitText = "Initializing"; }
public SoundDialog(int screenWidth, int screenHeight, Happiness game) { int width = 1200; int height = 700; int buttonWidth = 120; int buttonHeight = 32; int halfWidth = buttonWidth / 2; int halfHeight = buttonHeight / 2; int screenCenterX = screenWidth / 2; int screenCenterY = screenHeight / 2; m_Rect = new Rectangle(screenCenterX - (width / 2), screenCenterY - (height / 2), width, height); m_Frame = new UIFrame(2, m_Rect); int buttonSpace = 25; int buttonLeft = m_Rect.Left + 10; int buttonTop = m_Rect.Top + 10; m_Buttons = new UIButton[16]; m_Buttons[0] = new UIButton(0, "MenuNavigate", Assets.HelpFont, new Rectangle(buttonLeft, buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[0].ClickSound = SoundManager.SEInst.MenuNavigate; m_Buttons[1] = new UIButton(1, "MenuAccept", Assets.HelpFont, new Rectangle(buttonLeft + (buttonWidth + buttonSpace), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[1].ClickSound = SoundManager.SEInst.MenuAccept; m_Buttons[2] = new UIButton(2, "MenuCancel", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 2), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[2].ClickSound = SoundManager.SEInst.MenuCancel; m_Buttons[3] = new UIButton(3, "GameLoad", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 3), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[3].ClickSound = SoundManager.SEInst.GameLoad; m_Buttons[4] = new UIButton(4, "GameSave", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 4), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[4].ClickSound = SoundManager.SEInst.GameSave; m_Buttons[5] = new UIButton(5, "GameUnhideClues", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 5), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[5].ClickSound = SoundManager.SEInst.GameUnhideClues; m_Buttons[6] = new UIButton(6, "GameAction1", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 6), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[6].ClickSound = SoundManager.SEInst.GameAction1; m_Buttons[7] = new UIButton(7, "GameAction2", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 7), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[7].ClickSound = SoundManager.SEInst.GameAction2; buttonTop += buttonHeight + buttonSpace; m_Buttons[8] = new UIButton(8, "GameAction3", Assets.HelpFont, new Rectangle(buttonLeft, buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[8].ClickSound = SoundManager.SEInst.GameAction3; m_Buttons[9] = new UIButton(9, "GameAction4", Assets.HelpFont, new Rectangle(buttonLeft + (buttonWidth + buttonSpace), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[9].ClickSound = SoundManager.SEInst.GameAction4; m_Buttons[10] = new UIButton(10, "GameAction5", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 2), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[10].ClickSound = SoundManager.SEInst.GameAction5; m_Buttons[11] = new UIButton(11, "GameAction6", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 3), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[11].ClickSound = SoundManager.SEInst.GameAction6; m_Buttons[12] = new UIButton(12, "GamePuzzleFailed", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 4), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[12].ClickSound = SoundManager.SEInst.GamePuzzleFailed; m_Buttons[13] = new UIButton(13, "GamePuzzleComplete", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 5), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[13].ClickSound = SoundManager.SEInst.GamePuzzleComplete; m_Buttons[14] = new UIButton(14, "GameSliderMove", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 6), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[14].ClickSound = SoundManager.SEInst.GameSliderMove; m_Buttons[15] = new UIButton(15, "Happiness", Assets.HelpFont, new Rectangle(buttonLeft + ((buttonWidth + buttonSpace) * 7), buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[15].ClickSound = SoundManager.SEInst.Happiness; }
public TutorialSystem(int screenWidth, int screenHeight, Happiness game) { m_Game = game; m_Pieces = new Dictionary <TutorialPiece, PieceData>(); m_CurrentPiece = TutorialPiece.None; m_fArrowTravelDistance = Constants.TutorialSystem_ArrowTravelDistance * screenWidth; m_fArrowSpeed = Constants.TutorialSystem_ArrowSpeed; m_fArrowWidth = Constants.TutorialSystem_ArrowWidth * screenWidth; m_fArrowHeight = Constants.TutorialSystem_ArrowHeight * screenHeight; m_vArrowScale = new Vector2(m_fArrowWidth / Assets.Arrow.Width, m_fArrowHeight / Assets.Arrow.Height); m_vArrowOrigin = new Vector2(Assets.Arrow.Width, Assets.Arrow.Height >> 1); m_TextColor = Color.CornflowerBlue; m_iTextLineHeight = (int)Assets.HelpFont.MeasureString("qQ").Y + 1; m_iTextMarginTopBottom = (int)(Constants.TutorialSystem_TextMarginTopBottom * screenHeight); m_iTextMarginLeftRight = (int)(Constants.TutorialSystem_TextMarginLeftRight * screenWidth); m_iButtonWidth = (int)(Constants.TutorialSystem_ButtonWidth * screenWidth); m_iButtonHeight = (int)(Constants.TutorialSystem_ButtonHeight * screenHeight); Load(); }
public Options(Happiness game) { m_Game = game; m_rCheckBoxes = new Rectangle[5]; m_bChecks = new bool[5]; }
public MessageBox(string message, MessageBoxButtons buttons, int context, int screenWidth, int screenHeight, string checkboxText = null) { m_iContext = context; m_TextColor = Color.White; int iCheckboxSize = (int)(Constants.MessageBox_CheckboxSize * screenHeight); m_iMarginLeftRight = (int)(Constants.MessageBox_LeftRightMargin * screenWidth); m_iMarginTopBottom = (int)(Constants.MessageBox_TopBottomMargin * screenHeight); int checkboxHeight = checkboxText == null ? 0 : m_iMarginTopBottom + iCheckboxSize; int width = (int)(Constants.MessageBox_Width * screenWidth); m_Lines = Happiness.FormatLines(width - (m_iMarginLeftRight * 2), message, Assets.DialogFont); int buttonWidth = (int)(Constants.MessageBox_ButtonWidth * screenWidth); int buttonHeight = (int)(Constants.MessageBox_ButtonHeight * screenHeight); int lineSpace = (int)(Constants.MessageBox_LineSpace * screenHeight); Vector2 testTextSize = Assets.DialogFont.MeasureString("TEST"); m_iTextLineHeight = (int)testTextSize.Y + lineSpace; int buttonAreaHeight = buttons == MessageBoxButtons.None ? 0 : m_iMarginTopBottom + buttonHeight; int dialogHeight = (m_iMarginTopBottom + m_iMarginTopBottom) + (m_iTextLineHeight * m_Lines.Length) + buttonAreaHeight + checkboxHeight; int halfScreenW = screenWidth >> 1; int halfScreenH = screenHeight >> 1; int halfDialogW = width >> 1; int halfDialogH = dialogHeight >> 1; m_iCenterDialogX = halfScreenW; m_Rect = new Rectangle(halfScreenW - halfDialogW, halfScreenH - halfDialogH, width, dialogHeight); int buttonY = (m_Rect.Bottom - m_iMarginTopBottom) - buttonHeight; int halfButtonWidth = buttonWidth >> 1; switch (buttons) { case MessageBoxButtons.OK: m_Buttons = new UIButton[1]; m_Buttons[0] = new UIButton((int)MessageBoxResult.OK, "OK", Assets.HelpFont, new Rectangle(halfScreenW - halfButtonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); break; case MessageBoxButtons.YesNo: m_Buttons = new UIButton[2]; m_Buttons[0] = new UIButton((int)MessageBoxResult.Yes, "Yes", Assets.HelpFont, new Rectangle(halfScreenW - (halfButtonWidth + buttonWidth), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[1] = new UIButton((int)MessageBoxResult.No, "No", Assets.HelpFont, new Rectangle(halfScreenW + halfButtonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); break; case MessageBoxButtons.BuyCoinsCancel: m_Buttons = new UIButton[2]; m_Buttons[0] = new UIButton((int)MessageBoxResult.BuyCoins, "Buy Coins", Assets.HelpFont, new Rectangle(halfScreenW - (halfButtonWidth + buttonWidth), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); m_Buttons[1] = new UIButton((int)MessageBoxResult.Cancel, "Cancel", Assets.HelpFont, new Rectangle(halfScreenW + halfButtonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); break; case MessageBoxButtons.None: break; } if (checkboxText != null) { m_CheckBox = new UICheckbox(checkboxText, 0, buttonY - (m_iMarginTopBottom + iCheckboxSize), screenHeight); m_CheckBox.Left = m_iCenterDialogX - (m_CheckBox.Rect.Width >> 1); } }
public Scene(Happiness hgame) { m_Game = hgame; }
public void Update(Happiness theGame, GameTime time, PlayerIndex Primary) { UpdateMouse(); UpdateTouch(); if( OnKeyDown != null || OnKeyUp != null || OnKeyRepeat != null ) UpdateKeyboard(); }
public HubScene(Happiness game) : base(game) { InputController.IC.OnClick += IC_OnClick; InputController.IC.OnDragBegin += IC_OnDragBegin; InputController.IC.OnDrag += IC_OnDrag; InputController.IC.OnScroll += IC_OnScroll; InputController.IC.OnKeyDown += IC_OnKeyDown; SoundManager.Inst.PlayMainMenuMusic(); //m_SoundDialog = new SoundDialog(game.ScreenWidth, game.ScreenHeight, game); //game.SoundManager.StopMusic(); // Setup Towers int centerX = Game.ScreenWidth >> 1; int centerY = Game.ScreenHeight >> 1; int towerSize = (int)(Constants.HubScene_TowerSize * Game.ScreenHeight); int towerTop = (int)(Constants.HubScene_TowerAreaTop * Game.ScreenHeight); int leftX = centerX - towerSize - towerSize; int midX = centerX - (towerSize >> 1); int rightX = centerX + towerSize; m_Towers = new Tower[6]; m_Towers[0] = new Tower(3, game.TheGameInfo.GameData.TowerFloors[0], new Rectangle(leftX, towerTop, towerSize, towerSize), Assets.Towers[0]); m_Towers[1] = new Tower(4, game.TheGameInfo.GameData.TowerFloors[1], new Rectangle(midX, towerTop, towerSize, towerSize), Assets.Towers[1]); m_Towers[2] = new Tower(5, game.TheGameInfo.GameData.TowerFloors[2], new Rectangle(rightX, towerTop, towerSize, towerSize), Assets.Towers[2]); m_Towers[3] = new Tower(6, game.TheGameInfo.GameData.TowerFloors[3], new Rectangle(leftX, centerY, towerSize, towerSize), Assets.Towers[3]); m_Towers[4] = new Tower(7, game.TheGameInfo.GameData.TowerFloors[4], new Rectangle(midX, centerY, towerSize, towerSize), Assets.Towers[0]); m_Towers[5] = new Tower(8, game.TheGameInfo.GameData.TowerFloors[5], new Rectangle(rightX, centerY, towerSize, towerSize), Assets.Towers[0]); // Level/Exp display int expBarWidth = (int)(Constants.HubScene_ExpBarWidth * Game.ScreenWidth); int expBarHeight = (int)(Constants.HubScene_ExpBarHeight * Game.ScreenHeight); int marginLeftRight = (int)(Constants.HubScene_MarginLeftRight * Game.ScreenWidth); int levelY = (int)(Constants.HubScene_MarginTopBottom * Game.ScreenHeight); m_LevelLabel = new UILabel("Level: ", marginLeftRight, levelY, Color.Goldenrod, Assets.HelpFont, UILabel.XMode.Left); m_Level = new UILabel(game.TheGameInfo.GameData.Level.ToString(), marginLeftRight + m_LevelLabel.Width, levelY, Color.White, Assets.HelpFont, UILabel.XMode.Left); m_ExpBar = new UIProgressBar(new Rectangle(marginLeftRight, levelY + m_Level.Height, expBarWidth, expBarHeight)); m_ExpBar.ProgressColor = Color.Yellow; m_ExpBar.Progress = (float)game.TheGameInfo.GameData.Exp / Balance.ExpForNextLevel(game.TheGameInfo.GameData.Level); SetupTutorial(); int buttonWidth = (int)(Constants.HubScene_ButtonWidth * Game.ScreenWidth); int buttonHeight = (int)(Constants.HubScene_ButtonHeight * Game.ScreenHeight); int buttonY = Game.ScreenHeight - levelY - buttonHeight; m_ResetTutorial = new UIButton(0, "Reset Tutorial", Assets.HelpFont, new Rectangle(marginLeftRight, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); m_Options = new UIButton(0, "Options", Assets.HelpFont, new Rectangle((marginLeftRight * 2) + buttonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); m_BuyCoins = new UIButton(0, "Buy Coins", Assets.HelpFont, new Rectangle((marginLeftRight * 3) + (buttonWidth * 2), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); int buttonRight = Game.ScreenWidth - marginLeftRight - buttonWidth; m_Exit = new UIButton(0, "Exit", Assets.HelpFont, new Rectangle(buttonRight, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); m_SignOut = new UIButton(0, "Sign Out", Assets.HelpFont, new Rectangle(buttonRight - marginLeftRight - buttonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar); int startY = (int)(Constants.HelpPanel_Height * Game.ScreenHeight); int coinsWidth = (int)(Constants.HubScene_CoinsWidth * Game.ScreenWidth); int coinsLeft = Game.ScreenWidth - (coinsWidth + marginLeftRight); m_Coins = new UICoinsDisplay(startY, coinsLeft, levelY, coinsWidth); m_Coins.SetCoins(Game.TheGameInfo.HardCurrency); Game.OnCurrencyChange += Game_OnCurrencyChange; Game.OnVipDataChange += Game_OnVipDataChange; int vipTop = (levelY * 2) + m_Coins.Height; m_VIP = new UIVIPDisplay(coinsLeft + marginLeftRight, vipTop, coinsWidth - marginLeftRight); game.ValidateVIPSettings(); }
public VIPDialog() { Happiness game = Happiness.Game; int screenWidth = game.ScreenWidth; int screenHeight = game.ScreenHeight; int width = (int)(Constants.VIPDialog_Width * screenWidth); int height = (int)(Constants.VIPDialog_Height * screenHeight); int centerDialogX = (screenWidth >> 1); int left = centerDialogX - (width >> 1); int centerY = (screenHeight >> 1); int top = centerY - (height >> 1); m_Rect = new Rectangle(left, top, width, height); // Level/Exp display int expBarWidth = (int)(Constants.VIPDialog_ExpBarWidth * game.ScreenWidth); int expBarHeight = (int)(Constants.VIPDialog_ExpBarHeight * game.ScreenHeight); int marginTopBottom = (int)(Constants.VIPDialog_MarginTopBottom * game.ScreenWidth); int expBarLeft = centerDialogX - (expBarWidth >> 1); m_LevelLabel = new UILabel("Level: ", expBarLeft, marginTopBottom, Color.Goldenrod, Assets.DialogFont, UILabel.XMode.Left); m_Level = new UILabel(game.TheGameInfo.VipData.Level.ToString(), expBarLeft + m_LevelLabel.Width, top + marginTopBottom, Color.White, Assets.MenuFont, UILabel.XMode.Left); int xpBarTop = top + marginTopBottom + m_Level.Height; m_LevelLabel.PositionY = (xpBarTop - m_LevelLabel.Height) - 6; m_ExpBar = new UIProgressBar(new Rectangle(expBarLeft, xpBarTop, expBarWidth, expBarHeight)); m_ExpBar.ProgressColor = Color.DarkBlue; m_ExpBar.Progress = (game.TheGameInfo.VipData.Level >= 10) ? 1.0f : (float)game.TheGameInfo.VipData.Points / (float)VIPLevels.Levels[game.TheGameInfo.VipData.Level]; string expStr = (game.TheGameInfo.VipData.Level >= 10) ? game.TheGameInfo.VipData.Points.ToString("n0") : string.Format("{0} / {1}", game.TheGameInfo.VipData.Points.ToString("n0"), VIPLevels.Levels[game.TheGameInfo.VipData.Level].ToString("n0")); m_ExpText = new UILabel(expStr, centerDialogX, xpBarTop + expBarHeight, Color.WhiteSmoke, Assets.HelpFont, UILabel.XMode.Center); int buttonWidth = (int)(Constants.BuyCreditsDialog_ButtonWidth * screenWidth); int buttonHeight = (int)(Constants.BuyCreditsDialog_ButtonHeight * screenHeight); int centerButtonLeft = centerDialogX - (buttonWidth >> 1); int closeTop = (top + height) - (buttonHeight + marginTopBottom); m_Close = new UIButton(0, "Close", Assets.DialogFont, new Rectangle(centerButtonLeft, closeTop, buttonWidth, buttonHeight), Assets.ScrollBar); int levelsAreaTop = xpBarTop + expBarHeight + m_ExpText.Height + marginTopBottom; int levelsAreaWidth = (int)(Constants.VIPDialog_LevelsAreaWidth * screenWidth); int levelsAreaHeight = (closeTop - marginTopBottom) - levelsAreaTop; m_LevelsAreaFrame = new UIFrame(5, new Rectangle(centerDialogX - (levelsAreaWidth >> 1), levelsAreaTop, levelsAreaWidth, levelsAreaHeight)); int lrButtonSpace = (int)(Constants.VIPDialog_LRButtonSpace * screenWidth); int lrButtonWidth = (int)(Constants.VIPDialog_LRButtonWidth * screenWidth); int lrButtonHeight = (int)(Constants.VIPDialog_LRButtonHeight * screenHeight); int lrButtonTop = (levelsAreaTop + (levelsAreaHeight >> 1)) - (lrButtonHeight >> 1); m_BtnLeft = new UIButton(0, "<", Assets.MenuFont, new Rectangle(m_LevelsAreaFrame.Rect.Left - (lrButtonWidth + lrButtonSpace), lrButtonTop, lrButtonWidth, lrButtonHeight), Assets.ScrollBar); m_BtnRight = new UIButton(1, ">", Assets.MenuFont, new Rectangle(m_LevelsAreaFrame.Rect.Right + lrButtonSpace, lrButtonTop, lrButtonWidth, lrButtonHeight), Assets.ScrollBar); int lineSpace = (int)(Constants.VIPDialog_LineSpace * screenHeight); int rowY = levelsAreaTop + (lineSpace * 2); m_DetailsLevelLabel = new UILabel("VIP Level: 0", m_LevelsAreaFrame.Rect.Left + lrButtonSpace, rowY, Color.White, Assets.HelpFont, UILabel.XMode.Left); m_DetailsRequiredPoints = new UILabel("Points Required: 50000", m_LevelsAreaFrame.Rect.Right - lrButtonSpace, rowY, Color.White, Assets.HelpFont, UILabel.XMode.Right); rowY += m_DetailsLevelLabel.Height + (lineSpace * 3); m_HintsLabel = new UILabel("Hints (per puzzle): ", centerDialogX, rowY, Color.Goldenrod, Assets.DialogFont, UILabel.XMode.Right); m_Hints = new UILabel("0", centerDialogX, rowY, Color.Yellow, Assets.DialogFont, UILabel.XMode.Left); rowY += m_HintsLabel.Height + lineSpace; m_MegaHintsLabel = new UILabel("Mega Hints (per puzzle): ", centerDialogX, rowY, Color.Goldenrod, Assets.DialogFont, UILabel.XMode.Right); m_MegaHints = new UILabel("0", centerDialogX, rowY, Color.Yellow, Assets.DialogFont, UILabel.XMode.Left); rowY += m_HintsLabel.Height + lineSpace; m_UndoSizeLabel = new UILabel("Undo Size: ", centerDialogX, rowY, Color.Goldenrod, Assets.DialogFont, UILabel.XMode.Right); m_UndoSize = new UILabel("0", centerDialogX, rowY, Color.Yellow, Assets.DialogFont, UILabel.XMode.Left); rowY += m_HintsLabel.Height + lineSpace; m_ExpBonusLabel = new UILabel("Experience Bonus: ", centerDialogX, rowY, Color.Goldenrod, Assets.DialogFont, UILabel.XMode.Right); m_ExpBonus = new UILabel("1.5", centerDialogX, rowY, Color.Yellow, Assets.DialogFont, UILabel.XMode.Left); rowY += m_HintsLabel.Height + lineSpace; m_DisableTimer = new UILabel("Can Disable Timer", centerDialogX, rowY, Color.Yellow, Assets.DialogFont, UILabel.XMode.Center); rowY += m_HintsLabel.Height + lineSpace; m_DisableExpBonus = new UILabel("Can Disable VIP Exp Bonus", centerDialogX, rowY, Color.Yellow, Assets.DialogFont, UILabel.XMode.Center); rowY += m_HintsLabel.Height + lineSpace; m_ErrorDetector = new UILabel("Can enable the Error Detector", centerDialogX, rowY, Color.Yellow, Assets.DialogFont, UILabel.XMode.Center); rowY += m_HintsLabel.Height + lineSpace; m_ErrorDetector2 = new UILabel("Can enable the Super Error Detector", centerDialogX, rowY, Color.Yellow, Assets.DialogFont, UILabel.XMode.Center); SetDetailLevel(game.TheGameInfo.VipData.Level); }