public void Start() { StateControllerInit(); PD.sounds.SetVoiceAndPlay(SoundPaths.NarratorPath + "022", 0); p1_delay = 0; p2_delay = 0; p1eggState = 0; conf1 = false; conf1options = false; conf2 = true; int completionPercent = PD.GetSaveData().CalculateGameCompletionPercent(); string spPath = SpritePaths.CharSelSheet, crPath = SpritePaths.CharSelCursors; int crNum = 10; dX = 0.71f; initX = -3.2f; if (completionPercent == 100) { spPath = SpritePaths.CharSelSheetAll; crPath = SpritePaths.CharSelCursorsAll; crNum = 12; initX = -3.25f; dX = 0.591f; } else if (completionPercent >= 50) { spPath = SpritePaths.CharSelSheetWhite; crPath = SpritePaths.CharSelCursorsWhite; crNum = 11; initX = -3.21f; dX = 0.6455f; } charactersel = GetGameObject(new Vector3(0.0f, -0.99f), "Character Select", Resources.Load <Sprite>(spPath), true, "HUD"); cursor = GetMenuCursor(crNum, 1, crPath, initX, -0.99f, dX, 0.0f, 0, 0, 1, 0, 0.2f); beginSheet = Resources.LoadAll <Sprite>(SpritePaths.ShortButtons); begin = GetGameObject(new Vector3(0.0f, 0.3f), "Begin", beginSheet[0], true, "HUD"); FontData f = PD.mostCommonFont.Clone(); f.scale = 0.045f; XmlNode top = GetXMLHead(); beginText = GetMeshText(new Vector3(0.0f, 0.45f), GetXmlValue(top, "begin"), f).gameObject; f.color = Color.white; f.scale = 0.035f; chooseText = GetMeshText(new Vector3(0.0f, 1.11f), GetXmlValue(top, "chooseyourcharacter"), f).gameObject; int yMax = InitOptionsTextAndReturnValueCount(); cursorOp = GetOptionsCursor(1, yMax + 1, null, -0.2f, 0.45f, 0.0f, 0.25f, 0, yMax, 1); cursorOpDisplay = gameObject.AddComponent <OptionsSelector>(); cursorOpDisplay.Setup(0.2f, 0.45f, 0.25f); cursorOpDisplay.SetVisibility(false); cursorOpDisplay.SetWidth(PD.gameType == PersistData.GT.Training?0.85f:0.6f); InitPlayer1Select(); SetupBackgrounds(); ToggleDisplayOptions(false); if (PD.gameType == PersistData.GT.Arcade) { AddVictoryIcons(); } else if (PD.gameType == PersistData.GT.Versus) { SetupP2StartText(top, f); conf2 = false; } }
protected OptionsCursor GetOptionsCursor(int w, int h, string sprite, float px, float py, float dx, float dy, int initX, int initY, int p = 1, int frame = -1, float dtweenchange = -1) { GameObject g = Instantiate(gameObject, Vector3.zero, Quaternion.identity) as GameObject; OptionsCursor c = g.AddComponent <OptionsCursor>(); Destroy(g); c.SetPD(PD); c.player = p; c.SetController(p == 1?PD.controller:PD.controller2, PD.GetKeyBindings(p - 1)); c.setWidthAndHeight(w, h); c.Setup(th); c.SetupMenu(sprite, px, py, dx, dy, initX, initY, frame, dtweenchange); return(c); }
public void Start() { StateControllerInit(false); SaveData sd = PD.GetSaveData(); currentName = "---"; characters = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' }; string savedName = sd.highScoreName; inputName = new int[] { System.Array.IndexOf(characters, savedName[0]), System.Array.IndexOf(characters, savedName[1]), System.Array.IndexOf(characters, savedName[2]) }; GetGameObject(Vector3.zero, "BG", Resources.Load <Sprite>(SpritePaths.DefaultBG), false, "BG0"); keyPress = new Regex("[A-Za-z0-9]"); PD.sounds.SetMusicAndPlay(SoundPaths.M_Menu); writer = new ScoreTextFormatter(PD); List <KeyValuePair <string, int> > scores = sd.getHighScores(PD.gameType); int userScorePos = sd.getHighscorePos(scores, PD.runningScore, true); if (userScorePos < 0) { userScorePos = 100; } scorePosText = (userScorePos + 1).ToString() + ". "; if (userScorePos < 9) { scorePosText = " " + scorePosText; } scoreTxt = PD.runningScore.ToString(); float scoreX = -2.0f; List <KeyValuePair <string, int> > times = sd.getBestTimes(PD.gameType); int userTimePos = -1; if (PD.gameType == PersistData.GT.Campaign) { userTimePos = sd.getHighscorePos(times, PD.runningTime, true); } else { userTimePos = PD.won?sd.getHighscorePos(times, PD.runningTime, false):-1; } if (userTimePos < 0) { userTimePos = 100; } timePosText = (userTimePos + 1).ToString() + ". "; if (userTimePos < 9) { timePosText = " " + timePosText; } timeTxt = writer.ConvertSecondsToMinuteSecondFormat(PD.runningTime); float timeX = 2.0f; writer.SetScoreRowAndTimeRowWidths(scores, times); System.Xml.XmlNode top = GetXMLHead(); GetMeshText(new Vector3(scoreX, 1.4f), GetXmlValue(top, "highscores"), PD.mostCommonFont, "Prefabs/Text/FixedWidth"); GetMeshText(new Vector3(timeX, 1.4f), GetXmlValue(top, "besttimes"), PD.mostCommonFont, "Prefabs/Text/FixedWidth"); Sprite slab = Resources.Load <Sprite>(SpritePaths.HighScoreSlab); GetGameObject(new Vector3(scoreX, 0.15f), "Score Slab", slab); GetGameObject(new Vector3(timeX, 0.15f), "Time Slab", slab); for (int pos = 0; pos < 10; pos++) { if (pos < userScorePos) { GetTextRow(scores[pos], pos, scoreX); } else if (pos == userScorePos) { currentScore = GetTextRow(new KeyValuePair <string, int>(currentName, PD.runningScore), userScorePos, scoreX); } else if (pos > userScorePos) { GetTextRow(scores[pos - 1], pos, scoreX); } if (pos < userTimePos) { GetTextRow(times[pos], pos, timeX, true); } else if (pos == userTimePos) { currentTime = GetTextRow(new KeyValuePair <string, int>(currentName, PD.runningTime), pos, timeX, true); } else if (pos > userTimePos) { GetTextRow(times[pos - 1], pos, timeX, true); } } if (currentScore != null) { currentScore.color = Color.red; } if (currentTime != null) { currentTime.color = Color.red; } saved = (userScorePos > 10) && (userTimePos > 10); nameCursor = GetOptionsCursor(3, 1, SpritePaths.VerticalArrows, -0.17f, -0.8f, 0.17f, 0, 0, 0, 1); if (!saved) { FontData f = new FontData(TextAnchor.MiddleCenter, TextAlignment.Center); GetGameObject(new Vector3(0.0f, -0.65f), "Minislab", Resources.Load <Sprite>(SpritePaths.HighScoreInput)); GetMeshText(new Vector3(0.0f, -0.5f), GetXmlValue(top, "entername"), f); nameEntry = GetMeshText(new Vector3(0.0f, -0.8f), savedName, f, "Prefabs/Text/FixedWidth"); inputCollider = GetGameObject(new Vector3(0.0f, -0.8f), "Input Collider", Resources.Load <Sprite>(SpritePaths.ScoreCollider), true); confirmButtonSprites = Resources.LoadAll <Sprite>(SpritePaths.ConfirmButtons); confirmButton = GetGameObject(new Vector3(0.0f, -1.2f), "Confirm", confirmButtonSprites[0], true); confirmButton.SetActive(PD.usingMouse); mouseObjects.Add(confirmButton); PD.sounds.SetVoiceAndPlay(SoundPaths.NarratorPath + "036", 0); } else { nameCursor.cursor.SetActive(false); PD.sounds.SetVoiceAndPlay(SoundPaths.NarratorPath + "041", 0); } }