/// <summary> /// Get the language from index (a dropdown example) and translate every text /// </summary> /// <param name="language"></param> public void ChangeLanguageFromIndex(int language) { m_currentLanguage = ActiveLanguages[language]; m_currentLanguageIndex = language; PlayerPrefs.SetInt(PC_GameSetup.PlayerPrefs.LAST_LANGUAGE, m_currentLanguageIndex); PC_EventManager.TriggerEvent(PC_EventSetup.Localization.TRANSLATE_TEXTS); }
// Use this for initialization protected override void Start() { base.Start(); InitializeGame(DIFFICULTY.EASY); PC_EventManager.StartListening(PC_EventSetup.SlotMachine.CAN_INSERT, ResetLines); PC_EventManager.StartListening(PC_EventSetup.GAME_LOADED, GameLoaded); }
/// <summary> /// Load the data from the file /// </summary> public void LoadGame() { if (File.Exists(m_path)) { if (PC_GameSetup.Game_Settings.ENCRYPT_SAVE_FILES) { m_gameData = PC_ComplexFormatter.LoadObjectFromDESFile <PC_SaveData>(m_path); } else if (PC_GameSetup.Game_Settings.USE_BINARY_SAVE_FILES) { m_gameData = PC_ComplexFormatter.LoadObjectFromBinaryFile <PC_SaveData>(m_path); } else { m_gameData = m_gameData = PC_ComplexFormatter.LoadObjectFromJSONFile <PC_SaveData>(m_path); } PC_Casino.Instance.SetSaveData(m_gameData); Debug.Log("Loaded the game data from " + m_path); } else { // We create initial Data PC_Casino.Instance.InitData(); SaveGame(); PC_EventManager.TriggerEvent(PC_EventSetup.GAME_LOADED); } }
/// <summary> /// Method for changing the language. Calling this method will launch translate event so every text shows correctly /// </summary> /// <param name="language"></param> public void ChangeLanguage(SystemLanguage language) { m_currentLanguage = !m_activelanguages.Contains(language) ? SystemLanguage.English : language; m_currentLanguageIndex = m_activelanguages.IndexOf(m_currentLanguage); PlayerPrefs.SetInt(PC_GameSetup.PlayerPrefs.LAST_LANGUAGE, m_currentLanguageIndex); PC_EventManager.TriggerEvent(PC_EventSetup.Localization.TRANSLATE_TEXTS); }
// Use this for initialization void Start() { if (!m_animator) { m_animator = GetComponent <Animator>(); } PC_EventManager.StartListening(PC_EventSetup.SlotMachine.LOSE, Lose); PC_EventManager.StartListening <string>(PC_EventSetup.SlotMachine.PLAY_ANIMATION, PlayAnimation); }
// Use this for initialization void Start() { m_gameData = new PC_SaveData(); m_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\" + m_gameName; if (!Directory.Exists(m_path)) { Directory.CreateDirectory(m_path); Debug.Log("Creating Path in " + m_path); } m_path += "\\" + PC_SaveSetup.SAVE_FILE; PC_EventManager.StartListening(PC_EventSetup.SAVE_GAME, SaveGame); PC_EventManager.StartListening(PC_EventSetup.LOAD_GAME, LoadGame); }
void ResetLines() { StopAllCoroutines(); foreach (GameObject btn in m_buttons) { btn.SetActive(false); } foreach (GameObject ln in m_lines) { ln.SetActive(false); } m_gameEnded = false; m_needToPay = false; m_wager = 0; m_payout = 0; m_panel.m_lose = false; m_replay = false; m_payOutScore.SetScores(m_payout); PC_Casino.Instance.Coins = m_coins; PC_EventManager.TriggerEvent(PC_EventSetup.SlotMachine.PLAY_ANIMATION, PC_GameSetup.SlotMachine.INSERT); }
void Payout() { List <int> temp = new List <int>(); List <int> shownValues = new List <int>(); foreach (PC_SlotMachineReel r in m_reels) { temp.Clear(); temp = r.Show(); shownValues.Add(temp[0]); shownValues.Add(temp[1]); shownValues.Add(temp[2]); } int [,] combinations = new int[, ] { { shownValues[1], shownValues[4], shownValues[7] }, // Center row { shownValues[0], shownValues[3], shownValues[6] }, // Top row { shownValues[2], shownValues[5], shownValues[8] }, // Bottom row { shownValues[0], shownValues[4], shownValues[8] }, // Diagonal top left -> bottom right { shownValues[2], shownValues[4], shownValues[6] }, // Diagonal bottom left -> top right }; shownValues.Clear(); m_payout = 0; int bonus = 0; int length = combinations.GetLength(0); bool[] wonRow = new bool[length]; for (int i = 0; i < length; i++) { // One coin = centre row only and Two coins = three rows only if (i >= 1 && m_wager <= 1 || i >= 3 && m_wager <= 2) { break; } wonRow[i] = true; // Three Magnemites or shellders if ((combinations[i, 0] == 1 && combinations[i, 1] == 1 && combinations[i, 2] == 1) || (combinations[i, 0] == 2 && combinations[i, 1] == 2 && combinations[i, 2] == 2)) { m_payout += 8; } // Three Pikachus or Three Psyducks else if ((combinations[i, 0] == 3 && combinations[i, 1] == 3 && combinations[i, 2] == 3) || (combinations[i, 0] == 4 && combinations[i, 1] == 4 && combinations[i, 2] == 4)) { m_payout += 15; } // Three 777 blue or red else if ((combinations[i, 0] == 6 && combinations[i, 1] == 6 && combinations[i, 2] == 6) || (combinations[i, 0] == 5 && combinations[i, 1] == 5 && combinations[i, 2] == 5)) { m_payout += 300; if (bonus < 2) { bonus = 2; } } // 777, red red blue combinations else if ((combinations[i, 0] == 5 && combinations[i, 1] == 5 && combinations[i, 2] == 6) || (combinations[i, 0] == 5 && combinations[i, 1] == 6 && combinations[i, 2] == 5) || (combinations[i, 0] == 6 && combinations[i, 1] == 5 && combinations[i, 2] == 5) || (combinations[i, 0] == 6 && combinations[i, 1] == 6 && combinations[i, 2] == 5) || (combinations[i, 0] == 6 && combinations[i, 1] == 5 && combinations[i, 2] == 6) || (combinations[i, 0] == 5 && combinations[i, 1] == 6 && combinations[i, 2] == 6)) { m_payout += 90; if (bonus < 1) { bonus = 1; } } else if ((combinations[i, 0] == 7 && combinations[i, 1] == 7 && combinations[i, 2] == 7)) { m_replay = true; } else { if (combinations[i, 0] == 0) // Left cherry { if (combinations[i, 1] == 0) // Center cherry { if (combinations[i, 2] == 0) // Right Cherry { m_payout += 4; } else { m_payout += 2; } } } else { wonRow[i] = false; } } } m_payOutScore.SetScores(m_payout); if (m_payout > 0 || m_replay) { if (bonus > 0) { PC_AudioManager.PlayME(m_slotsBigWin); } else { PC_AudioManager.PlayME(m_slotsWin); } if (bonus > 0) { PC_EventManager.TriggerEvent(PC_EventSetup.SlotMachine.PLAY_ANIMATION, PC_GameSetup.SlotMachine.BONUS + (bonus - 1));//m_panel.PlayAnimation(PC_GameSetup.SlotMachine.BONUS+(bonus-1)); } else { PC_EventManager.TriggerEvent(PC_EventSetup.SlotMachine.PLAY_ANIMATION, PC_GameSetup.SlotMachine.WIN);//m_panel.PlayAnimation(PC_GameSetup.SlotMachine.WIN); } m_needToPay = true; StartCoroutine(DelayPayOut()); } else // LOOOSER { PC_AudioManager.PlaySE(m_error); PC_EventManager.TriggerEvent(PC_EventSetup.SlotMachine.LOSE); } }
// Update is called once per frame protected override void Update() { if (m_credit.m_scoreValue >= PC_GameSetup.Casino.COIN_LIMIT) { Debug.LogWarning("You've got 99,999 Coins."); EndGame(); } else if (m_coins <= 0) { Debug.LogError("GAME OVER"); EndGame(); } else if (m_gameRunning) // Reels are spinning { bool stop = false; if (PC_InputManager.IsConfirmInputPressedDown()) { PC_AudioManager.PlaySE(m_slotStop); if (m_reels[0].IsSpinning) { m_reels[0].StopSpinning(m_replay); m_buttons[0].SetActive(true); } else if (m_reels[1].IsSpinning) { m_reels[1].StopSpinning(m_replay); m_buttons[1].SetActive(true); } else if (m_reels[2].IsSpinning) { m_reels[2].StopSpinning(m_replay); m_buttons[2].SetActive(true); stop = true; } } if (stop) { m_gameRunning = false; m_gameEnded = true; Payout(); } } else if (m_gameEnded && m_panel.m_lose) { StartCoroutine(Delay(2f)); if (PC_InputManager.IsConfirmInputPressedDown()) { ResetLines(); } } else if (!m_gameEnded && m_panel.m_lose) { ResetLines(); return; } else if (m_needToPay) { return; } else // Awaiting coins for the next spin { if (m_wager < 3 && m_coins > 0 && PC_InputManager.IsWagerInputPressed()) { PC_AudioManager.PlaySE(m_slotCoin); if (m_wager == 0) { PC_EventManager.TriggerEvent(PC_EventSetup.SlotMachine.PLAY_ANIMATION, PC_GameSetup.SlotMachine.PRESS);//m_panel.PlayAnimation(PC_GameSetup.SlotMachine.PRESS); } ++m_wager; --m_coins; m_credit.SetScores(m_coins); if (m_wager >= 3) { m_lines[4].SetActive(true); m_lines[3].SetActive(true); } else if (m_wager >= 2) { m_lines[2].SetActive(true); m_lines[1].SetActive(true); } if (m_wager >= 1) { m_lines[0].SetActive(true); } } else if (m_wager >= 3 || (m_wager > 0 && m_coins == 0) || (PC_InputManager.IsConfirmInputPressedDown() && m_wager > 0) || m_replay) { if (m_replay) { m_wager = 3; foreach (GameObject ln in m_lines) { ln.SetActive(true); } } m_gameRunning = true; PC_EventManager.TriggerEvent(PC_EventSetup.SlotMachine.PLAY_ANIMATION, PC_GameSetup.SlotMachine.STOP); //m_panel.PlayAnimation(PC_GameSetup.SlotMachine.STOP); foreach (PC_SlotMachineReel reel in m_reels) { reel.StartSpinning(); } } if (PC_InputManager.IsCancelInputPressed() && m_wager == 0) { //GO OUT Debug.Log("EXIT GAME"); GoBackToCasino(); } } }
void CanInsertAgain() { m_lose = false; PC_EventManager.TriggerEvent(PC_EventSetup.SlotMachine.CAN_INSERT); }