/// <summary> /// The projectile will only damage anything for a short period after it hits something /// To support bouncing around /// </summary> public IEnumerator EndProjectile() { yield return(new WaitForSeconds(1.0f)); ObjectInteraction.DestroyObjectFromUW(this.GetComponent <ObjectInteraction>()); //Destroy(this.gameObject); }
private void EndAnimation() { CurrentTileMap().Overlays[OverlayIndex] = new TileMap.Overlay();//Clear the overlay from the list. if (this.GetComponent <ObjectInteraction>() != null) { this.GetComponent <ObjectInteraction>().BaseObjectData.InUseFlag = 0;//Free up the slot //Destroy(this.gameObject); ObjectInteraction.DestroyObjectFromUW(this.GetComponent <ObjectInteraction>()); } }
/// <summary> /// Handles throwing objects into lava. /// </summary> /// <param name="obj"></param> /// <param name="position"></param> /// Does not include handling of the talismans which use the larger shrine lava trigger. protected override void TileContactEvent(ObjectInteraction obj, Vector3 position) { if (obj.item_id != 456) { Impact.SpawnHitImpact(456, position, 9, 12); if (IsObjectDestroyable(obj)) { ObjectInteraction.DestroyObjectFromUW(obj); } } }
public override bool ApplyAttack(short damage) { quality -= damage; if (quality <= 0) { ChangeType(213); //Change to debris. this.gameObject.AddComponent <enchantment_base>(); //Add a generic object base for behaviour. THis is the famous magic debris //Remove the potion enchantment. ObjectInteraction.DestroyObjectFromUW(this.objInt()); } return(true); }
public override bool ApplyAttack(short damage) { quality -= damage; if (quality <= 0) { ChangeType(213); //Change to debris. this.gameObject.AddComponent <object_base>(); //Add a generic object base for behaviour objInt().BaseObjectData.InUseFlag = 0; ObjectInteraction.DestroyObjectFromUW(this.objInt()); } return(true); }
/*protected override void Start () * { * base.Start (); * //this.transform.localScale = new Vector3(4f,4f,4f); * }*/ public override bool ActivateByObject(ObjectInteraction ObjectUsed) { if (ObjectUsed.item_id == 296) {//Bashed with a rock hammer //ObjectInteraction newObj; switch (item_id) { case LargeBoulder1: //Large Boulders case LargeBoulder2: //Split into two boulders for (int i = 0; i < 2; i++) { ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(MediumBoulder, 0, 0, 0, 256); ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f))); objInt().BaseObjectData.InUseFlag = 0; Destroy(this.gameObject); ObjectInteraction.DestroyObjectFromUW(this.objInt()); } break; case MediumBoulder: //Boulder. //Split into 2 small boulders for (int i = 0; i < 2; i++) { ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(342, 0, 0, 0, 256); ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f))); objInt().BaseObjectData.InUseFlag = 0; ObjectInteraction.DestroyObjectFromUW(this.objInt()); } break; case SmallBoulder: //Small boulder { ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(16, 0, 0, 1, 256); newobjt.is_quant = 1; newobjt.link = Random.Range(1, 3); ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f))); objInt().BaseObjectData.InUseFlag = 0; ObjectInteraction.DestroyObjectFromUW(this.objInt()); break; } } //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault; CurrentObjectInHand = null; return(true); } else { return(base.ActivateByObject(ObjectUsed)); } }
protected virtual void DestroyProjectile() { ObjectInteraction objIntThis = this.GetComponent <ObjectInteraction> (); //if (objIntThis != null) { // objIntThis.BaseObjectData.InUseFlag = 0; // //Free up object slot //} // Object.Destroy(this.gameObject); //DestroyObject (this.gameObject); if (objIntThis != null) { ObjectInteraction.DestroyObjectFromUW(objIntThis); } }
private void ObjectHitsWater(ObjectInteraction obj, Vector3 position) { if (IsObjectDestroyable(obj)) { GameObject splash = Impact.SpawnHitImpact(453, position, splashanimstart(), splashanimstart() + 4); if (splash != null) { if (ObjectInteraction.PlaySoundEffects) { splash.GetComponent <ObjectInteraction>().aud.clip = MusicController.instance.SoundEffects[MusicController.SOUND_EFFECT_SPLASH_1]; splash.GetComponent <ObjectInteraction>().aud.Play(); } } ObjectInteraction.DestroyObjectFromUW(obj); } }
public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State) { GameObject triggerObj = ObjectLoader.getGameObjectAt(link); if (triggerObj != null) { triggerObj.GetComponent <ObjectInteraction>().BaseObjectData.InUseFlag = 0; if (triggerObj.GetComponent <map_object>() != null) { Destroy(triggerObj.GetComponent <map_object>().ModelInstance); } Debug.Log(this.name + " deleting in ExecuteTrap() " + triggerObj.name); //Destroy(triggerObj); ObjectInteraction.DestroyObjectFromUW(triggerObj.GetComponent <ObjectInteraction>()); } }
protected void DestroyTrap(object_base src) { if (src != null) { if (src.GetComponent <ObjectInteraction>() != null) { //Clear the link to the trigger/trap from the source if it is destroyed. if (src.GetComponent <ObjectInteraction>().link == this.gameObject.GetComponent <ObjectInteraction>().BaseObjectData.index) { src.GetComponent <ObjectInteraction>().link = 0; } } } objInt().BaseObjectData.InUseFlag = 0; Debug.Log("Destroying Trap: " + this.name); //Destroy(this.gameObject); ObjectInteraction.DestroyObjectFromUW(this.objInt()); }
/// <summary> /// Animate between the specified StartFrame and EndFrame. /// </summary> /// <param name="StartFrame">Start frame.</param> /// <param name="EndFrame">End frame.</param> public IEnumerator Animate(int StartFrame, int EndFrame) { //Loop throught the animation frames from StartFrame to EndFrame in order one time. bool Active = true; LoadAnimo(StartFrame); while (Active == true) { yield return(new WaitForSeconds(0.2f)); StartFrame++; if (StartFrame >= EndFrame) { Active = false; //Destroy (this.gameObject); ObjectInteraction.DestroyObjectFromUW(this.objInt()); } else { //Loads the next animation frame LoadAnimo(StartFrame); } } }
/// <summary> /// Destroys the object that has come into contact with this tile. /// </summary> /// <param name="obj">Object.</param> protected virtual void DestroyObject(ObjectInteraction obj) { // obj.BaseObjectData.InUseFlag = 0;//Free up the slot //Destroy(obj.gameObject); ObjectInteraction.DestroyObjectFromUW(obj); }
public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State) { GameObject door = DoorControl.findDoor(triggerX, triggerY); if (door != null) { DoorControl DC = door.GetComponent <DoorControl>(); switch (quality) { case 0: //Just lock //Copy the lock object at the link to use on this door if (link != 0) { //link to a lock if (ObjectLoader.GetItemTypeAt(link) == ObjectInteraction.LOCK) { ObjectInteraction lockToCopy = ObjectLoader.getObjectIntAt(link); ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(lockToCopy.item_id, lockToCopy.quality, lockToCopy.owner, lockToCopy.link, 256); newobjt.flags = lockToCopy.flags; newobjt.doordir = lockToCopy.doordir; newobjt.invis = lockToCopy.invis; newobjt.enchantment = lockToCopy.enchantment; newobjt.zpos = lockToCopy.zpos; newobjt.xpos = lockToCopy.xpos; newobjt.ypos = lockToCopy.ypos; newobjt.next = DC.link; //To allow proper triggering of traps newobjt.InUseFlag = 1; GameObject Created = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject; DC.link = newobjt.index; //Point the lock at this new lock } } else { //unlink the lock and tie the locks next back to the door as it's link ObjectInteraction linkedObj = ObjectLoader.getObjectIntAt(DC.link); if (linkedObj != null) { DC.link = linkedObj.next; linkedObj.BaseObjectData.InUseFlag = 0; //Destroy(linkedObj); ObjectInteraction.DestroyObjectFromUW(linkedObj); } } break; case 1: //try open if (TriggerInstantly) { DC.UnlockDoor(false); DC.OpenDoor(0f); } else { DC.UnlockDoor(false); DC.OpenDoor(DoorControl.DefaultDoorTravelTime); } break; case 2: //try close if (TriggerInstantly) { DC.CloseDoor(0f); DC.LockDoor(); } else { DC.CloseDoor(DoorControl.DefaultDoorTravelTime); DC.LockDoor(); } break; case 3: //try toggle //TODO:check if toggle respects unlocked status. (door trap 1001 on level 3) if (TriggerInstantly) { DC.ToggleDoor(0, false); } else { DC.ToggleDoor(DoorControl.DefaultDoorTravelTime, false); } break; } } else { Debug.Log("Door not found!"); } }