Esempio n. 1
0
    void Attack(BaseEnemy argBaseEnemy)
    {
        var targetDistance = Vector2.Distance(transform.position, targetPos_.position);

        if (targetDistance <= argBaseEnemy.EquipmentWeapon.AttackedReach)
        {
            //  TODO    :   animation

            argBaseEnemy.Attack();
        }
    }
Esempio n. 2
0
    void EnemyAttack()
    {
        BaseEnemy enemy = enemies[Random.Range(0, enemies.Count)];

        if (enemy != null)
        {
            enemy.Attack();
        }
        if (stateModal.getState() == GameState.play)
        {
            Invoke("EnemyAttack", Random.Range(minAttractRange, maxAttractRange));
        }
    }
Esempio n. 3
0
    protected virtual void HandleFleeState(BasePlayer player)
    {
        Vector3 dirToPlayer     = player.transform.position - transform.position;
        float   sqrdistToPlayer = dirToPlayer.sqrMagnitude;

        if (sqrdistToPlayer <= mAttackRadiusSquared && mAttackDelayTimer <= 0.0f)
        {
            mEnemy.Attack(player.transform.position);
            mCurrentState       = EnemyState.Attack;
            mResponseDelayTimer = mAttackPauseTime;
            mAttackDelayTimer   = mDefaultTimeBetweenAttacks;
        }
        else if (sqrdistToPlayer <= mVisionRadiusSquared)
        {
            dirToPlayer.Normalize();
            mEnemy.MoveDir(dirToPlayer * -1);
        }
        else
        {
            mEnemy.Stop();
            mCurrentState = EnemyState.Idle;
        }
    }