protected virtual void OnChangeState(RenderChunkState state) { switch (state) { case RenderChunkState.FadeOut: case RenderChunkState.FadeOutToDel: { stateAniCurTime = stateAniDuration; break; } case RenderChunkState.FadeIn: { stateAniCurTime = stateAniDuration; color.A = 0; break; } } }
private void UpdateStateAnimation(GameTime gametime) { switch (state) { case RenderChunkState.FadeOut: case RenderChunkState.FadeOutToDel: { if (stateAniCurTime >= 0.0f) { color.A = (byte)(MathHelper.SmoothStep(origincolor.ToVector4().W, 0.0f, (stateAniDuration - stateAniCurTime) / stateAniDuration) * 255.0f); stateAniCurTime -= (float)gametime.ElapsedGameTime.TotalSeconds; if (stateAniCurTime < 0.0f) { color.A = 0; state = state == RenderChunkState.FadeOut ? RenderChunkState.Hide : RenderChunkState.Delete; } } break; } case RenderChunkState.FadeIn: { if (stateAniCurTime >= 0.0f) { color.A = (byte)(MathHelper.SmoothStep(0.0f, origincolor.ToVector4().W, (stateAniDuration - stateAniCurTime) / stateAniDuration) * 255.0f); stateAniCurTime -= (float)gametime.ElapsedGameTime.TotalSeconds; if (stateAniCurTime < 0.0f) { color.A = origincolor.A; state = RenderChunkState.Show; } } break; } } }
protected override sealed void OnChangeState(RenderChunkState state) { base.OnChangeState(state); for (int i = 0; i < childs.Count; ++i) { childs[i].State = state; } }