コード例 #1
0
ファイル: EnemyBase.cs プロジェクト: Owlies/Coop_Next
    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);
    }
コード例 #2
0
ファイル: EnemyBase.cs プロジェクト: Owlies/Coop_Next
    private bool TryAttackBuilding()
    {
        if (!CanAttckCurrentTarget())
        {
            animator.SetBool(ANIMATION_IS_IDLE, true);
            return(false);
        }

        attackingTarget.TakeDamage(AttackDamage);
        attackCoolDownStartTime = Time.time;

        animator.SetBool(ANIMATION_IS_ATTACKING, true);

        enemyAttackState = EEnemyAttackState.COOLING_DOWN;
        enemyState       = EEnemyState.ATTACKING;
        transform.LookAt(attackingTarget.transform);

        return(true);
    }
コード例 #3
0
ファイル: EnemyBase.cs プロジェクト: Owlies/Coop_Next
 private void SetStateToIdle()
 {
     enemyState       = EEnemyState.IDLE;
     enemyAttackState = EEnemyAttackState.IDLE;
     SetIdelAnimationState();
 }