public override bool use() { trigger_base trigger = null; //If a door has a link and the link is to something that is not a lock then it is a trigger that I need to activae if (link != 0) { ObjectInteraction linkedObject = ObjectLoader.getObjectIntAt(link); if (linkedObject != null) { if (linkedObject.GetItemType() != ObjectInteraction.LOCK) { trigger = linkedObject.GetComponent <trigger_base>(); } } } if (CurrentObjectInHand != null) { ActivateByObject(CurrentObjectInHand); //Clear the object in hand //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault; CurrentObjectInHand = null; if (trigger != null) { trigger.Activate(this.gameObject); } return(true); } else { //Normal Usage PlayerUse = true; if ((UWCharacter.AutoKeyUse) && (locked())) {//Try each key in the players inventory to see if it can open the door foreach (Transform t in GameWorldController.instance.InventoryMarker.transform) { if (t.gameObject.GetComponent <DoorKey>() != null) { DoorKey key = t.gameObject.GetComponent <DoorKey>(); if (key.KeyId == KeyIndex) { ActivateByObject(key.objInt()); if (trigger != null) { trigger.Activate(this.gameObject); } PlayerUse = false; return(true); } } } } Activate(this.gameObject); PlayerUse = false; return(true); } }
/// <summary> /// Find the next trigger to execute and fire it. /// </summary> /// <param name="triggerX"></param> /// <param name="triggerY"></param> /// <param name="State"></param> public virtual void TriggerNext(int triggerX, int triggerY, int State) { if (link == 0) { return; } GameObject triggerObj = ObjectLoader.getGameObjectAt(link); // GameObject.Find (TriggerObject); if (triggerObj != null) { trigger_base trig = triggerObj.GetComponent <trigger_base>(); if (trig != null) { trig.Activate(this.gameObject); } else { //try and find a trap instead trap_base trap = triggerObj.GetComponent <trap_base>(); if (trap != null) { trap.Activate(this, triggerX, triggerY, State); } else { //Debug.Log ("no trigger or trap found on this object " + triggerObj); //return false; } } } }
public virtual void TriggerNext(int triggerX, int triggerY, int State) { GameObject triggerObj = GameObject.Find(TriggerObject); if (triggerObj != null) { trigger_base trig = triggerObj.GetComponent <trigger_base>(); if (trig != null) { trig.Activate(); } else { //try and find a trap instead trap_base trap = triggerObj.GetComponent <trap_base>(); if (trap != null) { trap.Activate(triggerX, triggerY, State); //return true; } else { Debug.Log("no trigger or trap found on this object"); //return false; } } } }
public void OpenDoor() { if (state == false) { if (!DoorBusy) { if (isPortcullis == false) { StartCoroutine(RotateDoor(this.transform, Vector3.up * 90, 1.0f)); } else { StartCoroutine(RaiseDoor(this.transform, new Vector3(0f, 1.1f, 0f), 1.0f)); } objInt.item_id += 8; state = true; if (UseLink != "") { GameObject trigObj = GameObject.Find(UseLink); if (trigObj != null) { trigger_base tb = trigObj.GetComponent <trigger_base>(); tb.Activate(); } } } } }
public override bool use() { trigger_base trigger = null; //If a door has a link and the link is to something that is not a lock then it is a trigger that I need to activae if (objInt().link != 0) { ObjectInteraction linkedObject = ObjectLoader.getObjectIntAt(objInt().link); if (linkedObject != null) { if (linkedObject.GetItemType() != ObjectInteraction.LOCK) { trigger = linkedObject.GetComponent <trigger_base>(); } } } if (UWCharacter.Instance.playerInventory.ObjectInHand != "") { ActivateByObject(UWCharacter.Instance.playerInventory.GetGameObjectInHand()); //Clear the object in hand UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault; UWCharacter.Instance.playerInventory.ObjectInHand = ""; if (trigger != null) { trigger.Activate(this.gameObject); } return(true); } else { //Normal Usage PlayerUse = true; Activate(this.gameObject); PlayerUse = false; //if (trigger!=null) //{ // trigger.Activate(); //} return(true); } }
/// <summary> /// Closes the door. /// </summary> public void CloseDoor(float DoorTravelTime) { if (state() == true) { if (!DoorBusy) { if (isPortcullis() == false) { if (ObjectInteraction.PlaySoundEffects) { objInt().aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_DOOR_MOVE]; objInt().aud.Play(); } StartCoroutine(RotateDoor(this.transform, Vector3.up * doordir() * CloseRotation, DoorTravelTime)); } else { if (ObjectInteraction.PlaySoundEffects) { objInt().aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_PORTCULLIS]; objInt().aud.Play(); } StartCoroutine(RaiseDoor(this.transform, new Vector3(0f, -1.1f, 0f), DoorTravelTime)); } objInt().item_id -= 8; objInt().zpos -= 24; objInt().flags = 0; objInt().enchantment = 0; //state=false; if (objInt().link != 0) { //If it's link is to something that is not a lock then it is likely to be a trigger if ( (ObjectLoader.GetItemTypeAt(objInt().link) != ObjectInteraction.LOCK) && (ObjectLoader.GetItemTypeAt(objInt().link) != ObjectInteraction.AN_OPEN_TRIGGER) ) { trigger_base tb = ObjectLoader.getObjectIntAt(objInt().link).GetComponent <trigger_base>(); if (tb != null) { tb.Activate(this.gameObject); } } else { //The object is linked to a lock. The next of the lock is the use trigger to use here ObjectInteraction LockObj = ObjectLoader.getObjectIntAt(objInt().link); if (LockObj != null) { int next = LockObj.next; while (next != 0) { ObjectInteraction TriggerObject = ObjectLoader.getObjectIntAt(next); if (TriggerObject != null) { next = 0; trigger_base tb = TriggerObject.GetComponent <trigger_base>(); if (tb != null) { if (tb.objInt().GetItemType() != ObjectInteraction.AN_OPEN_TRIGGER) { tb.Activate(this.gameObject); } next = tb.objInt().next; } } else { next = 0; } } } } } } } }
/// <summary> /// Opens the door. /// </summary> public void OpenDoor(float DoorTravelTime) { if (state() == false) { if (!DoorBusy) { if (isPortcullis() == false) { if (ObjectInteraction.PlaySoundEffects) { objInt().aud.clip = MusicController.instance.SoundEffects[MusicController.SOUND_EFFECT_DOOR_MOVE]; objInt().aud.Play(); } StartCoroutine(RotateDoor(this.transform, Vector3.up * doordirection() * OpenRotation, DoorTravelTime)); } else { if (ObjectInteraction.PlaySoundEffects) { objInt().aud.clip = MusicController.instance.SoundEffects[MusicController.SOUND_EFFECT_PORTCULLIS]; objInt().aud.Play(); } StartCoroutine(RaiseDoor(this.transform, new Vector3(0f, 1.1f, 0f), DoorTravelTime)); } owner = 0; item_id += 8; zpos += 24; enchantment = 1; if (isPortcullis()) { //flags=12; flags = 4; NavMeshObstacle nmo = this.GetComponent <NavMeshObstacle>(); if (nmo != null) { nmo.enabled = !state(); } } else { //flags=13; flags = 5; } //state=true; if (link != 0) { //If it's link is to something that is not a lock then it is likely to be a trigger if ( ( (ObjectLoader.GetItemTypeAt(link) != ObjectInteraction.LOCK) && (ObjectLoader.GetItemTypeAt(link) != ObjectInteraction.A_CLOSE_TRIGGER) ) ) { trigger_base tb = ObjectLoader.getObjectIntAt(link).GetComponent <trigger_base>(); if (tb != null) { tb.Activate(this.gameObject); } } else { //The object is linked to a lock. The next of the lock is the use trigger to use here ObjectInteraction LockObj = ObjectLoader.getObjectIntAt(link); if (LockObj != null) { int next = LockObj.next; while (next != 0) { ObjectInteraction TriggerObject = ObjectLoader.getObjectIntAt(next); if (TriggerObject != null) { next = 0; trigger_base tb = TriggerObject.GetComponent <trigger_base>(); if (tb != null) { if ( (tb.objInt().GetItemType() != ObjectInteraction.A_CLOSE_TRIGGER) && (tb.objInt().GetItemType() != ObjectInteraction.AN_UNLOCK_TRIGGER) ) { tb.Activate(this.gameObject); } next = tb.next; } } else { next = 0; } } } } } } } }