private void OnEnable() { if (CameraT == null) { return; } if (Target == null) { Target = CameraT.Target; } if (Target == null) { return; } //WaitForEndOfFrame w = new WaitForEndOfFrame(); Debug.Log("Called? " + Target.name); if (!created) { Character.Humus H = Target.GetComponent <Character.Humus>(); if (H == null) { return; } //Target not Human? if (H.GetInventorySpace() == 0) { return; } CreateSlots(H.GetInventorySpace()); AddInventory(H.GetInventory()); created = true; Target.GetComponentInChildren <Character.Inventory>().OnChange += InventoryUI_OnChange; //Might be bad check for it too MakeSelected(H.HoldIndex()); } }
private void I_OnInteract(Transform who) { Character.Humus H = who.GetComponent <Character.Humus>(); if (H == null) { return; } GiveItself(H); }
void OnEnable() { DisableAttacks(); CH = GetComponentInParent <Character.Humus>(); if (CH == null) { active = false; OnDisable(); } else { active = true; DoEquipAni(); } }
private void DoEquipAni() { if (MV == null) { return; } if (!equipanimate) { return; } //Character.Player P = GetComponentInParent<Character.Player>(); Character.Humus H = GetComponentInParent <Character.Humus>(); if (H != null && H.HeldItem == transform) //Only player can do animations for now { MV.PlayAnimation(1); counter = MV.currentAniTime(); canfire = false; } }
private void CameraT_TargetSwitched(Transform T) { if (Inv != null) { Inv.OnChange -= Inv_OnChange; } //I wonder why and where is it worth checking, becoming delirious HPBar.GetComponent <HealthBar>().GetTarget(T); //ABar.GetComponent<AmmoBar>().GetTarget(T); Character.Humus H = T.GetComponent <Character.Humus>(); if (H == null) { ABar.SetActive(false); Inv = null; return; } Inv = H.GetComponentInChildren <Character.Inventory>(); if (Inv != null) { Inv.OnChange += Inv_OnChange; } }
private void OnEnable() { Character.Humus H = GetComponentInParent <Character.Humus>(); // Just how far does it detect? //Debug.Log(H.gameObject.name); if (H != null && H != Owner) { H = Owner; return; } //If different parent (for whatever reason), he is now the owner! if (H == Owner) { return; } //If enabled and still belongs to owner, do nothing. (is still not interactible) if (H == null) { Owner = null; } //If no parent (owner), can be interacted again. This is very bad? Collider2D[] C = GetComponents <Collider2D>(); for (int i = 0; i < C.Length; i++) { C[i].isTrigger = false; } }
public void GiveItself(Character.Humus H) { //Debug.Log("Giving if possible!"); if (Owner == null && Owner != H) { if (H.TakeItem(this.transform)) { GetComponent <SpriteRenderer>().sortingOrder = H.GetComponent <SpriteRenderer>().sortingOrder + 1; Owner = H; if (RB != null && !RB.simulated) { RB.simulated = true; } Collider2D[] C = GetComponents <Collider2D>(); for (int i = 0; i < C.Length; i++) { C[i].isTrigger = true; } } //Should disable Interactible and collision } }