void Start() { //source = GetComponent<AudioSource>(); statusEffect = MODIFIER_EFFECT.MOD_NONE; statusTimer = 0; changeTimer = false; //Enemy healthbar setup maxHealth = health; healthBar = transform.Find("EnemyCanvas").Find("healthBG").Find("health").GetComponent <Image>(); healthBar.fillAmount = (float)health / (float)maxHealth; _navMeshAgent = this.GetComponent <NavMeshAgent>(); if (_navMeshAgent == null) { Debug.LogError("The navmesh agent component is not attached to " + gameObject.name); } else { SetDestination(); } _navMeshAgent.speed = agentMaxSpeed; _navMeshAgent.acceleration = agentAcceleration; MoneyHandle = GameObject.FindWithTag("Money"); }
private void ProcessStatus() { if (statusEffect == MODIFIER_EFFECT.MOD_NONE) { return; } statusTimer -= Time.deltaTime; if (statusTimer <= 0) { statusEffect = MODIFIER_EFFECT.MOD_NONE; statusTimer = 0; return; } switch (statusEffect) { case MODIFIER_EFFECT.MOD_SLOW: _navMeshAgent.speed = agentMaxSpeed * 0.5f; break; case MODIFIER_EFFECT.MOD_SLOW_HEAVY: _navMeshAgent.speed = agentMaxSpeed * 0.2f; break; default: break; } }
private void SetStatus(MODIFIER_EFFECT newEffect) { if (statusEffect == MODIFIER_EFFECT.MOD_SLOW_HEAVY && newEffect == MODIFIER_EFFECT.MOD_SLOW) { changeTimer = false; } else { statusEffect = newEffect; changeTimer = true; } }