public void die() { //add corpse to some kind of dead person list? if (this != playerHealth) { NPCManager.me.npcsInWorld.Remove(this.gameObject); NPCManager.me.corpsesInWorld.Add(this.gameObject); NPCController npc = this.GetComponent <NPCController> (); NPCManager.me.npcControllers.Remove(npc); if (npc.myText == null) { } else { npc.myText.fadeOutText = true; } Destroy(npc.currentBehaviour); npc.enabled = false; //this.GetComponent<NPCController> ().enabled = false; this.GetComponent <PersonWeaponController> ().enabled = false; this.GetComponent <PathFollower> ().enabled = false; this.GetComponent <CanWeDetectTarget> ().enabled = false; //this.gameObject.GetComponent<Pathfinding> ().enabled = false; this.gameObject.GetComponent <NPCBehaviourDecider> ().enabled = false; this.GetComponent <NPCMemory> ().enabled = false; this.GetComponent <PersonMovementController> ().enabled = false; npc.detect.fov.viewMeshFilter.gameObject.SetActive(false); npc.detect.fov.enabled = false; this.gameObject.AddComponent <PlayerAction_DragCorpse> (); this.gameObject.layer = 27; this.gameObject.GetComponentInChildren <CircleCollider2D> ().gameObject.layer = 27; this.transform.parent = null; Container c = this.gameObject.AddComponent <Container> (); c.containerName = "Corpse"; c.itemsInContainer = new List <Item> (); Inventory i = this.gameObject.GetComponent <Inventory> (); foreach (Item it in i.inventoryItems) { c.addItemToContainer(it); } i.inventoryItems.Clear(); if (npc.myHalo == null) { } else { Destroy(npc.myHalo); } // if (LoadingDataStore.me.loadingDone==true) // { LevelIncidentController.me.addIncident("Murder", this.transform.position); // } } SpriteRenderer[] srs = this.gameObject.GetComponentsInChildren <SpriteRenderer> (); foreach (SpriteRenderer sr in srs) { sr.sortingOrder = sr.sortingOrder - 10; } this.GetComponent <Rigidbody2D> ().isKinematic = false; this.GetComponent <Rigidbody2D> ().angularVelocity = 0.0f; this.GetComponent <Rigidbody2D> ().velocity = new Vector2(0, 0); PersonAnimationController pac = this.GetComponent <PersonAnimationController> (); pac.animationsToPlay.Clear(); pac.playing = null; pac.counter = 0; pac.playAnimation("Die", true); this.gameObject.GetComponent <SpriteRenderer> ().sortingOrder = 1; ArtemAnimationController ac = this.gameObject.GetComponentInChildren <ArtemAnimationController> (); ac.setFallen(); this.gameObject.tag = "Dead/Knocked"; this.gameObject.GetComponent <PersonColliderDecider> ().onDeath(); this.enabled = false; }
public void knockOutNPC() { if (npcB.myType == AIType.hostage) { return; } ArtemAnimationController ac = this.gameObject.GetComponentInChildren <ArtemAnimationController> (); ac.setFallen(); PersonAnimationController pac = this.GetComponent <PersonAnimationController> (); //pac.forceFinishCurrentAnim (); pac.animationsToPlay.Clear(); pac.playing = null; pac.counter = 0; pac.playAnimation("Knock", true); knockedDown = true; this.gameObject.GetComponent <SpriteRenderer> ().sortingOrder = 1; this.gameObject.tag = "Dead/Knocked"; //ac.disableBodyParts (); //legs = this.GetComponentInChildren<Legs> ().gameObject; //legs.SetActive (false); head = ac.getHead(); //this.GetComponentInChildren<HeadController> ().gameObject; //this.GetComponent<SpriteRenderer> ().sprite = ac.myAesthetic.knocked; this.GetComponent <Rigidbody2D> ().isKinematic = true; this.GetComponent <Rigidbody2D> ().angularVelocity = 0.0f; this.GetComponent <Rigidbody2D> ().velocity = new Vector2(0, 0); //head.SetActive (false); pmc.enabled = false; pwc.enabled = false; //this.GetComponent<Collider2D> ().isTrigger = true; myCol.setTrigger(); this.gameObject.GetComponentInChildren <CircleCollider2D> ().enabled = false; detect.fov.enabled = false; detect.fov.viewMeshFilter.gameObject.SetActive(false); //this.gameObject.AddComponent<PlayerAction_TieUpHostage> (); if (this.GetComponent <PlayerAction_HumanShield> () == true) { this.GetComponent <PlayerAction_HumanShield> ().enabled = false; } SpriteRenderer[] srs = this.gameObject.GetComponentsInChildren <SpriteRenderer> (); foreach (SpriteRenderer sr in srs) { sr.sortingOrder = sr.sortingOrder - 10; } Container c = this.gameObject.AddComponent <Container> (); c.containerName = "Unconscious Person"; c.itemsInContainer = new List <Item> (); Inventory i = this.gameObject.GetComponent <Inventory> (); foreach (Item it in i.inventoryItems) { c.addItemToContainer(it); } i.inventoryItems.Clear(); this.gameObject.AddComponent <PlayerAction_DragCorpse> (); }