public override SensorComponent MakeComponent(GameObject gameObject) { PulseComponent pulse = gameObject.AddComponent <PulseComponent>(); pulse.offTime = offTime; pulse.onTime = onTime; pulse.startOn = startOn; return(pulse); }
void Awake() { // _button = GetComponent<Button>(); // _defaultScale = _button.transform.localScale; _pulser = GetComponent <PulseComponent>(); if (_pulser != null) { _pulser.enabled = false; } }
public override void Update(float dt) { foreach (Entity pulseEntity in _pulseEntities) { PulseComponent pulseComp = pulseEntity.GetComponent <PulseComponent>(); SpriteComponent spriteComp = pulseEntity.GetComponent <SpriteComponent>(); pulseComp.Elapsed += dt; float beta = 0.5f * (float)Math.Cos(2 * MathHelper.Pi / pulseComp.Period * pulseComp.Elapsed) + 0.5f; spriteComp.Alpha = MathHelper.Lerp(pulseComp.AlphaMin, pulseComp.AlphaMax, beta); } }