void AddLife(float heal) { if (_invulnerable) { return; } Hp += heal; LightsModule.SetLifeValue(Hp / maxHP); }
void SubstractLife(float damage, Vector3 hitPosition) { if (_invulnerable) { return; } if (_vibrationAvailable) { ApplyVibration(0, 2, 0.2f); _vibrationAvailable = false; StartCoroutine(VibrationCooldown()); } Hp -= damage; LightsModule.SetLifeValue(Hp / maxHP); _lifeForcefield.TakeDamage(hitPosition); }
/// <summary> /// Create VGO_PS_LightsModule from LightsModule. /// </summary> /// <param name="module"></param> /// <returns></returns> protected virtual VGO_PS_LightsModule CreateVgoModule(LightsModule module) { return(new VGO_PS_LightsModule() { enabled = module.enabled, ratio = module.ratio, useRandomDistribution = module.useRandomDistribution, light = VgoLightConverter.CreateFrom(module.light), useParticleColor = module.useParticleColor, sizeAffectsRange = module.sizeAffectsRange, alphaAffectsIntensity = module.alphaAffectsIntensity, range = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.range), rangeMultiplier = module.rangeMultiplier, intensity = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.intensity), intensityMultiplier = module.intensityMultiplier, maxLights = module.maxLights, }); }
protected override YAMLMappingNode ExportYAMLRoot(IAssetsExporter exporter) { #warning TODO: values acording to read version (current 2017.3.0f3) YAMLMappingNode node = base.ExportYAMLRoot(exporter); node.AddSerializedVersion(GetSerializedVersion(exporter.Version)); node.Add("lengthInSec", LengthInSec); node.Add("simulationSpeed", SimulationSpeed); node.Add("stopAction", StopAction); node.Add("looping", Looping); node.Add("prewarm", Prewarm); node.Add("playOnAwake", PlayOnAwake); node.Add("useUnscaledTime", UseUnscaledTime); node.Add("autoRandomSeed", AutoRandomSeed); node.Add("useRigidbodyForVelocity", UseRigidbodyForVelocity); node.Add("startDelay", StartDelay.ExportYAML(exporter)); node.Add("moveWithTransform", MoveWithTransform); node.Add("moveWithCustomTransform", MoveWithCustomTransform.ExportYAML(exporter)); node.Add("scalingMode", ScalingMode); node.Add("randomSeed", RandomSeed); node.Add("InitialModule", InitialModule.ExportYAML(exporter)); node.Add("ShapeModule", ShapeModule.ExportYAML(exporter)); node.Add("EmissionModule", EmissionModule.ExportYAML(exporter)); node.Add("SizeModule", SizeModule.ExportYAML(exporter)); node.Add("RotationModule", RotationModule.ExportYAML(exporter)); node.Add("ColorModule", ColorModule.ExportYAML(exporter)); node.Add("UVModule", UVModule.ExportYAML(exporter)); node.Add("VelocityModule", VelocityModule.ExportYAML(exporter)); node.Add("InheritVelocityModule", InheritVelocityModule.ExportYAML(exporter)); node.Add("ForceModule", ForceModule.ExportYAML(exporter)); node.Add("ExternalForcesModule", ExternalForcesModule.ExportYAML(exporter)); node.Add("ClampVelocityModule", ClampVelocityModule.ExportYAML(exporter)); node.Add("NoiseModule", NoiseModule.ExportYAML(exporter)); node.Add("SizeBySpeedModule", SizeBySpeedModule.ExportYAML(exporter)); node.Add("RotationBySpeedModule", RotationBySpeedModule.ExportYAML(exporter)); node.Add("ColorBySpeedModule", ColorBySpeedModule.ExportYAML(exporter)); node.Add("CollisionModule", CollisionModule.ExportYAML(exporter)); node.Add("TriggerModule", TriggerModule.ExportYAML(exporter)); node.Add("SubModule", SubModule.ExportYAML(exporter)); node.Add("LightsModule", LightsModule.ExportYAML(exporter)); node.Add("TrailModule", TrailModule.ExportYAML(exporter)); node.Add("CustomDataModule", CustomDataModule.ExportYAML(exporter)); return(node); }
/// <summary> /// Set ParticleSystem lightsModule field value. /// </summary> /// <param name="particleSystem"></param> /// <param name="vgoModule"></param> protected virtual void SetModuleValue(ParticleSystem particleSystem, VGO_PS_LightsModule vgoModule) { if (vgoModule == null) { return; } LightsModule module = particleSystem.lights; module.enabled = vgoModule.enabled; module.ratio = vgoModule.ratio; module.useRandomDistribution = vgoModule.useRandomDistribution; module.useParticleColor = vgoModule.useParticleColor; module.sizeAffectsRange = vgoModule.sizeAffectsRange; module.alphaAffectsIntensity = vgoModule.alphaAffectsIntensity; module.range = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.range); module.rangeMultiplier = vgoModule.rangeMultiplier; module.intensity = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.intensity); module.intensityMultiplier = vgoModule.intensityMultiplier; module.maxLights = vgoModule.maxLights; if (vgoModule.light != null) { // @notice Light goLight = particleSystem.gameObject.GetComponent <Light>(); if (goLight == null) { goLight = particleSystem.gameObject.AddComponent <Light>(); } VgoLightConverter.SetComponentValue(goLight, vgoModule.light); goLight.enabled = false; module.light = goLight; if (Application.isEditor) { // @todo } } }
public override void Read(AssetReader reader) { base.Read(reader); LengthInSec = reader.ReadSingle(); if (IsStartDelayFirst(reader.Version)) { if (HasStartDelaySingle(reader.Version)) { StartDelaySingle = reader.ReadSingle(); } else { StartDelay.Read(reader); } } SimulationSpeed = reader.ReadSingle(); if (HasStopAction(reader.Version)) { StopAction = (ParticleSystemStopAction)reader.ReadInt32(); } if (IsRandomSeedFirst(reader.Version)) { RandomSeed = unchecked ((int)reader.ReadUInt32()); } if (HasCullingMode(reader.Version)) { CullingMode = (ParticleSystemCullingMode)reader.ReadInt32(); RingBufferMode = (ParticleSystemRingBufferMode)reader.ReadInt32(); RingBufferLoopRange.Read(reader); } Looping = reader.ReadBoolean(); Prewarm = reader.ReadBoolean(); PlayOnAwake = reader.ReadBoolean(); if (HasUseUnscaledTime(reader.Version)) { UseUnscaledTime = reader.ReadBoolean(); } if (IsMoveWithTransformBool(reader.Version)) { MoveWithTransform = reader.ReadBoolean() ? ParticleSystemSimulationSpace.Local : ParticleSystemSimulationSpace.World; } if (HasAutoRandomSeed(reader.Version)) { AutoRandomSeed = reader.ReadBoolean(); } if (HasUseRigidbodyForVelocity(reader.Version)) { UseRigidbodyForVelocity = reader.ReadBoolean(); } if (IsAlign(reader.Version)) { reader.AlignStream(); } if (!IsStartDelayFirst(reader.Version)) { StartDelay.Read(reader); reader.AlignStream(); } if (!IsMoveWithTransformBool(reader.Version)) { MoveWithTransform = (ParticleSystemSimulationSpace)reader.ReadInt32(); reader.AlignStream(); } if (HasMoveWithCustomTransform(reader.Version)) { MoveWithCustomTransform.Read(reader); } if (HasScalingMode(reader.Version)) { ScalingMode = (ParticleSystemScalingMode)reader.ReadInt32(); } if (!IsRandomSeedFirst(reader.Version)) { RandomSeed = reader.ReadInt32(); } InitialModule.Read(reader); ShapeModule.Read(reader); EmissionModule.Read(reader); SizeModule.Read(reader); RotationModule.Read(reader); ColorModule.Read(reader); UVModule.Read(reader); VelocityModule.Read(reader); if (HasInheritVelocityModule(reader.Version)) { InheritVelocityModule.Read(reader); } ForceModule.Read(reader); if (HasExternalForcesModule(reader.Version)) { ExternalForcesModule.Read(reader); } ClampVelocityModule.Read(reader); if (HasNoiseModule(reader.Version)) { NoiseModule.Read(reader); } SizeBySpeedModule.Read(reader); RotationBySpeedModule.Read(reader); ColorBySpeedModule.Read(reader); CollisionModule.Read(reader); if (HasTriggerModule(reader.Version)) { TriggerModule.Read(reader); } SubModule.Read(reader); if (HasLightsModule(reader.Version)) { LightsModule.Read(reader); TrailModule.Read(reader); } if (HasCustomDataModule(reader.Version)) { CustomDataModule.Read(reader); } }
public override void Read(AssetStream stream) { base.Read(stream); LengthInSec = stream.ReadSingle(); if (IsStartDelayFirst(stream.Version)) { if (IsReadStartDelaySingle(stream.Version)) { StartDelaySingle = stream.ReadSingle(); } else { StartDelay.Read(stream); } } SimulationSpeed = stream.ReadSingle(); if (IsReadStopAction(stream.Version)) { StopAction = stream.ReadInt32(); } if (IsRandomSeedFirst(stream.Version)) { RandomSeed = unchecked ((int)stream.ReadUInt32()); } Looping = stream.ReadBoolean(); Prewarm = stream.ReadBoolean(); PlayOnAwake = stream.ReadBoolean(); if (IsReadUseUnscaledTime(stream.Version)) { UseUnscaledTime = stream.ReadBoolean(); } if (IsMoveWithTransformBool(stream.Version)) { MoveWithTransform = stream.ReadBoolean() ? 1 : 0; } if (IsReadAutoRandomSeed(stream.Version)) { AutoRandomSeed = stream.ReadBoolean(); } if (IsReadUseRigidbodyForVelocity(stream.Version)) { UseRigidbodyForVelocity = stream.ReadBoolean(); } if (IsAlign(stream.Version)) { stream.AlignStream(AlignType.Align4); } if (!IsStartDelayFirst(stream.Version)) { StartDelay.Read(stream); stream.AlignStream(AlignType.Align4); } if (!IsMoveWithTransformBool(stream.Version)) { MoveWithTransform = stream.ReadInt32(); stream.AlignStream(AlignType.Align4); } if (IsReadMoveWithCustomTransform(stream.Version)) { MoveWithCustomTransform.Read(stream); } if (IsReadScalingMode(stream.Version)) { ScalingMode = stream.ReadInt32(); } if (!IsRandomSeedFirst(stream.Version)) { RandomSeed = stream.ReadInt32(); } InitialModule.Read(stream); ShapeModule.Read(stream); EmissionModule.Read(stream); SizeModule.Read(stream); RotationModule.Read(stream); ColorModule.Read(stream); UVModule.Read(stream); VelocityModule.Read(stream); if (IsReadInheritVelocityModule(stream.Version)) { InheritVelocityModule.Read(stream); } ForceModule.Read(stream); if (IsReadExternalForcesModule(stream.Version)) { ExternalForcesModule.Read(stream); } ClampVelocityModule.Read(stream); if (IsReadNoiseModule(stream.Version)) { NoiseModule.Read(stream); } SizeBySpeedModule.Read(stream); RotationBySpeedModule.Read(stream); ColorBySpeedModule.Read(stream); CollisionModule.Read(stream); if (IsReadTriggerModule(stream.Version)) { TriggerModule.Read(stream); } SubModule.Read(stream); if (IsReadLightsModule(stream.Version)) { LightsModule.Read(stream); TrailModule.Read(stream); } if (IsReadCustomDataModule(stream.Version)) { CustomDataModule.Read(stream); } }
public void ResetHP() { Hp = maxHP; LightsModule.SetLifeValue(Hp / maxHP); }