public virtual void OnEnable() { if (!enemyObject) { enemyObject = this.gameObject; } if (this.IsDead) { this.IsDead = false; } if (enemyObject) { this.Sight = this.GetComponentInChildren <CEnemySight>(); enemyController = enemyObject.GetComponent <IController>(); enemyAI = enemyObject.GetComponent <IBasicAI>(); if (this.GetComponent <SpriteRenderer>()) { this.SetSpriteOrigin(); } enemyAI.LivingEntity = this; enemyAI.Speed = this.fSpeed; enemyController.AtkEvent += this.AttackObject; enemyController.MoveEvent += this.MoveForwardObject; enemyController.TurnEvent += this.TurnObject; enemyController.RandomMoveEvent += this.MoveForwardObject; enemyAI.FacingRight = false; enemyAI.EnemySight = this.Sight; animator = this.GetComponent <Animator>(); } this.fCurrentHealth = fMaxHealth; this.IsDamaged = false; }
public virtual void OnDisable() { this.ReturnToOriginAtk(); this.ReturnToOriginSpeed(); enemyController = null; enemyAI = null; this.Sight.IsAttackRange = false; this.Sight = null; this.bIsBuff = false; }