using UnityEngine; using System.Collections; /// /// Example interactive object: A bridge that the player can cross. /// Can be destroyed, collapsed, or require conditions to cross safely. /// public class Bridge : MonoBehaviour, IInteractiveObject { [Header("Bridge Settings")] public string bridgeName = "Bridge"; public bool isPassable = true; [SerializeField] private float crossingDuration = 3f; // Time to cross the bridge [Header("Interaction Point")] public Transform interactionPoint; // Where player should stand to interact private Coroutine crossingRoutine; public Vector3 GetInteractionPoint() { if (interactionPoint != null) return interactionPoint.position; return transform.position; } public bool CanInteract() { return isPassable; } public void Interact(GameObject player) { if (!isPassable) { Debug.Log("Bridge is not passable!", gameObject); return; } Debug.Log($"Player {player.name} is crossing {bridgeName}", gameObject); // You can add animation, effects, or checks here // For example: play crossing animation, check integrity, trigger events, etc. } public string GetDisplayName() => bridgeName; /// /// Make the bridge impassable (destroyed, collapsed, etc.) /// public void Collapse() { isPassable = false; Debug.Log($"{bridgeName} has collapsed!", gameObject); // Add visual effects, sounds, animations here } /// /// Repair the bridge /// public void Repair() { isPassable = true; Debug.Log($"{bridgeName} has been repaired!", gameObject); } }