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