Revision 6281,
1.9 KB
checked in by mijoliim, 6 years ago
(diff) |
Wooo versionhallinta
|
Line | |
---|
1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | using Jypeli; |
---|
6 | |
---|
7 | public class Pointer : Widget |
---|
8 | { |
---|
9 | Widget Border = new Widget(24, 24); |
---|
10 | |
---|
11 | public Vector BorderPosition |
---|
12 | { |
---|
13 | get |
---|
14 | { |
---|
15 | return Border.Position; |
---|
16 | } |
---|
17 | set |
---|
18 | { |
---|
19 | Border.Position = value; |
---|
20 | Position = value + new Vector(0, -1); |
---|
21 | } |
---|
22 | } |
---|
23 | |
---|
24 | private Timer FlashTimer { get; set; } |
---|
25 | private bool _IsFlashing = false; |
---|
26 | public float FlashSpeed = 0.002f; |
---|
27 | public bool IsFlashing |
---|
28 | { |
---|
29 | get |
---|
30 | { |
---|
31 | return _IsFlashing; |
---|
32 | } |
---|
33 | set |
---|
34 | { |
---|
35 | _IsFlashing = value; |
---|
36 | if (value) |
---|
37 | { |
---|
38 | FlashTimer.Start(); |
---|
39 | } |
---|
40 | else if (!value) |
---|
41 | { |
---|
42 | FlashTimer.Stop(); |
---|
43 | } |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | public Pointer (Vector Position) |
---|
48 | : base(24, 25, Shape.Triangle) |
---|
49 | { |
---|
50 | this.Angle = Angle.FromDegrees(180); |
---|
51 | this.Position = Position + new Vector(0,-1); |
---|
52 | Border.Image = Images.HUD.Pointer; |
---|
53 | Border.Position = Position; |
---|
54 | |
---|
55 | float LerpAmount = 0; |
---|
56 | bool Increase = true; |
---|
57 | |
---|
58 | FlashTimer = new Timer(); |
---|
59 | FlashTimer.Interval = 0.001; |
---|
60 | FlashTimer.Timeout += delegate |
---|
61 | { |
---|
62 | if (LerpAmount > 1.0f) Increase = false; |
---|
63 | else if (LerpAmount < 0.0f) Increase = true; |
---|
64 | |
---|
65 | if (Increase) |
---|
66 | { |
---|
67 | LerpAmount = LerpAmount + FlashSpeed; |
---|
68 | } |
---|
69 | else if (!Increase) |
---|
70 | { |
---|
71 | LerpAmount = LerpAmount - FlashSpeed; |
---|
72 | } |
---|
73 | |
---|
74 | Color = Color.Lerp(Color.White, Color.Gold, LerpAmount); |
---|
75 | }; |
---|
76 | |
---|
77 | AddedToGame += delegate |
---|
78 | { |
---|
79 | JRPG.Game.Add(Border); |
---|
80 | }; |
---|
81 | |
---|
82 | Destroyed += delegate |
---|
83 | { |
---|
84 | Border.Destroy(); |
---|
85 | }; |
---|
86 | } |
---|
87 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.