Exemple #1
0
    public void Initialize(int currentWave, EnemyMetadata config, GameObject targetGameObject)
    {
        targetGameOjbects = new List <GameObject>();
        targetGameOjbects.Add(targetGameObject);

        maxHitPoint  = config.hp;
        AttackDamage = config.attack;
        AttackRange  = config.attackRange;
        //type = config.enemyType;
        AttackCoolDownSeconds = 1.0f / config.attackFrequency;
        MoveSpeed             = config.moveSpeed;
        SearchRange           = config.searchRange;
        lootIds = config.lootIds;

        enemyState              = EEnemyState.IDLE;
        enemyAttackState        = EEnemyAttackState.IDLE;
        currentHitPoint         = maxHitPoint;
        attackCoolDownStartTime = 0.0f;

        hpBarBehaviour = GetComponentInChildren <HpBarBehaviour>();
        if (hpBarBehaviour == null)
        {
            Debug.LogError("Enemy missing HP bar component");
        }

        animator = GetComponent <Animator>();
        SetStateToIdle();

        // ANIMATION_IS_DEAD should only be set to false at the beginning
        animator.SetBool(ANIMATION_IS_DEAD, false);
    }
Exemple #2
0
    public override void Init()
    {
        base.Init();
        InitializeWithBuildingConfig();

        hpBarBehaviour = GetComponentInChildren <HpBarBehaviour>();
    }