61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
/// <summary>
|
|
/// Example interactive object: A bridge that the player can cross.
|
|
/// Can be destroyed, collapsed, or require conditions to cross safely.
|
|
/// </summary>
|
|
public class Bridge : InteractiveObjectBase
|
|
{
|
|
[Header("Bridge Settings")]
|
|
public string bridgeName = "Bridge";
|
|
public bool isPassable = true;
|
|
[SerializeField]
|
|
private float crossingDuration = 3f; // Time to cross the bridge
|
|
|
|
private Coroutine crossingRoutine;
|
|
|
|
public override bool CanInteract()
|
|
{
|
|
return isPassable;
|
|
}
|
|
|
|
public override void Interact(GameObject player)
|
|
{
|
|
if (!isPassable)
|
|
{
|
|
Log("Bridge is not passable!");
|
|
return;
|
|
}
|
|
|
|
Log($"Player {player.name} is crossing {bridgeName}");
|
|
|
|
// You can add animation, effects, or checks here
|
|
// For example: play crossing animation, check integrity, trigger events, etc.
|
|
}
|
|
|
|
void OnValidate()
|
|
{
|
|
objectDisplayName = bridgeName;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Make the bridge impassable (destroyed, collapsed, etc.)
|
|
/// </summary>
|
|
public void Collapse()
|
|
{
|
|
isPassable = false;
|
|
Log($"{bridgeName} has collapsed!");
|
|
// Add visual effects, sounds, animations here
|
|
}
|
|
|
|
/// <summary>
|
|
/// Repair the bridge
|
|
/// </summary>
|
|
public void Repair()
|
|
{
|
|
isPassable = true;
|
|
Log($"{bridgeName} has been repaired!");
|
|
}
|
|
}
|