Ejemplo n.º 1
0
    void OnTriggerStay(Collider other)
    {
        if (other.tag == "Enemy")
        {
            bool didHit = false;
            foreach (Collider col in alreadyHit)
            {
                if (other.Equals(col))
                {
                    didHit = true;
                    break;
                }
            }
            if (!didHit)
            {
                alreadyHit.Add(other);
                Vector3 effectSpawn = other.transform.position;

                Enemy_Combat enemyCombat = other.GetComponent <Enemy_Combat>();
                if (enemyCombat != null)
                {
                    effectSpawn.y += enemyCombat.effectShift_Y;
                }

                Instantiate(slash, effectSpawn, Quaternion.Euler(new Vector3(0, 0, 0)));
                Instantiate(bloodSplat, effectSpawn, Quaternion.Euler(new Vector3(0, 0, 0)));
                other.gameObject.SendMessage("getHurt", damage);
                other.gameObject.SendMessage("knockBack");

                FollowCam2D camComponent = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <FollowCam2D>();
                camComponent.SendMessage("Shake", 0.05);

                //Destroy(gameObject,0.1f);
            }
        }

        if (other.tag == "Soul" && alreadyHit.Count == 0)
        {
            alreadyHit.Add(other);
            SoulMovement soul = other.GetComponent <SoulMovement>();
            soul.destroySoul();
        }
    }
Ejemplo n.º 2
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     combat = animator.GetComponent <Enemy_Combat>();
 }