Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kukant committed Jun 15, 2020
1 parent d4147fc commit 6c9e602
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 63 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ crashlytics-build.properties


.DS_Store

v0.9.app/Contents/
2 changes: 1 addition & 1 deletion Assets/Scenes/GamePlayScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!82 &1873260204
AudioSource:
m_ObjectHideFlags: 0
Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/HealthBar.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor.UI;
using UnityEngine;

public class HealthBar : MonoBehaviour {
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/LaserEye.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void Start()
upTrans = GameObject.Find("ultraplex")?.transform;
if (!upTrans) {
Destroy(gameObject);
return;
}

movement = (upTrans.position - transform.position).normalized;
Expand Down
18 changes: 17 additions & 1 deletion Assets/Scripts/LevelScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class LevelScript : MonoBehaviour {
private int generations = 0;
private float generationRangeY = 4;
private Vector3 cameraInitPos;
private List<GameObject> generatedEnemies;

public void Start() {
initialPos = transform.position;
Expand All @@ -40,6 +41,7 @@ public void Load() {
lastCameraPos = 0f;
generations = 0;
}


public void Run() {
mcMovement.Run();
Expand All @@ -49,6 +51,15 @@ public void Restart() {
Destroy(movingBackground);
Destroy(player);

for (var i = 0; i < generatedEnemies.Count; i++) {
var e = generatedEnemies[i];
if (e != null) {
Destroy(e);
}
}

generatedEnemies.Clear();

transform.position = initialPos;
mainCamera.transform.position = cameraInitPos;

Expand All @@ -74,6 +85,10 @@ void FixedUpdate() {
}

private void generateEnemies(float fromX, float toX) {
if (generatedEnemies == null) {
generatedEnemies = new List<GameObject>();
}

float enemiesToGenerate = Convert.ToInt32(Random.value * enemiesPerIntervalBase) + generations;
generations++;

Expand All @@ -85,7 +100,8 @@ private void generateEnemies(float fromX, float toX) {
y = 0;
}

Instantiate(EnemiesPrefabs[enemIdx], new Vector2(x, y), EnemiesPrefabs[enemIdx].transform.rotation);
var e = Instantiate(EnemiesPrefabs[enemIdx], new Vector2(x, y), EnemiesPrefabs[enemIdx].transform.rotation);
generatedEnemies.Add(e);
}
}
}
26 changes: 23 additions & 3 deletions Assets/Scripts/MovingBackground.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using UnityEditor.UI;
using UnityEngine;
using UnityEngine.Serialization;
using Debug = UnityEngine.Debug;

using Object = UnityEngine.Object;

public class MovingBackground : MonoBehaviour {
Expand Down Expand Up @@ -46,6 +44,15 @@ void FixedUpdate() {
physicalBackgroundInstance.update(cameraXMin);
}

private void OnDestroy() {
if (physicalBackgroundInstance != null)
physicalBackgroundInstance.DestroyChildren();

if (slowBackgrounds != null)
for (var i = 0; i < slowBackgrounds.Count; i++) {
slowBackgrounds[i].DestroyChildren();
}
}
}

class PhysicalBackground {
Expand Down Expand Up @@ -75,8 +82,15 @@ public void update(float cameraXMin) {
);
Object.Destroy(instances.Dequeue());
}
}

public void DestroyChildren() {
while (instances.Count > 0) {
Object.Destroy(instances.Dequeue());
}
}


}


Expand Down Expand Up @@ -124,4 +138,10 @@ public void update(float cameraXMin, float cameraPos) {
go.transform.position = new Vector3(oldPos.x + slowdownStep + jump, oldPos.y);
}
}

public void DestroyChildren() {
for (var i = 0; i < backgrounds.Count; i++) {
Object.Destroy(backgrounds[i]);
}
}
}
120 changes: 63 additions & 57 deletions ProjectSettings/GraphicsSettings.asset
Original file line number Diff line number Diff line change
@@ -1,57 +1,63 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!30 &1
GraphicsSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_Deferred:
m_Mode: 1
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
m_DeferredReflections:
m_Mode: 1
m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
m_ScreenSpaceShadows:
m_Mode: 1
m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
m_LegacyDeferred:
m_Mode: 1
m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
m_DepthNormals:
m_Mode: 1
m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
m_MotionVectors:
m_Mode: 1
m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
m_LightHalo:
m_Mode: 1
m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
m_LensFlare:
m_Mode: 1
m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
m_AlwaysIncludedShaders:
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
m_CustomRenderPipeline: {fileID: 0}
m_TransparencySortMode: 0
m_TransparencySortAxis: {x: 0, y: 0, z: 1}
m_DefaultRenderingPath: 1
m_DefaultMobileRenderingPath: 1
m_TierSettings: []
m_LightmapStripping: 0
m_FogStripping: 0
m_InstancingStripping: 0
m_LightmapKeepPlain: 1
m_LightmapKeepDirCombined: 1
m_LightmapKeepDynamicPlain: 1
m_LightmapKeepDynamicDirCombined: 1
m_LightmapKeepShadowMask: 1
m_LightmapKeepSubtractive: 1
m_FogKeepLinear: 1
m_FogKeepExp: 1
m_FogKeepExp2: 1
m_AlbedoSwatchInfos: []
m_LightsUseLinearIntensity: 0
m_LightsUseColorTemperature: 0
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!30 &1
GraphicsSettings:
m_ObjectHideFlags: 0
serializedVersion: 13
m_Deferred:
m_Mode: 1
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
m_DeferredReflections:
m_Mode: 1
m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
m_ScreenSpaceShadows:
m_Mode: 1
m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
m_LegacyDeferred:
m_Mode: 1
m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
m_DepthNormals:
m_Mode: 1
m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
m_MotionVectors:
m_Mode: 1
m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
m_LightHalo:
m_Mode: 1
m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
m_LensFlare:
m_Mode: 1
m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
m_AlwaysIncludedShaders:
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
m_CustomRenderPipeline: {fileID: 0}
m_TransparencySortMode: 0
m_TransparencySortAxis: {x: 0, y: 0, z: 1}
m_DefaultRenderingPath: 1
m_DefaultMobileRenderingPath: 1
m_TierSettings: []
m_LightmapStripping: 0
m_FogStripping: 0
m_InstancingStripping: 0
m_LightmapKeepPlain: 1
m_LightmapKeepDirCombined: 1
m_LightmapKeepDynamicPlain: 1
m_LightmapKeepDynamicDirCombined: 1
m_LightmapKeepShadowMask: 1
m_LightmapKeepSubtractive: 1
m_FogKeepLinear: 1
m_FogKeepExp: 1
m_FogKeepExp2: 1
m_AlbedoSwatchInfos: []
m_LightsUseLinearIntensity: 0
m_LightsUseColorTemperature: 0
m_LogWhenShaderIsCompiled: 0
m_AllowEnlightenSupportForUpgradedProject: 1

0 comments on commit 6c9e602

Please sign in to comment.