public void UpdateDificultyAllGuardians() { foreach (Transform npc in npcHolder.transform) { WizardController wc = npc.gameObject.GetComponentInChildren <WizardController>(); if (wc != null) { NPCPatrolMovement pm = npc.gameObject.GetComponentInChildren <NPCPatrolMovement>(); wc.UpdateDifficulty(); } } }
public void NPC_Colision(GameObject otherNPC) { WizardController wcA = this.transform.GetChild(1).GetComponent <WizardController>(); WizardController wcB = otherNPC.transform.GetChild(1).GetComponent <WizardController>(); //Ignore communication with wizards if (wcA != null || wcB != null) { return; } NPCPatrolMovement movA = this.transform.GetChild(1).GetComponent <NPCPatrolMovement>(); NPCPatrolMovement movB = otherNPC.transform.GetChild(1).GetComponent <NPCPatrolMovement>(); if ((wcA != null && wcA.isFollowingPlayer) || (wcB != null && wcB.isFollowingPlayer) || movA.isBeingAtacked || movB.isBeingAtacked || tattling) { return; } else if (!otherNPC.transform.GetComponent <Social>().isTalking&& !otherNPC.transform.GetComponent <Social>().onTalkCooldown && !onTalkCooldown) { choosedMessage = null; //Randomly choose who starts to talk /* * if (Random.Range(0, 2) == 0) * { * //Debug.Log(this.name + " initiated conversation"); * choosedMessage = getBestMessageToTalk(this.GetComponent<NPCData>(), otherNPC.transform.GetComponent<NPCData>()); * otherNPC.transform.GetComponent<Social>().choosedMessage = choosedMessage; * } * else * { * //Debug.Log(npc.gameObject.name + " initiated conversation"); * choosedMessage = otherNPC.transform.GetComponent<Social>().getBestMessageToTalk(otherNPC.transform.GetComponent<NPCData>(), this.GetComponent<NPCData>()); * otherNPC.transform.GetComponent<Social>().choosedMessage = choosedMessage; * } */ choosedMessage = getBestMessageToTalk(this.GetComponent <NPCData>(), otherNPC.GetComponent <NPCData>()); otherNPC.GetComponent <Social>().choosedMessage = choosedMessage; messageOfInterest = false; //If there is a message and npc is recieving the message //and message is of interest for him (this happens when NPC did not exceed limit of messages and //this message is more interesting then at least one of the messages he is holding) if (choosedMessage != null && !this.GetComponent <NPCData>().messages.Contains(choosedMessage) && this.GetComponent <NPCData>().isMessageOfInterest(choosedMessage)) { messageOfInterest = true; } if (choosedMessage != null && messageOfInterest) { talkPartner = otherNPC; if (this.GetComponent <NPCData>().messages.Contains(choosedMessage)) { isReceivingMessage = false; } else { isReceivingMessage = true; } remainingMessageTransmissionTime = choosedMessage.messageTransmissionTime; otherNPC.GetComponentInParent <Social>().remainingMessageTransmissionTime = choosedMessage.messageTransmissionTime; this.isTalking = true; otherNPC.GetComponentInParent <Social>().isTalking = true; otherNPC.GetComponentInParent <Social>().talkPartner = this.gameObject; if (!isReceivingMessage) { otherNPC.GetComponentInParent <Social>().isReceivingMessage = true; } else { otherNPC.GetComponentInParent <Social>().isReceivingMessage = false; } //this.GetComponentInChildren<NPCPatrolMovement>().agent.isStopped = true; //otherNPC.transform.GetComponentInParent<NPCPatrolMovement>().agent.isStopped = true; this.GetComponentInChildren <NPCPatrolMovement>().stopped = true; otherNPC.GetComponentInChildren <NPCPatrolMovement>().stopped = true; } } }