Exemple #1
0
    public void Attack(_CharacterStat targetStat)
    {
        if (attackCoolDown <= 0)
        {
            opponentStat = targetStat;
            opponentStat.TakeDamage(myStat.damage.GetValue());

            if (OnAttack != null)
            {
                OnAttack();
            }

            attackCoolDown = 1f / attackSpeed;
            inCombat       = true;
            lastAttackTime = Time.time;
        }
    }
Exemple #2
0
    void Update()
    {
        float distance = Vector3.Distance(transform.position, player.position);

        if (distance <= lookRadius)
        {
            agent.SetDestination(player.position);
            if (distance <= agent.stoppingDistance)
            {
                _CharacterStat targetStat = player.GetComponent <_CharacterStat> ();
                if (targetStat != null)
                {
                    combat.Attack(targetStat);
                }
                FaceToTarget();
            }
        }
    }
Exemple #3
0
 void Start()
 {
     myStat = GetComponent <_CharacterStat> ();
 }