-
Notifications
You must be signed in to change notification settings - Fork 1
/
Animations.cs
145 lines (140 loc) · 4.93 KB
/
Animations.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Maid
{
class Animations
{
List<string> idleAnimation = new List<string>
{
"pack://application:,,,/images/idle1.png"
};
List<string> runAnimation = new List<string>
{
"pack://application:,,,/images/run1.png",
"pack://application:,,,/images/run2.png"
};
List<string> climbAnimation = new List<string>
{
"pack://application:,,,/images/climb1.png",
"pack://application:,,,/images/climb2.png",
"pack://application:,,,/images/climb3.png"
};
List<string> dragAnimation = new List<string>
{
"pack://application:,,,/images/drag.png",
};
List<string> dragRight = new List<string>
{
//"pack://application:,,,/images/dragRight1.png",
"pack://application:,,,/images/dragRight2.png",
};
List<string> dragLeft = new List<string>
{
//"pack://application:,,,/images/dragLeft1.png",
"pack://application:,,,/images/dragLeft2.png",
};
List<string> fallAnimation = new List<string>
{
"pack://application:,,,/images/fall1.png",
};
int playerCounter = 0;
public void PlayPlayerAnimation(Rectangle avatarCanvas, string avatarState,bool climbing)
{
if (MainWindow.dragged)
{
{
if (playerCounter >= dragAnimation.Count)
{
playerCounter = 0;
}
avatarCanvas.Fill = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(dragAnimation[playerCounter], UriKind.Absolute))
};
playerCounter++;
}
}
else
{
if (climbing)
{
if (playerCounter >= climbAnimation.Count)
{
playerCounter = 0;
}
avatarCanvas.Fill = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(climbAnimation[playerCounter], UriKind.Absolute))
};
playerCounter++;
}
else if (avatarState == "idle")
{
if (playerCounter >= idleAnimation.Count)
{
playerCounter = 0;
}
avatarCanvas.Fill = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(idleAnimation[playerCounter], UriKind.Absolute))
};
playerCounter++;
}
else if (avatarState == "runRight" || avatarState == "runLeft")
{
if (playerCounter >= runAnimation.Count)
{
playerCounter = 0;
}
avatarCanvas.Fill = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(runAnimation[playerCounter], UriKind.Absolute))
};
playerCounter++;
}
else if (avatarState == "dragRight")
{
if (playerCounter >= dragRight.Count)
{
playerCounter = 0;
}
avatarCanvas.Fill = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(dragRight[playerCounter], UriKind.Absolute))
};
playerCounter++;
}
else if (avatarState == "dragLeft")
{
if (playerCounter >= dragLeft.Count)
{
playerCounter = 0;
}
avatarCanvas.Fill = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(dragLeft[playerCounter], UriKind.Absolute))
};
playerCounter++;
}
else if (avatarState == "fall")
{
if (playerCounter >= fallAnimation.Count)
{
playerCounter = 0;
}
avatarCanvas.Fill = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(fallAnimation[playerCounter], UriKind.Absolute))
};
playerCounter++;
}
}
}
}
}