Skip to content
Snippets Groups Projects
PlayerController.cs 2.38 KiB
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;
        //adicionar delegate a IAController pra atualizar a mao atual automaticamente e configurar aqui pra mudar a referencia
        opponentHand = -1;
        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
    }
}