// ANIMATION EVENTS
        private void MeleeAttackAnimEvent()
        {
            if (currentBehaviour != EnemyBehaviours.Dead && currentBehaviour != EnemyBehaviours.FleeFromPlayer && currentBehaviour != EnemyBehaviours.Knockback)
            {
                if (Physics.Raycast(transform.position + transform.up, transform.forward, out RaycastHit hit, meleeAttackRangeRealUnits, playerLayerMask))
                {
                    ParticleEffectBase hitParticles = (ParticleEffectBase)GameMan.Instance.ObjPoolMan.GetObjectFromPool(ObjectPoolType.MeleeHitParticles);
                    hitParticles.Activate(hit.point, Quaternion.identity);
                    //playerT.gameObject.GetComponent<IHealth>().DecreaseHealth(meleeDamageAmount, meleeAttackDmgType);
                    IHealth otherHealth = playerT.GetComponent <IHealth>();
                    if (otherHealth == null)
                    {
                        otherHealth = playerT.GetComponentInParent <IHealth>();
                    }

                    otherHealth.DecreaseHealth(meleeDamageAmount, meleeAttackDmgType);
                }
            }
        }
        private void ShootLaser()
        {
            Vector3 transPos = transform.position;
            Vector3 lookRot  = Quaternion.LookRotation(playerT.position - transPos, Vector3.up).eulerAngles;
            Vector3 ogRot    = transform.rotation.eulerAngles;

            transform.rotation = Quaternion.Euler(lookRot.x, ogRot.y, ogRot.z);

            RaycastHit hit;

            if (Physics.Raycast(transPos, transform.forward, out hit, rayMaxDistance, raycastMask))
            {
                if (!isHit)
                {
                    GameObject hitGO = hit.collider.gameObject;
                    if (hitGO.layer == GlobalVariables.PLAYER_LAYER)
                    {
                        IHealth otherHealth = hitGO.GetComponent <IHealth>();
                        if (otherHealth == null)
                        {
                            otherHealth = hitGO.GetComponentInParent <IHealth>();
                        }

                        otherHealth.DecreaseHealth(dmgAmount, dmgType);
                        isHit = true;
                    }
                }

                ParticleEffectBase hitParticles = (ParticleEffectBase)GameMan.Instance.ObjPoolMan.GetObjectFromPool(ObjectPoolType.MeleeHitParticles);
                hitParticles.Activate(hit.point, Quaternion.identity);

                float hitDistance = hit.distance;
                //AfterRay(transPos, hit.point, wasHit: true);
                //Debug.DrawLine(transform.position, hit.point, Color.red, 1.0f, false);
                lineRenderer.SetPosition(1, new Vector3(0f, 0f, hitDistance));
            }
            else
            {
                //AfterRay(transPos, transPos + transform.forward * rayMaxDistance, wasHit: false);
                //Debug.DrawLine(transform.position, transform.position + (transform.forward * rayMaxDistance), Color.green, 1f, false);
                lineRenderer.SetPosition(1, new Vector3(0f, 0f, rayMaxDistance));
            }
        }
        private void OnTriggerEnter(Collider other)
        {
            if (!TreeBoss.hasMeleeHit)
            {
                if (other.gameObject.layer == GlobalVariables.PLAYER_LAYER)
                {
                    IHealth otherHealth = other.GetComponent <IHealth>();
                    if (otherHealth == null)
                    {
                        otherHealth = other.GetComponentInParent <IHealth>();
                    }

                    otherHealth.DecreaseHealth(currentAttackDmg, attackDmgType);
                    TreeBoss.hasMeleeHit = true;

                    ParticleEffectBase hitParticles = (ParticleEffectBase)GameMan.Instance.ObjPoolMan.GetObjectFromPool(ObjectPoolType.MeleeHitParticles);
                    hitParticles.Activate(GameMan.Instance.PlayerT.position, Quaternion.identity);
                }
            }
        }
Ejemplo n.º 4
0
        private void OnTriggerEnter(Collider other)
        {
            if (canHit)
            {
                int otherLayer = other.gameObject.layer;
                if (otherLayer == GlobalVariables.PLAYER_LAYER)
                {
                    IHealth otherHealth = other.GetComponent <IHealth>();
                    if (otherHealth == null)
                    {
                        otherHealth = other.GetComponentInParent <IHealth>();
                    }

                    otherHealth.DecreaseHealth(damageAmount, damageType);
                    canHit = false;
                }

                ParticleEffectBase hitParticles = (ParticleEffectBase)GameMan.Instance.ObjPoolMan.GetObjectFromPool(ObjectPoolType.MeleeHitParticles);
                hitParticles.Activate(playerT.position, Quaternion.identity);
            }
        }
Ejemplo n.º 5
0
        private void OnTriggerEnter(Collider other)
        {
            if (!hitColliders.Contains(other))
            {
                hitColliders.Add(other);

                int otherLayer = other.gameObject.layer;
                if (otherLayer == GlobalVariables.ENEMY_LAYER)
                {
                    ParticleEffectBase hitParticles = (ParticleEffectBase)GameMan.Instance.ObjPoolMan.GetObjectFromPool(ObjectPoolType.MeleeHitParticles);
                    hitParticles.Activate(transform.position, Quaternion.identity);
                    IHealth otherHealth = other.GetComponent <IHealth>();
                    if (otherHealth == null)
                    {
                        otherHealth = other.GetComponentInParent <IHealth>();
                    }

                    otherHealth.DecreaseHealth(damageAmount, damageType);
                }
            }
        }