Exemplo n.º 1
0
        protected override void OnShowTowerLevelSuccess(Entity entity)
        {
            base.OnShowTowerLevelSuccess(entity);

            EntityTowerLevel entityTowerLevel = entity.Logic as EntityTowerLevel;

            targetter.SetAlignment(Alignment);
            targetter.SetTurret(entityTowerLevel.turret);
            targetter.SetSearchRange(entityDataTower.Tower.Range);
            targetter.ResetTargetter();

            AttackerData attackerData = AttackerData.Create(entityDataTower.Tower.Range,
                                                            entityDataTower.Tower.FireRate,
                                                            entityDataTower.Tower.IsMultiAttack,
                                                            entityDataTower.Tower.ProjectileType,
                                                            entityDataTower.Tower.ProjectileEntityId
                                                            );

            attacker.SetData(attackerData, entityDataTower.Tower.ProjectileData);
            attacker.SetTargetter(targetter);
            attacker.SetProjectilePoints(entityTowerLevel.projectilePoints);
            attacker.SetEpicenter(entityTowerLevel.epicenter);
            attacker.SetLaunch(entityTowerLevel.launcher);
            attacker.ResetAttack();
        }
        public override void Launch(List <EntityTargetable> targets, AttackerData attackerData, ProjectileData projectileData, Vector3 origin, Transform[] firingPoints)
        {
            EntityTargetable target      = targets[UnityEngine.Random.Range(0, targets.Count)];
            Transform        firingPoint = GetRandomTransform(firingPoints);

            Launch(target, attackerData, projectileData, origin, firingPoint);
        }
        public override void Launch(EntityTargetable target, AttackerData attackerData, ProjectileData projectileData, Vector3 origin, Transform firingPoint)
        {
            GameEntry.Event.Fire(this, ShowEntityInLevelEventArgs.Create(
                                     attackerData.ProjectileEntityId,
                                     TypeUtility.GetEntityType(attackerData.ProjectileType),
                                     null,
                                     EntityDataProjectile.Create(target, projectileData, origin, firingPoint, firingPoint.position, firingPoint.rotation)));

            PlayParticles(fireParticleSystem, firingPoint.position, target.transform.position);
        }
        private void EmptyData()
        {
            if (attackerData != null)
            {
                ReferencePool.Release(attackerData);
            }

            this.attackerData   = null;
            this.projectileData = null;
        }
        public void SetData(AttackerData attackerData, ProjectileData projectileData)
        {
            if (this.attackerData != null)
            {
                ReferencePool.Release(this.attackerData);
            }

            this.attackerData   = attackerData;
            this.projectileData = projectileData;
        }
Exemplo n.º 6
0
        public static AttackerData Create(float range, float fireRate, bool isMultiAttack, string projectileType, int projectileEntityId)
        {
            AttackerData attackerData = ReferencePool.Acquire <AttackerData>();

            attackerData.Range              = range;
            attackerData.FireRate           = fireRate;
            attackerData.IsMultiAttack      = isMultiAttack;
            attackerData.ProjectileType     = projectileType;
            attackerData.ProjectileEntityId = projectileEntityId;
            return(attackerData);
        }
        public virtual void Launch(List <EntityTargetable> targets, AttackerData attackerData, ProjectileData projectileData, Vector3 origin, Transform[] firingPoints)
        {
            int count = targets.Count;
            int currentFiringPointIndex = 0;
            int firingPointLength       = firingPoints.Length;

            for (int i = 0; i < count; i++)
            {
                EntityTargetable target      = targets[i];
                Transform        firingPoint = firingPoints[currentFiringPointIndex];
                currentFiringPointIndex = (currentFiringPointIndex + 1) % firingPointLength;
                Launch(target, attackerData, projectileData, origin, firingPoint);
            }
        }
Exemplo n.º 8
0
        protected override void OnShow(object userData)
        {
            base.OnShow(userData);
            AttackerData attackerData = AttackerData.Create(entityDataTower.Tower.Range,
                                                            entityDataTower.Tower.FireRate,
                                                            entityDataTower.Tower.IsMultiAttack,
                                                            entityDataTower.Tower.ProjectileType,
                                                            entityDataTower.Tower.ProjectileEntityId
                                                            );

            attacker.SetData(attackerData, entityDataTower.Tower.ProjectileData);

            targetter.OnShow(userData);
            attacker.OnShow(userData);
            attacker.SetOwnerEntity(Entity);
        }
        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 virtual void Launch(EntityTargetable target, AttackerData attackerData, ProjectileData projectileData, Vector3 origin, Transform[] firingPoints)
 {
     Launch(target, attackerData, projectileData, origin, GetRandomTransform(firingPoints));
 }
 public abstract void Launch(EntityTargetable target, AttackerData attackerData, ProjectileData projectileData, Vector3 origin, Transform firingPoint);