void OnTriggerEnter(Collider collider) { if (collider.gameObject.tag == "Enemy") { EnemyController enemy = collider.gameObject.GetComponent <EnemyController>(); if (enemy.Hp > 0) { enemy.Hp -= damage; } } if (collider.gameObject.tag == "Mutant") { MutantController mutant = collider.transform.root.gameObject.GetComponent <MutantController>(); if (!mutant.GetDestroyed()) { mutant.MutantHp -= damage; } } if (collider.gameObject.tag == "Titan") { TitanController titan = collider.transform.root.gameObject.GetComponent <TitanController>(); if (!titan.GetDestroyed()) { titan.TitanHp -= damage; } } if (collider.gameObject.tag == "Reptile") { ReptileController reptile = collider.transform.root.gameObject.GetComponent <ReptileController>(); if (!reptile.GetDestroyed()) { reptile.ReptileHp -= damage; } } if (collider.gameObject.tag == "Magmadar") { MagmadarController magmadar = collider.transform.root.gameObject.GetComponent <MagmadarController>(); if (!magmadar.GetDestroyed()) { magmadar.MagmadarHp -= damage; } } if (collider.gameObject.tag == "OrkBerserker") { OrkberserkerController orkBerserker = collider.transform.root.gameObject.GetComponent <OrkberserkerController>(); if (!orkBerserker.GetDestroyed()) { orkBerserker.OrkBerserkerHp -= damage; } } }
void Update() { if (isShooting) { Shoot(); // shotCounter -= Time.deltaTime; // if(shotCounter <= 0){ // shotCounter = timeBetweenShots; // Debug.Log(firePoint); // GlobeController newGlobe = Instantiate(globe,firePoint.position,firePoint.rotation) as GlobeController; // newGlobe.speed = globeSpeed; // } } else { //shotCounter = 0; ReptileTrigger.gameObject.SetActive(false); charachterTrigger = ReptileTrigger.GetComponent <ReptileController>(); charachterTrigger.hasTriggered = false; } }
public void shoot() { Ray ray = new Ray(transform.position, transform.forward); //Ray ray = Camera.main.ScreenPointToRay(new Vector3(Random.Range(-limitReticleRadius,limitReticleRadius)+Screen.width/2,Random.Range(-limitReticleRadius,limitReticleRadius)+Screen.height/2 , 0f)); RaycastHit hit; player.shootCount++; MuzzleFlash(); //レイを飛して、ヒットしたオブジェクトの情報を得る。 if (Physics.Raycast(ray, out hit, shootRange)) { //ヒットエフェクトON if (hitEffectPrefab != null) { if (!explosion) { if (hitEffect != null) { hitEffect.transform.position = hit.point; hitEffect.transform.rotation = Quaternion.FromToRotation(Vector3.forward, hit.normal); hitEffect.SetActive(true); } else { hitEffect = Instantiate(hitEffectPrefab, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal)); //hitEffect.transform.parent = hit.transform; } } else { Instantiate(hitEffectPrefab2, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal)); } //Instantiate(hitEffectPrefab, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal)); } //敵へのダメージ処理 string tagName = hit.collider.gameObject.tag; if (tagName == "EnemyHead") { EnemyController enemy = hit.collider.transform.parent.gameObject.GetComponent <EnemyController>(); if (!enemy.GetDead()) { gameManager.Score += gameManager.headScore; enemy.Hp -= damage * 5; player.hitCount++; } } if (tagName == "Enemy") { EnemyController enemy = hit.collider.gameObject.GetComponent <EnemyController>(); if (!enemy.GetDead()) { gameManager.Score += gameManager.bodyScore; enemy.Hp -= damage; player.hitCount++; player.audioSource.PlayOneShot(hitSe); } } if (tagName == "Mutant") { MutantController mutant = hit.collider.transform.root.gameObject.GetComponent <MutantController>(); if (!mutant.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; mutant.MutantHp -= damage; player.hitCount++; } } if (tagName == "MutantHead") { MutantController mutant = hit.collider.transform.root.gameObject.GetComponent <MutantController>(); if (!mutant.GetDestroyed()) { gameManager.Score += gameManager.headScore; mutant.MutantHp -= damage * 5; player.hitCount++; } } if (tagName == "Titan") { TitanController titan = hit.collider.transform.root.gameObject.GetComponent <TitanController>(); if (!titan.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; titan.TitanHp -= damage; player.hitCount++; } } if (tagName == "TitanHead") { TitanController titan = hit.collider.transform.root.gameObject.GetComponent <TitanController>(); if (!titan.GetDestroyed()) { gameManager.Score += gameManager.headScore; titan.TitanHp -= damage * 5; player.hitCount++; } } if (tagName == "Reptile") { ReptileController reptile = hit.collider.transform.root.gameObject.GetComponent <ReptileController>(); if (!reptile.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; reptile.ReptileHp -= damage; player.hitCount++; } } if (tagName == "ReptileHead") { ReptileController reptile = hit.collider.transform.gameObject.GetComponent <ReptileController>(); if (!reptile.GetDestroyed()) { gameManager.Score += gameManager.headScore; reptile.ReptileHp -= damage * 5; player.hitCount++; } } if (tagName == "Magmadar") { MagmadarController magmadar = hit.collider.transform.root.gameObject.GetComponent <MagmadarController>(); if (!magmadar.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; magmadar.MagmadarHp -= damage; player.hitCount++; } } if (tagName == "MagmadarHead") { MagmadarController magmadar = hit.collider.transform.root.gameObject.GetComponent <MagmadarController>(); if (!magmadar.GetDestroyed()) { gameManager.Score += gameManager.headScore; magmadar.MagmadarHp -= damage * 5; player.hitCount++; } } if (tagName == "OrkBerserker") { OrkberserkerController orkBerserker = hit.collider.transform.root.gameObject.GetComponent <OrkberserkerController>(); if (!orkBerserker.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; orkBerserker.OrkBerserkerHp -= damage; player.hitCount++; } } if (tagName == "OrkBerserkerWeapon") { OrkberserkerController orkBerserker = hit.collider.transform.root.gameObject.GetComponent <OrkberserkerController>(); if (!orkBerserker.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; orkBerserker.OrkBerserkerHp -= damage; orkBerserker.OrkBerserkerWeaponHP -= damage; player.hitCount++; } } if (tagName == "OrkBerserkerHead") { OrkberserkerController orkBerserker = hit.collider.transform.root.gameObject.GetComponent <OrkberserkerController>(); if (!orkBerserker.GetDestroyed()) { gameManager.Score += gameManager.headScore; orkBerserker.OrkBerserkerHp -= damage * 5; player.hitCount++; } } } Ammo--; }
void EnemyMoveStop() { hitTimer += Time.deltaTime; if (transform.parent.tag == "EnemyHead" || transform.parent.tag == "Enemy") { EnemyController enemy = transform.root.gameObject.GetComponent <EnemyController>(); enemy.moveEnabled = false; if (hitTimer >= lifeTime && enemy.Hp > 0) { enemy.moveEnabled = true; enemy.Hp -= damage; } } if (transform.parent.tag == "Mutant" || transform.parent.tag == "MutantHead") { MutantController mutant = transform.root.gameObject.GetComponent <MutantController>(); mutant.mutantMoveEnabled = false; if (!mutant.GetDestroyed() && hitTimer >= lifeTime) { mutant.mutantMoveEnabled = true; mutant.MutantHp -= damage; } } if (transform.parent.tag == "Titan" || transform.parent.tag == "TitanHead") { TitanController titan = transform.root.gameObject.GetComponent <TitanController>(); if (!titan.GetDestroyed()) { titan.TitanHp -= damage; } /**titan.titanMoveEnabled = false; * if (!titan.GetDestroyed() && hitTimer >= lifeTime) * titan.titanMoveEnabled = true; **/ } if (transform.parent.tag == "Reptile" || transform.parent.tag == "ReptileHead") { ReptileController reptile = transform.root.gameObject.GetComponent <ReptileController>(); reptile.reptileMoveEnabled = false; if (!reptile.GetDestroyed() && hitTimer >= lifeTime) { reptile.reptileMoveEnabled = true; reptile.ReptileHp -= damage; } } if (transform.parent.tag == "Magmadar" || transform.parent.tag == "MagMadarHead") { MagmadarController magmadar = transform.root.gameObject.GetComponent <MagmadarController>(); if (!magmadar.GetDestroyed()) { magmadar.MagmadarHp -= damage; } /**magmadar.magmadarMoveEnabled = false; * if (!magmadar.GetDestroyed() && hitTimer >= lifeTime) * magmadar.magmadarMoveEnabled = true; **/ } if (transform.parent.tag == "OrkBerserker" || transform.parent.tag == "OrkBerserkerWeapon" || transform.parent.tag == "OrkBerserkerHead") { OrkberserkerController orkBerserker = transform.root.gameObject.GetComponent <OrkberserkerController>(); if (!orkBerserker.GetDestroyed()) { orkBerserker.OrkBerserkerHp -= damage; } } ScaleManager(); if (hitTimer >= lifeTime) { Destroy(this.gameObject); } }
void Damage() { if (transform.parent.tag == "EnemyHead") { hitTimer += Time.deltaTime; if (hitTimer >= lifeTime / 10) { EnemyController enemy = transform.parent.transform.parent.gameObject.GetComponent <EnemyController>(); if (enemy.Hp > 0) { enemy.Hp -= damage * 5; } hitTimer = 0f; } } if (transform.parent.tag == "Enemy") { hitTimer += Time.deltaTime; if (hitTimer >= lifeTime / 10) { EnemyController enemy = transform.parent.gameObject.GetComponent <EnemyController>(); if (enemy.Hp > 0) { enemy.Hp -= damage; } hitTimer = 0f; } } if (transform.parent.tag == "Mutant") { hitTimer += Time.deltaTime; if (hitTimer >= lifeTime / 10) { MutantController mutant = transform.root.gameObject.GetComponent <MutantController>(); if (!mutant.GetDestroyed()) { mutant.MutantHp -= damage; } hitTimer = 0f; } } if (transform.parent.tag == "MutantHead") { hitTimer += Time.deltaTime; if (hitTimer >= lifeTime / 10) { MutantController mutant = transform.root.gameObject.GetComponent <MutantController>(); if (!mutant.GetDestroyed()) { mutant.MutantHp -= damage * 5; } hitTimer = 0f; } } if (transform.parent.tag == "Titan") { hitTimer += Time.deltaTime; if (hitTimer >= lifeTime / 10) { TitanController titan = transform.root.transform.gameObject.GetComponent <TitanController>(); if (!titan.GetDestroyed()) { titan.TitanHp -= damage; } hitTimer = 0f; } } if (transform.parent.tag == "TitanHead") { hitTimer += Time.deltaTime; if (hitTimer >= lifeTime / 10) { TitanController titan = transform.root.gameObject.GetComponent <TitanController>(); if (!titan.GetDestroyed()) { titan.TitanHp -= damage * 5; } hitTimer = 0f; } } if (transform.parent.tag == "Reptile") { hitTimer += Time.deltaTime; if (hitTimer >= lifeTime / 10) { ReptileController reptile = transform.root.gameObject.GetComponent <ReptileController>(); if (!reptile.GetDestroyed()) { reptile.ReptileHp -= damage; } hitTimer = 0f; } } if (transform.parent.tag == "ReptileHead") { hitTimer += Time.deltaTime; if (hitTimer >= lifeTime / 10) { ReptileController reptile = transform.parent.transform.gameObject.GetComponent <ReptileController>(); if (!reptile.GetDestroyed()) { reptile.ReptileHp -= damage * 5; } hitTimer = 0f; } } if (transform.parent.tag == "Magmadar") { hitTimer += Time.deltaTime; MagmadarController magmadar = transform.root.gameObject.GetComponent <MagmadarController>(); if (hitTimer >= lifeTime / 10) { if (!magmadar.GetDestroyed()) { magmadar.MagmadarHp -= damage; } hitTimer = 0f; } } if (transform.parent.tag == "MagmadarHead") { hitTimer += Time.deltaTime; MagmadarController magmadar = transform.root.gameObject.GetComponent <MagmadarController>(); if (hitTimer >= lifeTime / 10) { if (!magmadar.GetDestroyed()) { magmadar.MagmadarHp -= damage * 5; } hitTimer = 0f; } } if (transform.parent.tag == "OrkBerserker") { hitTimer += Time.deltaTime; OrkberserkerController orkBerserker = transform.root.gameObject.GetComponent <OrkberserkerController>(); if (hitTimer >= lifeTime / 10) { if (!orkBerserker.GetDestroyed()) { orkBerserker.OrkBerserkerHp -= damage; } hitTimer = 0f; } } if (transform.parent.tag == "OrkBerserkerWeapon") { hitTimer += Time.deltaTime; OrkberserkerController orkBerserker = transform.root.gameObject.GetComponent <OrkberserkerController>(); if (hitTimer >= lifeTime / 10) { if (!orkBerserker.GetDestroyed()) { orkBerserker.OrkBerserkerHp -= damage; orkBerserker.OrkBerserkerWeaponHP -= damage; } hitTimer = 0f; } } if (transform.parent.tag == "OrkBerserkerHead") { hitTimer += Time.deltaTime; OrkberserkerController orkBerserker = transform.root.gameObject.GetComponent <OrkberserkerController>(); if (hitTimer >= lifeTime / 10) { if (!orkBerserker.GetDestroyed()) { orkBerserker.OrkBerserkerHp -= damage * 5; } hitTimer = 0f; } } }
void OnCollisionStay(Collision collision) { string tagName = collision.gameObject.tag; if (tagName == "EnemyHead") { EnemyController enemy = collision.transform.parent.gameObject.GetComponent <EnemyController>(); if (!enemy.GetDead()) { gameManager.Score += gameManager.headScore; enemy.Hp -= damage * 5; player.hitCount++; } } if (tagName == "Enemy") { EnemyController enemy = collision.gameObject.GetComponent <EnemyController>(); if (!enemy.GetDead()) { gameManager.Score += gameManager.bodyScore; enemy.Hp -= damage; player.hitCount++; } } if (tagName == "Mutant") { MutantController mutant = collision.transform.root.gameObject.GetComponent <MutantController>(); if (!mutant.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; mutant.MutantHp -= damage; player.hitCount++; } } if (tagName == "MutantHead") { MutantController mutant = collision.transform.root.gameObject.GetComponent <MutantController>(); if (!mutant.GetDestroyed()) { gameManager.Score += gameManager.headScore; mutant.MutantHp -= damage * 5; player.hitCount++; } } if (tagName == "Titan") { TitanController titan = collision.transform.root.gameObject.GetComponent <TitanController>(); if (!titan.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; titan.TitanHp -= damage; player.hitCount++; } } if (tagName == "TitanHead") { TitanController titan = collision.transform.root.gameObject.GetComponent <TitanController>(); if (!titan.GetDestroyed()) { gameManager.Score += gameManager.headScore; titan.TitanHp -= damage * 5; player.hitCount++; } } if (tagName == "Reptile") { ReptileController reptile = collision.transform.root.gameObject.GetComponent <ReptileController>(); if (!reptile.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; reptile.ReptileHp -= damage; player.hitCount++; } } if (tagName == "ReptileHead") { ReptileController reptile = collision.transform.gameObject.GetComponent <ReptileController>(); if (!reptile.GetDestroyed()) { gameManager.Score += gameManager.headScore; reptile.ReptileHp -= damage * 5; player.hitCount++; } } if (tagName == "Magmadar") { MagmadarController magmadar = collision.transform.root.gameObject.GetComponent <MagmadarController>(); if (!magmadar.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; magmadar.MagmadarHp -= damage; player.hitCount++; } } if (tagName == "MagmadarHead") { MagmadarController magmadar = collision.transform.root.gameObject.GetComponent <MagmadarController>(); if (!magmadar.GetDestroyed()) { gameManager.Score += gameManager.headScore; magmadar.MagmadarHp -= damage * 5; player.hitCount++; } } if (tagName == "OrkBerserker") { OrkberserkerController orkBerserker = collision.transform.root.gameObject.GetComponent <OrkberserkerController>(); if (!orkBerserker.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; orkBerserker.OrkBerserkerHp -= damage; player.hitCount++; } } if (tagName == "OrkBerserkerWeapon") { OrkberserkerController orkBerserker = collision.transform.root.gameObject.GetComponent <OrkberserkerController>(); if (!orkBerserker.GetDestroyed()) { gameManager.Score += gameManager.bodyScore; orkBerserker.OrkBerserkerHp -= damage; orkBerserker.OrkBerserkerWeaponHP -= damage; player.hitCount++; } } if (tagName == "OrkBerserkerHead") { OrkberserkerController orkBerserker = collision.transform.root.gameObject.GetComponent <OrkberserkerController>(); if (!orkBerserker.GetDestroyed()) { gameManager.Score += gameManager.headScore; orkBerserker.OrkBerserkerHp -= damage * 5; player.hitCount++; } } if (tagName != "ScifiGunObj" && tagName != "Player") { if (ScifiGun.bulletMode == ScifiGunController.BulletMode.FIRE) { GameObject childObject = Instantiate(hitEffectPrefab, transform.position, Quaternion.identity) as GameObject; childObject.transform.parent = collision.transform; } else if (ScifiGun.bulletMode == ScifiGunController.BulletMode.ICE) { GameObject childObject = Instantiate(hitEffectPrefab, transform.position, Quaternion.Euler(-90f, 0f, 0f)) as GameObject; childObject.transform.parent = collision.transform; } else if (ScifiGun.bulletMode == ScifiGunController.BulletMode.EXPLOSION) { GameObject childObject = Instantiate(hitEffectPrefab, transform.position, Quaternion.identity) as GameObject; childObject.transform.parent = collision.transform; } Destroy(this.gameObject); } }