Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by omriben3110 · Dec 29, 2017 at 07:41 PM · guibattle-systempokemon

looking for a way to register Input from the UI canvas and such

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;

public class BattleManager : MonoBehaviour {

 public BattleMenu currentMenu;
 public BasePokemon CurrentPokemon;
 public BasePokemon EnemysCurrentPokemon;
 public attack action;
 //public BattleStateMachine BSM;
   
 
 //public List<HandleTurn> PreformList = new List<HandleTurn>();
 //public BasePokemon PlayerPokeInBattle = new BasePokemon();
 //public BasePokemon EnemyPokeInBattle = new BasePokemon();

 [Header("Selection")]
 public GameObject SelectionMenu;
 public GameObject SelectionInfo;
 public Text SelectionInfoText;
 public Text fight;
 private string fightT;
 public Text bag;
 private string bagT;
 public Text pokemon;
 private string pokemonT;
 public Text run;
 private string runT;

 [Header("Player's pokemon")]
 public Text Name;
 public Text HP;    
 public Text level;
 public GameObject HealthBar;
 private string NameT;
 private string HPT;
 private string LvT;
 

 [Header("Opponant's Pokemon")]
 public Text OpponantName;
 public Text OpponantLevel;
 public GameObject OpponantHealthBar;
 private string OpponantName_T;
 private string OpponantLevel_T;
   

 [Header("Moves")]
 public GameObject movesMenu;
 public GameObject movesDetails;
 public Text PP;
 private string PP_T;
 public Text pType;
 private string pType_T;
 public Text moveO;
 private string moveOT;
 public Text moveT;
 private string moveTT;
 public Text moveTH;
 private string moveTHT;
 public Text movef;
 private string movefT;


 [Header("Info")]
 public GameObject InfoMenu;
 public Text InfoText;

 [Header("Misc")]
 public int currentSelection;
 

 
 
 

