using System.Collections; using System.Collections.Generic; using UnityEngine; namespace WSMGameStudio.RailroadSystem { public class TrainDoor : MonoBehaviour { private bool _isOpen = false; public List animators; public bool IsOpen { get { return _isOpen; } set { _isOpen = value; } } /// /// Play open door animation /// /// True if opened successfully, false if already open public bool Open() { if (!_isOpen) { _isOpen = true; UpdateDoorAnimator(_isOpen); return true; } return false; } /// /// Play close door animation /// /// True if closed successfully, false if already closed public bool Close() { if (_isOpen) { _isOpen = false; UpdateDoorAnimator(_isOpen); return true; } return false; } /// /// Set animator parameters /// /// private void UpdateDoorAnimator(bool open) { if (animators == null) return; foreach (var animator in animators) { animator.SetBool(AnimationParameters.Open, open); } } } }