// Use this for initialization void Start() { enemyQuantity = GetComponent <EnemyQuantity>(); battleLogic = GetComponent <BattleLogic>(); character = battleLogic.getCharacter(); whichSkill = battleLogic.whichSkill; state = GetComponent <BattleScreenStates>(); arrow = transform.FindChild("EnemyPanel/selectionarrow").GetComponent <SpriteRenderer>(); enemy1 = transform.FindChild("EnemyPanel/Enemy").GetComponent <SpriteRenderer>(); enemy2 = transform.FindChild("EnemyPanel/Enemy2").GetComponent <SpriteRenderer>(); enemy3 = transform.FindChild("EnemyPanel/Enemy3").GetComponent <SpriteRenderer>(); playerImage = transform.FindChild("PlayerInfo/PlayerImage").GetComponent <Image>(); arrow.enabled = false; }
// Instead of start function, call this with a little delay (maybe .1s). // This will assign everything from infoDump. Delay is used to make sure Info dump has been assigned. void startFromDump() { attack = GetComponent <BattleAttackHandler>(); state = GetComponent <BattleScreenStates>(); selection = GetComponent <ArrowSelection>(); stateQueue = new List <BattleScreenStates.FightStates>(); stateQueue.Add(BattleScreenStates.FightStates.BEGINNING); activeTime = transform.FindChild("PlayerInfo/ActiveTimeBar").GetComponent <ActiveTime>(); enemies = new Monster[3]; if (infoDump != null) { enemies[0] = infoDump.enemy0; enemies[1] = infoDump.enemy1; enemies[2] = infoDump.enemy2; activeTime.setEnemyMaxTime(infoDump.info.enemy0Max); activeTime.setEnemySeconds(infoDump.info.enemy0Sec); if (infoDump.info.numEnemies > 2) { enemy2ActiveTime.setEnemyMaxTime(infoDump.info.enemy1Max); enemy2ActiveTime.setEnemySeconds(infoDump.info.enemy1Sec); enemy3ActiveTime.setEnemyMaxTime(infoDump.info.enemy2Max); enemy3ActiveTime.setEnemySeconds(infoDump.info.enemy2Sec); } else if (infoDump.info.numEnemies > 1) { enemy2ActiveTime.setEnemyMaxTime(infoDump.info.enemy1Max); enemy2ActiveTime.setEnemySeconds(infoDump.info.enemy1Sec); } numPlayers = infoDump.info.numPlayers; numEnemies = infoDump.info.numEnemies; playerNum = infoDump.info.numPlayers - 1; setEnemyHP(); switch (playerNum) { case 0: character = infoDump.player0; break; case 1: character = infoDump.player1; break; case 2: character = infoDump.player2; break; default: print("Character still null in Battle Logic"); break; } playerMaxHP = character.getHP(); setPlayerHP(); enemyAttackFlag = infoDump.info.enemyAttackFlag; setEnemyMaxTime(); setEnemyTime(); GetComponent <BattleScreenGUI>().fillSkillButtons(); } else { print("infoDUmp null"); } dumpLoad = false; for (int i = 0; i < enemies.Length; i++) { //enemies[i].setDead(false); } }
void Start() { // Set listeners for our four main buttons. fightButton = transform.FindChild("FightMenu/FightButtonsPanel/FightButton").GetComponent <Button>(); fightButton.onClick.AddListener(() => FightButtonClicked()); skillsButton = transform.FindChild("FightMenu/FightButtonsPanel/SkillsButton").GetComponent <Button>(); skillsButton.onClick.AddListener(() => SkillButtonClicked()); itemsButton = transform.FindChild("FightMenu/FightButtonsPanel/ItemsButton").GetComponent <Button>(); itemsButton.onClick.AddListener(() => ItemsButtonClicked()); runButton = transform.FindChild("FightMenu/FightButtonsPanel/RunButton").GetComponent <Button>(); runButton.onClick.AddListener(() => RunButtonClicked()); fightMessage = transform.FindChild("FightMenu/FightTextPanel/FightMessage").GetComponent <Text>(); // Get the components from our Battle Screen GUI. playerHealthString = transform.FindChild("PlayerInfo/HealthBar/HP").GetComponent <Text>(); playerHealthBar = transform.FindChild("PlayerInfo/HealthBar").GetComponent <Image>(); playerActiveTimerBar = transform.FindChild("PlayerInfo/ActiveTimeBar").GetComponent <Image>(); // The menus, so we can set them to visible or invisible, then the scripts. optionsPanel = transform.FindChild("OptionsMenu").GetComponent <CanvasGroup>(); fightButtonsPanel = transform.FindChild("FightMenu/FightButtonsPanel").GetComponent <CanvasGroup>(); fightTextPanel = transform.FindChild("FightMenu/FightTextPanel").GetComponent <CanvasGroup>(); activeTime = transform.FindChild("PlayerInfo/ActiveTimeBar").GetComponent <ActiveTime>(); state = GetComponent <BattleScreenStates>(); battleLogic = GetComponent <BattleLogic>(); // The Skill Buttons. skillButton1 = transform.FindChild("OptionsMenu/VisibleArea/SkillsMenu/SkillsScroll/SkillButton1").GetComponent <Button>(); skillButton2 = transform.FindChild("OptionsMenu/VisibleArea/SkillsMenu/SkillsScroll/SkillButton2").GetComponent <Button>(); skillButton3 = transform.FindChild("OptionsMenu/VisibleArea/SkillsMenu/SkillsScroll/SkillButton3").GetComponent <Button>(); skillButton4 = transform.FindChild("OptionsMenu/VisibleArea/SkillsMenu/SkillsScroll/SkillButton4").GetComponent <Button>(); skillButton5 = transform.FindChild("OptionsMenu/VisibleArea/SkillsMenu/SkillsScroll/SkillButton5").GetComponent <Button>(); skillButton6 = transform.FindChild("OptionsMenu/VisibleArea/SkillsMenu/SkillsScroll/SkillButton6").GetComponent <Button>(); skillButton7 = transform.FindChild("OptionsMenu/VisibleArea/SkillsMenu/SkillsScroll/SkillButton7").GetComponent <Button>(); skillButton8 = transform.FindChild("OptionsMenu/VisibleArea/SkillsMenu/SkillsScroll/SkillButton8").GetComponent <Button>(); skillButtons = new Button[8]; skillButtons[0] = skillButton1; skillButtons[1] = skillButton2; skillButtons[2] = skillButton3; skillButtons[3] = skillButton4; skillButtons[4] = skillButton5; skillButtons[5] = skillButton6; skillButtons[6] = skillButton7; skillButtons[7] = skillButton8; for (int i = 0; i < skillButtons.Length; i++) { skillButtons[i].enabled = false; skillButtons[i].GetComponent <Image>().enabled = false; skillButtons[i].transform.Find("Text").GetComponent <Text>().enabled = false; } // The enemy sprites. enemy1 = transform.FindChild("EnemyPanel/Enemy").GetComponent <SpriteRenderer>(); enemy2 = transform.FindChild("EnemyPanel/Enemy2").GetComponent <SpriteRenderer>(); enemy3 = transform.FindChild("EnemyPanel/Enemy3").GetComponent <SpriteRenderer>(); enemy2.enabled = false; enemy2.gameObject.GetComponent <Image>().enabled = false; enemy3.enabled = false; enemy3.gameObject.GetComponent <Image>().enabled = false; enemies = new Monster[3]; //character = GetComponent<Characters>(); // Replace with Holder that has copy //StartCoroutine(updateFromDatabase()); }