Files
RPGBook/Assets/Scripts/NPCInteraction.cs
SHOUTING_PIRATE f5928e04c4 intial commit
2025-07-21 17:10:16 +01:00

54 lines
1.7 KiB
C#

using UnityEngine;
[RequireComponent(typeof(CharacterStats))]
public class NPCInteraction : MonoBehaviour
{
private CharacterStats characterStats;
void Awake()
{
characterStats = GetComponent<CharacterStats>();
}
// Called by the player's interaction system
public void Interact()
{
var profile = characterStats.profile;
if (profile.disposition == NPCProfile.Disposition.Hostile)
{
Debug.Log($"{profile.npcName} is hostile and attacks on sight!");
// BattleSystem.Instance.StartBattle(PlayerController.Instance.playerStats, this.characterStats);
return;
}
// If not hostile, show a UI with choices: Talk, Avoid, Attack
// The buttons on that UI would call the methods below.
Debug.Log($"You encounter {profile.npcName}. What do you do?");
}
/*public void AttemptTalk()
{
var playerStats = PlayerController.Instance.playerStats;
var profile = characterStats.profile;
int talkDC = 12; // You can get this from the NPCProfile in the future
int playerRoll = Dice.Roll("1d20") + playerStats.charisma;
if (playerRoll >= talkDC)
{
Debug.Log("You successfully begin a conversation.");
// Trigger your dialogue system here
}
else
{
Debug.Log($"{profile.npcName} seems uninterested in talking.");
// NPC could become hostile or simply end the interaction
}
}*/
public void AttemptAttack()
{
Debug.Log($"You decide to attack {characterStats.profile.npcName}!");
// BattleSystem.Instance.StartBattle(PlayerController.Instance.playerStats, this.characterStats);
}
}