 void Start () {
     fightT = fight.text;
     bagT = bag.text;
     pokemonT = pokemon.text;
     runT = run.text;

     Debug.Log(CurrentPokemon);
     Debug.Log("move1's text is "+moveO.text);      
     Debug.Log("move2's text is "+moveT.text);
     Debug.Log("move3's etxt is "+moveTH.text);        
     Debug.Log("move4's text is "+movef.text);

    
    

    //battleStates = PerformAction.WAIT;
    //PlayerPokeInBattle = CurrentPokemon;
    // EnemyPokeInBattle = EnemysCurrentPokemon;


 }
 
 
 void Update () {
     

     if(Input.GetKeyDown(KeyCode.DownArrow))
     {
         if (currentSelection < 4)
         {
             currentSelection++;
         }
     }
     
     if (Input.GetKeyDown(KeyCode.UpArrow))
     {
         if (currentSelection > 0)
         {
             currentSelection--;
         }
     }
     
     if (currentSelection == 0) currentSelection = 1;

     moveOT = CurrentPokemon.moves[0].atkName;
     moveTT = CurrentPokemon.moves[1].atkName;
     moveTHT = CurrentPokemon.moves[2].atkName;
     movefT = CurrentPokemon.moves[3].atkName;

     NameT = CurrentPokemon.MonName;
     HPT = CurrentPokemon.HP + "/" + CurrentPokemon.maxHP;
     LvT = "Lv" + CurrentPokemon.level;
     Name.text = NameT;
     HP.text = HPT;
     level.text = LvT;

     OpponantName_T = EnemysCurrentPokemon.MonName;
     OpponantLevel_T = "Lv" + EnemysCurrentPokemon.level;
     OpponantName.text = OpponantName_T;
     OpponantLevel.text = OpponantLevel_T;

     

     switch (currentMenu)
     {
         case BattleMenu.Fight: 
             switch (currentSelection) 
             {
                 case 1:
                     moveO.text = ">" + moveOT;
                     moveT.text = moveTT;
                     moveTH.text = moveTHT;
                     movef.text = movefT;

                     pType_T = CurrentPokemon.moves[0].MoveType.ToString() + "/" + "Type";
                     pType.text = pType_T;
                     PP_T = CurrentPokemon.moves[0].PP.ToString();
                     PP.text = PP_T;


                     break;
                 case 2:
                     moveO.text = moveOT;
                     moveT.text = ">" + moveTT;
                     moveTH.text = moveTHT;
                     movef.text = movefT;

                     pType_T = CurrentPokemon.moves[1].MoveType.ToString() + "/" + "TYPE";
                     pType.text = pType_T;
                     PP_T = CurrentPokemon.moves[1].PP.ToString();
                     PP.text = PP_T;
                     break;
                 case 3:
                     moveO.text = moveOT;
                     moveT.text = moveTT;
                     moveTH.text = ">" + moveTHT;
                     movef.text = movefT;

                     pType_T = CurrentPokemon.moves[2].MoveType.ToString() + "/" + "TYPE";
                     pType.text = pType_T;
                     PP_T = CurrentPokemon.moves[2].PP.ToString();
                     PP.text = PP_T;
                     break;
                 case 4:
                     moveO.text = moveOT;
                     moveT.text = moveTT;
                     moveTH.text = moveTHT;
                     movef.text = ">" +  movefT;

                     pType_T = CurrentPokemon.moves[3].MoveType.ToString() + "/" + "TYPE";
                     pType.text = pType_T;
                     PP_T = CurrentPokemon.moves[3].PP.ToString();
                     PP.text = PP_T;
                     break;                                                                        
             }
         break;
         case BattleMenu.Selection:
             switch (currentSelection)
             {
                 case 1:
                     fight.text = ">" + fightT;
                     bag.text = bagT;
                     pokemon.text = pokemonT;
                     run.text = runT;


                     break;
                 case 2:
                     fight.text = fightT;
                     bag.text = ">" + bagT;
                     pokemon.text = pokemonT;
                     run.text = runT;
                     break;
                 case 3:
                     fight.text = fightT;
                     bag.text = bagT;
                     pokemon.text = ">" + pokemonT;
                     run.text = runT;
                     break;
                 case 4:
                     fight.text = fightT;
                     bag.text = bagT;
                     pokemon.text = pokemonT;
                     run.text = ">" + runT;
                     break;                                                                       
             }
         break;
     }

     if (Input.GetKey(KeyCode.Z) && currentMenu == BattleMenu.Selection)
     {
         //Debug.Log("select (Z was pressed once)");
         if(currentSelection == 1) { ChangeMenu(BattleMenu.Fight); }
         /*if(currentSelection == 3) { ChangeMenu(BattleMenu.Pokemon);}*/                       
     }

     if (Input.GetKey(KeyCode.Z) && currentMenu == BattleMenu.Fight)
     {
        
         switch (currentSelection)
         {
             case 1:
                 action = CurrentPokemon.moves[0];
                 Debug.Log("the move " + action.atkName + " was activated");
                 
                 break;
             case 2: 
                 action = CurrentPokemon.moves[1];
                 Debug.Log("the move " + CurrentPokemon.moves[1].atkName + " was activated");
                 break;
             case 3: 
                 action = CurrentPokemon.moves[2];
                 Debug.Log("the move " + CurrentPokemon.moves[2].atkName + " was activated");
                 break;
             case 4: 
                 action = CurrentPokemon.moves[3];
                 Debug.Log("the move " + CurrentPokemon.moves[3].atkName + " was activated");
                 break;
             
         }
         
        
     }




     if (Input.GetKey(KeyCode.X))
     {
         Debug.Log("return (X was pressed once)");
         ChangeMenu(BattleMenu.Selection);
     }

     
 }

 public void DisplayDamage(GameObject HealthBarGM, float DamageCalculated)
 {
     

 }
   
 public void ChangeMenu (BattleMenu bm)
 {
     currentMenu = bm;
     currentSelection = 0; 

     switch(bm)
     {
         case BattleMenu.Selection:
             SelectionMenu.gameObject.SetActive(true);
             SelectionInfo.gameObject.SetActive(true);
             movesMenu.gameObject.SetActive(false);
             movesDetails.gameObject.SetActive(false);
             InfoMenu.gameObject.SetActive(false);
             break;
         case BattleMenu.Fight:
             SelectionMenu.gameObject.SetActive(false);
             SelectionInfo.gameObject.SetActive(false);
             movesMenu.gameObject.SetActive(true);
             movesDetails.gameObject.SetActive(true);
             InfoMenu.gameObject.SetActive(false);
             break;
         case BattleMenu.Info:
             SelectionMenu.gameObject.SetActive(false);
             SelectionInfo.gameObject.SetActive(false);
             movesMenu.gameObject.SetActive(false);
             movesDetails.gameObject.SetActive(false);
             InfoMenu.gameObject.SetActive(true);
             break;
         
     }
 }

} public enum BattleMenu { Selection, Pokemon, Bag, Fight, Info }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

174 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do i change a Sprite renderer when I click a GUI button? 0 Answers

pokemon battle start 1 Answer

How to create an if statement for each element within a list C# 2 Answers

Unity 5.1 GUI mask disappears in Android build 0 Answers

Adjusting content display. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges