GoodNoodle

BattleDialogueBox.cs

Jul 11th, 2022 (edited)
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class BattleDialogueBox : MonoBehaviour
  7. {
  8.  
  9.     [SerializeField] GameObject actionSelector, magicSelector, magicDetails;
  10.  
  11.     [SerializeField] List<Text> actionText, magicText;
  12.  
  13.     [SerializeField] Text MPText;
  14.  
  15.     [SerializeField] Color highlightedColor;
  16.    
  17.  
  18.  
  19.     public void EnableActionSelector(bool enabled)
  20.     {
  21.         actionSelector.SetActive(enabled);
  22.        
  23.     }
  24.     public void EnableMagicSelector(bool enabled)
  25.     {
  26.         magicSelector.SetActive(enabled);
  27.         magicDetails.SetActive(enabled);
  28.     }
  29.  
  30.     public void UpdateMagicSelection(int selectedSpell, Move move)
  31.     {
  32.         for(int i = 0; i < magicText.Count; ++i)
  33.         {
  34.             if (i == selectedSpell)
  35.               actionText[i].color = highlightedColor;
  36.            
  37.              else
  38.              actionText[i].color = Color.black;
  39.            
  40.             MPText.text = $"MP { move.MP}/{ move.Base.Mp}";
  41.         }
  42.     }
  43.  
  44.     public void UpdateActionSelection(int selectedAction)
  45.     {
  46.         for(int i = 0; i < actionText.Count; ++i)
  47.         {
  48.             if(i == selectedAction)
  49.               actionText[i].color = highlightedColor;
  50.            
  51.             else
  52.              actionText[i].color = Color.black;
  53.            
  54.             }
  55.      }
  56.     public void SetMagicNames(List<Move> moves)
  57.     {
  58.         for (int i = 0; i < magicText.Count; ++i)
  59.         {
  60.             if (i < moves.Count)
  61.              magicText[i].text = moves[i].Base.Name;
  62.              
  63.             else
  64.                magicText[i].text = "";
  65.            
  66.         }
  67.     }
  68. }
  69.  
Add Comment
Please, Sign In to add comment