using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 人马分离障碍物类
/// </summary>
public class HumanHorseBreakObstacle : Obstacle
{
    bool hasShoot = false;
    private void OnTriggerEnter2D(Collider2D other) {
        //如果人进入了人马分离的触发器,触发人的发射函数
        if(other.TryGetComponent<Person>(out Person person) && !hasShoot)    {person.Shoot();hasShoot = true;}
    }

    private void OnCollisionEnter2D(Collision2D other) {
        //如果人到了平台上，触发Walk
        if(other.gameObject.TryGetComponent<Person>(out Person person) && person.state == Person.PersonState.Shoot)    {person.Walk();}
    }

    private void OnCollisionExit2D(Collision2D other) {
        //如果人离开了平台上，触发FallingOff
        if(other.gameObject.TryGetComponent<Person>(out Person person) && person.state == Person.PersonState.Walk)    {person.FallingOff();}
    }

}
