Advertisement
Flippy456

Original For Loop for Buttons

Jan 17th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.02 KB | None | 0 0
  1.     public void SkillsMenu()
  2.     {
  3.         defaultMenu.SetActive(false);
  4.         skillsMenu.SetActive(true);
  5.         nativeSkillsMenu.SetActive(true);
  6.         otherSkillsMenu.SetActive(true);
  7.  
  8.         //Clearing the native moves list of the player. (This isn't really needed because it should be clear beforehand)
  9.         //This is just for testing purposes, when adding a new move to the moves available within the job class and refreshing.
  10.         activeBattlers[0].nativeMoves.Clear();
  11.  
  12.         //Setting it so you cannot scroll out of range of your moves with the buttons.
  13.         scrollNativeMoves = Mathf.Clamp(scrollNativeMoves, 0, Mathf.Abs(activeBattlers[0].movesAvailable.Length - battleSkills.Length));
  14.         //Setting what moves appear on the skill buttons.
  15.         for (int i = 0; i < battleSkills.Length; i++)
  16.         {
  17.             //Checking to what job class the player is.
  18.             if (activeBattlers[0].jobClass == moveList[i].jobClass)
  19.             {
  20.                 //Setting what skills the player will have.
  21.                 for (int j = 0; j < activeBattlers[0].movesAvailable.Length; j++)
  22.                 {
  23.                     //Checking to see what move the player has within the job class.
  24.                     if (activeBattlers[0].movesAvailable[j] == moveList[i].moveName)
  25.                     {
  26.                         //Adding that move to the nativeMoves list.
  27.                         activeBattlers[0].nativeMoves.Add(moveList[i].moveName);                        
  28.                     }
  29.                 }
  30.             }
  31.  
  32.             //Making sure the buttons have a move they can be assigned.
  33.             if (activeBattlers[0].movesAvailable.Length > i)
  34.             {
  35.                 //Setting the button to be true.
  36.                 battleSkills[i].gameObject.SetActive(true);
  37.                 //Setting the skill name to the moves found on the list.
  38.                 battleSkills[i].skillName = activeBattlers[0].movesAvailable[i + scrollNativeMoves];
  39.                 //Changing the skill text to the skill name.
  40.                 battleSkills[i].skillText.text = battleSkills[i].skillName;
  41.  
  42.                 //Setting the cost of the move.
  43.                 for (int j = 0; j < moveList.Length; j++)
  44.                 {
  45.                     //If the movelist finds a move that the player also has.
  46.                     if (moveList[j].moveName == battleSkills[i].skillName)
  47.                     {
  48.                         //Setting the hp cost of the move.
  49.                         battleSkills[i].hpCost = moveList[j].hpCost;
  50.                         //Setting the mp cost of the move.
  51.                         battleSkills[i].mpCost = moveList[j].mpCost;
  52.                         //Setting the st cost of the move.
  53.                         battleSkills[i].stCost = moveList[j].stCost;
  54.                     }
  55.                 }
  56.             }
  57.             else
  58.             {
  59.                 //The button is turned off.
  60.                 battleSkills[i].gameObject.SetActive(false);
  61.             }
  62.  
  63.             //Setting the main button to have information from the first skill set as default.
  64.             skillText.text = battleSkills[0].skillName;
  65.             hpCost.text = battleSkills[0].hpCost.ToString();
  66.             mpCost.text = battleSkills[0].mpCost.ToString();
  67.             spCost.text = battleSkills[0].stCost.ToString();
  68.         }
  69.         /*for (int i = 0; i < battleSkills.Length; i++)
  70.         {
  71.             //Setting the skill name to the moves found on the list.
  72.             battleSkills[i].skillName = moveList[i].moveName;
  73.             //Changing the skill text to the skill name.
  74.             battleSkills[i].skillText.text = battleSkills[i].skillName;
  75.             //Setting the hp cost of the move.
  76.             battleSkills[i].hpCost = moveList[i].hpCost;
  77.             //Setting the mp cost of the move.
  78.             battleSkills[i].mpCost = moveList[i].mpCost;
  79.             //Setting the st cost of the move.
  80.             battleSkills[i].stCost = moveList[i].stCost;
  81.             Debug.Log("Test");
  82.         }*/
  83.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement