From 80efc9790bf6e5170d40a2dbb6a9e0512a486f02 Mon Sep 17 00:00:00 2001 From: Naliwe GS Date: Tue, 25 Oct 2016 23:56:20 +0200 Subject: [PATCH] Gameplay fixes --- Assets/Scripts/GameController.cs | 3 ++- Assets/Scripts/Player.cs | 9 +++++++-- Assets/Scripts/Spawner.cs | 12 +++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 9de49cf..7e3c188 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -33,7 +33,8 @@ namespace Assets.Scripts var leftBorder = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x; if (!(rightBorder > (size.x*mult) - 5)) return; - BG = (GameObject) Instantiate(BG, new Vector3(size.x + tra.position.x - .5f, tra.position.y, 0), Quaternion.identity); + + BG = (GameObject) Instantiate(BG, new Vector3(size.x + tra.position.x - .5f, tra.position.y, 2), Quaternion.identity); tra = BG.GetComponent(); mult++; } diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 4e187f7..7715510 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -25,17 +25,22 @@ namespace Assets.Scripts var newPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); newPos.z = -1; - _pos.position = Vector3.Lerp(_pos.position, newPos, 10 * Time.deltaTime); + _pos.position = Vector3.Lerp(_pos.position, newPos, 10*Time.deltaTime); if (IsBlinking) Blink(); if (Battery < 12) { - PlayerPrefs.SetInt("highscore", Score); + if (PlayerPrefs.GetInt("highscore") < Score) + PlayerPrefs.SetInt("highscore", Score); SceneManager.LoadScene("GameOver"); } if (Progression == 25) + { + if (PlayerPrefs.GetInt("highscore") < Score) + PlayerPrefs.SetInt("highscore", Score); SceneManager.LoadScene("Win"); + } } public void Blink() diff --git a/Assets/Scripts/Spawner.cs b/Assets/Scripts/Spawner.cs index 15278f5..93ec543 100644 --- a/Assets/Scripts/Spawner.cs +++ b/Assets/Scripts/Spawner.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using System; +using UnityEngine; using System.Collections; public class Spawner : MonoBehaviour @@ -22,7 +23,7 @@ public class Spawner : MonoBehaviour _timer += Time.deltaTime; _rightBorder = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0)).x + 2; - if (_timer >= 2f) + if (_timer >= Math.Max((2 / (Time.time / 10)), .5f)) { Spawn(); _timer = 0f; @@ -35,9 +36,10 @@ public class Spawner : MonoBehaviour if (r < 20) Instantiate(StaticEnemy, new Vector3(_rightBorder, _rand.Next(1, 9), 0), Quaternion.identity); - else if (r < 50) - Instantiate(BasicEnemy, new Vector3(_rightBorder, _rand.Next(1, 9), 0), Quaternion.identity); - else + else if (r < 45) Instantiate(Toluen, new Vector3(_rightBorder, _rand.Next(1, 9), 0), Quaternion.identity); + r = _rand.Next(100); + if (r < 50) + Instantiate(BasicEnemy, new Vector3(_rightBorder, _rand.Next(1, 9), 0), Quaternion.identity); } } -- libgit2 0.27.0