예제 #1
0
    public void DecreaseHpByWolf(int cnt, WolfAgent wolf = null)
    {
        if (state == EnemyState.die || state == EnemyState.hit)
        {
            return;
        }
        hp      -= cnt;
        oldState = state;
        state    = EnemyState.hit;
        velocity = 0;
        EnemyExplosion enemyExplosion = GetComponentInChildren <EnemyExplosion>();

        enemyExplosion.isEnemyAtked = true;
        if (wolf != null)
        {
            enemiesManager.AtkReward(atk, wolf);
            Runaway(wolf.gameObject);
        }

        if (hp <= 0)
        {
            //Debug.Log("주겄당!!");
            if (wolf != null)
            {
                enemiesManager.DieReward(wolf);
            }
            state       = EnemyState.die;
            oldRotation = transform.rotation;
            animator.SetTrigger("dieTrigger");
        }
    }
예제 #2
0
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log(other.name + " - UnderMap trigger enter!");

        if (other.CompareTag("item"))
        {
            Vector3 itemPos = other.gameObject.transform.position;
            other.gameObject.transform.position = new Vector3(itemPos.x, replaceHeight, itemPos.z);
        }
        else if (other.CompareTag("agent"))
        {
            WolfAgent agent = other.gameObject.GetComponent <WolfAgent>();
            agent.Done();
            agent.AgentReset();
        }
        else if (other.CompareTag("enemyCollider"))
        {
            Enemy enemy = other.gameObject.GetComponentInParent <Enemy>();
            enemy.state = Enemy.EnemyState.die;
        }
        else
        {
            Destroy(other.gameObject);
        }
    }
예제 #3
0
    void Attack()
    {
        if (!isAttack)
        {
            animator.SetTrigger("attackTrigger");

            nextStateTime = atkTime;

            float tempAtk = atk;

            Vector3 atkPosition = new Vector3(transform.forward.x + transform.position.x, transform.position.y + atkPos, transform.forward.z * atkPos + transform.position.z);

            Collider[] targets = Physics.OverlapSphere(atkPosition, atkRange, targetMask);
            foreach (Collider t in targets)
            {
                if (t.gameObject.CompareTag(targetTag))
                {
                    if (enemiesManager.isNight)
                    {
                        tempAtk = atk * 1.5f;
                    }
                    //GameObject.Find("UIManager").transform.GetChild(0).Find("Status").GetComponent<StatusController>().HitEnemy((int)tempAtk);
                    //GameObject.Find("CameraManager").GetComponent<EffectCameraController>().EffectCameraOn();
                    enemiesManager.statusController.HitEnemy((int)tempAtk);
                    enemiesManager.effectCameraController.EffectCameraOn();
                }
                else if (t.gameObject.CompareTag(agentTag))
                {
                    if (enemiesManager.isNight)
                    {
                        tempAtk = atk * 1.5f;
                    }
                    WolfAgent wolf = t.GetComponent <WolfAgent>();
                    if (wolf.isDeadResting)
                    {
                        state  = EnemyState.escape;
                        target = t.gameObject;
                        return;
                    }
                    wolf.Hp -= tempAtk;
                }

                isAttack = true;
                return;
            }
        }

        if (!animator.GetCurrentAnimatorStateInfo(0).IsName("attack"))
        {
            state = EnemyState.trace;
            ChangeNextState();
            isAttack = false;
            Debug.Log("공격끗!");
        }
        return;
    }
예제 #4
0
 public void DieReward(WolfAgent wolf)
 {
     wolfAgent = wolf;
     if (wolfAgent == null)
     {
         Debug.Log("EnemiesManager - Wolf Agent is null.");
         wolfAgent = FindObjectOfType <WolfAgent>();
         return;
     }
     wolfAgent.EnemyDieReward();
 }
예제 #5
0
 public void AtkReward(int atk, WolfAgent wolf)
 {
     wolfAgent = wolf;
     if (wolfAgent == null)
     {
         Debug.Log("EnemiesManager - Wolf Agent is null.");
         wolfAgent = FindObjectOfType <WolfAgent>();
         return;
     }
     wolfAgent.EnemyAtkReward(atk);
 }
예제 #6
0
 private void Start()
 {
     wolfAgent = FindObjectOfType <WolfAgent>();
 }