protected virtual void OnCollisionEnter(Collision _cCollision) { if (_cCollision.gameObject.CompareTag("Bullet")) { S_Bullet bBullet = _cCollision.gameObject.GetComponent <S_Bullet>(); if (CompareTag("Player")) { if (!bBullet.bIsSpawnByPlayer) { GetComponent <S_Player>().LoseLife(10f); Destroy(_cCollision.gameObject); } } else if (CompareTag("AI")) { if (bBullet.bIsSpawnByPlayer) { GetComponent <S_AI>().LoseLife(10f); Destroy(_cCollision.gameObject); } } else { if (bBullet.bIsSpawnByPlayer) { StartCoroutine(GetComponent <S_Boss>().ShieldFeedback()); GetComponent <S_Boss>().LoseLife(10f); Destroy(_cCollision.gameObject); } } } }
protected void Batch() { batchsInShoot += 1; lastBatchTick = S_World.tick; for (int i = 0; i < shellBullets; i++) { S_Bullet bs = CreateBullet(); if (shootDirectionType == shootDirectionTypes.random) { shootDirection = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)).normalized; bs.initialRotation = Quaternion.LookRotation(characterActor.Forward).normalized; } else if (shootDirectionType == shootDirectionTypes.towardsPlayer) { GameObject player = GameObject.FindWithTag("Player"); Vector3 horizontal = Vector3.right + Vector3.forward; Vector3 toPlayerDirection = (player.transform.position - gameObject.transform.position).normalized; float deltaAngle = 0f; if (shellBullets > 1) { deltaAngle = shellSpreadArch * 2.0f / (shellBullets - 1); toPlayerDirection = Quaternion.AngleAxis(-shellSpreadArch + deltaAngle * i, Vector3.up) * toPlayerDirection; } toPlayerDirection = Quaternion.AngleAxis(Random.Range(-1f, 1f) * angleVariance, Vector3.up) * toPlayerDirection; shootDirection = Vector3.Scale(toPlayerDirection, horizontal); bs.initialRotation = Quaternion.LookRotation(characterActor.Forward).normalized; } else if (shootDirectionType == shootDirectionTypes.given) { // } if (upwards) { shootDirection = new Vector3(shootDirection.x, 2.0f, shootDirection.z); } bs.moveDirection = shootDirection; bs.moveSpeed = bulletSpeed; } }