Skip to content

Commit

Permalink
added option to invert controls
Browse files Browse the repository at this point in the history
  • Loading branch information
maxilevi committed Nov 15, 2017
1 parent ba55c4d commit e8d6821
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Assets/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ OcclusionCullingSettings:
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 8
m_Fog: 1
m_Fog: 0
m_FogColor: {r: 0, g: 0, b: 0, a: 1}
m_FogMode: 1
m_FogDensity: 0.01
Expand Down
4 changes: 2 additions & 2 deletions Assets/Generation/ChunkLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private IEnumerator LoadChunks()
}
}
}
_lastRadius = GraphicsOptions.ChunkLoaderRadius;
_lastRadius = Options.ChunkLoaderRadius;
_lastOffset = Offset;
World.SortGenerationQueue();
}
Expand Down Expand Up @@ -119,7 +119,7 @@ private IEnumerator ManageChunksMesh()
continue;
}

if ((Chunks[i].Position - _playerPosition).sqrMagnitude > (GraphicsOptions.ChunkLoaderRadius) * .5f * Chunk.ChunkSize * (GraphicsOptions.ChunkLoaderRadius) * Chunk.ChunkSize * .5f )
if ((Chunks[i].Position - _playerPosition).sqrMagnitude > (Options.ChunkLoaderRadius) * .5f * Chunk.ChunkSize * (Options.ChunkLoaderRadius) * Chunk.ChunkSize * .5f )
{
World.RemoveChunk(Chunks[i]);
continue;
Expand Down
26 changes: 0 additions & 26 deletions Assets/GraphicsOptions.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Assets/GraphicsOptions.cs.meta

This file was deleted.

9 changes: 6 additions & 3 deletions Assets/Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using UnityEngine;
using System.Collections;
using Assets;

public class Movement : MonoBehaviour {

Expand Down Expand Up @@ -85,13 +86,15 @@ void Update () {
}

float scale = (Time.timeScale != 1) ? (1 / Time.timeScale) * .5f : 1;
KeyCode UpKey = (Options.Invert) ? KeyCode.W : KeyCode.S;
KeyCode DownKey = (Options.Invert) ? KeyCode.S : KeyCode.W;

if (Input.GetKey(KeyCode.W))
if (Input.GetKey(UpKey))
{
transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles + Vector3.right * Time.deltaTime * 64f * TurnSpeed * scale);
}

if (Input.GetKey(KeyCode.S))
if (Input.GetKey(DownKey))
{
transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles - Vector3.right * Time.deltaTime * 64f * TurnSpeed * scale);
}
Expand Down Expand Up @@ -119,7 +122,7 @@ void StartTrail(ref TrailRenderer Trail, Vector3 Position){
Trail.startColor = TrailColor;
Trail.transform.localPosition = Position;
Trail.material = TrailMaterial;
Trail.time = 3;
Trail.time = 1.5f;
}

void StopTrail(ref TrailRenderer Trail){
Expand Down
4 changes: 2 additions & 2 deletions Assets/Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9b67576e7da945d4abe2e66b1d91a4a9, type: 3}
m_Name:
m_EditorClassIdentifier:
Speed: 16
Speed: 12
TurnSpeed: 2.75
LeftTrail: {fileID: 96019907841751074}
RightTrail: {fileID: 96556101435154620}
TrailColor: {r: 1, g: 0.5568628, b: 0, a: 1}
TrailColor: {r: 1, g: 0.30980393, b: 0, a: 1}
LeftPosition: {x: 3, y: -0.6, z: -0.9}
RightPosition: {x: -3, y: -0.6, z: -0.9}
TrailMaterial: {fileID: 10306, guid: 0000000000000000f000000000000000, type: 0}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Ship1.mat
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ Material:
- _Color: {r: 0.28676468, g: 0.28676468, b: 0.28676468, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _GColor: {r: 1, g: 0.30980393, b: 0, a: 1}
- _WColor: {r: 1, g: 0.31034487, b: 0, a: 1}
- _WColor: {r: 1, g: 0.31034487, b: 0, a: 1}
8 changes: 4 additions & 4 deletions Assets/Terrain.mat
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Material:
- _WUV: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 0.39215687, b: 0, a: 1}
- _EmissionColor: {r: 1, g: 0.39215687, b: 0, a: 1}
- _GColor: {r: 1, g: 0.39215687, b: 0, a: 1}
- _WColor: {r: 1, g: 0.39215687, b: 0, a: 1}
- _Color: {r: 0.9999998, g: 0.39215696, b: 4e-45, a: 1}
- _EmissionColor: {r: 0.9999998, g: 0.39215696, b: 4e-45, a: 1}
- _GColor: {r: 0.9999998, g: 0.39215696, b: 4e-45, a: 1}
- _WColor: {r: 0.9999998, g: 0.39215696, b: 4e-45, a: 1}
14 changes: 13 additions & 1 deletion Assets/TimeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using UnityEngine.UI;
using UnityStandardAssets.ImageEffects;
using Assets.Generation;
using Assets;

