public void ManageMeleeAttack(MeleeScript attacker, HealthScript victim) { //if (particleSystem == null) //{ // Debug.Log("Finding blood particle: " + m_NameOfParticleSys); // particleSystem = GameObject.Find(m_NameOfParticleSys); //} //if (debugginMesh == null) // debugginMesh = GameObject.Find("Remove TODO").GetComponent<TextMesh>(); float m_damage_ = attacker.m_damage_; // If the enemy has a magic defense //Debug.Log("Passing to ManageMeleeAttack"); if (victim.GetComponent <MagicDefendScript>() != null) { // If the attack has no magic attack, reduce the damage! if (attacker.GetComponent <MagicAttackScript>() == null) { m_damage_ *= 0.75f; } else { m_damage_ *= attacker.GetComponent <MagicAttackScript>().CompareEffectiveOfThisToOtherMagic(victim.GetComponent <MagicDefendScript>()); } } // If the victim has no magic defense and the attack has a magic attack, just multiply the health! else if (attacker.GetComponent <MagicAttackScript>() != null) { m_damage_ *= 1.25f; } victim.modifyHealth(-m_damage_); //Debug.Log("Trying to play particle effects in: " + particleSystem.name); //debugginMesh.text = "Trying to find particle system: " + particleSystem.name; if (m_bloodParticleSystem != null) { Debug.Log("Playing particle effects"); //debugginMesh.text = "Successful playing particle effects"; #if UNITY_ANDROID //particleSystem.SetActive(true); //particleSystem.GetComponent<ParticleScript>().resetToActive(); #endif //Vector3 directionOfParticle = victim.transform.position - attacker.transform.position; //directionOfParticle = new Vector3(directionOfParticle.x * victim.transform.localScale.x, directionOfParticle.y * victim.transform.localScale.y); //particleSystem.transform.position = directionOfParticle + victim.transform.position; m_bloodParticleSystem.transform.position = victim.transform.position; m_bloodParticleSystem.GetComponent <ParticleScript>().playEffect(); } }
public void Awake() { if (instance != null && instance != this) { GameObject.DestroyImmediate(gameObject); return; } instance = this; if (playerHealth != null) { playerMovement = playerHealth.GetComponent <DownShoot>(); playerHealth.onDeath += OnPlayerDeath; //gameOverCanvas.SetActive(true); } }
public void RemoveTentacle(HealthScript tentacleHealthScript) { if (tentacleHealthScripts.Contains(tentacleHealthScript)) { tentacleHealthScripts.Remove(tentacleHealthScript); tentacles.Remove(tentacleHealthScript.GetComponent <Animator>()); } else { Debug.LogError("Warning: TentacleHealthScripts does not contain the referenced TentacleHealthScript"); return; } Debug.Log(tentacleHealthScripts.Count + " Tentacles remain in TentacleHealthScripts"); if (tentacleHealthScripts.Count <= 0) { coreHealthScript.invincible = false; Debug.Log("Boss Core now vulnerable"); } }
private void Explode() { // play the bee bomb sound LayerMask playerMask = LayerMask.GetMask("Player"); // spawn main swarm of the boid bees GameObject beeSwarmTargetClone = Instantiate(_beeSwarmTarget, _bombClone.transform.position, _bombClone.transform.rotation); GameObject beeSwarmContollerClone = Instantiate(_beeSwarmController, _bombClone.transform.position, _bombClone.transform.rotation); beeSwarmContollerClone.GetComponent <JobsBoidController>().SetPostion(beeSwarmTargetClone.transform); AkSoundEngine.PostEvent(_bombExplodeSound, beeSwarmContollerClone.gameObject); // Set the SubSwarm Targets SetBeeTargets(); // explosion position Vector3 explosionPos = _rb.transform.position; // give all of the spawned bees explosion force Collider[] targets = Physics.OverlapSphere(explosionPos, _radius); foreach (Collider target in targets) { BaseAI enemy = target.GetComponent <BaseAI>(); // if there is no enemy and/or if the overlapped collider is the player, skip this iteration of the loop if (target.gameObject.layer == playerMask.value) { continue; } // Find the boss and and if the player hit the weak point. deal extra damage TODO: Boss getting returned as NULL, FIX THIS if (enemy == null) { continue; } Rigidbody rb = target.gameObject.GetComponent <Rigidbody>(); HealthScript enemyHealth = target.gameObject.GetComponent <HealthScript>(); if (enemyHealth == null) { continue; } else { Debug.Log("boss is not null"); _weakPoints.FindBosses(targets, _damage); } subController._boidPrefab.EnemyHealth = enemyHealth; DeathBoss deathBoss = enemyHealth.GetComponent <DeathBoss>(); if (deathBoss == null) { Debug.Log("boss is null"); continue; } // enemyHealth.Damage(_damage, AttackType.MAGICAL, gameObject); rb.AddExplosionForce(_power, explosionPos, _radius, 3.0f); } }