Beispiel #1
0
    protected virtual void HitObstacle(GridObject obstacle)
    {
        //Obstacle takes damage
        switch (obstacle.GetObjectType())
        {
        case ObjectType.Unit:
        {
            FaceTarget(gridSpace.transform.position, 0.25f);
            break;
        }
        }
        obstacle.TakeDamage(KnockbackDamage);

        //Invoke On Obstacle Hit
        OnObstacleHit?.Invoke(this);

        //If the object hasn't died then deal damage to itself
        if (gameObject.activeSelf)
        {
            switch (GetObjectType())
            {
            case ObjectType.Unit:
            {
                FaceTarget(obstacle.transform.position, 0.25f);
                break;
            }
            }
            TakeDamage(KnockbackDamage);
        }
    }
        private void OnCollisionEnter2D(Collision2D other)
        {
            if (other.gameObject.CompareTag("Fire"))
            {
                OnFireTouched?.Invoke();
            }

            if (other.gameObject.tag.Contains("Obstacle"))
            {
                Destroy(other.gameObject);
                OnObstacleHit?.Invoke();
            }

            if (other.gameObject.CompareTag("Ground"))
            {
                OnJumpLanding?.Invoke();
            }

            if (other.gameObject.tag.Contains("PowerUp"))
            {
                Destroy(other.gameObject);
                MainScript.Instance.obstaclesInScene.RemoveAt(0);
                if (other.gameObject.tag.Contains("Clock"))
                {
                    OnClockPowerUpCollected?.Invoke();
                }
                else if (other.gameObject.tag.Contains("Shield"))
                {
                    OnShieldPowerUpCollected?.Invoke();
                }
            }
        }
 void ColliderWrapper_OnTriggerEnter(Collider other)
 {
     if (other.gameObject.layer == platformExitLayer)
     {
         IsExitTriggering = true;
     }
     else if (other.gameObject.layer == obstacleLayer)
     {
         OnObstacleHit?.Invoke();
         rotatingObject.ResetRotation();
     }
 }
Beispiel #4
0
    public void KnockbackOnDeath()
    {
        StopAllCoroutines();
        willDieOnKnockback = false;
        knockedback        = false;

        if (OnObstacleHit != null)
        {
            OnObstacleHit.Invoke(this);
        }
        if (FinishedKnockback != null)
        {
            FinishedKnockback.Invoke(this);
        }
    }