Newer
Older
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Animator))]
public class PlayerController : MonoBehaviour
{
[HideInInspector] public int currentHand;
[HideInInspector] public int opponentHand;
private Animator animatorController;
private bool canMove;
private bool canSkill;
private bool myTurn;
[SerializeField] private float speed;
[HideInInspector] public ControlStrategy controlType;
[HideInInspector] public IEnumerator skill;
// Use this for initialization
void Start ()
{
//fazer dinamico
setupComponents();
canMove = true;
canSkill = true;
myTurn = true;
currentHand = 1;
OpponentController.handChange += updateOpponentHand;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
changeTurn();
}
public void updateMovementLockStates()
{
canMove = canMove == true ? false : true;
canSkill = canSkill == true ? false : true;
}
public bool isSkillUsing()
{
return !canSkill;
}
public bool isMoving()
{
return !canMove;
}
public float getSpeed()
{
return speed;
}
public bool isMyturn()
{
return !myTurn;
}
private void setupComponents()
{
controlType = new KeyBoardControl();
animatorController = GetComponent<Animator>();
}
public void changeTurn()
{
GetComponentInParent<StepBackScript>().enabled = GetComponentInParent<StepBackScript>().enabled == true? false : true;
GetComponentInParent<CrossOverScript>().enabled = GetComponentInParent<CrossOverScript>().enabled == true? false : true;
GetComponentInParent<BehindBackScript>().enabled = GetComponentInParent<BehindBackScript>().enabled == true? false : true;
GetComponentInParent<RoubarBolaScript>().enabled = GetComponentInParent<RoubarBolaScript>().enabled == true? false : true;
FindObjectOfType<ForceBarController>().enabled = FindObjectOfType<ForceBarController>().enabled == true? false : true;
if (myTurn)
{
animatorController.SetTrigger("AtkTurn");
myTurn = false;
}
else
{
animatorController.SetTrigger("DefTurn");
myTurn = true;
}
//do something
}
private void updateOpponentHand(int currentHand)
{
opponentHand = currentHand;
}