void PopulatePlayer(TileProxy[] sideTiles) { PlayerMeta player = BaseSaver.GetPlayer(); //Queue<TileProxy> validTls = new Queue<TileProxy>(GetSideTiles(BoardProxy.PLAYER_TEAM)); Queue <TileProxy> validTls = new Queue <TileProxy>(sideTiles); List <UnitProxy> units = new List <UnitProxy>(); List <Unit> roster = new List <Unit>(player.characters); roster.Reverse(); //Debug.Log("PopulatePlayer: " + validTls.Count.ToString()); List <Unit> inactiveUnits = new List <Unit>(); for (int i = 3; i < roster.Count; i++) { inactiveUnits.Add(roster[i]); } for (int i = 0; i < roster.Count && i < 3; i++) { Unit cMeta = new Unit(roster[i]); //UnitProxy goodGuy = Instantiate(glossary.GetComponent<Glossary>().units[PLAYER_TEAM], transform); UnitProxy goodGuy = Instantiate(ClassNode.ComputeClassBaseUnit(cMeta.GetFactionType(), cMeta.GetUnitType(), glossary.GetComponent <Glossary>()), transform); units.Add(goodGuy); cMeta = ClassNode.ApplyClassBonusesBattle(cMeta, inactiveUnits.ToArray()); goodGuy.PutData(cMeta); goodGuy.Init(); TileProxy popTile = validTls.Dequeue(); popTile.ReceiveGridObjectProxy(goodGuy); goodGuy.SnapToCurrentPosition(); //Debug.Log("goodGuy placed at: " + popTile.GetPosition().ToString()); } }
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!"); } }
//void Flush(){ // foreach (Transform child in techSelect.transform) // { // Destroy(child.gameObject); // } // foreach (Transform child in techNext.transform) // { // Destroy(child.gameObject); // } //} public void CharClicked(Unit unt) { clickedUnit = unt; RefreshTech(); Debug.Log("Clicked: " + unt.characterMoniker); PlayerMeta player = BaseSaver.GetPlayer(); IterateThroughTreeUp(unt.GetCurrentClass()); IterateThroughTreeDown(unt.GetLvl(), unt.GetCurrentClass()); //UnitProxy unt = ClassNode.ComputeClassBaseUnit(instance.player.faction, unt.GetUnitType(), instance.glossary.GetComponent<Glossary>()); string lvlupstr = unt.GetCurrentClass().GetWhenToUpgrade() == StaticClassRef.LEVEL4 ? "Fully Upgraded" : "Next lvl at: " + unt.GetCurrentClass().GetWhenToUpgrade().ToString(); techSelect.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = lvlupstr; selectTag.SetActive(true); selectTag.transform.GetChild(0).GetComponent <Image>().sprite = ClassNode.ComputeClassBaseUnit(instance.player.faction, unt.GetUnitType(), instance.glossary.GetComponent <Glossary>()) .transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; selectTag.transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = unt.characterMoniker; selectTag.transform.GetChild(2).GetComponent <TextMeshProUGUI>().text = unt.GetCurrentClass().ClassName(); }
void PopulateEnemies(TileProxy[] sideTiles) { //Queue<TileProxy> validTls = new Queue<TileProxy>(GetSideTiles(BoardProxy.ENEMY_TEAM)); Queue <TileProxy> validTls = new Queue <TileProxy>(sideTiles); List <UnitProxy> units = new List <UnitProxy>(); //Debug.Log("PopulateEnemies: " + validTls.Count.ToString()); TileProxy popTile; for (int i = 0; i < boardMeta.enemies.Length && i < height; i++) { //Unit cMeta = new Unit(boardMeta.enemies[i].name + i.ToString(),1); //glossary.GetComponent<Glossary>().units[ENEMY_TEAM] Unit cMeta = new Unit(boardMeta.enemies[i]); UnitProxy badGuy = Instantiate(ClassNode.ComputeClassBaseUnit(cMeta.GetFactionType(), cMeta.GetUnitType(), glossary.GetComponent <Glossary>()), transform); units.Add(badGuy); badGuy.PutData(cMeta); badGuy.Init(); popTile = validTls.Dequeue(); popTile.ReceiveGridObjectProxy(badGuy); badGuy.SnapToCurrentPosition(); //Debug.Log("badGuy placed at: " + popTile.GetPosition().ToString()); } }
static void RefreshMainPanel(GameObject panel, Unit unit, int unitIdx) { Debug.Log("RefreshMainPanel: " + unit.characterMoniker); panel.SetActive(true); foreach (Transform child in panel.transform) { if (child.name.Equals("CharImg")) { UnitProxy unt = ClassNode.ComputeClassBaseUnit(instance.player.faction, unit.GetUnitType(), instance.glossary.GetComponent <Glossary>()); child.GetComponent <Image>().sprite = unt.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; } if (child.name.Equals("CharName")) { child.GetComponent <TextMeshProUGUI>().text = unit.characterMoniker; } if (child.name.Equals("CharType")) { child.GetComponent <TextMeshProUGUI>().text = unit.GetCurrentClass().ClassName(); } if (child.name.Equals("HPImg")) { child.GetChild(0).GetComponent <TextMeshProUGUI>().text = unit.GetMaxHP().ToString(); } if (child.name.Equals("Lineup")) { if (unitIdx > 2) { //Reserves child.GetComponent <Image>().color = Color.red; child.GetChild(0).GetComponent <TextMeshProUGUI>().text = "Inactive"; } else { //Roster child.GetComponent <Image>().color = Color.green; child.GetChild(0).GetComponent <TextMeshProUGUI>().text = "Battle Ready"; } } if (child.name.Equals("ExpImg")) { string expStr = "*"; if (unit.GetLvl() >= unit.GetCurrentClass().GetWhenToUpgrade()) { Debug.Log("Rotate!"); child.eulerAngles = new Vector3(0, 0, -25); iTween.RotateTo(child.gameObject, iTween.Hash( "z", 25, "time", 5, "easetype", "easeInOutSine", "looptype", "pingpong" )); iTween.ScaleTo(child.gameObject, iTween.Hash( "x", 1.3, "y", 1.3, "time", 2, "easetype", "easeInOutSine", "looptype", "pingpong" )); } else { expStr = unit.GetLvl().ToString(); } child.GetChild(0).GetComponent <TextMeshProUGUI>().text = expStr; } if (child.name.Equals("Stats")) { foreach (Transform t in child.transform) { if (t.name.Equals("Move")) { RefreshSkillPnl(t, unit.GetMoveSpeed().ToString()); } if (t.name.Equals("AtkPwr")) { RefreshSkillPnl(t, unit.GetAttack().ToString()); } if (t.name.Equals("AtkRng")) { RefreshSkillPnl(t, unit.GetAtkRange().ToString()); } } } if (child.name.Equals("Turn")) { foreach (Transform t in child.transform) { if (t.name.Equals("MvTrn")) { RefreshSkillPnl(t, unit.GetTurnMoves().ToString()); } if (t.name.Equals("AtkTrn")) { RefreshSkillPnl(t, unit.GetTurnAttacks().ToString()); } } } } }
void Awake() { PlayerMeta player = BaseSaver.GetPlayer(); List <string> mages = new List <string>(new string[] { "HumanBaseMage", "EgyptBaseMage", "CthulhuBaseMage" }); List <string> scouts = new List <string>(new string[] { "HumanBaseScout", "EgyptBaseScout", "CthulhuBaseScout" }); int rM = 0; int rSc = 0; int rSo = 0; foreach (Unit unt in player.characters) { ClassNode clss = unt.GetCurrentClass(); while (clss.GetParent() != null) { clss = clss.GetParent(); } if (mages.Contains(clss.GetType().ToString())) { rM++; } else if (scouts.Contains(clss.GetType().ToString())) { rSc++; } else { rSo++; } } //rosterTxt.text = "Current Army: \nMage: " + rM.ToString() + "\nScout: " + rSc.ToString() + "\nSoldier: " + rSo.ToString(); armyPnl.transform.GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>().text = rM.ToString(); armyPnl.transform.GetChild(1).GetChild(0).GetComponent <TextMeshProUGUI>().text = rSc.ToString(); armyPnl.transform.GetChild(2).GetChild(0).GetComponent <TextMeshProUGUI>().text = rSo.ToString(); switch (player.faction) { case Unit.FactionType.Cthulhu: armyPnl.transform.GetChild(0).GetChild(2).GetComponent <Image>().sprite = glossary.GetComponent <Glossary>().cthulhuMage.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; armyPnl.transform.GetChild(1).GetChild(2).GetComponent <Image>().sprite = glossary.GetComponent <Glossary>().cthulhuScout.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; armyPnl.transform.GetChild(2).GetChild(2).GetComponent <Image>().sprite = glossary.GetComponent <Glossary>().cthulhuSoldier.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; break; case Unit.FactionType.Human: armyPnl.transform.GetChild(0).GetChild(2).GetComponent <Image>().sprite = glossary.GetComponent <Glossary>().humanMage.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; armyPnl.transform.GetChild(1).GetChild(2).GetComponent <Image>().sprite = glossary.GetComponent <Glossary>().humanScout.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; armyPnl.transform.GetChild(2).GetChild(2).GetComponent <Image>().sprite = glossary.GetComponent <Glossary>().humanSoldier.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; break; case Unit.FactionType.Egypt: armyPnl.transform.GetChild(0).GetChild(2).GetComponent <Image>().sprite = glossary.GetComponent <Glossary>().egyptMage.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; armyPnl.transform.GetChild(1).GetChild(2).GetComponent <Image>().sprite = glossary.GetComponent <Glossary>().egyptScout.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; armyPnl.transform.GetChild(2).GetChild(2).GetComponent <Image>().sprite = glossary.GetComponent <Glossary>().egyptSoldier.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; break; } panels = new GameObject[panelGroup.transform.childCount]; for (int i = 0; i < panelGroup.transform.childCount; i++) { panels[i] = panelGroup.transform.GetChild(i).gameObject; UnitProxy unt = ClassNode.ComputeClassBaseUnit(player.faction, (Unit.UnitType)i, glossary.GetComponent <Glossary>()); panels[i].transform.GetChild(1).GetComponent <Image>().sprite = unt.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite; } selectableUnits = new Unit[] { Unit.BuildInitial(player.faction, Unit.UnitType.Mage, BoardProxy.PLAYER_TEAM), Unit.BuildInitial(player.faction, Unit.UnitType.Scout, BoardProxy.PLAYER_TEAM), Unit.BuildInitial(player.faction, Unit.UnitType.Soldier, BoardProxy.PLAYER_TEAM), }; for (int i = 0; i < selectableUnits.Length && i < panels.Length; i++) { RefreshPanel(panels[i], selectableUnits[i]); } selected = null; contBtn.gameObject.SetActive(false); ResetParticles(); GetComponent <Image>().color = HelperScripts.GetColorByFaction(player.faction); }