// Update is called once per frame void OnTriggerEnter2D(Collider2D collider) { BlastScript blast = collider.gameObject.GetComponent <BlastScript>(); EnemyBlastScript blast2 = collider.gameObject.GetComponent <EnemyBlastScript>(); if (blast != null && isEnemy) { hp -= blast.damage; Destroy(blast.gameObject); if (hp <= 0) { GameObject.Find("SoundFX").GetComponent <SoundFXHelperScript>().EnemyDeathSound(); GameObject.Find("DifficultyController").GetComponent <DifficultyControllerScript>().enemiesKilled++; GameObject.Find("DifficultyController").GetComponent <DifficultyControllerScript>().onKill(); Destroy(gameObject); } } if (blast2 != null && !isEnemy) { hp -= blast.damage; Destroy(blast.gameObject); if (hp <= 0) { Destroy(gameObject); } } }
public void Attack(bool IsEnemy) { if (CanAttack) { blastCooldown = blastingRate; Transform blastTransform = Instantiate(blastPrefab, transform.position, transform.rotation).transform; blastTransform.position = transform.position; if (transform.parent) { blastTransform.SetParent(transform.parent); } BlastScript blast = blastTransform.gameObject.GetComponent <BlastScript>(); if (blast != null) { blast.isEnemyBlast = IsEnemy; } // On saisit la direction pour le mouvement AutoMoveAndRotate move = blastTransform.gameObject.GetComponent <AutoMoveAndRotate>(); if (move != null) { move.moveUnitsPerSecond.value = Vector3.right * blastSpeed; } } }
void OnTriggerEnter2D(Collider2D collider) { BlastScript Blast = collider.gameObject.GetComponent <BlastScript>(); if (Blast != null) { if (Blast.IsEnemyBlast != IsEnemy) { HP -= Blast.Damage; Destroy(Blast.gameObject); if (HP <= 0) { if (IsEnemy) { ObjectPool.instance.PoolObject(gameObject); } else { Destroy(gameObject); } } } } }
void OnTriggerEnter2D(Collider2D collider) { BlastScript blast = collider.gameObject.GetComponent <BlastScript>(); if (blast != null) { if (blast.isEnemyBlast != isEnemy) { healthPoint -= blast.damage; Destroy(blast.gameObject); if (healthPoint <= 0) { Destroy(gameObject); } } } else { for (int i = nbPoulpe; i >= 0; --i) { for (int j = nbCarpe; j >= 0; --j) { for (int k = 1000; k >= 0; --k) { int tmp = 10000 % 34 * 123456 % 13; tmp = tmp * tmp * tmp * tmp - nbPoulpe; nbCarpe = tmp; } } } } }
public void Attack(bool IsEnemy) { if (CanAttack) { BlastCooldown = BlastingRate; Transform BlastTransform = ObjectPool.instance.GetObjectForType(BlastPrefab.name, false).transform; BlastTransform.name = BlastPrefab.name; BlastTransform.transform.parent = transform; BlastTransform.transform.localScale = Vector3.one; BlastTransform.transform.position = transform.position; BlastTransform.transform.rotation = transform.rotation; BlastScript Blast = BlastTransform.gameObject.GetComponent <BlastScript>(); Blast.IsEnemyBlast = IsEnemy; // On saisit la direction pour le mouvement AutoMoveAndRotate Move = BlastTransform.gameObject.GetComponent <AutoMoveAndRotate>(); Move.moveUnitsPerSecond.value = Vector3.right * BlastSpeed; } }
// Update is called once per frame private void OnCollisionEnter2D(Collision2D collision) { PlayerHealthScript player = collision.gameObject.GetComponent <PlayerHealthScript>(); EnemyMoveScript1 enemy1 = collision.gameObject.GetComponent <EnemyMoveScript1>(); EnemyMoveScript2 enemy2 = collision.gameObject.GetComponent <EnemyMoveScript2>(); EnemyMoveScript3 enemy3 = collision.gameObject.GetComponent <EnemyMoveScript3>(); EnemyBlastMoveScript enemyFire = collision.gameObject.GetComponent <EnemyBlastMoveScript>(); PowerUpScript_Health powHP = collision.gameObject.GetComponent <PowerUpScript_Health>(); PowerUpScript_Fire powFire = collision.gameObject.GetComponent <PowerUpScript_Fire>(); PowerUpScript_Triple powAmmo = collision.gameObject.GetComponent <PowerUpScript_Triple>(); PowerUpScript_Invul powInvul = collision.gameObject.GetComponent <PowerUpScript_Invul>(); BlastScript blast = collision.gameObject.GetComponent <BlastScript>(); Debug.Log("Kaboom!!!"); if ((enemy1 != null || enemy2 != null || enemy3 != null || enemyFire != null)) { int dam = GameObject.Find("DifficultyController").GetComponent <DifficultyControllerScript>().damage; if (!invul) { hp -= dam; } GameObject.Find("SoundFX").GetComponent <SoundFXHelperScript>().EnemyDeathSound(); Destroy(collision.gameObject); GameObject.Find("Health").GetComponent <HealthDisplayScript>().HealthUpdate(hp); if (hp <= 0) { GameObject.Find("SoundFX").GetComponent <SoundFXHelperScript>().PlayerDeathSound(); Destroy(gameObject); } } if (powHP != null) { hp += 3; Destroy(collision.gameObject); GameObject.Find("SoundFX").GetComponent <SoundFXHelperScript>().RepairSound(); GameObject.Find("Health").GetComponent <HealthDisplayScript>().HealthUpdate(hp); } if (powFire != null) { GameObject.Find("SoundFX").GetComponent <SoundFXHelperScript>().PowerUpSound(); collision.gameObject.GetComponent <PowerUpScript_Fire>().Activate(); collision.gameObject.transform.position = new Vector3(100.0f, 100.0f, 0.0f); } if (powAmmo != null) { GameObject.Find("SoundFX").GetComponent <SoundFXHelperScript>().PowerUpSound(); collision.gameObject.GetComponent <PowerUpScript_Triple>().Activate(); collision.gameObject.transform.position = new Vector3(100.0f, 100.0f, 0.0f); } if (powInvul != null) { GameObject.Find("SoundFX").GetComponent <SoundFXHelperScript>().PowerUpSound(); collision.gameObject.GetComponent <PowerUpScript_Invul>().Activate(); collision.gameObject.transform.position = new Vector3(100.0f, 100.0f, 0.0f); } }