private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name == "Player") { HealthComponent hc = other.gameObject.GetComponent <HealthComponent>(); hc.Hurt(); SFXHelper.PlayEffect(SFXs.ReceiveDamage); } }
void Shoot() { if (currentCooldown <= 0) { pc.DeleteHarpoon(); currentCooldown = cooldown; var missile = Instantiate(harpoonMissile, fire.transform.position, Quaternion.identity).GetComponent <MissileComponent>(); missile.Setup(missileStrenght, missileDistance, PointHelper.DirectionToMouse(fire.transform)); an.Play("harpoon_shoot"); SFXHelper.PlayEffect(SFXs.ShootHarpoon); } else { return; } }
void Update() { if (currentCooldown >= 0) { currentCooldown -= Time.deltaTime; } if (resLight) { var currIn = resLight.intensity; resLight.intensity = Mathf.Clamp(Mathf.Sin(Time.time * 1.3f), 0, 1); } if (hc.isDead) { if (this.gameObject.name.Contains("Copper") || this.gameObject.name.Contains("Silicon")) { SFXHelper.PlayEffect(SFXs.BreakRock); } if (this.gameObject.name.Contains("Algae")) { SFXHelper.PlayEffect(SFXs.BreakAlgae); } var drops = Random.Range(minAmount, maxAmount); for (int i = 0; i < drops; i++) { Instantiate(resource.droppable, this.transform.position, Quaternion.identity); } this.gameObject.SetActive(false); if (respawneable) { RespawnHelper.AddToRestore(this.gameObject); } } }
void Update() { if (currentCooldown >= 0) { currentCooldown -= Time.deltaTime; } //Dead if (hc.isDead) { if (this.gameObject.name.Contains("Big Fish Enemy")) { SFXHelper.PlayEffect(SFXs.BigFishDeath); } if (this.gameObject.name.Contains("Jelly Fish Enemy")) { SFXHelper.PlayEffect(SFXs.JellyFishDeath); } Destroy(this.gameObject); } /* BEHAVIOUR ACTIONS */ timeSinceLastAction += Time.deltaTime; if (timeSinceLastAction > TimeBetweenActions) { timeSinceLastAction = 0; currentBehaviour.BehaviorAction(this); //Flock adjustments CurrentDirection += AIHelper.FlockMainBehaviour(this).normalized; } UpdateVelocity(); UpdateSpriteDirection(); enemyBrain.CheckConditionsForNewBehaviours(this); }
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); }