protected override void Start() { base.Start(); if (!isServer) { return; } m_AnimAudioController = GetComponent <SporeGunAnimAudioController>(); if (NoduleProducer == null) { NoduleProducer = GetComponent <DaytimeNoduleProducer>(); } if (NoduleProducer == null) { Debug.LogError("NoduleProducer is set to null in SporeGun", this); } NoduleProducer.Type = NoduleType.SporeGun; NoduleProducer.RotationOption = NoduleSpawnRotationOption.Self; NoduleProducer.enabled = false; m_Grower = new ScaledGrowth(transform, DataStore.GetFloat(Data.SporeGunInitialScale), DataStore.GetFloat(Data.SporeGunFinalScaleMin), DataStore.GetFloat(Data.SporeGunFinalScaleMax)); AgeData.LifeSpan = DataStore.GetFloat(Data.SporeGunLifeSpan); AgeData.DaysToGrown = DataStore.GetFloat(Data.SporeGunDaysToGrown); NodulesPerDay = DataStore.GetInt(Data.SporeGunNodulesPerDay); NoduleFiringSpread = DataStore.GetFloat(Data.SporeGunNoduleFiringSpread); NoduleSpeed = DataStore.GetFloat(Data.SporeGunNoduleSpeed); NoduleProducer.NodulesPerCycle = NodulesPerDay; NoduleProducer.NoduleDirectionSpread = NoduleFiringSpread; NoduleProducer.OnNoduleSpawned += OnNoduleSpawn; GrowthBrain.In(GrowthState.Growing) .If(() => AgeData.DaysOld > AgeData.DaysToGrown) .GoTo(GrowthState.Grown) .ExecuteOnEntry(GrowingStart) .ExecuteWhileIn(GrowingUpdate); GrowthBrain.In(GrowthState.Grown) .If(() => AgeData.DaysOld > AgeData.LifeSpan) .GoTo(GrowthState.Dead) .ExecuteOnEntry(GrownStart) .ExecuteWhileIn(GrownUpdate, NoduleProducer.NoduleReleaseUpdate); GrowthBrain.In(GrowthState.Dead) .DoOnce(Die) .If(() => true) .GoTo(GrowthState.Growing); GrowthBrain.Initialize(GrowthState.Growing); }
protected override void Start() { base.Start(); if (!isServer) { return; } Grower = new ScaledGrowth(transform, DataStore.GetFloat(Data.FloatGLBladeInitialYScale), DataStore.GetFloat(Data.FloatGLBladeFinalYScaleMin), DataStore.GetFloat(Data.FloatGLBladeFinalYScaleMax), ScaledGrowth.GrowthAxes.All); NoduleProducer = GetComponent <DaytimeNoduleProducer>() ?? gameObject.AddComponent <DaytimeNoduleProducer>(); NoduleProducer.Type = NoduleType.Floating; DaysToGrown = DataStore.GetFloat(Data.FloatGLBladeDaysToGrown); FloatSpeed = DataStore.GetFloat(Data.FloatGLBladeFloatSpeed); FloatRange = DataStore.GetFloat(Data.FloatGLBladeFloatRange); CheckForPlayerRate = DataStore.GetFloat(Data.FloatGLBladePlayerCheckRate); CheckForPlayerRange = DataStore.GetFloat(Data.FloatGLBladePlayerCheckRange); NoduleProducer.NodulesPerCycle = DataStore.GetInt(Data.FloatGLBladeNodulesPerDay); NoduleProducer.NoduleDispersalRange = DataStore.GetInt(Data.FloatGLBladeNoduleDispersalRange); NodulesPerDay = NoduleProducer.NodulesPerCycle; NoduleDispersalRange = NoduleProducer.NoduleDispersalRange; m_FloatVel = new Vector3(0, Random.Range(0, 2) == 0 ? -FloatSpeed : FloatSpeed, 0); m_StartPos = transform.position; m_LifespawnModifier = Random.Range(.9f, 1.1f); m_SpeedModifier = Random.Range(.95f, 1.05f); GrowthBrain.In(GrowthState.Growing) .If(() => DaysOld > DaysToGrown * m_LifespawnModifier) .GoTo(GrowthState.Grown) .ExecuteOnEntry(GrowingStart) .ExecuteWhileIn(GrowingUpdate /*, AvoidPlayerUpdate*/, NoduleProducer.NoduleReleaseUpdate); GrowthBrain.In(GrowthState.Grown) .If(() => DaysOld > (DaysToGrown * 2f * m_LifespawnModifier)) .GoTo(GrowthState.Dead) .ExecuteOnEntry(GrownStart) .ExecuteWhileIn(GrownUpdate /*, AvoidPlayerUpdate*/, NoduleProducer.NoduleReleaseUpdate); GrowthBrain.In(GrowthState.Dead) .DoOnce(Die) .If(() => true) .GoTo(GrowthState.Growing); GrowthBrain.Initialize(GrowthState.Growing); }
private void Update() { if (isClient) { transform.localScale = Scale; } if (isServer) { GrowthBrain.Update(Time.deltaTime); DaysOld = DayClock.Singleton.SecondsToDays(Time.time - BirthTime); } }
public override void BladeUpdate(float dt) { if (DayClock.Singleton != null) { DaysOld = DayClock.Singleton.SecondsToDays(Time.time - BirthTime); } GrowthBrain.Update(dt); if (isServer && Grower != null && Grower.Scale.PercentDifference(m_Scale) > .03f) { m_Scale = Grower.Scale; } }
public override void BladeUpdate(float dt) { if (DayClock.Singleton != null) { DaysOld = DayClock.Singleton.SecondsToDays(Time.time - BirthTime); } GrowthBrain.Update(dt); if (isServer && Grower != null && Mathf.Abs(Grower.Scale - m_Scale) > (.03f * Grower.Scale)) { m_Scale = Grower.Scale; } }
protected override void Start() { base.Start(); if (!isServer) { return; } LifeSpan = DataStore.GetFloat(Data.PlantLifeSpan); DaysBeforeRebirth = DataStore.GetFloat(Data.PlantDaysBeforeRebirth); DaysToDoubleSize = DataStore.GetFloat(Data.PlantDaysToDoubleSize); DaysToDieInShade = DataStore.GetFloat(Data.PlantDaysToDieInShade); FullSizeMin = DataStore.GetFloat(Data.PlantFullSizeMin); FullSizeMax = DataStore.GetFloat(Data.PlantFullSizeMax); NodulesPerDay = DataStore.GetInt(Data.PlantNodulesPerDay); NoduleDispersalRange = DataStore.GetFloat(Data.PlantNoduleDispersalRange); m_LifeColor = GetComponent <Renderer>().material.color; DayClock.Singleton = FindObjectOfType <DayClock>(); GrowthBrain.In(GrowthState.Growing) .If(() => Scale.sqrMagnitude >= m_FinalScale.sqrMagnitude) .GoTo(GrowthState.Grown) .ExecuteOnEntry(GrowingStart) .ExecuteWhileIn(NoduleReleaseUpdate, GrowingUpdate); GrowthBrain.In(GrowthState.Grown) .If(() => DaysOld > LifeSpan) .GoTo(GrowthState.Dead) .ExecuteWhileIn(NoduleReleaseUpdate); GrowthBrain.In(GrowthState.Dead) .If(() => m_DaysDead > DaysBeforeRebirth) .GoTo(GrowthState.Growing) .ExecuteOnEntry(DeathStart) .ExecuteWhileIn(DeathUpdate) .ExecuteOnExit(DeathExit); GrowthBrain.Initialize(GrowthState.Growing); }
private void Update() { if (Scale != 0f) { transform.localScale = new Vector3(Scale, Scale, Scale); } if (!isServer) { return; } DaysOld = DayClock.Singleton.SecondsToDays(Time.time - BirthTime); GrowthBrain.Update(Time.deltaTime); if (isServer && m_Grower.Scale.PercentDifference(Scale) > .03f) { Scale = m_Grower.Scale; } }
protected override void Start() { base.Start(); if (!isServer) { return; } m_Grower = new ScaledGrowth(transform, DataStore.GetFloat(Data.AirPlantInitialScale), DataStore.GetFloat(Data.AirPlantFinalScaleMin), DataStore.GetFloat(Data.AirPlantFinalScaleMax)); LifeSpan = DataStore.GetFloat(Data.AirPlantLifeSpan); DaysToGrown = DataStore.GetFloat(Data.AirPlantDaysToGrown); GrowthBrain.In(GrowthState.Growing) .If(() => DaysOld > DaysToGrown) .GoTo(GrowthState.Grown) .ExecuteOnEntry(GrowingStart) .ExecuteWhileIn(GrowingUpdate); GrowthBrain.In(GrowthState.Grown) .If(() => DaysOld > LifeSpan) .GoTo(GrowthState.Dead) .ExecuteOnEntry(GrownStart) .ExecuteWhileIn(GrownUpdate); GrowthBrain.In(GrowthState.Dead) .DoOnce(Die) .If(() => true) .GoTo(GrowthState.Growing); GrowthBrain.Initialize(GrowthState.Growing); transform.rotation = Random.rotation; }
protected override void Start() { if (NoduleTarget == null) { Debug.LogError("NoduleTarget is set to null in SnatcherPlant", this); } if (TongueEnd == null) { Debug.LogError("TongueEnd is set to null in SnatcherPlant", this); } if (BodyCollider == null) { Debug.LogError("BodyCollider is set to null in SnatcherPlant", this); } base.Start(); m_Rigidbody = GetComponent <Rigidbody>(); m_AnimAudioController = GetComponent <SnatcherAnimAudioController>(); if (!isServer) { m_Rigidbody.isKinematic = true; } if (!isServer) { return; } m_AnimAudioController.OnTongueExtended += OnTongueExtended; m_AnimAudioController.OnAttackFinished += OnAttackFinished; m_AnimAudioController.OnReleaseSpore += OnReleaseSpore; m_AnimAudioController.OnDeathFinished += OnDeath; m_Grower = new ScaledGrowth(transform, DataStore.GetFloat(Data.SnatcherInitialScale), DataStore.GetFloat(Data.SnatcherFullScaleMin), DataStore.GetFloat(Data.SnatcherFullScaleMax)); NoduleDistance = DataStore.GetFloat(Data.SnatcherNoduleDistance); NoduleRespawnDelay = DataStore.GetFloat(Data.SnatcherNoduleRespawnDelay); DaysToGrown = DataStore.GetFloat(Data.SnatcherDaysToGrown); DaysBeforeVulnerable = DataStore.GetFloat(Data.SnatcherDaysBeforeVulnerable); FloatSpeed = DataStore.GetFloat(Data.SnatcherFloatSpeed); RotationSpeed = DataStore.GetFloat(Data.SnatcherRotationSpeed); ChildDelay = DataStore.GetFloat(Data.SnatcherChildDelay); m_TimeLastEaten = Time.time; GrowthBrain.In(GrowthState.Growing) .If(() => DaysOld > DaysToGrown) .GoTo(GrowthState.Grown) .ExecuteOnEntry(GrowingStart, FloatingStart) .ExecuteWhileIn(GrowingUpdate, FloatingUpdate, IdleActionUpdate); GrowthBrain.In(GrowthState.Grown) /*.If(() => m_Clock.SecondsToDays(m_TimeLastEaten - Time.time) > DaysBeforeVulnerable) * .GoTo(GrowthState.Dead)*/ .ExecuteOnEntry(GrownStart) .ExecuteWhileIn(GrownUpdate, FloatingUpdate, VulnerableUpdate, IdleActionUpdate); GrowthBrain.In(GrowthState.Dead) .DoOnce(Die); GrowthBrain.Initialize(GrowthState.Growing); }