void OnTriggerEnter(Collider col) { Vector3 enemyImpactPos = col.transform.position; //enemyLaserRed = GetComponent<Collider> (); enemyBasicLaser = EnemyBasicLaserScript.FindObjectOfType <EnemyBasicLaserScript> (); //enemyRedRocket = GetComponent<Collider> (); redRocketDamage = RedRocketScript.FindObjectOfType <RedRocketScript> (); float chanceEnemyHit = Random.Range(1, 100); if (chanceEnemyHit > evade) { if (enemyLaserRed) { GameObject redLaserHit = Instantiate(redLaserImpact, enemyImpactPos, Quaternion.identity) as GameObject; Destroy(col.gameObject); shieldHealth = shieldHealth - enemyBasicLaser.damage; shieldBar.fillAmount = shieldHealth * PlayerPrefs.GetFloat("SHIELD_MULTIPLY_BY"); } } }
void OnTriggerEnter(Collider deflectorshield) { EnemyBasicLaserScript enemylaserred = deflectorshield.gameObject.GetComponent <EnemyBasicLaserScript>(); damage = EnemyBasicLaserScript.FindObjectOfType <EnemyBasicLaserScript>(); if (enemylaserred) { Destroy(deflectorshield.gameObject); Vector3 startPostion = transform.position + new Vector3(0, 0, 0); GameObject laserRedBack = Instantiate(enemyProjectile, startPostion, Quaternion.identity) as GameObject; laserRedBack.GetComponent <Rigidbody>().velocity = new Vector3(EnemyShip.transform.position.x, EnemyShip.transform.position.y, EnemyShip.transform.position.z); RTSBattleController.shieldDeflectorHealth = RTSBattleController.shieldDeflectorHealth - 10; if (RTSBattleController.shieldDeflectorHealth <= 0) { RTSBattleController.shieldDeflectorCharged = false; } } }
//------------------------------------PLAYER DAMAGE TAKEN HERE--------------------- void OnTriggerEnter(Collider collider) { Vector3 enemyProjectilePos = collider.transform.position; EnemyBasicLaserScript enemylaserred = collider.gameObject.GetComponent <EnemyBasicLaserScript>(); damage = EnemyBasicLaserScript.FindObjectOfType <EnemyBasicLaserScript>(); RedRocketScript redrocket = collider.gameObject.GetComponent <RedRocketScript> (); redRocketDamage = RedRocketScript.FindObjectOfType <RedRocketScript> (); float chanceEnemyHit = Random.Range(1, 85); Debug.Log("Evade is " + evade); if (enemylaserred && deflectorShieldOn && chanceEnemyHit > evade) { Debug.Log("INSIDE SHIELD DEFLECT"); Destroy(collider.gameObject); Vector3 startPostion2 = transform.position + new Vector3(0, 0, 0); GameObject deflectBack = Instantiate(shieldDeflectorEnergy, startPostion2, Quaternion.identity) as GameObject; deflectBack.GetComponent <Rigidbody>().velocity = new Vector3(enemyShip.transform.position.x, enemyShip.transform.position.y, enemyShip.transform.position.z); shieldDeflectorHealth = shieldDeflectorHealth - 10; if (shieldDeflectorHealth <= 0) { deflectorShieldOn = false; shieldDeflector.SetActive(false); } } if (ShieldScript.shieldHealth <= 0) { Debug.Log("Shield HEalth is : " + ShieldScript.shieldHealth); shieldOn = false; shieldOffAudio.Play(); shieldBarPanel.SetActive(false); shieldAnimator.SetTrigger("ShieldOff"); shield.SetActive(false); ShieldCharge(); } // create if for shieldkill here CREATE NEW SCRIPT ON TOP OF SHIELD KILL PROCJECTILE AND ACTIVATE IT HERE /* if (shieldKill = true && chanceEnemyHit > evade){ * * shieldHealth = 0; * shieldBar.fillAmount = 0; * Destroy (collider.gameObject); * * shieldOn = false; * shield.SetActive(false); * ShieldCharge(); * }*/ if (enemylaserred && !shieldOn && chanceEnemyHit > evade && !deflectorShieldOn) { playerhealth.LoseHealth(damage.damage); Destroy(collider.gameObject); GameObject redLaserHit = Instantiate(EnemyImpactRedLaser, enemyProjectilePos, Quaternion.identity) as GameObject; //SMOKE GRAPHICS if (PlayerHealth.playerHealth == 80) { Vector3 startPostion = transform.position + new Vector3(0, -.38f, 0.47f); GameObject smokeHit = Instantiate(smoke, startPostion, Quaternion.identity) as GameObject; smokeHit.transform.parent = gameObject.transform; } if (PlayerHealth.playerHealth == 60) { Vector3 startPostion = transform.position + new Vector3(0, 0, 0); GameObject bigExplosi = Instantiate(bigExplosion, startPostion, Quaternion.identity) as GameObject; } if (PlayerHealth.playerHealth < 20) { Vector3 startPostion = transform.position + new Vector3(0, -.38f, 0.47f); GameObject smokeHit = Instantiate(smoke, startPostion, Quaternion.identity) as GameObject; smokeHit.transform.parent = gameObject.transform; } if (PlayerHealth.playerHealth <= 0) { Vector3 startPostion = transform.position + new Vector3(0, 0, 0); GameObject deathexplosion = Instantiate(DeadExplosion, startPostion, Quaternion.identity) as GameObject; this.gameObject.SetActive(false); Application.LoadLevel("GameOver"); Destroy(gameObject); } } //RED ROCKET DAMAGE ------------------------------------------------------------------------------------------------------------------ /// /// /// if (redrocket && deflectorShieldOn && chanceEnemyHit > evade) { Debug.Log("INSIDE SHIELD DEFLECT"); Destroy(collider.gameObject); Vector3 startPostion2 = transform.position + new Vector3(0, 0, 0); GameObject deflectBack = Instantiate(shieldDeflectorEnergy, startPostion2, Quaternion.identity) as GameObject; deflectBack.GetComponent <Rigidbody>().velocity = new Vector3(enemyShip.transform.position.x, enemyShip.transform.position.y, enemyShip.transform.position.z); shieldDeflectorHealth = shieldDeflectorHealth - 10; if (shieldDeflectorHealth <= 0) { deflectorShieldOn = false; shieldDeflector.SetActive(false); } } if (ShieldScript.shieldHealth <= 0) { Debug.Log("Shield HEalth is : " + ShieldScript.shieldHealth); shieldOn = false; shield.SetActive(false); ShieldCharge(); } if (redrocket && !shieldOn && chanceEnemyHit > evade && !deflectorShieldOn) { playerhealth.LoseHealth(redRocketDamage.damage); GameObject redrocketHit = Instantiate(redRocketHit, enemyProjectilePos, Quaternion.identity) as GameObject; Destroy(collider.gameObject); //SMOKE GRAPHICS if (PlayerHealth.playerHealth == 80) { Vector3 startPostion = transform.position + new Vector3(0, -.38f, 0.47f); GameObject smokeHit = Instantiate(smoke, startPostion, Quaternion.identity) as GameObject; smokeHit.transform.parent = gameObject.transform; } if (PlayerHealth.playerHealth == 60) { Vector3 startPostion = transform.position + new Vector3(0, 0, 0); GameObject bigExplosi = Instantiate(bigExplosion, startPostion, Quaternion.identity) as GameObject; } if (PlayerHealth.playerHealth < 20) { Vector3 startPostion = transform.position + new Vector3(0, -.38f, 0.47f); GameObject smokeHit = Instantiate(smoke, startPostion, Quaternion.identity) as GameObject; smokeHit.transform.parent = gameObject.transform; } if (PlayerHealth.playerHealth <= 0) { Vector3 startPostion = transform.position + new Vector3(0, 0, 0); GameObject deathexplosion = Instantiate(DeadExplosion, startPostion, Quaternion.identity) as GameObject; this.gameObject.SetActive(false); Application.LoadLevel("GameOver"); Destroy(gameObject); } } }