-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathShapes.cs
75 lines (68 loc) · 1.66 KB
/
Shapes.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Roguelike
{
class Point
{
public int X { get; set; }
public int Y { get; set; }
public Point(int x, int y)
{
X = x;
Y = y;
}
public Point() { }
public bool IsPointEqual(Point x)
{
return ((x.X == this.X) && (x.Y == this.Y));
}
public void SetValue(int x, int y)
{
this.X = x;
this.Y = y;
}
public void SetValue(Point point)
{
this.X = point.X;
this.Y = point.Y;
}
public double GetDistance(Point x)
{
return Math.Sqrt(Math.Pow(x.X - this.X, 2) + Math.Pow(x.Y - this.Y, 2));
}
public Point Invert()
{
return new Point(Y, X);
}
public static void SwapPoints(ref Point x, ref Point y)
{
Point tmp = x;
x = y;
y = tmp;
}
}
class Rectangle
{
public Point Offset { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public Point Location { get; set; }
public Rectangle(int width, int height, Point location)
{
Width = width;
Height = height;
Location = location;
}
public Rectangle(int width, int height, int x, int y)
{
Width = width;
Height = height;
Location.X = x;
Location.Y = y;
}
public Rectangle() { }
}
}