示例#1
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.GetComponent <CometRotation>() != null ||
         collision.gameObject.GetComponent <CometFacing>() != null)
     {
         OnPlayerHit?.Invoke();
     }
 }
示例#2
0
    public override void TakeHit(int damage)
    {
        bool wasAlive = !dead;

        base.TakeHit(damage);
        if (wasAlive)
        {
            OnPlayerHit?.Invoke();
        }
    }
示例#3
0
 private void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.GetComponent <Player_Movement>())
     {
         if (other.gameObject == lastPlayer)
         {
             return;
         }
         OnPlayerHit?.Invoke(other.gameObject);
     }
 }
示例#4
0
        /// <summary>
        /// This entity was hit. Invoke <see cref="OnPlayerHit"/> if this entity is the player.
        /// </summary>
        /// <param name="damage">The damage dealt</param>
        /// <param name="attacker">The EnemyController of the attacker if it's an NPC.</param>
        public virtual void Hit(int damage, EnemyController attacker = null)
        {
            animator.SetTrigger(HitTrigger);
            OnHit?.Invoke(this);

            // yes I know this is kinda shitty
            if (attacker != null)
            {
                OnPlayerHit?.Invoke(attacker);
            }
        }
示例#5
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag(PlayerTag) || other.gameObject.CompareTag(JudahWeaponTag))
     {
         if (other.gameObject.CompareTag(PlayerTag))
         {
             OnPlayerHit?.Invoke(bulletDamage);
         }
         DestroyBullet();
         return;
     }
     Invoke(nameof(DestroyBullet), BulletDestructionDelay);
 }
 private void OnCollisionStay2D(Collision2D other)
 {
     _movementSpeed = WalkSpeed;
     if (other.gameObject.CompareTag(EnemyTag))
     {
         ChangeDirection();
     }
     if (other.gameObject.CompareTag(PlayerTag) && !_isCollidedWithPlayer)
     {
         _isCollidedWithPlayer = true;
         OnPlayerHit?.Invoke(damagePoint);
         StartCoroutine(DelayCollisionDamage());
     }
 }
示例#7
0
        void playerHit()
        {
            //If this is the last life player has
            if (PlayerLife == 1)
            {
                PlayerLife--;

                // If there are no more continues left
                if (PlayerContinues == 0)
                {
                    OnPlayerContinuesReachZero.Invoke(this, new EventArgs());
                }

                OnPlayerLifeReachZero.Invoke(this, new EventArgs());
            }
            else
            {
                PlayerLife--;
                OnPlayerHit.Invoke(this, new EventArgs());
            }
        }
示例#8
0
    public void Raycasting()
    {
        Vector2      CurMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        RaycastHit2D hit         = Physics2D.Raycast(CurMousePos, Vector2.zero);

        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            if (hit.collider.GetComponent <PlayerCircle>())
            {
                OnPlayerHit?.Invoke();

                return;
            }
        }
        if (Input.GetMouseButton(0) && timer > _timeForNextRay && !EventSystem.current.IsPointerOverGameObject())
        {
            //  Debug.DrawLine(Camera.main.transform.position, hit.point, Color.green, 1f);
            if (hit.collider.GetComponent <PlayerCircle>())
            {
                return;
            }
            OnGroundHit?.Invoke(CurMousePos);
            timer = 0;
        }
        if (Input.GetMouseButtonUp(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            //  Debug.DrawLine(Camera.main.transform.position, hit.point, Color.green, 1f);
            if (hit.collider.GetComponent <PlayerCircle>())
            {
                return;
            }
            OnGroundHit?.Invoke(CurMousePos);
            timer = 0;
        }
        timer += Time.deltaTime;
    }
 private void ShakeIt(OnPlayerHit eventData)
 {
     shaking = true;
     Invoke(nameof(StopCameraShaking), shakeTime);
 }
 public static void NotifyPlayerHit()
 {
     OnPlayerHit?.Invoke();
 }