public override void Init() { sfxCtrl = GetComponentInChildren <GeneralSoundController>(); platfromColldier = GetComponent <BoxCollider>(); anim = GetComponentInChildren <Animator>(); meshRenderer = GetComponentInChildren <MeshRenderer>(); rangeCollider = GetComponentInChildren <SphereCollider>(); toleranceCtrl = GetComponent <EnemyToleranceController>(); rotationBehaviour = GetComponent <Rotation>(); graphics = GetComponentInChildren <IGraphic>(); if (toleranceCtrl != null) { toleranceCtrl.Init(); } SetObjectState(true); graphics.ChangeTexture(TextureType.Default); Parasite += HandleParasite; LevelManager.OnPlayerDeath += HandleOnPlayerDeath; idleCommandsCtrl.Init(); parasiteCommandCtrl.Init(); idleCommandsCtrl.ToggleButton(false); parasiteCommandCtrl.ToggleButton(false); prevRotation = 90; transform.rotation = Quaternion.Euler(new Vector3(0, 0, prevRotation)); }
public override void Exit() { context.player.OnPlayerMaxHealth -= HandlePlayerMaxHealth; context.player.OnDamageableCollision -= HandlePlayerDamageableCollision; context.player.OnEnemyCollision -= HandlePlayerEnemyCollision; context.player.OnPlayerImmunityEnd -= HandlePlayerImmunityEnd; context.player = null; tolleranceCtrl.SetActive(false); tolleranceCtrl = null; uiManager.GetGamePanel().EnableToleranceBar(false); context.enemy.GetEnemyCommandsSpriteController().SetParasiteState(false); context.enemy.GetGraphics().ChangeTexture(TextureType.Default); context.enemy.SetCanStun(true); context.enemy.SetCanTakeDamage(true); context.enemy.gameObject.transform.parent = context.enemy.GetEnemyDefaultParent(); context.enemy.gameObject.layer = context.enemy.GetEnemyDefaultLayer(); }
public override void Enter() { uiManager = context.UIManager; tolleranceCtrl = context.enemy.GetToleranceCtrl(); tolleranceCtrl.Setup(); uiManager.GetGamePanel().SetMaxToleranceValue(tolleranceCtrl.GetMaxTolerance()); uiManager.GetGamePanel().EnableToleranceBar(true); context.enemy.SetCanStun(false); context.enemy.SetCanTakeDamage(false); context.enemy.GetGraphics().ChangeTexture(TextureType.Parasite); context.player.OnPlayerMaxHealth += HandlePlayerMaxHealth; context.enemy.GetEnemyCommandsSpriteController().SetParasiteState(true); if (context.player.gameObject.layer == LayerMask.NameToLayer("Player")) { context.player.OnDamageableCollision += HandlePlayerDamageableCollision; context.player.OnEnemyCollision += HandlePlayerEnemyCollision; immunity = false; } else { context.player.OnPlayerImmunityEnd += HandlePlayerImmunityEnd; immunity = true; } }
/// <summary> /// Initialize Script /// </summary> public virtual void Init(EnemyManager _enemyMng) { graphics = GetComponentInChildren <EnemyGraphicController>(); enemyMng = _enemyMng; startPosition = transform.position; startRotation = transform.rotation; ResetLife(); ResetStunHit(); ResetPosition(); SetCanStun(true); // Initialize Enemy State Machine enemySM = GetComponent <EnemySMController>(); if (enemySM != null) { enemySM.Init(this); } toleranceCtrl = GetComponent <EnemyToleranceController>(); if (toleranceCtrl != null) { toleranceCtrl.Init(); } collisionCtrl = GetComponent <EnemyCollisionController>(); if (collisionCtrl != null) { collisionCtrl.Init(); } movementCtrl = GetComponent <EnemyMovementController>(); if (movementCtrl != null) { movementCtrl.Init(collisionCtrl); } animCtrl = GetComponentInChildren <EnemyAnimationController>(); if (animCtrl != null) { animCtrl.Init(this); } commandsSpriteCtrl = GetComponentInChildren <EnemySpriteController>(); if (commandsSpriteCtrl != null) { commandsSpriteCtrl.Init(this); } vfxCtrl = GetComponentInChildren <EnemyVFXController>(); if (vfxCtrl != null) { vfxCtrl.Init(this); } sfxCtrl = GetComponentInChildren <EnemySoundController>(); if (sfxCtrl != null) { sfxCtrl.Setup(this); sfxCtrl.Init(); } viewCtrl = GetComponent <EnemyViewController>(); if (viewCtrl != null) { viewCtrl.Init(); } CalculatePathLenght(); }