コード例 #1
0
ファイル: Pulse.cs プロジェクト: kustomzone/voxel-editor
    public override SensorComponent MakeComponent(GameObject gameObject)
    {
        PulseComponent pulse = gameObject.AddComponent <PulseComponent>();

        pulse.offTime = offTime;
        pulse.onTime  = onTime;
        pulse.startOn = startOn;
        return(pulse);
    }
コード例 #2
0
 void Awake()
 {
     // _button = GetComponent<Button>();
     // _defaultScale = _button.transform.localScale;
     _pulser = GetComponent <PulseComponent>();
     if (_pulser != null)
     {
         _pulser.enabled = false;
     }
 }
コード例 #3
0
 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);
     }
 }