public LightSource(Texture2D texture, Color color, float range, Vector2 position) { lightTexture = texture; this.color = color; offRange = 30; onRange = range; this.range = offRange; this.position = position; currentState = LightSourceState.OFF; timeElapsed = 0; timeStep = 40; rangeStep = 30; }
public void Update(GameTime gameTime) { if (currentState == LightSourceState.CHANGING) { timeElapsed += gameTime.ElapsedGameTime.TotalMilliseconds; if (timeElapsed > timeStep) { timeElapsed = 0; if (targetState == LightSourceState.OFF) { range -= rangeStep; } else { range += rangeStep; } if (range < offRange) { range = offRange; currentState = LightSourceState.OFF; } else if (range > onRange) { range = onRange; currentState = LightSourceState.ON; } } ObjectManager.Instance.LightCacheIsDirty = true; } }
public void SwitchState() { if (currentState != LightSourceState.CHANGING) { targetState = currentState == LightSourceState.ON ? LightSourceState.OFF : LightSourceState.ON; currentState = LightSourceState.CHANGING; } }