void Awake() //varaibles to initiate only one time for scene { instance = this; //this script left_time = bonus_time; int_time = -1; GenerateCardDeckSprite();//fuse clubs[], spades[], diamonds[] and hearts[] in one array //setup deck sprite GetComponent <Image> ().sprite = card_back_sprite; new_card_anim.transform.GetChild(0).transform.GetChild(0).GetComponent <Image> ().sprite = card_back_sprite; animation_duration = new_card_anim.GetComponent <Animation> ().GetClip("new_card_anim").length; undo_animation_duration = new_card_anim.GetComponent <Animation> ().GetClip("undo_to_deck_card_anim").length; if (PyramidMenu.GetInstance().endDialog_moveAnimator.gameObject.activeSelf) { popup_animation_duration = PyramidMenu.GetInstance().endDialog_moveAnimator.GetCurrentAnimatorClipInfo(0).Length; } gpend_button.interactable = false; mustEnableEndButton = false; mustEnableDeckImage = false; total_card_on_board = 0; //Debug.Log ("board cards = " + total_card_on_board + " ...max same rank = " + max_number_of_card_with_the_same_rank_on_board); }
public void Restart() { //reset variables game_started = false; game_end = false; player_can_move = false; current_total_card_on_board = 0; current_deck_position = 0; current_target_deck_position = 0; unused_card_count = 0; animationsCount = 0; //combo previous_combo_count = 0; combo_count = 0; //score current_score = 0; score_text.text = current_score.ToString(); this.gameObject.GetComponent <Image> ().enabled = true; target_new_card.gameObject.SetActive(false); //game_screen.SetActive(true); UpdateUndoButton(); card_on_board_by_rank = new int[13]; left_time = bonus_time; int_time = -1; timer_paused = true; gpend_button.interactable = false; mustEnableEndButton = false; mustEnableDeckImage = false; PrintTime(); FillDeck();//crate the contents of the deck int val = PlayerData.GetInstance().GetValueAsInt("pyramidHTP"); if (val == 0) { PyramidMenu.GetInstance().OpenPopup(2); } else { StartCoroutine(StartGame(0.2F)); } }
public int AddCombo() { previous_combo_count = combo_count; combo_count++; for (int i = 6; i >= 0; i--) { if (combo_count == combo_triggers [i]) { combo_text.text = combo_texts [i]; PyramidMenu.GetInstance().OpenPopup(3); return(combo_scores [i]); } } return(0); }
public IEnumerator EnableGPEndButton() { mustEnableEndButton = true; yield return(new WaitForSeconds(0.4f)); if (mustEnableEndButton) { gpend_button.interactable = true; mustEnableEndButton = false; int val = PlayerData.GetInstance().GetValueAsInt("pyramidTips0"); if (val == 0) { PyramidMenu.GetInstance().OpenPopup(4); } } }
public IEnumerator ComboScore(int combo_score) { yield return(new WaitForSeconds(0.4f)); deck.GetInstance().CreateScoreEvent(PyramidMenu.GetInstance().combo_score_event.transform.position, combo_score.ToString(deck.GetInstance().scoreFormat), current_score + combo_score, 0.2f); }
public IEnumerator GameOver(int endMode) { //endMode => 0 = normal (no more cards on board), 1 = time, 2 = aborted (by buttons). int final_bonus_score_val = 0; int final_score_val = 0; final_score.text = current_score.ToString(scoreFormat); final_bonus_score.text = "0"; final_total_score.text = current_score.ToString(scoreFormat); final_bonus_score_val = 4 * ((int)(left_time * (cards_on_board.Length - current_total_card_on_board) / cards_on_board.Length)); final_score_val = current_score + final_bonus_score_val; if (GameTaco.TacoSetup.Instance.IsTournamentPlayed()) { GameTaco.TacoSetup.Instance.TacoPostScore(final_score_val); yield break; } if (!game_end) { game_end = true; player_can_move = false; PyramidMenu.GetInstance().ClosePopups(); PyramidMenu.GetInstance().OpenBlackFade(); if (endMode == 0) { MenuManager.GetInstance().PlaySound(MenuManager.SoundNamesEnum.WIN_SOUND, false, 1); } yield return(new WaitForSeconds(show_win_or_lose_screen_after_delay)); PyramidMenu.GetInstance().OpenPopup(1); if (PyramidMenu.GetInstance().endDialog_moveAnimator.gameObject.activeSelf) { popup_animation_duration = PyramidMenu.GetInstance().endDialog_moveAnimator.GetCurrentAnimatorClipInfo(0).Length; } yield return(new WaitForSeconds(popup_animation_duration + 0.5f)); if (final_bonus_score_val > 0) { MenuManager.GetInstance().PlaySound(MenuManager.SoundNamesEnum.SCORE_TALLY_SOUND, true, 0); } float time = 0; float displayEvery = 1.0F; while (time < 1) { float delta = Time.smoothDeltaTime / final_score_grow_time; time += delta; displayEvery += delta; if (displayEvery > 0.04F) { final_bonus_score.text = Mathf.Lerp(0, final_bonus_score_val, time).ToString(scoreFormat); final_total_score.text = Mathf.Lerp(current_score, final_score_val, time).ToString(scoreFormat); int ctime = Mathf.CeilToInt(Mathf.Lerp(0, left_time, 1.0f - time)); int seconds = ctime % 60; int minutes = ctime / 60; bonus_text.text = string.Format("{0}:{1:00}", minutes, seconds); displayEvery = 0.0F; } yield return(null); } final_score.text = current_score.ToString(scoreFormat); final_bonus_score.text = final_bonus_score_val.ToString(scoreFormat); final_total_score.text = final_score_val.ToString(scoreFormat); bonus_text.text = "0:00"; MenuManager.GetInstance().StopSound(0); UpdateScore(final_bonus_score_val); yield return(new WaitForSeconds(hide_win_or_lose_screen_after_delay)); MenuManager.GetInstance().StopAll(); //#if UNITY_EDITOR SceneManager.LoadScene(MenuManager.SceneNames [(int)MenuManager.SceneNamesEnum.MAIN_SCENE]); /*#else * SceneManager.LoadScene(MenuManager.SceneNames[(int)MenuManager.SceneNamesEnum.SKILLZ_SCENE]); * if (SkillzSDK.Api.IsTournamentInProgress) * { * SkillzSDK.Api.FinishTournament(final_score_val); * } #endif*/ } }
//this script void Awake() { instance = this; panel = GameObject.Find("Black_Panel"); panel_cg = panel.GetComponent <CanvasGroup> (); panel_cg.interactable = false; panel_cg.blocksRaycasts = false; Color c = Color.black; c.a = 0.0f; panel.GetComponent <Image> ().color = c; GameObject st = MenuManager.Find(gameObject, "Sound_Toggle", true); Toggle t = st.GetComponent <Toggle> (); int val = PlayerData.GetInstance().GetValueAsInt("soundVolume"); t.isOn = val == 0 ? false : true; MenuManager.GetInstance().MuteAll(!t.isOn); dialog_image = MenuManager.Find(gameObject, "Dialog_Image", true); dialog_cg = dialog_image.GetComponent <CanvasGroup> (); dialog_moveAnimator = dialog_image.GetComponent <Animator> (); dialog_cg.interactable = false; dialog_image.SetActive(false); confirmationDialog_image = MenuManager.Find(gameObject, "Confirmation_Image", true); confirmationDialog_cg = confirmationDialog_image.GetComponent <CanvasGroup> (); confirmationDialog_moveAnimator = confirmationDialog_image.GetComponent <Animator> (); confirmationDialog_cg.interactable = false; confirmationDialog_image.SetActive(false); pauseDialog_image = MenuManager.Find(gameObject, "Pause_Image", true); pauseDialog_cg = pauseDialog_image.GetComponent <CanvasGroup> (); pauseDialog_moveAnimator = pauseDialog_image.GetComponent <Animator> (); pauseDialog_cg.interactable = false; pauseDialog_image.SetActive(false); endDialog_image = MenuManager.Find(gameObject, "GameOver_Image", true); endDialog_cg = endDialog_image.GetComponent <CanvasGroup> (); endDialog_moveAnimator = endDialog_image.GetComponent <Animator> (); endDialog_cg.interactable = false; endDialog_image.SetActive(false); tutorialDialog_image = MenuManager.Find(gameObject, "HowToPlay_Image", true); tutorialDialog_cg = tutorialDialog_image.GetComponent <CanvasGroup> (); tutorialDialog_moveAnimator = tutorialDialog_image.GetComponent <Animator> (); tutorialDialog_cg.interactable = false; tutorialDialog_image.SetActive(false); GameObject combo = MenuManager.Find(gameObject, "ComboInfo_Image", true); combo_moveAnimator = combo.GetComponent <Animator> (); tipDialog_image = MenuManager.Find(gameObject, "Tip_Image", true); tipDialog_cg = tipDialog_image.GetComponent <CanvasGroup> (); tipDialog_moveAnimator = tipDialog_image.GetComponent <Animator> (); tipDialog_cg.interactable = false; tipDialog_image.SetActive(false); combo_score_event = MenuManager.Find(gameObject, "ComboScoreEvent", true); }