Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
BusyBarWidget.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class BusyBarWidget : Widget {
6 public const int m_barsCount = 5;
7
8 public const float m_barSize = 8f;
9
10 public const float m_barsSpacing = 24f;
11
12 public int m_boxIndex;
13
14 public double m_lastBoxesStepTime;
15
16 public Color LitBarColor { get; set; }
17
18 public Color UnlitBarColor { get; set; }
19
20 public BusyBarWidget() {
21 IsHitTestVisible = false;
22 LitBarColor = new Color(16, 140, 0);
23 UnlitBarColor = new Color(48, 48, 48);
24 }
25
26 public override void MeasureOverride(Vector2 parentAvailableSize) {
27 IsDrawRequired = true;
28 DesiredSize = new Vector2(120f, 12f);
29 }
30
31 public override void Draw(DrawContext dc) {
32 if (Time.RealTime - m_lastBoxesStepTime > 0.25) {
33 m_boxIndex++;
35 }
37 int count = flatBatch2D.TriangleVertices.Count;
38 for (int i = 0; i < 5; i++) {
39 Vector2 v = new((i + 0.5f) * 24f, 6f);
41 float v2 = i == m_boxIndex % 5 ? 12f : 8f;
42 flatBatch2D.QueueQuad(v - new Vector2(v2) / 2f, v + new Vector2(v2) / 2f, 0f, c * GlobalColorTransform);
43 }
44 flatBatch2D.TransformTriangles(GlobalTransform, count);
45 }
46 }
47}
Engine.Color Color
readonly DynamicArray< VertexPositionColor > TriangleVertices
void TransformTriangles(Matrix matrix, int start=0, int end=-1)
void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Color color)
FlatBatch2D FlatBatch(int layer=0, DepthStencilState depthStencilState=null, RasterizerState rasterizerState=null, BlendState blendState=null)
static double RealTime
定义 Time.cs:38
override void MeasureOverride(Vector2 parentAvailableSize)
override void Draw(DrawContext dc)
readonly PrimitivesRenderer2D PrimitivesRenderer2D
Color GlobalColorTransform
Vector2 DesiredSize
bool IsDrawRequired
virtual bool IsHitTestVisible
Matrix GlobalTransform