Commit f73e4ff9 by Naliwe GS

Small fixes

parent b33d8e90
fileFormatVersion: 2
guid: b8da779ffb69b984dbd3e41d6e16ffbb
timeCreated: 1477389059
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
...@@ -17,7 +17,8 @@ public class Collectible : MonoBehaviour ...@@ -17,7 +17,8 @@ public class Collectible : MonoBehaviour
void OnTriggerEnter2D(Collider2D other) void OnTriggerEnter2D(Collider2D other)
{ {
gameObject.SetActive(false); Destroy(gameObject);
_player.GetComponent<Player>().Score += 10; _player.GetComponent<Player>().Score += 10;
_player.GetComponent<Player>().Progression += 1;
} }
} }
\ No newline at end of file
...@@ -5,52 +5,23 @@ using System; ...@@ -5,52 +5,23 @@ using System;
namespace Assets.Scripts 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 class GameController : MonoBehaviour
{ {
public static int PoolSize = 256; public static int PoolSize = 256;
public GameObject Wall; public GameObject Wall;
public GameObject BG;
private Map _map; private Map _map;
private ObjectPool _pooledWalls; private Vector3 size;
private ObjectPool _pooledActors; private Transform tra;
private ObjectPool _pooledProjectiles; private int mult = 1;
private CellularAutomaton _ca;
private GameObject[] _tiles;
void Start() void Start()
{ {
// _map = new Map(128, 128); size = BG.GetComponent<SpriteRenderer>().sprite.bounds.size;
tra = BG.GetComponent<Transform>();
// _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);
// }
} }
void Update() void Update()
...@@ -59,28 +30,17 @@ namespace Assets.Scripts ...@@ -59,28 +30,17 @@ namespace Assets.Scripts
var rightBorder = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, var rightBorder = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width,
Screen.height, 0)).x; Screen.height, 0)).x;
var leftBorder = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 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<Transform>();
mult++;
}
// _ca.Step(rightBorder); // _ca.Step(rightBorder);
// DrawMap(leftBorder, rightBorder); // DrawMap(leftBorder, rightBorder);
// Debug.Log(_map); // 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
...@@ -10,6 +10,7 @@ namespace Assets.Scripts ...@@ -10,6 +10,7 @@ namespace Assets.Scripts
public int Score = 0; public int Score = 0;
public int Battery = 100; public int Battery = 100;
public int Progression = 0;
public bool IsBlinking = false; public bool IsBlinking = false;
void Start() void Start()
...@@ -41,11 +42,13 @@ namespace Assets.Scripts ...@@ -41,11 +42,13 @@ namespace Assets.Scripts
if (_blinkCount != 7) return; if (_blinkCount != 7) return;
_blinkCount = 0; _blinkCount = 0;
_blinkTimer = 0f; _blinkTimer = 0f;
GetComponent<BoxCollider2D>().enabled = true;
IsBlinking = false; IsBlinking = false;
} }
public void SetBlinking() public void SetBlinking()
{ {
GetComponent<BoxCollider2D>().enabled = false;
GetComponent<SpriteRenderer>().enabled = false; GetComponent<SpriteRenderer>().enabled = false;
IsBlinking = true; IsBlinking = true;
} }
......
...@@ -29,9 +29,10 @@ public class SimpleEnnemy : MonoBehaviour ...@@ -29,9 +29,10 @@ public class SimpleEnnemy : MonoBehaviour
void OnTriggerEnter2D(Collider2D other) void OnTriggerEnter2D(Collider2D other)
{ {
gameObject.SetActive(false); Destroy(gameObject);
_player.GetComponent<Player>().Battery -= 4; _player.GetComponent<Player>().Battery -= 4;
_player.GetComponent<Player>().SetBlinking();
//GetScores(); TODO: Successfully get scores from API //GetScores(); TODO: Successfully get scores from API
} }
......
...@@ -34,10 +34,10 @@ public class Spawner : MonoBehaviour ...@@ -34,10 +34,10 @@ public class Spawner : MonoBehaviour
var r = _rand.Next(100); var r = _rand.Next(100);
if (r < 20) 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) 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 else
Instantiate(StaticEnemy, new Vector3(_rightBorder, _rand.Next(9), 0), Quaternion.identity); Instantiate(StaticEnemy, new Vector3(_rightBorder, _rand.Next(1, 9), 0), Quaternion.identity);
} }
} }
...@@ -17,7 +17,7 @@ public class StaticEnemy : MonoBehaviour ...@@ -17,7 +17,7 @@ public class StaticEnemy : MonoBehaviour
{ {
if (_position.position.x < Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x) if (_position.position.x < Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x)
{ {
gameObject.SetActive(false); Destroy(gameObject);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment