GameObject[] GetNotOwnedShipsFromPrefabList() { //Get all ships available from repository GameObject[] ships = Resources.LoadAll <GameObject>("Prefabs/Ships"); var ownedShipdsIds = PlayerStatusService.LoadPlayerStatus().GetOwnedShipsIDs(); return(ships.Where(x => !ownedShipdsIds.Contains(x.GetComponent <Ship>().GetId())).ToArray()); }
public void LoadOwnedShips(bool displayPriceTag) { PlayerStatusData playerData = PlayerStatusService.LoadPlayerStatus(); GameObject[] ships = GetAllShipsFromPrefabList(); GameObject[] filteredList = ships.Where(x => playerData.GetOwnedShipsIDs().Contains(x.GetComponent <Ship>().shipId)).ToArray(); PlotShipsIntoCarousel(filteredList, displayPriceTag); }
void DisableOwnedShips() { PlayerStatusData playerData = PlayerStatusService.LoadPlayerStatus(); foreach (var shipInstance in shipsInstance) { //if player has already bought this ship, disable its button if (playerData.GetOwnedShipsIDs().Contains(shipInstance.GetComponent <Ship>().shipId)) { DisableShipButtonClick(shipInstance); } } }
public void HideNotOwnedShips() { PlayerStatusData playerData = PlayerStatusService.LoadPlayerStatus(); List <int> ownedShipsIDs = playerData.GetOwnedShipsIDs(); foreach (var shipInstance in shipsInstance) { //if player doesn't have a ship, remove it from the interface if (!ownedShipsIDs.Contains(shipInstance.GetComponent <Ship>().shipId)) { shipInstance.SetActive(false); } } }
void DisableOwnedShips(Ship[] instantiatedShips) { //player data in ShipCarousel instance has not been loaded yet, so we'll have to do it manually PlayerStatusData playerData = PlayerStatusService.LoadPlayerStatus(); foreach (var shipInstance in instantiatedShips) { //if player has already bought this ship, disable its button if (playerData.GetOwnedShipsIDs().Contains(shipInstance.GetId())) { shipInstance.DisableCharacterButton(); } } }
public void SetCulture(string culture) { selectAudioSource.Play(); var playerData = PlayerStatusService.LoadPlayerStatus(); playerData.SetCurrentLanguage(culture); PlayerStatusService.SavePlayerStatus(playerData); LanguageService.ReloadDictionary(); scenesManager.LoadMainMenu(); }
public override void GivePrize(GameOverManager gameOverManager) { PlayerStatusService.LoadPlayerStatus().storedLifePrizes += base.Amount; AdsPrizeData prizeData = new AdsPrizeData(); prizeData.message = base.languageDictionary.adsResultMsgLives; prizeData.prizeSprite = Resources.Load <Sprite>(base.resourcesSpritePath + "StoredLives"); gameOverManager.SetPrizeMessage(prizeData); resultPrizeOkBtn.onClick.RemoveAllListeners(); resultPrizeOkBtn.onClick.AddListener(() => { resultPrizePanel.SetActive(false); }); }
private void Start() { playerData = PlayerStatusService.LoadPlayerStatus(); priceTag.text = string.Format("{0}", shipPrice); ui_shipDescription = GameObject.Find("SelectedItemDescription").GetComponent <Text>(); var selectedObjectManager = GameObject.Find("SelectedObjectManager").GetComponent <SelectedObjectManager>(); shipButton = this.transform.Find("ShipButton"); var cmp = shipButton.gameObject.GetComponentInChildren <Image>(); cmp.sprite = shipImage; //set listener when clicking to select object shipButton.GetComponent <Button>().onClick.AddListener(() => selectedObjectManager.SetSelectedObject(this)); originalColor = shipButton.GetComponent <Image>().color; }
public override void GivePrize(GameOverManager gameOverManager) { int finalCredits = gameOverManager.GetFinalScore(); int totalCredits = base.Amount * finalCredits; PlayerStatusService.LoadPlayerStatus().score += totalCredits; AdsPrizeData prizeData = new AdsPrizeData(); if (!string.IsNullOrEmpty(base.languageDictionary.adsResultMsgCredits)) { prizeData.message = string.Format(base.languageDictionary.adsResultMsgCredits, base.Amount); } prizeData.prizeSprite = Resources.Load <Sprite>(base.resourcesSpritePath + "Coin"); gameOverManager.SetPrizeMessage(prizeData); resultPrizeOkBtn.onClick.RemoveAllListeners(); resultPrizeOkBtn.onClick.AddListener(() => { resultPrizePanel.SetActive(false); gameOverManager.RollScoreForAdsCredits(totalCredits); }); }
static LanguageDictionary LoadDictionary() { var currentCulture = PlayerStatusService.LoadPlayerStatus().GetCurrentLanguage(); LanguageDictionary ld = new LanguageDictionary(); ld.isLoaded = false; if (Application.platform == RuntimePlatform.Android) { string filePath = string.Format("{0}/Language_{1}.json", Application.streamingAssetsPath, currentCulture); WWW reader = new WWW(filePath); while (!reader.isDone) { } //we have to remove 3 bytes from the reader head and parse it into string string jsonString; jsonString = System.Text.Encoding.UTF8.GetString(reader.bytes, 3, reader.bytes.Length - 3); ld = JsonUtility.FromJson <LanguageDictionary>(jsonString); ld.isLoaded = true; } return(ld); }
public override Action BuyItem() { return(() => PlayerStatusService.LoadPlayerStatus().IncreaseLifeBuff(1)); }
public override Func <bool> HasReachedItemMax() { return(() => PlayerStatusService.LoadPlayerStatus().CanIncreaseLifeBuff()); }
public override Action BuyItem() { return(() => PlayerStatusService.LoadPlayerStatus().IncreaseJackpotTokens(1)); }
public override Action BuyItem() { return(() => PlayerStatusService.LoadPlayerStatus().IncreaseShieldUpgrade()); }
public override Func <bool> HasReachedItemMax() { return(() => PlayerStatusService.LoadPlayerStatus().CanUpgradeShield()); }