コード例 #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();
            }
        }
コード例 #2
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)));
            }
        }
コード例 #3
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;
            }
        }