using FOHEART.GlovePlugin;
using UnityEngine;

public class WolfMoveForwardLogic : MonoBehaviour
{
    [Tooltip("˶ٶ m/s")]
    public float speed = 1f;
    [Tooltip("̼")]
    public bool isItemActive = false;

    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        // Ѽ
        if (isItemActive)
        {
            // ǰ˶
            transform.Translate(0f, 0f, Time.deltaTime * speed, Space.Self);
        }
    }

    /// <summary>
    /// Զǰ˶
    /// </summary>
    public void activeItem()
    {
        // 弤ʼǰ˶
        isItemActive = true;
    }

    private void OnCollisionEnter(Collision collision)
    {
        meetOthers(collision.gameObject);
    }

    private void OnCollisionStay(Collision collision)
    {
        meetOthers(collision.gameObject);
    }

    private void OnTriggerStay(Collider other)
    {
        meetOthers(other.gameObject);
    }

    private void OnTriggerEnter(Collider other)
    {
        meetOthers(other.gameObject);
    }

    private void meetOthers(GameObject other)
    {
        float turnAngle = Random.Range(0, 360f) - 180f;
        transform.Rotate(0f, turnAngle, 0f, Space.Self);
    }

}