public class TimeControl : MonoBehaviour {

Expand All @@ -26,9 +27,12 @@ public class TimeControl : MonoBehaviour {
public Text GameOver;
public RawImage Title;
public Text RestartBtn, StartBtn;
private float _targetGameOver, _targetRestart, _targetScore, _targetStart, _targetTitle, _targetPitch = 1;
private float _targetGameOver, _targetRestart, _targetScore, _targetStart, _targetTitle, _targetPitch = 1, _targetInvert;
public GameObject PlayerPrefab;
public AudioSource Sound;
public Text InvertTxt;
public Image InvertCheck;
public Toggle Invert;

void Start(){
Lost = true;
Expand Down Expand Up @@ -118,11 +122,15 @@ void Update(){
Score.text = ((int) _score).ToString();
ScoreCenter.text = Score.text;

_targetInvert = Mathf.Min (1, _targetScore + _targetTitle);
Sound.pitch = Mathf.Lerp (Sound.pitch, _targetPitch, Time.deltaTime * 8f);
Title.color = new Color(Title.color.r, Title.color.g, Title.color.b, Mathf.Lerp (Title.color.a, _targetTitle, Time.deltaTime * 4f * (1/Time.timeScale)));
StartBtn.color = new Color(StartBtn.color.r, StartBtn.color.g, StartBtn.color.b, Mathf.Lerp (StartBtn.color.a, _targetStart, Time.deltaTime * 4f * (1/Time.timeScale)));
GameOver.color = new Color(GameOver.color.r, GameOver.color.g, GameOver.color.b, Mathf.Lerp (GameOver.color.a, _targetGameOver, Time.deltaTime * 4f * (1/Time.timeScale)));
RestartBtn.color = new Color(RestartBtn.color.r, RestartBtn.color.g, RestartBtn.color.b, Mathf.Lerp (RestartBtn.color.a, _targetRestart, Time.deltaTime * 4f * (1/Time.timeScale)));
Invert.targetGraphic.color = new Color (Invert.targetGraphic.color.r, Invert.targetGraphic.color.g, Invert.targetGraphic.color.b, Mathf.Lerp(Invert.targetGraphic.color.a, _targetInvert, Time.deltaTime * 4f * (1/Time.timeScale)));
InvertTxt.color = new Color(InvertTxt.color.r, InvertTxt.color.g, InvertTxt.color.b, Mathf.Lerp (InvertTxt.color.a, _targetInvert, Time.deltaTime * 4f * (1/Time.timeScale)));
InvertCheck.color = new Color(InvertCheck.color.r, InvertCheck.color.g, InvertCheck.color.b, Mathf.Lerp (InvertCheck.color.a, _targetTitle, Time.deltaTime * 4f * (1/Time.timeScale)));
if (_targetTitle != 1) {
Score.color = new Color (Score.color.r, Score.color.g, Score.color.b, Mathf.Lerp (Score.color.a, 1 - _targetScore, Time.deltaTime * 2f * (1 / Time.timeScale)));
ScoreCenter.color = new Color (ScoreCenter.color.r, ScoreCenter.color.g, ScoreCenter.color.b, Mathf.Lerp (ScoreCenter.color.a, _targetScore, Time.deltaTime * 2f * (1 / Time.timeScale)));
Expand Down Expand Up @@ -159,6 +167,10 @@ void Update(){
_score += Time.deltaTime * 8;
}

public void InvertControls(){
Options.Invert = Options.Invert;
}

Vector2 Lerp(Vector2 a, Vector2 b, float d){
return new Vector2 ( Mathf.Lerp(a.x,b.x,d), Mathf.Lerp(b.x,b.y,d) );
}
Expand Down
19 changes: 8 additions & 11 deletions project-skylines.userprefs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<Properties StartupItem="Assembly-CSharp.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\Movement.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\Generation\MeshQueue.cs">
<Files>
<File FileName="Assets\Generation\Chunk.cs" Line="101" Column="52" />
<File FileName="Assets\TimeControl.cs" Line="86" Column="15" />
<File FileName="Assets\ShipCollision.cs" Line="28" Column="6" />
<File FileName="Assets\World.cs" Line="81" Column="1" />
<File FileName="Assets\Generation\ChunkLoader.cs" Line="112" Column="10" />
<File FileName="Assets\FollowShip.cs" Line="12" Column="188" />
<File FileName="Assets\Generation\WorldGenerator.cs" Line="37" Column="27" />
<File FileName="Assets\Generation\GenerationQueue.cs" Line="1" Column="1" />
<File FileName="Assets\Explode.cs" Line="47" Column="45" />
<File FileName="Assets\Movement.cs" Line="100" Column="42" />
<File FileName="Assets\Generation\ChunkLoader.cs" Line="61" Column="22" />
<File FileName="Assets\FollowShip.cs" Line="12" Column="31" />
<File FileName="Assets\Movement.cs" Line="57" Column="59" />
<File FileName="Assets\Generation\MeshQueue.cs" Line="30" Column="4" />
<File FileName="Assets\Generation\Chunk.cs" Line="105" Column="6" />
<File FileName="Assets\Generation\WorldGenerator.cs" Line="47" Column="136" />
<File FileName="Assets\Generation\GenerationQueue.cs" Line="26" Column="4" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
Expand Down

0 comments on commit e8d6821

Please sign in to comment.