//#pragma strict
static var playerObj : GameObject;
static var talkCamera : GameObject;
static var sexCamera : GameObject;
static var linkToChat;
static var linkToInv;
static var quests = new Array([["Collect 5 Apples", 0]]);
function Start () {
playerObj = GameObject.Find("Main Camera");
talkCamera = GameObject.Find("QuestCamera");
sexCamera = GameObject.Find("Camera");
linkToChat = GameObject.Find("chat").GetComponent(chat);
linkToInv = GameObject.Find("Inventory").GetComponent(Inventory);
linkToItemEffect = GameObject.Find("Inventory").GetComponent(Inventory);
// Quest Name, State (0 = not started, 1 = in progress, 2 = completed)
//quests = [["Collect 5 Apples", 0]];
}
function Update ()
{
}
function startQuest(index)
{
switch (index)
{
case 0:
if (quests[index][1] == 0)
{
changeCamera("on");
linkToChat.addLine("Kat: I have a quest for you! Go pick 5 apples and bring them back to me!", 5);
yield WaitForSeconds (5);
changeCamera("off");
quests[index][1] = 1;
} else if (quests[index][1] == 1)
{
changeCamera("on");
apples = 0;
for(var t:Transform in linkToInv.Contents)
{
var a:Item=t.GetComponent(Item);
if (a.name == "default")
{
apples += a.stack;
}
}
//Debug.Log(apples);
if (apples >= 5)
{
linkToChat.addLine("Kat: Oh thank you! Here is your reward! *winks*", 5);
for (var count=0; count<5; count++)
{
for(var t:Transform in linkToInv.Contents)
{
var i:Item=t.GetComponent(Item);
if (i.name == "default")
{
playersInv = FindObjectOfType(Inventory); //finding the players inv.
if (i.stack == 1) //Remove item
{
playersInv.RemoveItem(i.transform);
break;
}
else //Remove from stack
{
i.stack -= 1;
break;
}
}
}
}
quests[index][1] = 2;
} else
{
linkToChat.addLine("Kat: Please go get me those apples I asked for!", 5);
}
yield WaitForSeconds (5);
changeCamera("off");
} else if (quests[index][1] == 2)
{
changeCamera("on");
linkToChat.addLine("Kat: I sure hope you liked your reward. *grins*", 5);
yield WaitForSeconds (5);
changeCamera("off");
}
//break;
}
}
function changeCamera(state)
{
switch(state)
{
case "on":
sexCamera.camera.active = false;
talkCamera.camera.active = true;
playerObj.camera.active = false;
break;
case "off":
talkCamera.camera.active = false;
playerObj.camera.active = true;
break;
}
}