void Awake()
    {
        #region Singleton boilerplate

        if (Singleton != null)
        {
            if (Singleton != this)
            {
                Debug.LogWarning($"There's more than one {Singleton.GetType()} in the scene!");
                Destroy(gameObject);
            }

            return;
        }

        Singleton = this;

        #endregion Singleton boilerplate

        healthController          = GetComponent <HealthLogic>();
        healthController.onDeath += Die;
        anim = GetComponent <Animator>();

        if (mainCrystal == null)
        {
            Debug.LogError("Main Crystal not set.");
        }
    }
Ejemplo n.º 2
0
    public void OnDealDamage()
    {
        switch (currentState)
        {
        case EnemyState.WALKING:
            break;

        case EnemyState.ATTACK_PLAYER:
            HealthLogic playerHealth = CurrentTarget.GetComponent <HealthLogic>();
            playerHealth.OnReceiveDamage(attackDamage);
            if (playerHealth.health <= 0)
            {
                SetState(EnemyState.WALKING);
                return;
            }

            if (transform.position.DistanceGreaterThan(playerAttackDistance, CurrentTarget.position))
            {
                SetState(EnemyState.CHASING);
            }

            break;

        case EnemyState.ATTACK_BASE:
            baseHealth?.OnReceiveDamage(attackDamage);
            break;

        case EnemyState.CHASING:
            break;

        case EnemyState.DEAD:
            break;
        }
    }
Ejemplo n.º 3
0
 void Awake()
 {
     body            = GetComponent <Rigidbody>();
     agent           = GetComponent <NavMeshAgent>();
     health          = GetComponent <HealthLogic>();
     health.onDeath += Launch;
 }
Ejemplo n.º 4
0
    //On collision -> call collided objects damagelogic if it has one and destroy this bullet
    void OnTriggerEnter(Collider other)
    {
        HealthLogic healthLogic = other.GetComponent <HealthLogic>();

        if (healthLogic)
        {
            healthLogic.OnReceiveDamage(Damage);
        }

        Destroy(gameObject);
    }
 void Start()
 {
     baseHealthLogic           = BaseController.Singleton.GetComponent <HealthLogic>();
     baseHealthLogic.onDamage += Distort;
 }
Ejemplo n.º 6
0
 // Use this for initialization
 void Awake()
 {
     Instance    = this;
     healthLogic = new HealthLogic();
 }
 void Awake()
 {
     health          = GetComponent <HealthLogic>();
     health.onDeath += DropLoot;
 }