Exemple #1
0
    //弹孔实现
    void HitEffect(RaycastHit hit)
    {
        #region Ragdoll
        //伤害判断
        if (hit.collider.gameObject.tag == "Ragdoll")
        {
            ZombieStats ZombieHP = hit.collider.gameObject.GetComponentInParent <ZombieStats>();
            //伤害判定本地计算
            if (owner.gameObject.GetComponent <PhotonView>().isMine)
            {
                ZombieHP.ApplyDamage(weaponSettings.damage);
            }

            //hitsound

            //hit forece 有点问题

            //bloodSplat
            if (weaponSettings.bloodSplat)
            {
                Vector3    hitPoint     = hit.point;
                Quaternion lookRotation = Quaternion.LookRotation(hit.normal);
                GameObject bloodSplat   = Instantiate(weaponSettings.bloodSplat, hitPoint, lookRotation) as GameObject;
                Transform  bloodSplatT  = bloodSplat.transform;
                Transform  hitT         = hit.transform;
                bloodSplatT.SetParent(hitT);
                Destroy(bloodSplat, 1.0f);
            }
        }
        //简单的玩家判断
        if (hit.collider.gameObject.tag == "Player")
        {
            CharacterStats otherPlayerState = hit.collider.gameObject.GetComponent <CharacterStats>();
            {
                otherPlayerState.ApplyDamage(weaponSettings.damage);
            }
        }

        #endregion

        #region decal
        //墙体标记tag,
        if (hit.collider.gameObject.tag == "StaticObj")
        {
            if (weaponSettings.decal)
            {
                Vector3    hitPoint    = hit.point;
                Quaternion lookRotaion = Quaternion.LookRotation(hit.normal);
                GameObject decal       = Instantiate(weaponSettings.decal, hitPoint, lookRotaion) as GameObject;
                Transform  decalT      = decal.transform;
                Transform  hitT        = hit.transform;
                decalT.SetParent(hitT);
                Destroy(decal, Random.Range(30.0f, 45.0f));
            }
        }
        #endregion
    }
Exemple #2
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     //Ignore Player
     if (collision.gameObject.GetComponentInChildren <CharacterStats>() != null)
     {
         GetCharacterStats = collision.gameObject.GetComponentInChildren <CharacterStats>();
         GetCharacterStats.ApplyDamage(totalDamageToApply);
         Destroy(gameObject);
     }
 }
Exemple #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag.Equals("Bullet"))
        {
            m_characterStats.ApplyDamage((other.GetComponent(typeof(BulletStats)) as BulletStats).BulletDamage);
            Destroy(other.gameObject);
        }

        if (other.tag.Equals("Ammo") && gameObject.name.Equals("Player"))
        {
            Destroy(other.gameObject);
            FindFireGun();
        }
    }
Exemple #4
0
    //使用射线投射判定伤害
    //在Animator motion中调用
    public void AttackJudge()
    {
        RaycastHit hit;
        Vector3    start = transform.position + transform.up;
        Vector3    dir   = (target.transform.position + target.transform.up) - start;

        if (Physics.Raycast(start, dir, out hit, attackSettings.attackRange, sight.sightLayers))
        {
            if (hit.collider.GetComponent <CharacterStats>())
            {
                CharacterStats c = hit.collider.GetComponent <CharacterStats>();
                c.ApplyDamage(attackSettings.damage);
            }
        }
    }