void Start() { Transform t = ExtraFunctions.searchInAncestor (this.transform, typeof(NPCBehaviour)); if (t != null) { parentNPC = t.gameObject; npcB = parentNPC.GetComponent<NPCBehaviour> (); } }
public override void Enter(NPCBehaviour behaviour) { base.Enter(behaviour); if (npcBehaviour.CurrentTarget == null) { npcBehaviour.ChangeBrainState(new IdleState(npcBehaviour.Blueprint.GetNewIdleTime)); } }
public override void OnComplete() { NPCBehaviour rep = this.gameObject.AddComponent <NPCBehaviour_FollowObject> (); rep.passInGameobject(CommonObjectsStore.player); myController.currentBehaviour = rep; Destroy(this); }
public void Damage(NPCBehaviour npc) { if (Health > 0) { Health -= 5; npc.Energy -= 10; } UpdateText(); }
public override void Enter(NPCBehaviour behaviour) { base.Enter(behaviour); npcBehaviour.Blueprint.OnMoveEnter(npcBehaviour); if (!npcBehaviour.CalculatePath(npcBehaviour.targetDestination)) { npcBehaviour.ChangeBrainState(new IdleState(npcBehaviour.Blueprint.GetNewIdleTime)); return; } }
public void Gather(NPCBehaviour npc) { if (Resources > 0) { Resources -= 10; npc.StoredMinerals += 10; npc.Energy -= 5; } else { Resources = 0; } UpdateText(); }
void Start() { oh = objcHandlerObj.GetComponent<ObjectiveHandler> (); pv = player.GetComponent<PlayerVolume> (); sQstring = startQuestText.text; fQstring = finishQuestText.text; char[] delimitingChars = {'\n'}; sQLines = sQstring.Split (delimitingChars); fQLines = fQstring.Split (delimitingChars); ch = chatHandlerObject.GetComponent<ChatHandler> (); npcb = this.GetComponent<NPCBehaviour> (); objectContainer = questObjectContainer.transform; questStarted = false; questFinished = false; r = new Reward (0, levelReward); q = new Quest (this.gameObject, r, quest_name, quest_description); }
// Update is called once per frame void Update() { Vector3 orPos = transform.position; Vector3 direction = transform.forward * (1.01f) - orPos; //射线的长度 //float shootLength = direction.magnitude; float shootLength = 5f; // print("shootLength="+ shootLength); //射线检测 检查是否碰撞 RaycastHit hitInfo; bool isCollider = Physics.Raycast(orPos, direction, out hitInfo, shootLength); if (isCollider) { NPCBehaviour beav = hitInfo.collider.GetComponent <NPCBehaviour>(); //撞到了NPC 然后可以对话 当然 也可以使用碰撞器来触发 if (hitInfo.collider.tag == "NPC") { // hitInfo.collider.GetComponent<NPCBehaviour>().NPCTalkSomething(); } } }
void Start() { if (completeQuestEventObj != null) { cqe = completeQuestEventObj.GetComponent<CompleteQuestEvent> (); } trigger = questTriggerObj.GetComponent<QuestTrigger> (); sQstring = startQuestText.text; fAQstring = failedQuestText.text; fQstring = finishQuestText.text; char[] delimitingChars = {'\n'}; sQLines = sQstring.Split (delimitingChars); fQLines = fQstring.Split (delimitingChars); fAQLines = fAQstring.Split (delimitingChars); npcb = this.GetComponent<NPCBehaviour> (); r = new Reward (0, rewardLevels); q = new Quest (this.gameObject, r, quest_name, quest_description); ch = chatHandlerObj.GetComponent<ChatHandler> (); }
void Start() { npcb = npc.GetComponent<NPCBehaviour> (); }
void Start() { startCheckChat = false; spawner = spawnerObj.GetComponent<Spawner> (); oh = objcHandlerObj.GetComponent<ObjectiveHandler> (); sQstring = startQuestText.text; fAQstring = failedQuestText.text; fQstring = finishQuestText.text; char[] delimitingChars = {'\n'}; sQLines = sQstring.Split (delimitingChars); fQLines = fQstring.Split (delimitingChars); fAQLines = fAQstring.Split (delimitingChars); ch = chatHandlerObj.GetComponent<ChatHandler> (); npcb = this.GetComponent<NPCBehaviour> (); rewardHandler = rewardParent.GetComponent<DestructiblesHandler> (); questStarted = false; questFinished = false; r = new Reward (0, rewardLevels); q = new Quest (this.gameObject, r, quest_name, quest_description); }