private void Attack() { if (Input.GetButton("Fire1") && currentAttackSpeed <= 0 && !isReload) { if (!isReload) { if (theGun.currentBulletCount > 0) { theCrosshair.FireAnimation(); theGun.currentBulletCount--; currentAttackSpeed = theGun.attackSpeed; // 공격 속도 계산 PlaySound(theGun.gunSound); theGun.effect.Play(); Hit(); StopAllCoroutines(); StartCoroutine(ReboundCourutine());// 총기 반동 } else { StartCoroutine(ReloadCoroutine()); } } } }
private void Shoot() // 발사 후 계산 { if (BossPlayer.isshoot == true && PlayerController.isshoot == true) { theCrosshair.FireAnimation(); currentGun.currentBulletCount--; currentFireRate = currentGun.fireRate; // 연사 속도 재계산 PlaySE(currentGun.fire_Sound); currentGun.muzzleFlash.Play(); Hit(); if (hitInfo.transform.tag == "WeakCr") { hitInfo.transform.GetComponent <Weak>().Damage(1, transform.position); monsterHp1.DecreaseHP(1); } else if (hitInfo.transform.tag == "Danger") { hitInfo.transform.GetComponent <Strong>().Damage(1, transform.position); } else if (hitInfo.transform.tag == "NPC") { hitInfo.transform.GetComponent <Pig1>().Damage(1, transform.position); } else if (hitInfo.transform.tag == "Boss") { hitInfo.transform.GetComponent <BossBasic>().Damage(1, transform.position); } StopAllCoroutines(); StartCoroutine(RetroActionCoroutine()); } }
private void Shoot()//발사후 { theCrosshair.FireAnimation(); currentGun.currentBulletCount--; currentFireRate = currentGun.fireRate;//연사속도 초기화 PlaySE(currentGun.fire_Sound); currentGun.muzzleFlash.Play(); Hit(); StopAllCoroutines();//RetroActionCoroutine의 if else 부분이 겹칠 수도 있다. StartCoroutine(RetroActionCoroutine()); }
//발사후계산 private void Shoot() { theCrosshair.FireAnimation(); //발사시 크로스헤어 발사애니메이션실행 currentGun.currentBulletCount--; currentFireRate = currentGun.fireRate; // 연사 속도 재계산. PlaySE(currentGun.fire_Sound); //발사 효과음 재생 currentGun.muzzleFlash.Play(); //발사 이펙트 재생 Hit(); StopAllCoroutines(); StartCoroutine(RetroActionCoroutine()); }
// after fire private void Shoot() { theCrosshair.FireAnimation(); currentGun.currentBulletCount--; currentFireRate = currentGun.fireRate; // fire speed recalculate PlaySE(currentGun.fire_Sound); currentGun.muzzleFlash.Play(); Hit(); StopAllCoroutines(); StartCoroutine(RetroActionCoroutine()); }
private void Shoot() { theCrosshair.FireAnimation(); currentGun.currentBulletCount--; currentFireRate = currentGun.fireRate; //연사 속도 재계산 PlaySE(currentGun.fireSound); currentGun.muzzleFlash.Play(); Hit(); //총기 반동 코루틴 StopAllCoroutines(); StartCoroutine(RetroActionCoroutine()); }
// 발사 후 계산 private void Shoot() { theCrosshair.FireAnimation(); currentGun.currentBulletCount--; currentFireRate = currentGun.fireRate; PlaySE(currentGun.fire_Sound); currentGun.muzzleFlash.Play(); Hit(); // 총기 반동 코루틴 StopAllCoroutines(); StartCoroutine(RetroActionCoroutine()); // 오브젝트 풀링 기법이 사용될 수도 있으나 // 간단하게 진행 }
//발사 private void Shoot() { theCrosshair.FireAnimation(); currentGun.currentBulletCount--; currentFireRate = currentGun.fireRate; PlaySE(currentGun.fire_Sound); currentGun.muzzleFlash.Play(); Hit(); //총기 반동 코루틴 실행 StopAllCoroutines(); StartCoroutine(RetroActionCoroutin()); Debug.Log("총알 발사함!"); }
// 발사 후 계산 private void Shoot() // 발사 후 { theCrosshair.FireAnimation(); currentGun.currentBulletCount--; // 현재 총알에서 Shoot 할때마다 1개씩 빼기 currentFireRate = currentGun.fireRate; // 연사 속도 재계산 PlaySE(currentGun.fire_Sounds); currentGun.muzzleFlash.Play(); Hit(); // 총기 반동 코루틴 실행 StopAllCoroutines(); // while문 2개가 같이 실행될 수 있기 때문에 코루틴을 멈춰준다 StartCoroutine(RetroActionCoroutine()); }
private void Shoot() { timer += Time.deltaTime; if (Input.GetButton("Fire1") && timer >= timeBetweenBullets) { timer = 0f; theCrosshair.FireAnimation(); Debug.DrawRay(transform.position, transform.forward * maxRange, Color.red, 0.3f); gunLight.enabled = true; gunLine.enabled = true; gunLine.SetPosition(0, transform.position); shootRay.origin = transform.position; shootRay.direction = transform.forward; // 레이 캐스트 if (Physics.Raycast(shootRay, out shootHit, maxRange)) { Collider collider = shootHit.collider; if (collider.tag == "Enemy") { collider.gameObject.SendMessage("OnHitBullet"); Instantiate(hitParticle, shootHit.point, Quaternion.identity); } gunLine.SetPosition(1, shootHit.point); } else { gunLine.SetPosition(1, shootRay.origin + shootRay.direction * maxRange); } // 파티클 gunParticle.Stop(); gunParticle.Play(); // 총 효과음 재생 gunAudioSource.Play(); if (timer > waitingTime) { timer = 0; } } if (timer >= timeBetweenBullets * effectDisplayTime) { DisableEffects(); } }
/* * private void Fire() * { * if (Input.GetButton("Fire1") && currentFireRate <= 0 && !isReload) * { * rifleFire = true; * if (currentRifle.currentBulletCount > 0) * Shoot(); * else * { * CancelAim(); * StartCoroutine(Reload()); * } * * } * if (Input.GetButtonUp("Fire1")) * rifleFire = false; * } */ //발사 private void Shoot() { currentRifle.currentBulletCount--; //연사 속도 재계산 currentFireRate = currentRifle.fireRate; currentRifle.muzzleFlash.Play(); audio.Play(); StartCoroutine(ShootBullet()); //Hit(); player.animator.SetTrigger("Shoot"); if (!isAimMode) { crosshair.FireAnimation(); } //총기 반동 코루틴 StopAllCoroutines(); StartCoroutine(RetroactionCoroutine()); }
// 발사후 계산 private void Shoot() { theCrosshair.FireAnimation(); currentGun.currentBulletCount--; // 연사속도 재계산 currentFireRate = currentGun.fireRate; // 발사와 동시에 sound 집어넣기 //PlaySE(currentGun.fire_sound); SoundManager.instance.PlaySE(shoot_Sound); // 섬광 발동 currentGun.muzzleFlash.Play(); // Hit(); // 반동 실시 StopAllCoroutines(); StartCoroutine(RetroActionCoroutine()); }