-
Notifications
You must be signed in to change notification settings - Fork 0
/
Autoload.cs
98 lines (80 loc) · 1.97 KB
/
Autoload.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
using Godot;
using System;
using System.Collections.Generic;
public class Autoload : Node
{
public int score = 123;
public bool paused = false;
public int currentCommandBuffer = 0;
public String playerState = "";
public int level = 0;
public Random randomGenerator = null;
public float[] commandVelocity = new float[]{
1600, 1600, 1400, 1400, 1000, 1000, 800, 800, 800, 800
};
public float commandMinimumVelocity = 300;
public float[] commandLatencyFactor = new float[]{
0.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f
};
public float[] levelSpawnTime = new float[]{
3, 3, 3, 2.5f, 2.5f, 2.5f, 2, 2, 2, 2
};
public float[] asteroidInitialVelocity = new float[]{
50, 50, 50,
70, 70,
30, 30, 30
};
public double[] aimToShipRotation = new double[]{
Math.PI/4, Math.PI/2, 3*Math.PI/4,
0, Math.PI,
7*Math.PI/4, 3*Math.PI/2, 5*Math.PI/4
};
public void GotoScene(Node source, string destinationSceneName)
{
source.GetTree().ChangeScene("res://Scenes/"+destinationSceneName+".tscn");
}
public void Randomize()
{
if(randomGenerator == null)
randomGenerator = new Random();
}
public float GetCommandVelocityForCurrentLevel()
{
return commandVelocity[GetLevelForUseAsIndex()-1];
}
public float GetCommandLatencyFactorForCurrentLevel()
{
return commandLatencyFactor[GetLevelForUseAsIndex()-1];
}
public float GetLevelSpawnTimeForCurrentLevel()
{
return levelSpawnTime[GetLevelForUseAsIndex()-1];
}
public int GetLevelForUseAsIndex()
{
if(level > 10)
return 10;
else
return level;
}
public List<int> GenerateSpawnPattern()
{
List<int> result = new List<int>();
int counter = 0;
int maxCounter = randomGenerator.Next() % 2 + 3;
if (level==1 || level ==2)
maxCounter = level;
else
maxCounter = randomGenerator.Next() % 2 + 3;
while(counter < maxCounter)
{
int val = randomGenerator.Next() % 8 + 1;
if(result.IndexOf(val) == -1)
{
result.Add(val);
counter++;
}
}
return result;
}
}