protected virtual void Start() { player = GameObject.Find("Hero"); rb2D = gameObject.GetComponent <Rigidbody2D>(); knockbackController = gameObject.GetComponent <KnockbackController>(); actualAttackCooldown = 0; // Debug.Log($"Start attacking distance {startAttackingStateDistance}, {endAttackingStateDistance}"); if (startAttackingStateDistance < 0) { startAttackingStateDistance = enemyConfig.defaultStartAttackingStateDistance; } if (endAttackingStateDistance < 0) { endAttackingStateDistance = enemyConfig.defaultEndAttackingStateDistance; } foreach (Transform child in transform) { if (child.GetComponent <Patrol>() != null) { patrol = child.GetComponent <Patrol>(); break; } } GetComponent <HealthController>().HealthUpdateEvent.AddListener(RecieveDamage); }
void Awake() { weapons = new List <Weapon>(); foreach (Transform child in transform) { if (child.tag == Constants.WEAPON_TAG) { weapons.Add(child.GetComponent <Weapon>()); } } foreach (Weapon weapon in weapons) { if (!activeWeapon && weapon.gameObject.activeSelf) { activeWeapon = weapon; } else { weapon.gameObject.SetActive(false); } } rb2D = gameObject.GetComponent <Rigidbody2D>(); knockbackController = gameObject.GetComponent <KnockbackController>(); audioController = gameObject.GetComponent <AudioController>(); animator = GetComponent <Animator>(); StatsUpgrades.Instance.Subscribe(this); }
private void Start() { hasDied = false; playerSounds = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <PlayerSounds>(); _knockbackController = GetComponent <KnockbackController>(); _animator = GetComponentInChildren <Animator>(); whiteScreenOn = false; redScreenOn = false; if (isPlayer) { whiteScreen = transform.Find("UI/ScreenBlinkEnemy").gameObject; redScreen = transform.Find("UI/ScreenBlinkPlayer").gameObject; } _cooldown = _damageCooldown; _cooldownRatio = 1 / _damageCooldown; }