public override void equipItem() { this.gameObject.GetComponentInParent <PersonWeaponController>().setWeapon(this); Inventory i = this.gameObject.GetComponentInParent <Inventory> (); i.equipItem(this, slot); ammoItem = i.getAmmoForGun(WeaponName); this.gameObject.GetComponent <SpriteRenderer> ().sprite = holding; this.gameObject.SetActive(true); ArtemAnimationController ac = this.gameObject.transform.root.gameObject.GetComponentInChildren <ArtemAnimationController> (); if (melee == true) { this.transform.rotation = Quaternion.Euler(0, 0, ac.rightHand.transform.rotation.eulerAngles.z + 35); } else { this.transform.rotation = ac.rightHand.transform.rotation; } this.gameObject.transform.parent = ac.rightHand.transform; this.gameObject.transform.position = ac.rightHand.transform.position; this.gameObject.transform.localPosition = ac.myAesthetic.handgunOffset; this.gameObject.SetActive(true); inUse = true; this.GetComponent <SpriteRenderer> ().sortingOrder = 3; }
void Awake() { sr = this.GetComponent <SpriteRenderer>(); pac = this.GetComponent <PersonAnimationController> (); myInv = this.GetComponent <Inventory> (); ac = this.GetComponentInChildren <ArtemAnimationController> (); }
public override void equipItem() { //equips item to relevant slot //this.gameObject.GetComponentInParent<PersonWeaponController>().setWeapon(this); myRid = this.GetComponent <Rigidbody2D>(); Inventory i = this.gameObject.GetComponentInParent <Inventory> (); i.equipItem(this, slot); // ammoItem = i.getAmmoForGun (WeaponName); this.gameObject.GetComponent <SpriteRenderer> ().sprite = inHand; this.gameObject.SetActive(true); ac = this.gameObject.transform.root.gameObject.GetComponentInChildren <ArtemAnimationController> (); this.gameObject.transform.parent = ac.rightHand.transform; //this.gameObject.transform.position = ac.rightHand.transform.position; //this.gameObject.transform.localPosition = ac.myAesthetic.throwableOffset; ac.setHoldingThrowable(); this.gameObject.SetActive(true); inUse = true; this.transform.rotation = ac.rightHand.transform.rotation; this.GetComponent <SpriteRenderer> ().sortingOrder = 3; ////////Debug.Log ("Root is " + this.transform.root.gameObject.name); //ac = this.transform.root.gameObject.GetComponentInChildren<AnimationController> (); thrower = this.transform.parent.root.gameObject; this.gameObject.GetComponent <Collider2D> ().enabled = false; spawnPos = this.transform.root.position; myRid.isKinematic = true; myRid.freezeRotation = true; }
/// <summary> /// On start objects to create a shadow are calculated, if its a person it gets the torso & arms else we just get all children with a sprite renderer. /// </summary> void Start() { if (this.gameObject.GetComponent <Item> () == true) { isItem = true; } StartCoroutine(setLightSource()); if (this.gameObject.GetComponentInChildren <ArtemAnimationController> () == true) { ArtemAnimationController ac = this.gameObject.GetComponentInChildren <ArtemAnimationController> (); toCreateShadowsFor.Add(ac.myAesthetic.torsoObj); toCreateShadowsFor.Add(ac.myAesthetic.lShoulderObj); toCreateShadowsFor.Add(ac.myAesthetic.lForeObj); toCreateShadowsFor.Add(ac.myAesthetic.lHandObj); toCreateShadowsFor.Add(ac.myAesthetic.rShoulderObj); toCreateShadowsFor.Add(ac.myAesthetic.rForeObj); toCreateShadowsFor.Add(ac.myAesthetic.rHandObj); } else { if (this.GetComponent <SpriteRenderer> () == true) { toCreateShadowsFor.Add(this.gameObject); } //for (int x = 0; x < transform.childCount; x++) { // GameObject g = transform.GetChild (x).gameObject; // if (g.GetComponent<SpriteRenderer> () == true) { // toCreateShadowsFor.Add (g); // } //} } foreach (GameObject g in toCreateShadowsFor) { GameObject shadow = new GameObject(); if (staticShadow == true) { shadow.transform.position = this.transform.position + new Vector3(0.1f, 0.1f, 0); shadow.transform.rotation = g.transform.rotation; } else { shadow.transform.position = this.transform.position; shadow.transform.rotation = g.transform.rotation; } shadow.transform.parent = g.transform; //GameObject shadow = (GameObject)Instantiate (new GameObject (), g.transform); SpriteRenderer sr = shadow.AddComponent <SpriteRenderer> (); sr.sortingOrder = g.GetComponent <SpriteRenderer> ().sortingOrder - 1; sr.color = new Color(0, 0, 0, 0.5f); sr.sprite = g.GetComponent <SpriteRenderer> ().sprite; myShadows.Add(shadow); } }
void Awake() { pmc = this.GetComponent <PersonMovementController> (); pwc = this.GetComponent <PersonWeaponController> (); inv = this.GetComponent <Inventory> (); detect = this.GetComponent <CanWeDetectTarget> (); pf = this.GetComponent <PathFollower> (); memory = this.GetComponent <NPCMemory> (); npcB = this.GetComponent <NPCBehaviourDecider> (); myCol = this.GetComponent <PersonColliderDecider> (); myHealth = this.gameObject.GetComponent <PersonHealth> (); ac = this.GetComponentInChildren <ArtemAnimationController> (); pcc = this.GetComponent <PersonClothesController> (); }
public override void equipItem() { Inventory i = this.GetComponentInParent <Inventory> (); ArtemAnimationController ac = this.transform.root.GetComponentInChildren <ArtemAnimationController> (); this.transform.parent = ac.leftHand.transform; this.transform.localPosition = new Vector3(0, 0, 0); this.gameObject.SetActive(true); this.transform.rotation = ac.leftHand.transform.rotation; this.gameObject.GetComponent <SpriteRenderer> ().sortingOrder = ac.leftHand.gameObject.GetComponent <SpriteRenderer> ().sortingOrder - 1; if (this.GetComponent <PlayerAction_SearchContainer> () == false) { this.gameObject.AddComponent <PlayerAction_SearchContainer> (); } this.GetComponent <PlayerAction_SearchContainer> ().enabled = false; //i.addItemToInventory (this); //if (this.gameObject.activeInHierarchy == false) { // i.equipItem (this, slot); ////////Debug.Break(); //this.transform.parent.gameObject.GetComponentInChildren<PortableContainerVisual> ().myItem = this; //} }
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 override void unequipItem() { if (this.transform.parent == null) { return; } Inventory myInv = this.gameObject.GetComponentInParent <Inventory> (); this.gameObject.transform.root.gameObject.GetComponent <PersonWeaponController>().setWeapon(null); this.gameObject.GetComponent <SpriteRenderer> ().sprite = pickup; ArtemAnimationController ac = this.gameObject.transform.root.gameObject.GetComponentInChildren <ArtemAnimationController> (); this.gameObject.transform.parent = ac.gameObject.transform.parent; this.gameObject.SetActive(false); //inUse = false; this.GetComponent <SpriteRenderer> ().sortingOrder = 1; if (slot == itemEquipSlot.bothHands) { if (myInv.leftArm == null) { } else { myInv.leftArm = null; if (myInv == Inventory.playerInventory) { InventoryUI.me.leftArm.resetGearSlot(); } } if (myInv.rightArm == null) { } else { myInv.rightArm = null; if (myInv == Inventory.playerInventory) { InventoryUI.me.rightArm.resetGearSlot(); } } } else if (slot == itemEquipSlot.rightHand) { myInv.rightArm = null; if (myInv == Inventory.playerInventory) { InventoryUI.me.rightArm.resetGearSlot(); } } else if (slot == itemEquipSlot.leftHand) { myInv.leftArm = null; if (myInv == Inventory.playerInventory) { InventoryUI.me.leftArm.resetGearSlot(); } } }
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> (); }
void Update() { if (ac == null) { if (transform.parent == null) { return; } else if (transform.root.tag == "Player" || transform.root.tag == "NPC") { ac = transform.root.GetComponentInChildren <ArtemAnimationController> (); } else { return; } } if (inUse == true) { if (ac == null) { ac = this.transform.root.gameObject.GetComponentInChildren <ArtemAnimationController> (); } if (hasBeenThrown == false) { this.transform.position = ac.rightHand.transform.position; //ac.setThrowableThrown (); } } if (inUse == true && hasBeenThrown == false && Inventory.playerInventory.inventoryGUI.activeInHierarchy == false) { ThrowableUI.me.setLine(this.transform.root, hold); if (Input.GetMouseButtonDown(1)) { ac.switchThrow(); } if (ac.shortThrown == false) { hold = 12; } else { hold = 6; } if (Input.GetMouseButtonUp(0)) { ac.setThrowableThrown(); throwItem(); } //if (ac.thrownAnimDone == true) { //} } if (hasBeenThrown == true) { ThrowableUI.me.displayUI = false; if (Vector3.Distance(this.transform.position, thrower.transform.position) > 1.25f) { this.GetComponent <Collider2D> ().enabled = true; } if (detonateOnImpact == false) { countDownFuse(); } else { detonateOnStop(); } } }