コード例 #1
0
    void Shoot()
    {
        muzzle.Play();
        currentAmmo -= 1;
        RaycastHit hit;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            //Debug.Log(hit.transform.name);
            HitEnemy hitEnemy = hit.transform.GetComponent <HitEnemy>();
            if (hitEnemy != null)
            {
                if (hit.transform.name.Equals("HeadHitMarker"))
                {
                    hitEnemy.Damage(headDamage);
                }
                else
                {
                    hitEnemy.Damage(torsoArmDamage);
                }
                GameObject go1 = Instantiate(enemyHit, hit.point, Quaternion.LookRotation(hit.normal));
                Destroy(go1, 2f);
            }
            else
            {
                GameObject go2 = Instantiate(impact, hit.point, Quaternion.LookRotation(hit.normal));
                Destroy(go2, 2f);
            }
        }
    }
コード例 #2
0
 // Start is called before the first frame update
 void Start()
 {
     animator    = GetComponent <Animator>();
     enemyScript = GetComponentInChildren <HitEnemy>();
     if (enemyScript != null)
     {
         enemyScript.isKicking = false;
     }
 }
コード例 #3
0
ファイル: PA_Rush.cs プロジェクト: bigstupidx/gameWaveRush
 public void Init(Player player, HitEnemy onHitEnemyCallback)
 {
     base.Init(player);
     movement.Init(player);
     effect.Init(player);
     OnHitEnemy = onHitEnemyCallback;
     sound      = SoundManager.instance;
     collision.OnTriggerStay += HandleCollideWithEnemy;
 }
コード例 #4
0
 // Start is called before the first frame update
 void Start()
 {
     combat        = GetComponent <PlayerCombat>();
     shotgunShells = GameObject.FindGameObjectsWithTag("ShotgunShell");
     maxAmmo       = shotgunShells.Length;
     enemyHealth   = GameObject.FindGameObjectWithTag("Enemy").GetComponent <EnemyHealth>();
     currentAmmo   = maxAmmo;
     source        = GetComponent <AudioSource>();
     anim          = GetComponent <Animator>();
     hitEnemy      = pellets.GetComponent <HitEnemy>();
     hitEnemy.SetDamage(damage);
 }
コード例 #5
0
 protected override void OnCollisionEnter(Collision collision)
 {
     Debug.Log("OnHit");
     if (collision.collider.CompareTag("Enemy"))
     {
         HitEnemy.Invoke();
     }
     else
     {
         HitDown.Invoke();
     }
 }
コード例 #6
0
 public void Destroy()
 {
     foreach (BattleUnitModel unit in BattleObjectManager.instance.GetAliveList())
     {
         if (unit.bufListDetail.GetActivatedBufList().Find((Predicate <BattleUnitBuf>)(x => x is HitDebuff)) is HitDebuff Hit)
         {
             Hit.Destroy();
         }
         if (unit.bufListDetail.GetActivatedBufList().Find((Predicate <BattleUnitBuf>)(x => x is HitDebuffEnemy)) is HitDebuffEnemy HitEnemy)
         {
             HitEnemy.Destroy();
         }
     }
 }
コード例 #7
0
 public void Init(Player player, HitEnemy onHitEnemyCallback)
 {
     base.Init(player);
     OnHitEnemy = onHitEnemyCallback;
     sound      = SoundManager.instance;
 }