Newer
Older
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Controller))]
[RequireComponent(typeof(Rigidbody2D))]
public class CrossOverScript : MonoBehaviour
{
private Animator animatorController;
private Rigidbody2D rb;
private bool isActive;
[SerializeField] float speedModifier;
// Use this for initialization
void Start ()
{
controller = GetComponent<Controller>();
animatorController = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
CrossOverBehaviour.action += updateState;
isActive = false;
}
// Update is called once per frame
private void Update()
{
if (controller.getCrossOverInput() == 1)
if (controller.isMyturn() && !controller.isSkillUsing() && !usingAxis)
{
activateSkill("crossOver");
}
usingAxis = true;
}
else
{
usingAxis = false;
private IEnumerator crossOver()
controller.updateMovementLockStates();
animatorController.SetTrigger("CrossOver");
while(isActive)
{
rb.velocity = new Vector2(-1, controller.currentHand) * controller.getSpeed() * speedModifier;
yield return null;
}
controller.updateMovementLockStates();
}
private void activateSkill(string method)
{
StopCoroutine("move");
StartCoroutine(method);
}
private void updateState()
{
isActive = isActive == true? false : true;
}