I was trying to convert ‘enum TurnState’ into ‘Selecting’ by both ‘switch case’ and ‘if’ to pause variable ‘TPvalue’ but this did’t work.
‘enum TurnState’ was always ‘Waiting’.
I’m sorry if this problem is due to a stupid reason but I couldn’t really find.
Here is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BattleSystemPlayer : MonoBehaviour
{
public int formation = 1;
public float TPValue = 0;
int TPspeed;
string name;
int maxHP;
int currentHP;
int maxMP;
int currentMP;
int atk;
int def;
int mag;
int mdef;
int dex;
int agi;
public enum TurnState
{
Waiting,
Selecting,
Action,
Defensing,
Dead
}
public TurnState currentState;
void Awake()
{
}
void Start()
{
Debug.Log("Player " + formation + " "+ PlayerAssigner.CharacterOfFormation(formation).name + " is in the battle.");
agi = PlayerAssigner.CharacterOfFormation(formation).agi;
TurnState currentState = TurnState.Waiting;
}
void Update()
{
Debug.Log(PlayerAssigner.CharacterOfFormation(formation).name + " is in State " +currentState +".");
Debug.Log(PlayerAssigner.CharacterOfFormation(formation).name + "'s TP value is " + TPValue + ".");
Debug.Log(PlayerAssigner.CharacterOfFormation(formation).name + "'s TP speed is " + TPspeed + ".");
Debug.Log(PlayerAssigner.CharacterOfFormation(formation).name + "'s Agi is " + PlayerAssigner.CharacterOfFormation(formation).agi + ".");
switch (currentState)
{
case TurnState.Waiting:
TPspeed = agi * 2;
TPValue += TPspeed * 1.0f * Time.deltaTime;
if (TPValue >= 100 || GameObject.FindGameObjectsWithTag("Player")[0].GetComponent<BattleSystemPlayer>().TPValue >= 100)
{
TurnState currentState = TurnState.Selecting;
}
break;
case TurnState.Selecting:
TPspeed = 0;
break;
}
}
}