public string EndGameDialog() { PlayerMeta player = BaseSaver.GetPlayer(); GameMeta game = BaseSaver.GetGame(); Unit.FactionType faction = player.faction; World world = player.world; string returnStr = "Congratulations! You have completed the campaign for faction: " + faction.ToString() + "!"; List <World> unlockedWorldsLst = new List <World>(game.unlockedWorlds); if (world != World.candy) { List <Unit.FactionType> unlockedFactionLst = new List <Unit.FactionType>(game.unlockedFactions); switch (faction) { case Unit.FactionType.Human: if (!unlockedWorldsLst.Contains(World.mountain)) { unlockedWorldsLst.Add(World.mountain); unlockedFactionLst.Add(Unit.FactionType.Egypt); returnStr += "\n\n Unlocked faction: " + Unit.FactionType.Egypt.ToString() + "!"; } break; case Unit.FactionType.Egypt: if (!unlockedWorldsLst.Contains(World.pyramid)) { unlockedWorldsLst.Add(World.pyramid); unlockedFactionLst.Add(Unit.FactionType.Cthulhu); returnStr += "\n\n Unlocked faction: " + Unit.FactionType.Cthulhu.ToString() + "!"; } break; case Unit.FactionType.Cthulhu: if (!unlockedWorldsLst.Contains(World.candy)) { unlockedWorldsLst.Add(World.candy); returnStr += "\n\n Unlocked world: " + World.candy.ToString() + "!"; } break; } game.unlockedFactions = unlockedFactionLst.ToArray(); game.unlockedWorlds = unlockedWorldsLst.ToArray(); } else { if (!unlockedWorldsLst.Contains(World.final)) { unlockedWorldsLst.Add(World.final); } returnStr += "\n\n The world has been saved! Your accomplishments have been logged in the annals history."; } BaseSaver.PutGame(game); HighScoreMeta.SaveCurrentScore(); //Reset the current save now that the factions / worlds have been unlocked and highscores saved BaseSaver.ResetAtSave(); return(returnStr); }
void PopulateClassesPanel() { classPnl.SetActive(true); classBtn.GetComponent <Outline>().effectColor = Color.red; GameMeta game = BaseSaver.GetGame(); string pnlString = ""; classPnl.transform.GetChild(1).GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>().text = pnlString; classPnl.transform.GetChild(1).GetChild(1).GetChild(0).GetComponent <Animator>().runtimeAnimatorController = null; classPnl.transform.GetChild(1).GetChild(1).GetChild(0).GetComponent <ImageAnimation>().Flush(); classPnl.transform.GetChild(1).GetChild(2).GetComponent <TextMeshProUGUI>().text = pnlString; classPnl.transform.GetChild(1).GetChild(3).GetComponent <TextMeshProUGUI>().text = pnlString; string[] clssSeen = game.classesSeen.Where(clss => !(clss.Contains("BaseMage") || clss.Contains("BaseScout") || clss.Contains("BaseSoldier"))).ToArray(); if (clssSeen.Length > 0) { game.classesSeen = game.classesSeen.OrderBy(nm => nm).ToArray(); classPnl.transform.GetChild(0).GetChild(0).GetComponent <RectTransform>().sizeDelta = new Vector2(800, 150 * game.classesSeen.Length); foreach (Transform child in classPnl.transform.GetChild(0).GetChild(0)) { Destroy(child.gameObject); } //string[] clssSeen = game.classesSeen.Where(clss => !(clss.Contains("BaseMage") || clss.Contains("BaseScout") || clss.Contains("BaseSoldier"))).ToArray(); for (int i = 0; i < clssSeen.Length; i++) { //foreach(string clss in game.classesSeen.Where(clss => !(clss.Contains("BaseMage") || clss.Contains("BaseScout") || clss.Contains("BaseSoldier"))).ToArray()){ string clss = clssSeen[i]; GameObject clssCpy = Instantiate(clssRw, classPnl.transform.GetChild(0).GetChild(0)); clssCpy.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = ClassNode.FormatClass(clss); ClassNode nde = StaticClassRef.GetClass((StaticClassRef.AvailableClasses)Enum.Parse(typeof(StaticClassRef.AvailableClasses), clss)); UnitProxy baseUnit = ClassNode.ComputeClassBaseUnit(nde, glossy); clssCpy.transform.GetChild(1).GetComponent <Image>().sprite = baseUnit.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; clssCpy.transform.GetChild(2).GetComponent <TextMeshProUGUI>().text = " " + ClassNode.GetFactionFromClass(clss); clssCpy.GetComponent <Button>().onClick.AddListener(() => { instance.SetClassInfoText("Battle Bonus: " + StaticClassRef.GetFullClassDescription(clss) + "\n\nInactive Bonus: " + nde.ClassInactiveDesc(), StaticClassRef.GetClassByReference(clss).ClassName(), ClassNode.GetClassHeirarchyString(nde)); instance.SetClassSpriteAnimator(baseUnit.transform.GetChild(0).GetComponent <Animator>()); }); if (i == 0) { clssCpy.GetComponent <Button>().onClick.Invoke(); } } classPnl.transform.GetChild(0).GetComponent <ScrollRect>().normalizedPosition = new Vector2(0, 1); } else { SetClassInfoText("", "", "No classes found yet... Explore a little bit more and maybe something will be here!"); } }
// Update is called once per frame public void Click(string faction) { Debug.Log("Click: " + faction); string aiStr = "\nCampaign: Easy\n"; GameMeta game = BaseSaver.GetGame(); PlayerMeta player = BaseSaver.GetPlayer(); player.faction = (Unit.FactionType)Enum.Parse(typeof(Unit.FactionType), faction); Color mainColor = HelperScripts.GetColorByFaction(player.faction); mainColor.a = .5f; GetComponent <Image>().color = mainColor; //transform.GetChild(2).GetComponent<Image>().color = HelperScripts.GetColorByFactionBold(player.faction); ResetParticles(); if (finalWorld) { player.world = GameMeta.World.candy; aiStr = "\nCampaign: Hard\n"; } else { switch (player.faction) { case Unit.FactionType.Human: player.world = GameMeta.World.nile; break; case Unit.FactionType.Egypt: player.world = GameMeta.World.mountain; break; case Unit.FactionType.Cthulhu: player.world = GameMeta.World.pyramid; aiStr = "\nCampaign: Hard\n"; break; default: player.world = GameMeta.World.nile; break; } } switch (player.faction) { case Unit.FactionType.Human: SetParticles(human, true); break; case Unit.FactionType.Egypt: SetParticles(egypt, true); break; case Unit.FactionType.Cthulhu: SetParticles(cthulhu, true); break; } BaseSaver.PutPlayer(player); desc.text = "- " + faction + " - " + aiStr + "Strategy: " + Unit.GetFactionDesc(player.faction); btn.SetActive(true); }
// Start is called before the first frame update void Awake() { btn.SetActive(false); finale.SetActive(false); desc.text = ""; human.SetActive(true); egypt.SetActive(true); cthulhu.SetActive(true); GameMeta game = BaseSaver.GetGame(); List <Unit.FactionType> factions = new List <Unit.FactionType>(game.unlockedFactions); //if (factions.Contains(Unit.FactionType.Human)) { // human.SetActive(true); //} if (factions.Contains(Unit.FactionType.Egypt)) { //foreach(Transform child in egypt.transform){ // if (child.name.Equals("lock")) { // child.gameObject.SetActive(false); // } //} //egypt.SetActive(true); egypt.transform.GetChild(1).gameObject.SetActive(false); } else { egypt.GetComponent <Button>().enabled = false; } if (factions.Contains(Unit.FactionType.Cthulhu)) { //cthulhu.SetActive(true); cthulhu.transform.GetChild(1).gameObject.SetActive(false); } else { cthulhu.GetComponent <Button>().enabled = false; } if (factions.Contains(Unit.FactionType.Human) && factions.Contains(Unit.FactionType.Egypt) && factions.Contains(Unit.FactionType.Cthulhu)) { finale.SetActive(true); SetFinaleColors(); } finale.transform.GetChild(0).gameObject.SetActive(false); ResetParticles(); }
public static void SaveCurrentScore() { GameMeta game = BaseSaver.GetGame(); PlayerMeta player = BaseSaver.GetPlayer(); List <HighScoreMeta> hScores = new List <HighScoreMeta>(game.scores); HighScoreMeta thisScore = new HighScoreMeta(); thisScore.score = player.characters.Sum(pChar => pChar.GetLvl()); thisScore.faction = player.faction; thisScore.world = player.world; thisScore.name = "tom"; hScores.Add(thisScore); game.scores = hScores.ToArray(); BaseSaver.PutGame(game); }
void PopulateSkillsPanel() { skillPnl.SetActive(true); skillBtn.GetComponent <Outline>().effectColor = Color.red; GameMeta game = BaseSaver.GetGame(); string pnlString = ""; skillPnl.transform.GetChild(1).GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>().text = pnlString; skillPnl.transform.GetChild(1).GetChild(1).GetChild(0).GetComponent <Animator>().runtimeAnimatorController = null; skillPnl.transform.GetChild(1).GetChild(1).GetChild(0).GetComponent <ImageAnimation>().Flush(); skillPnl.transform.GetChild(1).GetChild(2).GetComponent <TextMeshProUGUI>().text = pnlString; skillPnl.transform.GetChild(1).GetChild(3).GetComponent <TextMeshProUGUI>().text = pnlString; if (game.skillsSeen.Length > 0) { game.skillsSeen = game.skillsSeen.OrderBy(nm => nm).ToArray(); skillPnl.transform.GetChild(0).GetChild(0).GetComponent <RectTransform>().sizeDelta = new Vector2(800, 220 * game.skillsSeen.Length); foreach (Transform child in skillPnl.transform.GetChild(0).GetChild(0)) { Destroy(child.gameObject); } for (int i = 0; i < game.skillsSeen.Length; i++) { //foreach(string skll in game.skillsSeen){ string skll = game.skillsSeen[i]; GameObject skllCpy = Instantiate(skillRw, skillPnl.transform.GetChild(0).GetChild(0)); skllCpy.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = skll; Skill tSkill = Skill.ReturnSkillByString((Skill.SkillClasses)Enum.Parse(typeof(Skill.SkillClasses), skll)); skllCpy.GetComponent <Button>().onClick.AddListener(() => { instance.SetSkillInfoText(tSkill.PrintDetails() + " " + tSkill.PrintStackDetails() + "\n", skll, ""); instance.SetSkillSpriteAnimator(tSkill.GetSkillGen()); }); if (i == 0) { skllCpy.GetComponent <Button>().onClick.Invoke(); } } skillPnl.transform.GetChild(0).GetComponent <ScrollRect>().normalizedPosition = new Vector2(0, 1); } else { SetSkillInfoText("", "", "No skills found yet... Explore a little bit more and maybe something will be here!"); } }
void Refresh() { PrintSave("sv1", save1); PrintSave("sv2", save2); PrintSave("sv3", save3); GameMeta game = BaseSaver.GetGame(); if (game == null) { Debug.Log("Game is null"); BaseSaver.PutGame(new GameMeta()); } else { Debug.Log("Game is not null"); } }
/* * Save Player */ public static void PutPlayer(PlayerMeta player) { /* * Here is where the classes and skills need to be looked at to * see if the player has seen anything new */ GameMeta game = BaseSaver.GetGame(); if (game != null) { List <string> classesSeen = new List <string>(game.classesSeen); List <string> skillsSeen = new List <string>(game.skillsSeen); foreach (Unit unt in player.characters) { if (!classesSeen.Contains(unt.GetCurrentClassString())) { classesSeen.Add(unt.GetCurrentClassString()); } foreach (string skill in unt.GetSkills()) { if (!skillsSeen.Contains(skill)) { skillsSeen.Add(skill); } } } game.classesSeen = classesSeen.ToArray(); game.skillsSeen = skillsSeen.ToArray(); PutGame(game); } string json = JsonUtility.ToJson(player); PlayerPrefs.SetString(AdjKy(PLAYER), json); Debug.Log("PLAYER set: " + AdjKy(PLAYER) + ":" + json); }
void PopulateHScoresPanel() { hScorePnl.SetActive(true); hScoreBtn.GetComponent <Outline>().effectColor = Color.red; camp1.transform.GetChild(1).gameObject.SetActive(false); camp2.transform.GetChild(1).gameObject.SetActive(false); camp3.transform.GetChild(1).gameObject.SetActive(false); camp4.transform.GetChild(1).gameObject.SetActive(false); GameMeta game = BaseSaver.GetGame(); foreach (GameMeta.World world in game.unlockedWorlds) { switch (world) { case GameMeta.World.mountain: camp1.transform.GetChild(1).gameObject.SetActive(true); camp1.transform.GetChild(0).gameObject.SetActive(false); camp1.GetComponent <Image>().enabled = false; break; case GameMeta.World.pyramid: camp2.transform.GetChild(1).gameObject.SetActive(true); camp2.transform.GetChild(0).gameObject.SetActive(false); camp2.GetComponent <Image>().enabled = false; break; case GameMeta.World.candy: camp3.transform.GetChild(1).gameObject.SetActive(true); camp3.transform.GetChild(0).gameObject.SetActive(false); camp3.GetComponent <Image>().enabled = false; break; case GameMeta.World.final: camp4.transform.GetChild(1).gameObject.SetActive(true); camp4.transform.GetChild(0).gameObject.SetActive(false); camp4.GetComponent <Image>().enabled = false; break; } } string pnlString = "High Scores:\n\n"; //if (game.scores.Length > 0) { List <HighScoreMeta> scores = new List <HighScoreMeta>(game.scores); List <HighScoreMeta> camp1scrs = scores.Where(scr => scr.world == GameMeta.World.nile).ToList(); List <HighScoreMeta> camp2scrs = scores.Where(scr => scr.world == GameMeta.World.mountain).ToList(); List <HighScoreMeta> camp3scrs = scores.Where(scr => scr.world == GameMeta.World.pyramid).ToList(); List <HighScoreMeta> camp4scrs = scores.Where(scr => scr.world == GameMeta.World.candy).ToList(); camp1scrs.OrderBy(scr => scr.score); camp2scrs.OrderBy(scr => scr.score); camp3scrs.OrderBy(scr => scr.score); camp4scrs.OrderBy(scr => scr.score); pnlString += (" Campaign 1 => " + (camp1scrs.Count > 0 ? camp1scrs[0].score.ToString() : "0") + "\n"); pnlString += (" Campaign 2 => " + (camp2scrs.Count > 0 ? camp2scrs[0].score.ToString() : "0") + "\n"); pnlString += (" Campaign 3 => " + (camp3scrs.Count > 0 ? camp3scrs[0].score.ToString() : "0") + "\n"); pnlString += (" Campaign 4 => " + (camp4scrs.Count > 0 ? camp4scrs[0].score.ToString() : "0") + "\n"); //foreach(HighScoreMeta scr in scores.Take(10)){ // pnlString += scr.ToString() + "\n"; //} //} hScorePnl.transform.GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>().text = pnlString; }
//private float percentsPerSecond = 0.2f; //private float sceneProgress = 0; void Awake() { GameMeta game = BaseSaver.GetGame(); PlayerMeta player = BaseSaver.GetPlayer(); waiting = false; candleIdx = 0; lightIdx = 0; //lightNUM = SwitchLights(); //candleNUM = SwitchCandles(); cutsceneSnapshot = FMODUnity.RuntimeManager.CreateInstance(FMODPaths.CutsceneSnapshot); musicIntro = FMODUnity.RuntimeManager.CreateInstance(FMODPaths.MusicIntroEvent); StartCoroutine(SwitchLights()); StartCoroutine(SwitchCandles()); textHolder = new string[] { }; gameEnded = GameMeta.GameEnded(); if (!gameEnded) { List <string> txts = new List <string>(); if (!game.intro) { txts = new List <string>(StoryStatic.INTRO_STRING); game.intro = true; BaseSaver.PutGame(game); } switch (player.faction) { case Unit.FactionType.Cthulhu: txts.Add(StoryStatic.CTHULHU_INTRO); break; case Unit.FactionType.Egypt: txts.Add(StoryStatic.EGYPT_INTRO); break; case Unit.FactionType.Human: txts.Add(StoryStatic.HUMAN_INTRO); break; } textHolder = txts.ToArray(); } else { backgrounds.SetActive(false); if (player.world == GameMeta.World.tutorial) { textHolder = new string[] { "Congratulations! Tutorial completed. Good luck with the main story!" }; } else { textHolder = new string[] { game.EndGameDialog() }; if (player.world == GameMeta.World.candy) { switch (player.faction) { case Unit.FactionType.Cthulhu: textHolder = new string[] { StoryStatic.CTHULHU_WIN }; break; case Unit.FactionType.Egypt: textHolder = new string[] { StoryStatic.EGYPT_WIN }; break; case Unit.FactionType.Human: textHolder = new string[] { StoryStatic.HUMAN_WIN }; break; } } } } clickToContinue.SetActive(false); }