浏览代码

Checking if the talking to array is not empty before going through it

/main
Amel 4 年前
当前提交
148e0a62
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 16
      UOP1_Project/Assets/Scripts/Quests/StepController.cs

16
UOP1_Project/Assets/Scripts/Quests/StepController.cs


private void StopTalkingToCurrentActor()
{
GameObject[] talkingTo = gameObject.GetComponent<NPC>().talkingTo;
for (int i = 0; i < talkingTo.Length; ++i)
if(talkingTo != null)
talkingTo[i].GetComponent<NPC>().npcState = NPCState.Idle;
for (int i = 0; i < talkingTo.Length; ++i)
{
talkingTo[i].GetComponent<NPC>().npcState = NPCState.Idle;
}
}
}

for (int i = 0; i < talkingTo.Length; ++i)
if (talkingTo != null)
talkingTo[i].GetComponent<NPC>().npcState = NPCState.Talk;
for (int i = 0; i < talkingTo.Length; ++i)
{
talkingTo[i].GetComponent<NPC>().npcState = NPCState.Talk;
}
}
正在加载...
取消
保存