public void SpawnBlood(int bloodParticleCount, Vector3 position, Vector3 direction) { for (int i = 0; i < bloodParticleCount; i++) { singleList.Add(new Single(position, UtilsClass.ApplyRotationToVector(direction, Random.Range(-15f, 15f)), meshParticleSystem)); } }
public void SpawnShell(Vector3 position, Vector3 direction, string weaponName) { Vector3 quadPosition = position; quadPosition += (direction * -0.1f) * 2f; // Offset to get it close to the weapon float shellAngle = Random.Range(-90f, 90f); Vector3 shellMoveDirection = UtilsClass.ApplyRotationToVector(direction, shellAngle); int uvIndex = 0; switch (weaponName) { case "Pistol": uvIndex = 0; break; case "Shotgun": uvIndex = 1; break; case "Assault Rifle": uvIndex = 2; break; } ShellParticleSystemHandler.Instance.SpawnShell(quadPosition, shellMoveDirection, uvIndex); }
/* * private void Update() { * TrySpawnDirtParticlesDelay(); * TrySpawnFootprintParticlesDelay(); * } * * private void TrySpawnDirtParticlesDelay() { * if (Time.time >= nextSpawnDirtTime) { * if (characterAimHandler.IsMoving()) { * DirtParticleSystemHandler.Instance.SpawnDirt(characterAimHandler.GetPosition() + new Vector3(0, -3f), characterAimHandler.GetMoveDir() * -1f); * nextSpawnDirtTime = Time.time + .08f; * } * } * } * * private void TrySpawnFootprintParticlesDelay() { * if (Time.time >= nextSpawnFootprintTime) { * if (characterAimHandler.IsMoving()) { * FootprintParticleSystemHandler.Instance.SpawnFootprint(characterAimHandler.GetPosition() + new Vector3(0, -3f), characterAimHandler.GetMoveDir() * -1f); * nextSpawnFootprintTime = Time.time + .3f; * } * } * } */ private void CharacterAimHandler_OnShoot(object sender, CharacterAimHandler.OnShootEventArgs e) { Vector3 quadPosition = e.gunEndPointPosition; Vector3 shootDir = (e.shootPosition - e.gunEndPointPosition).normalized; quadPosition += (shootDir * -1f) * 8f; float applyRotation = Random.Range(+95f, +85f); if (shootDir.x < 0) { applyRotation *= -1f; } Vector3 shellMoveDir = UtilsClass.ApplyRotationToVector(shootDir, applyRotation); ShellParticleSystemHandler.Instance.SpawnShell(quadPosition, shellMoveDir); /* * int uvIndex = Random.Range(0, 8); * int spawnedQuadIndex = AddQuad(quadPosition, rotation, quadSize, true, uvIndex); * * FunctionUpdater.Create(() => { * quadPosition += new Vector3(1, 1) * 3f * Time.deltaTime; * //quadSize += new Vector3(1, 1) * Time.deltaTime; * //rotation += 360f * Time.deltaTime; * UpdateQuad(spawnedQuadIndex, quadPosition, rotation, quadSize, true, uvIndex); * }); */ }
public void BulletParticles(Vector3 position) { Vector3 quadPosition = position; Vector3 quadSize = new Vector3(0.5f, 0.5f); Vector3 shootDir = (pc.firePoint.transform.position - pc.gameObject.transform.position).normalized; quadPosition += (shootDir * -0.5f); Vector3 shellMoveDir = UtilsClass.ApplyRotationToVector(shootDir, Random.Range(-95f, -85f)); ShellParticleSystemHandler.Instance.SpawnShell(quadPosition, shellMoveDir); /* * int uvIndex = UnityEngine.Random.Range(0, 8); * int spawnedQuadIndex = AddQuad(quadPosition, rotation, quadSize, true, uvIndex); * * FunctionUpdater.Create(() => * { * quadPosition += new Vector3(0.2f, 0.2f) * 3f * Time.deltaTime; * //quadSize += new Vector3(0.2f, 0.2f) * Time.deltaTime; * //rotation += 360f * Time.deltaTime; * UpdateQuad(spawnedQuadIndex, quadPosition, rotation, quadSize, true, uvIndex); * });*/ }
private void PlayerAimWeapon_OnShoot(object sender, PlayerAimWeapon.OnShootEventArgs e) { UtilsClass.ShakeCamera(.6f, .05f); WeaponTracer.Create(e.gunEndPointPosition, e.shootPosition); Shoot_Flash.AddFlash(e.gunEndPointPosition); Vector3 shootDir = (e.shootPosition - e.gunEndPointPosition).normalized; shootDir = UtilsClass.ApplyRotationToVector(shootDir, 90f); ShellParticleSystemHandler.Instance.SpawnShell(e.shellPosition, shootDir); }
private void PlayerAimWeapon_OnShoot(object sender, PlayerAimWeapon.OnShootEventArgs e) { //UtilsClass.ShakeCamera(.6f, .05f); WeaponTracer.Create(e.gunEndPointPosition, e.shootPosition); //Shoot_Flash.AddFlash(e.gunEndPointPosition); World_Sprite world_Sprite = World_Sprite.Create(e.gunEndPointPosition, GameAssets.i.s_ShootFlash); FunctionTimer.Create(world_Sprite.DestroySelf, .1f); Vector3 shootDir = (e.shootPosition - e.gunEndPointPosition).normalized; shootDir = UtilsClass.ApplyRotationToVector(shootDir, 90f); //ShellParticleSystemHandler.Instance.SpawnShell(e.shellPosition, shootDir); }
public void SpawnBlood(Vector3 position, Vector3?direction = null, float distanceMax = 7f, float particles = 3) { var dir = direction ?? new Vector3(Random.Range(-5, 5), 0, Random.Range(-5, 5)).normalized; for (int i = 0; i < Random.Range(3, particles + 1); i++) { singleList.Add( new Single( position, UtilsClass.ApplyRotationToVector(dir, Random.Range(-15f, 15f)), Random.Range(2f, distanceMax), meshParticleSystem ) ); } }
public void SpawnBlood(int bloodParticleCount, Vector3 position, Vector3 direction) { for (int i = 0; i < bloodParticleCount; i++) { Vector3 dir; if (meshParticleSystem.GetAxis() == MeshParticleSystem.Axis.XY) { dir = UtilsClass.ApplyRotationToVector(direction, Random.Range(-15f, 15f)); } else { dir = UtilsClass.ApplyRotationToVectorXZ(direction, Random.Range(-15f, 15f)); } singleList.Add(new Single(position, dir, meshParticleSystem)); } }
private void SpawnBulletShellCasing(Vector3 gunEndPointPosition, Vector3 shootPosition) { Vector3 shellSpawnPosition = gunEndPointPosition; Vector3 shootDir = (shootPosition - gunEndPointPosition).normalized; float backOffsetPosition = 8f; shellSpawnPosition += (shootDir * -1f) * backOffsetPosition; float applyRotation = Random.Range(+130f, +95f); if (shootDir.x < 0) { applyRotation *= -1f; } Vector3 shellMoveDir = UtilsClass.ApplyRotationToVector(shootDir, applyRotation); ShellParticleSystemHandler.Instance.SpawnShell(shellSpawnPosition, shellMoveDir); }
private void SpawnBulletShellCasing(Vector3 gunEndPointPosition, Vector3 shootPosition) { Vector3 shellSpawnPosition = gunEndPointPosition; Vector3 shootDir = (shootPosition - gunEndPointPosition).normalized; float backOffsetPosition = 8f; if (weapon.GetWeaponType() == Weapon.WeaponType.Pistol) { backOffsetPosition = 6f; } shellSpawnPosition += (shootDir * -1f) * backOffsetPosition; float applyRotation = UnityEngine.Random.Range(+130f, +95f); if (shootDir.x < 0) { applyRotation *= -1f; } //Sound_Manager.PlaySound(Sound_Manager.Sound.BulletShell, GetPosition()); Vector3 shellMoveDir = UtilsClass.ApplyRotationToVector(shootDir, applyRotation); ShellParticleSystemHandler.Instance.SpawnShell(shellSpawnPosition, shellMoveDir); }