-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainFish.cs
113 lines (91 loc) · 3.29 KB
/
MainFish.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
using System;
using System.Reflection.Metadata;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using static System.Formats.Asn1.AsnWriter;
namespace rybki
{
public class MainFish : Fish
{
public bool ToUp { get; set; }
public Image Image { get { return image; } }
public Point position { get; set; }
public MainFish(string imagePath, int speed, bool toright, int score, Point initialPosition)
: base(imagePath, speed, toright, score, initialPosition)
{
image = new Image();
image.Source = new BitmapImage(new Uri(imagePath, UriKind.Relative));
image.Width = score*10;
image.Height = score*10;
Speed = speed;
position = initialPosition;
ToRight = true;
Points = score;
InitializePosition();
// image.Background = Brushes.Transparent;
}
public new void ResetPosition()
{
position = new Point(0, 0);
image.Width = Points * 10;
image.Height = Points * 10;
image.Visibility = Visibility.Hidden;
InitializePosition();
}
public void MoveLeft()
{
image.Margin = new Thickness(image.Margin.Left - Speed, image.Margin.Top, 0, 0);
if (ToRight)
{
image.RenderTransformOrigin = new Point(0.5, 0.5);
image.RenderTransform = new ScaleTransform(-1, 1);
}
ToRight = false;
}
public void MoveRight()
{
image.Margin = new Thickness(image.Margin.Left + Speed, image.Margin.Top, 0, 0);
if (!ToRight)
{
image.RenderTransformOrigin = new Point(0.5, 0.5);
image.RenderTransform = new ScaleTransform(1, 1);
}
ToRight = true;
}
public void MoveDown()
{
image.Margin = new Thickness(image.Margin.Left, image.Margin.Top + Speed, 0, 0);
if (!ToRight)
{
image.RenderTransformOrigin = new Point(0.5, 0.5);
image.RenderTransform = new ScaleTransform(1, 1);
}
image.RenderTransform = new RotateTransform(90);
ToRight = true;
}
public void MoveUp()
{
image.Margin = new Thickness(image.Margin.Left, image.Margin.Top - Speed, 0, 0);
if (!ToRight)
{
image.RenderTransformOrigin = new Point(0.5, 0.5);
image.RenderTransform = new ScaleTransform(1, 1);
}
image.RenderTransform = new RotateTransform(-90);
ToRight = true;
}
public void SetNormal(int angle)
{
image.RenderTransformOrigin = new Point(0.5, 0.5);
image.RenderTransform = new RotateTransform(angle);
}
public void Eat(int fishPoints)
{
Points += (int)(fishPoints/2);
image.Width = Points * 10;
image.Height = Points * 10;
}
}
}