コード例 #1
0
        public virtual void Damage(float value)
        {
            if (IsDead)
            {
                return;
            }

            if (!loadedHPBar)
            {
                GameEntry.Event.Fire(this, ShowEntityInLevelEventArgs.Create(
                                         (int)EnumEntity.HPBar,
                                         typeof(EntityHPBar),
                                         OnLoadHpBarSuccess,
                                         EntityDataFollower.Create(hpBarRoot)));

                loadedHPBar = true;
            }

            hp -= value;

            if (entityHPBar)
            {
                entityHPBar.UpdateHealth(hp / MaxHP);
            }


            if (hp <= 0)
            {
                hp = 0;
                Dead();
            }
        }
        public static ShowEntityInLevelEventArgs Create(int entityId, Type entityType, Action <Entity> showSuccess, EntityData entityData, object userData = null)
        {
            ShowEntityInLevelEventArgs ShowEntityInLevelEventArgs = ReferencePool.Acquire <ShowEntityInLevelEventArgs>();

            ShowEntityInLevelEventArgs.EntityId    = entityId;
            ShowEntityInLevelEventArgs.Type        = entityType;
            ShowEntityInLevelEventArgs.ShowSuccess = showSuccess;
            ShowEntityInLevelEventArgs.EntityData  = entityData;
            return(ShowEntityInLevelEventArgs);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        private void OnShowEntityInLevel(object sender, GameEventArgs e)
        {
            ShowEntityInLevelEventArgs ne = (ShowEntityInLevelEventArgs)e;

            if (ne == null)
            {
                return;
            }

            levelControl.ShowEntity(ne.EntityId, ne.Type, ne.ShowSuccess, ne.EntityData);
        }
コード例 #5
0
        protected virtual void OnShowTowerLevelSuccess(Entity entity)
        {
            entityTowerLevel      = entity;
            entityLogicTowerLevel = entityTowerLevel.Logic as EntityTowerLevel;
            GameEntry.Entity.AttachEntity(entityTowerLevel, this.Entity);

            GameEntry.Event.Fire(this, ShowEntityInLevelEventArgs.Create(
                                     (int)EnumEntity.BuildPfx,
                                     typeof(EntityParticleAutoHide),
                                     null,
                                     EntityData.Create(transform.position, transform.rotation)));

            GameEntry.Sound.PlaySound(EnumSound.TDTowerUpgrade);
        }
コード例 #6
0
        protected virtual void Dead()
        {
            if (OnDead != null)
            {
                OnDead(this);
            }

            if (deadEffect != null)
            {
                GameEntry.Event.Fire(this, ShowEntityInLevelEventArgs.Create(
                                         (int)deadEffect.deadEffectEntity,
                                         typeof(EntityParticleAutoHide),
                                         null,
                                         EntityDataFollower.Create(randomSound ? randomSound.GetRandomSound() : EnumSound.None, transform.position + DeadEffectOffset, transform.rotation)));
            }
        }
コード例 #7
0
        protected void SpawnCollisionParticles()
        {
            if (collisionParticlesEntityId <= 0 || UnityEngine.Random.value > chanceToSpawnCollisionPrefab)
            {
                return;
            }

            if (!entityDataProjectile.EntityTargetable.IsDead)
            {
                Vector3 pos = entityDataProjectile.EntityTargetable.transform.position + entityDataProjectile.EntityTargetable.ApplyEffectOffset;
                GameEntry.Event.Fire(this, ShowEntityInLevelEventArgs.Create(
                                         collisionParticlesEntityId,
                                         typeof(EntityParticleAutoHide),
                                         null,
                                         EntityData.Create(pos, transform.rotation)));
            }
        }
コード例 #8
0
        private void ApplySlowEffect()
        {
            if (slowDownEffect == null && !loadSlowDownEffect)
            {
                GameEntry.Event.Fire(this, ShowEntityInLevelEventArgs.Create((int)EnumEntity.SlowFx,
                                                                             typeof(EntityAnimation),
                                                                             OnLoadSlowEffectSuccess,
                                                                             EntityDataFollower.Create(transform,
                                                                                                       ApplyEffectOffset,
                                                                                                       Vector3.one * ApplyEffectScale,
                                                                                                       EnumSound.None,
                                                                                                       transform.position,
                                                                                                       transform.rotation)
                                                                             )
                                     );

                loadSlowDownEffect = true;
            }
        }