protected void CheckDmg(_EnemyController enemyHit, int tempDmg) { for (int y = 0; y < damageType.Length; y++) { for (int z = 0; z < enemyHit.m_EnemyStats.weakness.Length; z++) { if (damageType[y] == enemyHit.m_EnemyStats.weakness[z].type) { tempDmg += enemyHit.m_EnemyStats.weakness[z].value; break; } } for (int z = 0; z < enemyHit.m_EnemyStats.resistance.Length; z++) { if (damageType[y] == enemyHit.m_EnemyStats.resistance[z].type) { tempDmg -= enemyHit.m_EnemyStats.resistance[z].value; break; } } } if (tempDmg < 0) { tempDmg = 0; } //Debug.Log(tempDmg + " " + enemyHit.currentLife); }
protected virtual void DamageDealer(_EnemyController enemyHit) { // check damage type and enemy resistance int tempDmg = damage; CheckDmg(enemyHit, tempDmg); enemyHit.enemyOwnership = membership; enemyHit.currentLife -= tempDmg; enemyHit.gotHit = true; GMController.instance.TensionThresholdCheck(GMController.instance.tensionStats.enemyHitPoints); //add tension }
protected virtual void EmissionHandler() { if (bullets == null || bullets.Length < Gun.main.maxParticles) { bullets = new ParticleSystem.Particle[Gun.main.maxParticles]; } int numParticlesAlive = Gun.GetParticles(bullets); // cast ray from all the particles that are alive ti register hits for (int i = 0; i < numParticlesAlive; i++) { RaycastHit2D hit = Physics2D.Raycast(bullets[i].position, bullets[i].velocity.normalized, weapon.rayLenght, weapon.obstacleMask); Debug.DrawRay(bullets[i].position, bullets[i].velocity.normalized, Color.blue); if (hit) { if (hit.transform.CompareTag("Enemy")) { _EnemyController enemyHit = hit.transform.GetComponent <_EnemyController>(); if (leaveDecal) { currentDecal.PlaceDecal(hit, bullets[i].velocity, enemyHit); } bullets[i].remainingLifetime = 0; DamageDealer(enemyHit); } else if (canBounce) { CheckBulletLife(hit, i); // bounce here Vector2 hitNorm = hit.normal; Vector2 newDir = Vector2.Reflect(bullets[i].velocity, hitNorm); bullets[i].velocity = newDir; } else { if (leaveDecal) { currentDecal.PlaceDecal(hit, bullets[i].velocity); } bullets[i].remainingLifetime = 0; } } } // Apply the particle changes to the particle system Gun.SetParticles(bullets, numParticlesAlive); }
// [HideInInspector] public NavMeshAgent navMeshAgent; // Use this for initialization protected override void Awake() { base.Awake(); inactiveState = (State)Resources.Load("Inactive"); // navMeshAgent = GetComponent<NavMeshAgent>(); lastActiveState = currentState; m_EnemyController = GetComponent <_EnemyController>(); gameStartState = (State)Resources.Load("StartState"); defeatedState = (State)Resources.Load("Defeated"); }
protected virtual void DamageDealer(Collider2D[] Hit) { for (int i = 0; i < Hit.Length; i++) { _EnemyController enemyHit = Hit[i].transform.parent.GetComponent <_EnemyController>(); // check damage type and enemy resistance int tempDmg = damage; CheckDmg(enemyHit, tempDmg); enemyHit.enemyOwnership = membership; enemyHit.currentLife -= tempDmg; enemyHit.gotHit = true; GMController.instance.TensionThresholdCheck(GMController.instance.tensionStats.enemyHitPoints); //add tension } Debug.Log("boom"); }
public void DoDamage(_EnemyController enemyHit, int i) { // check damage type and enemy resistance int tempDmg = damage; CheckDmg(enemyHit, tempDmg); perfPool[i].numberOfHits--; // apply decal if needed if (perfPool[i].numberOfHits <= 0 && leaveDecal) { currentDecal.PlaceDecal(perfPool[i].bullet.transform, enemyHit); } enemyHit.enemyOwnership = playerNumber; enemyHit.currentLife -= tempDmg; enemyHit.gotHit = true; GMController.instance.TensionThresholdCheck(GMController.instance.tensionStats.enemyHitPoints); //add tension }
protected void RaycastHitApply(Transform hit, Vector3 normal, int i) { if (hit.CompareTag("Enemy")) { _EnemyController enemy = hit.GetComponent <_EnemyController>(); if (System.Array.IndexOf(perfPool[i].enemyHit, enemy) == -1) { int index = System.Array.IndexOf(perfPool[i].enemyHit, null); if (index >= 0) { perfPool[i].enemyHit[index] = enemy; DoDamage(perfPool[i].enemyHit[index], i); } } } else if (canBounce) { Vector2 hitNorm = normal; perfPool[i].newDir = Vector2.Reflect(perfPool[i].dir, hitNorm); perfPool[i].dir = perfPool[i].newDir; //take angle of shoot float angle = Mathf.Atan2(perfPool[i].dir.y, perfPool[i].dir.x) * Mathf.Rad2Deg; //rotate bullet to target perfPool[i].bullet.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle)); perfPool[i].numberOfHits--; if (perfPool[i].numberOfHits <= 0 && leaveDecal) { currentDecal.PlaceDecal(perfPool[i].bullet.transform); } } else if (!canBounce) { if (leaveDecal) { currentDecal.PlaceDecal(perfPool[i].bullet.transform); } Collector(i); } }
public void PlaceDecal(RaycastHit2D hit, Vector3 velocity, _EnemyController enemyHit) { int decalChosen = CheckForDecal(); // set the decal to be used again and remove it from the previous enemy (if there was one) if (decalList[decalChosen].enemyHit != null) { decalList[decalChosen].enemyHit.decalsNum--; } // place the decal decalList[decalChosen].lifeTime = decalLifeTime; decalList[decalChosen].decal.transform.position = hit.point; decalList[decalChosen].decal.transform.rotation = Quaternion.LookRotation(velocity.normalized); decalList[decalChosen].enemyHit = enemyHit; decalList[decalChosen].decal.transform.parent = enemyHit.transform; enemyHit.hasDecalsOn = true; enemyHit.decalsNum++; decalList[decalChosen].isActive = true; }
public void PlaceDecal(Transform bulletHit, _EnemyController enemyHit) { int decalChosen = CheckForDecal(); // set the decal to be used again and remove it from the previous enemy (if there was one) if (decalList[decalChosen].enemyHit != null) { decalList[decalChosen].enemyHit.decalsNum--; } // place the decal decalList[decalChosen].lifeTime = decalLifeTime; decalList[decalChosen].decal.transform.position = bulletHit.position; decalList[decalChosen].decal.transform.rotation = Quaternion.LookRotation(bulletHit.forward, bulletHit.up); decalList[decalChosen].enemyHit = enemyHit; decalList[decalChosen].decal.transform.parent = enemyHit.transform; enemyHit.hasDecalsOn = true; enemyHit.decalsNum++; decalList[decalChosen].isActive = true; }
private IEnumerator SpawnKamikaze() { spawnDone = false; GMController.instance.AddKamikazeCount(); // add kamikaze count anim.SetInteger("State", 1); WaitForSeconds delay = new WaitForSeconds(0.2f); yield return(delay); GameObject newEnemy = Instantiate(enemyList.Kamikaze[spawnLevel - 1].gameObject, transform.position, Quaternion.identity); _EnemyController controller = newEnemy.GetComponent <_EnemyController>(); controller.myEnemySpawn = thisSpawn; // add reference to this spawn GMController.instance.allEnemies.Add(controller); // add to enemies list anim.SetInteger("State", 2); yield return(delay); anim.SetInteger("State", 0); timer = spawnTimer; spawnDone = true; yield return(null); }
public void DestroyObjects(_EnemyController[] objectsToDestroy) { for (int i = 0; i < objectsToDestroy.Length; i++) { Destroy(objectsToDestroy[i].gameObject); } }