public void RemoveTowerTargetter()
        {
            towerTargetter.acquiredTarget -= OnAcquiredTarget;
            towerTargetter.lostTarget     -= OnLostTarget;

            this.towerTargetter = null;
        }
示例#2
0
        protected override void OnInit(object userData)
        {
            base.OnInit(userData);
            targetter = transform.Find("Targetter").GetComponent <Targetter>();
            attacker  = transform.Find("Attack").GetComponent <Attacker>();

            targetter.OnInit(userData);
            attacker.OnInit(userData);
        }
        protected override void OnInit(object userData)
        {
            base.OnInit(userData);

            targetter = transform.Find("Targetter").GetComponent <Targetter>();

            slowList = new List <EntityEnemy>();

            targetter.OnInit(userData);
        }
        protected override void OnInit(object userData)
        {
            base.OnInit(userData);

            Agent            = GetComponent <NavMeshAgent>();
            hpBarRoot        = transform.Find("HealthBar");
            dicSlowDownRates = new Dictionary <int, float>();
            stateList        = new List <FsmState <EntityEnemy> >();
            CurrentSlowRate  = 1;

            Targetter = transform.Find("Targetter").GetComponent <Targetter>();
            Attacker  = transform.Find("Attack").GetComponent <Attacker>();

            Targetter.OnInit(userData);
            Attacker.OnInit(userData);
        }
        protected override void OnHide(bool isShutdown, object userData)
        {
            base.OnHide(isShutdown, userData);

            Targetter.OnHide(isShutdown, userData);
            Attacker.OnHide(isShutdown, userData);
            Attacker.EmptyOwnerEntity();

            LevelPath       = null;
            EntityDataEnemy = null;
            hp            = 0;
            Agent.enabled = false;
            TargetPlayer  = null;
            hide          = true;
            dataPlayer    = null;
            DestroyFsm();
            RemoveSlowEffect();
            dicSlowDownRates.Clear();
        }
        protected override void OnShow(object userData)
        {
            base.OnShow(userData);

            EntityDataEnemy = userData as EntityDataEnemy;

            if (EntityDataEnemy == null)
            {
                Log.Error("Entity enemy '{0}' entity data invaild.", Id);
                return;
            }

            hide          = false;
            Agent.enabled = true;
            LevelPath     = EntityDataEnemy.LevelPath;
            hp            = EntityDataEnemy.EnemyData.MaxHP;
            dataPlayer    = GameEntry.Data.GetData <DataPlayer>();

            Attacker.SetOwnerEntity(Entity);
            Targetter.SetAlignment(Alignment);
            Targetter.SetTurret(turret);
            Targetter.SetSearchRange(EntityDataEnemy.EnemyData.Range);
            Targetter.ResetTargetter();

            AttackerData attackerData = AttackerData.Create(EntityDataEnemy.EnemyData.Range,
                                                            EntityDataEnemy.EnemyData.FireRate,
                                                            EntityDataEnemy.EnemyData.IsMultiAttack,
                                                            EntityDataEnemy.EnemyData.ProjectileType,
                                                            EntityDataEnemy.EnemyData.ProjectileEntityId
                                                            );

            Attacker.SetData(attackerData, EntityDataEnemy.EnemyData.ProjectileData);
            Attacker.SetTargetter(Targetter);
            Attacker.SetProjectilePoints(projectilePoints);
            Attacker.SetEpicenter(epicenter);
            Attacker.SetLaunch(launcher);
            Attacker.ResetAttack();

            Targetter.OnShow(userData);
            Attacker.OnShow(userData);

            CreateFsm();
        }
 public void SetTargetter(Targetter towerTargetter)
 {
     this.towerTargetter = towerTargetter;
     this.towerTargetter.acquiredTarget += OnAcquiredTarget;
     this.towerTargetter.lostTarget     += OnLostTarget;
 }