diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab new file mode 100644 index 0000000..ff80f6a Binary files /dev/null and b/Assets/Prefabs/Player.prefab differ diff --git a/Assets/Prefabs/Player.prefab.meta b/Assets/Prefabs/Player.prefab.meta new file mode 100644 index 0000000..8f012fd --- /dev/null +++ b/Assets/Prefabs/Player.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b8da779ffb69b984dbd3e41d6e16ffbb +timeCreated: 1477389059 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Collectible.cs b/Assets/Scripts/Collectible.cs index bb63eac..a76b08c 100644 --- a/Assets/Scripts/Collectible.cs +++ b/Assets/Scripts/Collectible.cs @@ -17,7 +17,8 @@ public class Collectible : MonoBehaviour void OnTriggerEnter2D(Collider2D other) { - gameObject.SetActive(false); + Destroy(gameObject); _player.GetComponent().Score += 10; + _player.GetComponent().Progression += 1; } } \ No newline at end of file diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 64cd759..1223385 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -5,52 +5,23 @@ using System; namespace Assets.Scripts { - internal class CADelegates - { - static System.Random r = new System.Random(); - - public static bool CanGrow(Cell cell) - { - if (cell.Position.y == 0) - return true; - if (cell.Position.x%4 == 0) - return cell.Position.y < 16 && ((100/cell.Position.y)) > 6 + r.Next(94); - return false; - } - } - public class GameController : MonoBehaviour { public static int PoolSize = 256; public GameObject Wall; + public GameObject BG; private Map _map; - private ObjectPool _pooledWalls; - private ObjectPool _pooledActors; - private ObjectPool _pooledProjectiles; - - private CellularAutomaton _ca; - - private GameObject[] _tiles; + private Vector3 size; + private Transform tra; + private int mult = 1; void Start() { - // _map = new Map(128, 128); - - // _pooledActors = new ObjectPool(PoolSize); - // _pooledProjectiles = new ObjectPool(PoolSize); - // _pooledWalls = new ObjectPool(PoolSize); - - // _ca = new CellularAutomaton(_map, TileType.Wall) {CanGrowRule = CADelegates.CanGrow}; - // _tiles = new GameObject[_map.Columns*_map.Rows]; - - // for (uint i = 0; i < _map.Columns*_map.Rows; i++) - // { - // _tiles[i] = (GameObject) Instantiate(Wall, new Vector3(0, 0, 0), Quaternion.identity); - // _tiles[i].SetActive(false); - // } + size = BG.GetComponent().sprite.bounds.size; + tra = BG.GetComponent(); } void Update() @@ -59,28 +30,17 @@ namespace Assets.Scripts var rightBorder = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0)).x; var leftBorder = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x; + + if (rightBorder > (size.x - 2) * mult) + { + BG = (GameObject) Instantiate(BG, new Vector3(size.x + tra.position.x - .5f, tra.position.y, 0), Quaternion.identity); + tra = BG.GetComponent(); + mult++; + } // _ca.Step(rightBorder); // DrawMap(leftBorder, rightBorder); // Debug.Log(_map); } - - void DrawMap(float min, float max) - { - for (uint y = 0; y < _map.Rows; y++) - { - for (uint x = (uint) min%_map.Columns; x < max + 1%_map.Columns; x++) - { - if (_map[x, y] == TileType.Wall) - { - var tile = _tiles[_map.Columns*y + x]; - var newX = (uint) (min/_map.Columns)*_map.Columns + x; - - tile.transform.position = new Vector3(newX, y, 0); - tile.SetActive(true); - } - } - } - } } } \ No newline at end of file diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 23548c7..884889f 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -10,6 +10,7 @@ namespace Assets.Scripts public int Score = 0; public int Battery = 100; + public int Progression = 0; public bool IsBlinking = false; void Start() @@ -41,11 +42,13 @@ namespace Assets.Scripts if (_blinkCount != 7) return; _blinkCount = 0; _blinkTimer = 0f; + GetComponent().enabled = true; IsBlinking = false; } public void SetBlinking() { + GetComponent().enabled = false; GetComponent().enabled = false; IsBlinking = true; } diff --git a/Assets/Scripts/SimpleEnnemy.cs b/Assets/Scripts/SimpleEnnemy.cs index 1eeeb9b..7e4ac9a 100644 --- a/Assets/Scripts/SimpleEnnemy.cs +++ b/Assets/Scripts/SimpleEnnemy.cs @@ -29,9 +29,10 @@ public class SimpleEnnemy : MonoBehaviour void OnTriggerEnter2D(Collider2D other) { - gameObject.SetActive(false); + Destroy(gameObject); _player.GetComponent().Battery -= 4; + _player.GetComponent().SetBlinking(); //GetScores(); TODO: Successfully get scores from API } diff --git a/Assets/Scripts/Spawner.cs b/Assets/Scripts/Spawner.cs index 8eb518f..fee3924 100644 --- a/Assets/Scripts/Spawner.cs +++ b/Assets/Scripts/Spawner.cs @@ -34,10 +34,10 @@ public class Spawner : MonoBehaviour var r = _rand.Next(100); if (r < 20) - Instantiate(Toluen, new Vector3(_rightBorder, _rand.Next(9), 0), Quaternion.identity); + Instantiate(Toluen, new Vector3(_rightBorder, _rand.Next(1, 9), 0), Quaternion.identity); else if (r < 50) - Instantiate(BasicEnemy, new Vector3(_rightBorder, _rand.Next(9), 0), Quaternion.identity); + Instantiate(BasicEnemy, new Vector3(_rightBorder, _rand.Next(1, 9), 0), Quaternion.identity); else - Instantiate(StaticEnemy, new Vector3(_rightBorder, _rand.Next(9), 0), Quaternion.identity); + Instantiate(StaticEnemy, new Vector3(_rightBorder, _rand.Next(1, 9), 0), Quaternion.identity); } } diff --git a/Assets/Scripts/StaticEnemy.cs b/Assets/Scripts/StaticEnemy.cs index 0d3a616..4136921 100644 --- a/Assets/Scripts/StaticEnemy.cs +++ b/Assets/Scripts/StaticEnemy.cs @@ -17,7 +17,7 @@ public class StaticEnemy : MonoBehaviour { if (_position.position.x < Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x) { - gameObject.SetActive(false); + Destroy(gameObject); } }