private IEnumerator StartExploreClock(exploreGroups eG) { Debug.Log("SEC Started ETC:" + (eG.ETC - ConvertToUnixTimestamp(System.DateTime.Now))); OnExploreStarted.Invoke(); yield return(new WaitForSecondsRealtime((int)(eG.ETC - ConvertToUnixTimestamp(System.DateTime.Now)))); Debug.Log("SEC Ended"); for (int i = 0; i < overallData.gameData.exploreGroups.Count; i++) { if (IsSame(overallData.gameData.exploreGroups[i], eG)) { ExploreEnded(i); } } }
//------------ //Change Text //------------ void ChangeGroupText() { string outputText = ""; for (int i = 0; i < overallStats.groupCount; i++) { exploreGroups eG = overallStats.GetGroupData(i); string crews = ""; foreach (int id in eG.crews) { crews += CLD.GetCatName(id); } if (i > 0) { outputText += "\n"; } outputText += string.Format("{0} crews:{1} ETC:{2}", eG.groupName, crews, eG.ETC - ConvertToUnixTimestamp(System.DateTime.Now)); } groupText.text = outputText; }
public bool IsSame(exploreGroups eg1, exploreGroups eg2) { if (eg1.ETC != eg2.ETC) { return(false); } if (eg1.crews.Length == eg2.crews.Length) { for (int i = 0; i < eg1.crews.Length; i++) { if (eg1.crews[i] != eg2.crews[i]) { return(false); } } } else { return(false); } return(eg1.destination == eg2.destination && eg1.groupName == eg2.groupName); }
public bool SendGroup(int[] crew, int levelID) { exploreGroups eG = new exploreGroups(); eG.crews = crew; eG.destination = levelID; eG.groupName = "Group " + (groupCount + 1); eG.ETC = ConvertToUnixTimestamp(System.DateTime.Now) + CLD.GetLevelByID(levelID).distance; if (!canSendGroup) { Debug.LogError("CAN'T SEND MORE GROUP F****R"); return(false); } int count = 0; for (int i = 0; i < eG.crews.Length; i++) { if (i == 0 || eG.crews[i] == eG.crews[i - 1]) { count++; } else { CatControl(eG.crews[i - 1], -count, CatControlType.avaliable); count = 1; } if (i + 1 == eG.crews.Length) { CatControl(eG.crews[i], -count, CatControlType.avaliable); } } overallData.gameData.exploreGroups.Add(eG); StartCoroutine(StartExploreClock(eG)); Debug.Log("Explore Started"); return(true); }
private void ExploreEnded(int indexInList) { Debug.Log("Explore Ended"); exploreGroups eG = overallData.gameData.exploreGroups[indexInList]; levels lvl = CLD.GetLevelByID(eG.destination); List <Ientity> loots = new List <Ientity>(CalculateLoots(lvl, eG.crews)); bool explored = false; int count = 0; //return cats to count for (int i = 0; i < eG.crews.Length; i++) { if (i == 0 || eG.crews[i] == eG.crews[i - 1]) { count++; } else { CatControl(eG.crews[i - 1], count, CatControlType.avaliable); count = 1; } if (i + 1 == eG.crews.Length) { CatControl(eG.crews[i], count, CatControlType.avaliable); } } //adding loots to inventory for (int i = 0; i < loots.Count; i++) { Debug.Log("aye" + loots[i].GetType()); count = 1; for (int j = i + 1; j < loots.Count; j++) { Debug.Log("aye" + loots[j].GetType()); if (loots[i].GetType() == loots[j].GetType() && loots[i].id == loots[j].id) { Debug.Log("DIE"); count++; loots.RemoveAt(j); j--; } } if (loots[i].GetType() == typeof(catData)) { CatControl(loots[i].id, count, CatControlType.count); } else { ItemControl(loots[i].id, count); } } //setting explored level foreach (exploredLevels exLvl in overallData.gameData.exploredLevels) { if (exLvl.id == lvl.id) { exLvl.rate += lvl.rate; explored = true; if (exLvl.rate >= 100) { unlockScore++; } } } if (!explored) { exploredLevels exLvl = new exploredLevels(); exLvl.id = lvl.id; exLvl.rate = lvl.rate; overallData.gameData.exploredLevels.Add(exLvl); if (exLvl.rate >= 100) { unlockScore++; } } overallData.gameData.exploreGroups.RemoveAt(indexInList); OnLevelDataChanged.Invoke(); OnGroupDataChanged.Invoke(); OnExploreEnded.Invoke(); }