//Event based function - Disabling move // Changes color of icon purple public void cooldownUpdate(ISecMove move) { Image curIcon = iconMapping[move].transform.GetChild(0).GetComponent <Image>(); float cooldown = move.getCDProgress(); curIcon.fillAmount = cooldown; iconMapping[move].color = (cooldown <= 0) ? Color.yellow : new Color(0.4f, 0.4f, 0f); }
//Sets up ability UI for a fighter public void setUp(PKMNEntity newFighter) { iconMapping.Clear(); fighter = newFighter; List <IMove> fighterMoves = fighter.getMoves(); //Setting fighter icon if (fighterIcon != null) { fighterIcon.sprite = Resources.Load <Sprite>("Portraits/" + fighter.fighterName); } int curIconIndex = 0; int numSecMoves = newFighter.getNumSecMoves(); //Enabling ability icons while (curIconIndex < numSecMoves) { ISecMove curMove = (ISecMove)fighterMoves[curIconIndex]; Image curIcon = abilityIcons[curIconIndex]; curIcon.gameObject.SetActive(true); iconMapping[curMove] = curIcon; cooldownUpdate(curMove); curIconIndex++; } //Disabling redundant ability icons while (curIconIndex < MAX_SEC_ABILITIES) { abilityIcons[curIconIndex].gameObject.SetActive(false); curIconIndex++; } //Settings for exp bar if (fighter.getNumStatBoosts() > 0) { levelUp.SetActive(true); expBar.fillAmount = 1f; } else { expBar.fillAmount = fighter.getPercentToLvL(); levelUp.SetActive(false); } }
//Executes an assist, automated version of the sec move for the player // Pre: moveIndex >= 0 && moveIndex < numSecMoves() // Post: returns a boolean indicating that the move ran public bool executeAssistMove(int moveIndex) { if (moveIndex < 0 || moveIndex >= moves.Count - 1) { throw new System.ArgumentException("Error: Invalid index for moves"); } ISecMove secMove = (ISecMove)moves[moveIndex]; bool executed = secMove.canRun(); if (executed) { StartCoroutine(secMove.assistExecute()); } else { Debug.Log("You can't run that move at this moment"); } return(executed); }
//Updates cooldown display from the move itself private void updateCooldownDisplay(ISecMove move) { PKMNEntity fighter = move.getBasis(); abilityUIMap[fighter].cooldownUpdate(move); }