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

public class GameController : UnitySingleton<GameController>
{   
    
    public struct Death{
        public enum DeadReason { Camera , PersonFall }
        public DeadReason deadReason;
    }

    private Horse horse;
    private CameraManager cameraManager;
    private Person person;

    void Start(){
        FindSth();
    }

    void Update(){
        //当同时按下左右扳机，触发重开,仅调试用
        if(Gamepad.current != null && Gamepad.current.leftTrigger.isPressed && Gamepad.current.rightTrigger.isPressed){
            UnityEngine.SceneManagement.SceneManager.LoadScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
        }
    }

    void FindSth(){
        horse = FindObjectOfType<Horse>();
        cameraManager = FindObjectOfType<CameraManager>();
        person = FindObjectOfType<Person>();
    }

    public void GameOver(Death deathInfo){
        //触发马的死亡功能
        horse.Death(deathInfo);
        //触发人的死亡功能
        person.Death(deathInfo);
        //告诉相机马死了
        cameraManager.Death(deathInfo);
    }
   
}
