Skip to content

Commit

Permalink
now score starts counting when you are out of the spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
maxilevi committed Dec 28, 2017
1 parent 27ee91e commit 52a6983
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Assets/Generation/WorldGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace Assets.Generation
{
public class WorldGenerator : IDisposable
{
public const float SpawnRadius = 64f;
public static Vector3 SpawnPosition = Vector3.forward * 32f;

public void BuildArray(float[][][] Densities)
{
for (int x = 0; x < Chunk.ChunkSize; x++)
Expand Down Expand Up @@ -42,7 +45,7 @@ public void Generate(float[][][] Densities, Vector3 Offsets)
Densities [x] [y] [z] = Mathf.Lerp (prev, next, (float) (z / (float) lerp) );

//Make a sphere on spawn point
Densities [x] [y] [z] = ( ( Vector3.forward * 32f - new Vector3(x + Offsets.x, y + Offsets.y, z + Offsets.z) ).sqrMagnitude < 64f*64f) ? 0 : Densities[x][y][z];
Densities [x] [y] [z] = ( ( SpawnPosition - new Vector3(x + Offsets.x, y + Offsets.y, z + Offsets.z) ).sqrMagnitude < SpawnRadius*SpawnRadius) ? 0 : Densities[x][y][z];
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Assets/Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using UnityEngine;
using System.Collections;
using Assets;
using Assets.Generation;

public class Movement : MonoBehaviour {

Expand All @@ -23,6 +24,10 @@ public class Movement : MonoBehaviour {
private float _originalVolume;
private float _speed = 0;

public bool IsInSpawn{
get{ return (transform.parent.position - WorldGenerator.SpawnPosition).sqrMagnitude < WorldGenerator.SpawnRadius * WorldGenerator.SpawnRadius; }
}

void Start(){
Debris = GameObject.FindGameObjectWithTag ("Debris");
LeftSource = GameObject.FindGameObjectWithTag ("LeftSource").GetComponent<AudioSource>();
Expand Down
4 changes: 3 additions & 1 deletion Assets/TimeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ void Update(){
if(!Using)
WasPressed = Input.GetKey(KeyCode.Space);

_score += Time.deltaTime * 8;
if(!_movement.IsInSpawn)
_score += Time.deltaTime * 8;

if (_score < 125)
_movement.Speed = 12;
else if (_score < 275)
Expand Down
6 changes: 3 additions & 3 deletions project-skylines.userprefs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Properties StartupItem="Assembly-CSharp.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\Generation\GenerationQueue.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\Generation\MeshQueue.cs">
<Files>
<File FileName="Assets\Generation\GenerationQueue.cs" Line="24" Column="25" />
<File FileName="Assets\Generation\MeshQueue.cs" Line="10" Column="19" />
<File FileName="Assets\Generation\GenerationQueue.cs" Line="1" Column="1" />
<File FileName="Assets\Generation\MeshQueue.cs" Line="29" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
Expand Down

0 comments on commit 52a6983

Please sign in to comment.