-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions
64 lines (54 loc) · 1.26 KB
/
Functions
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
static class Functions
{
public static float random(float x, float y)
{
return Random.Range(x, y);
}
public static int randomInt(int x, int y)
{
return (int)Mathf.Round(Random.Range(x, y));
}
public static float SquaredDistance(Vector2 p1, Vector2 p2)
{
return (p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y);
}
}
[System.Serializable]
public class SerializableVector
{
public float x, y;
public Vector2 Vector2
{
get
{
return new Vector2(x, y);
}
set
{
x = value.x;
y = value.y;
}
}
public void SetVector2(Vector2 vector)
{
x = vector.x;
y = vector.y;
}
public SerializableVector() { x = y = 0f; }
public SerializableVector(Vector2 vector) : this(vector.x, vector.y) { }
public SerializableVector(float x_, float y_)
{
x = x_;
y = y_;
}
public void Random(float x1, float x2, float y1, float y2)
{
x = Functions.random(x1, x2);
y = Functions.random(y1, y2);
}
}