Okey so I need My NPC that is friendly and you can make conversation with it, to after the last conversation outcome become enemy to PC and start shooting. I need this in C# Would appreciate all the help. Here is my NPC Talk conversation Which work well. And I need to after clicking the second option and second outcome to become unfriendly to PC and starts shooting at him. I got a prefab made also with NPC_Chaser maybe it could be done somehow to replace one NPC with another I don’t know, please help. Thank you.
using UnityEngine;
using System.Collections;
public class DD_NPC_talk : MonoBehaviour {
//-------------------------------------------------------------------------
// ----- Declare Variables
// Game Objects
private GameObject go_PC;
//Dialogue Variables
public string st_NPC_name = "Tower Guard";
public string st_NPC_inital_text = "You there, Halt where do you think you are going?";
public string st_PC_response_1 = "Sorry Sir, I was looking for the guards base,
I want to report a crime";
public string st_PC_response_2 = “Shove off you trout faced old Fart!!”;
public string st_NPC_outcome1 = “You poor young scamp, it is in the north west part of town, but watch out for the Pirates”;
public string st_NPC_outcome2 = “Well I have never been so insulted, I hope the guards fill you with holes, and the try and fill them with their pork swords!”;
public string st_NPC_return_text = “Leave me alone before I call the guards!”;
private string st_NPC_outcome;
private bool bl_dialogue_on;
private bool bl_PC_responded;
private bool bl_conversation_complete;
private DD_Level_Manager LM_Script;
//-------------------------------------------------------------------------
// Start - only called once
void Start()
{
// Find the level manager script
LM_Script = GameObject.Find("Level_Manager").GetComponent<DD_Level_Manager>();
// Find the PC GameObject
go_PC = GameObject.Find("PC");
}
//-------------------------------------------------------------------------
// Update is called once per frame
void Update ()
{
// Is the PC in the Scene
if(go_PC)
{
// when the PC is close Turn the GUI box and start Converstation
if (Vector3.Distance( transform.position , go_PC.transform.position) < 3 )
{
bl_dialogue_on = true;
}
else
{
bl_dialogue_on = false;
}
}
else
{
go_PC = GameObject.Find("PC");
}
}//---
// ----- Interface Control GUI Display -----------------------------------------
void OnGUI()
{
if (bl_dialogue_on)
{
// Draw Outline Box
GUI.Box(new Rect ((Screen.width/2)-200, (Screen.height/2)-150, 400, 250), st_NPC_name);
if (!bl_conversation_complete)
{
if (!bl_PC_responded)
{
// NPC Inital text
GUI.Label(new Rect ( (Screen.width/2)-160, (Screen.height/2)-120, 350, 50), st_NPC_inital_text);
Screen.lockCursor = false;
// PC option 1
if ( GUI.Button(new Rect ( (Screen.width/2)-180, (Screen.height/2)-60, 350, 60), st_PC_response_1) )
{
// Set NPC response 1 and flag we have spoken
st_NPC_outcome = st_NPC_outcome1;
bl_PC_responded = true;
}
// PC option 2
if ( GUI.Button(new Rect ( (Screen.width/2)-180, (Screen.height/2)+10, 350, 60), st_PC_response_2) )
{
// Set NPC response 1 and flag we have spoken
st_NPC_outcome = st_NPC_outcome2;
bl_PC_responded = true;
}
}
else
{
// bl_PC_responded is now true
// Display the NPC response to the PC's Choice
GUI.Label(new Rect ( (Screen.width/2)-180, (Screen.height/2)-130, 350, 50), st_NPC_outcome);
// PC Goodbye - and set end flag
if ( GUI.Button(new Rect ( (Screen.width/2)-180, (Screen.height/2)-60, 350, 60), " Thanks, Goodbye") )
{
bl_conversation_complete = true ;
Screen.lockCursor = true;
}
}
}
else
{
// bl_conversation_complete is now true
// Display text indicating we have spoken
GUI.Label(new Rect ( (Screen.width/2)-180, (Screen.height/2)-60, 350, 50), st_NPC_return_text);
}
}
}// ---
}// -----