public override void Execute(HealthComponent t) { self_destruct = true; Collider2D[] hit = Physics2D.OverlapCircleAll((Vector2)this.transform.position, range); foreach (Collider2D c in hit) { HealthComponent h = c.gameObject.GetComponent <HealthComponent> (); if (h != null && UnitAIBehaviour.ObjectInMask(h.gameObject, layerTarget)) { h.Damage(damage); } } HealthComponent self = this.GetComponent <HealthComponent> (); if (self != null) { self.Kill(); } else { Destroy(this.gameObject); } }
void Update() { // Debug.Log(controller.collisions.below); if (bubbleCount >= bubbleRndEmit) { be.Emit(Random.Range(1, 2), 40f, Vector2.up); SetupNextBubbleEmit(); } else { bubbleCount += Time.deltaTime; } st = new status().Init(); // if(Input.GetKeyDown(KeyCode.Q)) hc.Kill(); // gameObject.GetComponent<BubbleEmitter>().Emit(10, 50f, new Vector2(0.5f, 0.5f)); if (hc.isDead) { st.Dead(); an.Play("player_death"); SFXHelper.PlayEffect(SFXs.Death); if (coroutine == null) { coroutine = StartCoroutine(ResetPlayerAfterSeconds(secondsToRespawn)); } } //Movement var dir = HandleInput(); HandleMovement(); OrganizeInventory(); //Animation if (!hc.isDead) { Animate(); } //Loop currentOxygen -= Time.deltaTime; if (currentOxygen <= lastBreath) { //TODO: implement vision loss if (currentOxygen <= 0) { hc.Kill(); } } //Open Inventory if (Input.GetKeyDown(KeyCode.E)) { openInventory = !openInventory; if (Time.timeScale == 1.0f) { Time.timeScale = 0; inventoryManager.SetAvailableItems(GameObject.Find("ProximityRadius").GetComponent <ProximityFinder>().nearPickables); inventoryManager.inventoryPanel.gameObject.SetActive(openInventory); } else { Time.timeScale = 1.0F; inventoryManager.inventoryPanel.gameObject.SetActive(openInventory); } } //update oxygen panel oxyPanel.UpdateOxygenBar(currentOxygen / maxOxygen); }