//TODO: reset attempts after midnight public int GetMissionAttemptsUsed(EPlanetKey planetKey, EMissionKey missionKey) { if (_dailyMissionAttempts.ContainsKey(planetKey) && _dailyMissionAttempts[planetKey].ContainsKey(missionKey)) { return _dailyMissionAttempts[planetKey][missionKey]; } return 0; }
public void Start() { #if UNITY_EDITOR && MISSIONS_TEST if (!Global.IsInitialized) { Global.Instance.Initialize(); } #endif Global.Instance.Initialize(); PlanetData pd = MissionsConfig.Instance.GetPlanet(_missionKey); if (pd != null) { _planetKey = MissionsConfig.Instance.GetPlanet(_missionKey).Key; } bool missionAvailable = false; if (_planetKey != EPlanetKey.None && _missionKey != EMissionKey.None) { if (Global.Instance.Player.StoryProgress != null && Global.Instance.Player.StoryProgress.IsMissioAvailable(_planetKey, _missionKey)) { missionAvailable = true; } } if (missionAvailable) { gameObject.GetComponent <Button>().onClick.AddListener(OnIconClick); } else { gameObject.GetComponent <Button>().interactable = false; } }
public bool IsMissioAvailable(EPlanetKey planetKey, EMissionKey missionKey) { PlanetData pd = MissionsConfig.Instance.GetPlanet(planetKey); if (pd != null) { for (int i = 0; i < pd.Missions.Length; i++) { if (pd.Missions[i].Key == missionKey) { //first mission if (i == 0) { if (MissionsConfig.Instance.Planets[i].Key == pd.Key) { //first planet return(true); } else { //check prev planet return(IsPlanetCompleted(MissionsConfig.Instance.GetPreviuosPlanet(planetKey).Key)); } } else { //check prev mission return(IsMissionCompleted(planetKey, pd.Missions[i - 1].Key)); } } } } return(false); }
public void Setup(EPlanetKey planetKey, EMissionKey missionKey) { _planetKey = planetKey; _missionKey = missionKey; MissionData md = MissionsConfig.Instance.GetPlanet(planetKey).GetMission(missionKey); if (md != null) { _lblCreditsAmount.text = string.Format("+ {0}", md.RewardCredits); _lblExpAmount.text = string.Format("+ {0}", md.RewardExperienceWin); Sprite heroBackIconResource = UIResourcesManager.Instance.GetResource<Sprite>(GameConstants.Paths.GetUnitBGIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName)); if (heroBackIconResource != null) { _imgHeroBG.sprite = heroBackIconResource; _imgHeroBG.enabled = true; } else { _imgHeroBG.enabled = false; } Sprite heroIconResource = UIResourcesManager.Instance.GetResource<Sprite>(GameConstants.Paths.GetUnitIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName)); if (heroIconResource != null) { _imgHeroFG.sprite = heroIconResource; _imgHeroFG.enabled = true; } else { _imgHeroFG.enabled = false; } SetupLoot(MissionsConfig.Instance.GetPlanet(planetKey).GetMission(missionKey).RewardItems); } }
public void Start() { #if UNITY_EDITOR && MISSIONS_TEST if (!Global.IsInitialized) { Global.Instance.Initialize(); } #endif Global.Instance.Initialize(); PlanetData pd = MissionsConfig.Instance.GetPlanet(_missionKey); if (pd != null) { _planetKey = MissionsConfig.Instance.GetPlanet(_missionKey).Key; } bool missionAvailable = false; if (_planetKey != EPlanetKey.None && _missionKey != EMissionKey.None) { if (Global.Instance.Player.StoryProgress != null && Global.Instance.Player.StoryProgress.IsMissioAvailable(_planetKey, _missionKey)) { missionAvailable = true; } } if (missionAvailable) { gameObject.GetComponent<Button>().onClick.AddListener(OnIconClick); } else { gameObject.GetComponent<Button>().interactable = false; } }
public void Setup(EPlanetKey planetKey, EMissionKey missionKey) { _planetKey = planetKey; _missionKey = missionKey; MissionData md = MissionsConfig.Instance.GetPlanet(planetKey).GetMission(missionKey); if (md != null) { _lblExpAmount.text = string.Format("+ {0}", md.RewardExperienceWin); Sprite heroBackIconResource = UIResourcesManager.Instance.GetResource <Sprite>(GameConstants.Paths.GetUnitBGIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName)); if (heroBackIconResource != null) { _imgHeroBG.sprite = heroBackIconResource; _imgHeroBG.enabled = true; } else { _imgHeroBG.enabled = false; } Sprite heroIconResource = UIResourcesManager.Instance.GetResource <Sprite>(GameConstants.Paths.GetUnitIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName)); if (heroIconResource != null) { _imgHeroFG.sprite = heroIconResource; _imgHeroFG.enabled = true; } else { _imgHeroFG.enabled = false; } } }
public void SaveProgress(EPlanetKey planetKey, EMissionKey missionKey) { if (!IsMissionCompleted(planetKey, missionKey)) { if (!_progress.ContainsKey(planetKey)) { _progress.Add(planetKey, new List<EMissionKey>()); } _progress[planetKey].Add(missionKey); } }
public bool IsMissionCompleted(EPlanetKey planetKey, EMissionKey missionKey) { if (!_progress.ContainsKey(planetKey)) { return(false); } return(_progress[planetKey].IndexOf(missionKey) != -1); }
//TODO: reset attempts after midnight public int GetMissionAttemptsUsed(EPlanetKey planetKey, EMissionKey missionKey) { if (_dailyMissionAttempts.ContainsKey(planetKey) && _dailyMissionAttempts[planetKey].ContainsKey(missionKey)) { return(_dailyMissionAttempts[planetKey][missionKey]); } return(0); }
public void Setup(EPlanetKey planetKey, EMissionKey missionKey) { _planetKey = planetKey; _missionKey = missionKey; SetupAvailableUnits(); SetupHiredUnits(); UpdateLeadership(); UpdateSoldiersHireAvailability(); }
public void RegisterAttemptUsage(EPlanetKey planetKey, EMissionKey missionKey) { if (!_dailyMissionAttempts.ContainsKey(planetKey)) { _dailyMissionAttempts.Add(planetKey, new Dictionary<EMissionKey,int>()); } if(!_dailyMissionAttempts[planetKey].ContainsKey(missionKey)) { _dailyMissionAttempts[planetKey].Add(missionKey, 1); } else { _dailyMissionAttempts[planetKey][missionKey]++; } }
public PlanetData GetPlanet(EPlanetKey planetKey) { for (int i = 0; i < _planets.Length; i++) { if (_planets[i].Key == planetKey) { return(_planets[i]); } } return(null); }
public void SaveProgress(EPlanetKey planetKey, EMissionKey missionKey) { if (!IsMissionCompleted(planetKey, missionKey)) { if (!_progress.ContainsKey(planetKey)) { _progress.Add(planetKey, new List <EMissionKey>()); } _progress[planetKey].Add(missionKey); } }
public void Setup(EPlanetKey planetKey, EMissionKey missionKey) { _planetKey = planetKey; _missionKey = missionKey; SetupCurrentHero(); //SetupAvailableUnits(); //SetupHiredUnits(); _imgCurrrentSoldier.GetComponent<MultiImageButton>(); UpdateLeadership(); //UpdateSoldiersHireAvailability(); }
public void Setup(EPlanetKey planetKey, EMissionKey missionKey) { _planetKey = planetKey; _missionKey = missionKey; SetupCurrentHero(); //SetupAvailableUnits(); //SetupHiredUnits(); _imgCurrrentSoldier.GetComponent <MultiImageButton>(); UpdateLeadership(); //UpdateSoldiersHireAvailability(); }
public bool IsPlanetCompleted(EPlanetKey planetKey) { if (!_progress.ContainsKey(planetKey)) { return false; } PlanetData pd = MissionsConfig.Instance.GetPlanet(planetKey); for (int i = 0; i < pd.Missions.Length; i++) { if (!IsMissionCompleted(planetKey, pd.Missions[i].Key)) { return false; } } return true; }
public void Setup(EPlanetKey planetKey, EMissionKey missionKey) { _planetKey = planetKey; _missionKey = missionKey; MissionData md = MissionsConfig.Instance.GetPlanet(planetKey).GetMission(missionKey); if (md != null) { //TODO: setup title SetupAttempts(md); SetupFuel(md); SetupEnemies(md); SetupLoot(md); } }
private void OnWindowHide(UIWindow window) { _planetKey = EPlanetKey.None; _missionKey = EMissionKey.None; //hero //if (_imgHero.sprite != null) { // _imgHero.sprite = null; // UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName)); //} //TODO: free resources and clear data _slotManager.Clear(); SetSelectedUnit(null); }
public void RegisterAttemptUsage(EPlanetKey planetKey, EMissionKey missionKey) { if (!_dailyMissionAttempts.ContainsKey(planetKey)) { _dailyMissionAttempts.Add(planetKey, new Dictionary <EMissionKey, int>()); } if (!_dailyMissionAttempts[planetKey].ContainsKey(missionKey)) { _dailyMissionAttempts[planetKey].Add(missionKey, 1); } else { _dailyMissionAttempts[planetKey][missionKey]++; } }
private void OnWindowHide(UIWindow window) { _planetKey = EPlanetKey.None; _missionKey = EMissionKey.None; //clear labels _lblExpAmount.text = "+ 0"; //hero if (_imgHeroBG.sprite != null) { _imgHeroBG.sprite = null; UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitBGIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName)); } if (_imgHeroFG.sprite != null) { _imgHeroFG.sprite = null; UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName)); } }
public PlanetData GetPreviuosPlanet(EPlanetKey planetKey) { for (int i = 0; i < _planets.Length; i++) { if (_planets[i].Key == planetKey) { if (i > 0) { return(_planets[i - 1]); } else { return(null); } } } return(null); }
public bool IsPlanetCompleted(EPlanetKey planetKey) { if (!_progress.ContainsKey(planetKey)) { return(false); } PlanetData pd = MissionsConfig.Instance.GetPlanet(planetKey); for (int i = 0; i < pd.Missions.Length; i++) { if (!IsMissionCompleted(planetKey, pd.Missions[i].Key)) { return(false); } } return(true); }
private void OnWindowHide(UIWindow window) { _planetKey = EPlanetKey.None; _missionKey = EMissionKey.None; //clear loot if (_lootItems != null) { for (int i = 0; i < _lootItems.Length; i++) { _lootItemImages[i].sprite = null; if (i > 0) { GameObject.Destroy(_lootItemImages[i].gameObject); } UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetLootIconResourcePath(_lootItems[i])); } } _lootItems = null; _lootItemImages = null; //clear labels _lblCreditsAmount.text = "+ 0"; _lblExpAmount.text = "+ 0"; //hero if (_imgHeroBG.sprite != null) { _imgHeroBG.sprite = null; UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitBGIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName)); } if (_imgHeroFG.sprite != null) { _imgHeroFG.sprite = null; UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetUnitIconResourcePath(Global.Instance.Player.Heroes.Current.Data.IconName)); } }
public bool IsMissioAvailable(EPlanetKey planetKey, EMissionKey missionKey) { PlanetData pd = MissionsConfig.Instance.GetPlanet(planetKey); if(pd != null) { for (int i = 0; i < pd.Missions.Length; i++) { if (pd.Missions[i].Key == missionKey) { //first mission if (i == 0) { if (MissionsConfig.Instance.Planets[i].Key == pd.Key) { //first planet return true; } else { //check prev planet return IsPlanetCompleted(MissionsConfig.Instance.GetPreviuosPlanet(planetKey).Key); } } else { //check prev mission return IsMissionCompleted(planetKey, pd.Missions[i - 1].Key); } } } } return false; }
private void OnWindowHide(UIWindow window) { _planetKey = EPlanetKey.None; _missionKey = EMissionKey.None; //clear enemies if (_enemies != null) { for (int i = 0; i < _enemies.Length; i++) { _enemyIcons[i].Clear(); if (i > 0) { GameObject.Destroy(_enemyIcons[i].gameObject); } } } _enemies = null; _enemyIcons = null; //clear loot if (_lootItems != null) { for (int i = 0; i < _lootItems.Length; i++) { _lootItemImages[i].sprite = null; if (i > 0) { GameObject.Destroy(_lootItemImages[i].gameObject); } UIResourcesManager.Instance.FreeResource(GameConstants.Paths.GetLootIconResourcePath(_lootItems[i])); } } _lootItems = null; _lootItemImages = null; }
public void Show(EPlanetKey planetKey, EMissionKey missionKey) { Setup(planetKey, missionKey); Show(); }
public bool IsMissionCompleted(EPlanetKey planetKey, EMissionKey missionKey) { if (!_progress.ContainsKey(planetKey)) { return false; } return _progress[planetKey].IndexOf(missionKey) != -1; }