Beispiel #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);
            }
        }
    }
Beispiel #2
0
 // Start is called before the first frame update
 void Start()
 {
     animator    = GetComponent <Animator>();
     enemyScript = GetComponentInChildren <HitEnemy>();
     if (enemyScript != null)
     {
         enemyScript.isKicking = false;
     }
 }
Beispiel #3
0
 public void Init(Player player, HitEnemy onHitEnemyCallback)
 {
     base.Init(player);
     movement.Init(player);
     effect.Init(player);
     OnHitEnemy = onHitEnemyCallback;
     sound      = SoundManager.instance;
     collision.OnTriggerStay += HandleCollideWithEnemy;
 }
Beispiel #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);
 }
Beispiel #5
0
 protected override void OnCollisionEnter(Collision collision)
 {
     Debug.Log("OnHit");
     if (collision.collider.CompareTag("Enemy"))
     {
         HitEnemy.Invoke();
     }
     else
     {
         HitDown.Invoke();
     }
 }
Beispiel #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();
         }
     }
 }
Beispiel #7
0
 public void Init(Player player, HitEnemy onHitEnemyCallback)
 {
     base.Init(player);
     OnHitEnemy = onHitEnemyCallback;
     sound      = SoundManager.instance;
 }