Commit f33f917f by Naliwe GS

Added simple generation

parent 83befd93
fileFormatVersion: 2 fileFormatVersion: 2
guid: c56230d4575634b8896a178b68e9a055 guid: 67ef126a7ce40434caffe1a9ac2eb7f0
folderAsset: yes timeCreated: 1477303258
timeCreated: 1477229352
licenseType: Free licenseType: Free
DefaultImporter: NativeFormatImporter:
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
fileFormatVersion: 2
guid: dad1063b37800dd4f836d3673c4b3956
timeCreated: 1477303253
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c632e4ae2f6870d4ba2bde7b02807416
timeCreated: 1477303248
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
No preview for this file type
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using Assets.Scripts;
public class Collectible : MonoBehaviour public class Collectible : MonoBehaviour
{ {
private GameObject _player;
void Start() void Start()
{ {
_player = GameObject.FindWithTag("Player");
} }
void Update() void Update()
...@@ -14,5 +18,6 @@ public class Collectible : MonoBehaviour ...@@ -14,5 +18,6 @@ public class Collectible : MonoBehaviour
void OnTriggerEnter2D(Collider2D other) void OnTriggerEnter2D(Collider2D other)
{ {
gameObject.SetActive(false); gameObject.SetActive(false);
_player.GetComponent<Player>().Score += 10;
} }
} }
\ No newline at end of file
...@@ -37,20 +37,20 @@ namespace Assets.Scripts ...@@ -37,20 +37,20 @@ namespace Assets.Scripts
void Start() void Start()
{ {
_map = new Map(128, 128); // _map = new Map(128, 128);
_pooledActors = new ObjectPool(PoolSize); // _pooledActors = new ObjectPool(PoolSize);
_pooledProjectiles = new ObjectPool(PoolSize); // _pooledProjectiles = new ObjectPool(PoolSize);
_pooledWalls = new ObjectPool(PoolSize); // _pooledWalls = new ObjectPool(PoolSize);
_ca = new CellularAutomaton(_map, TileType.Wall) {CanGrowRule = CADelegates.CanGrow}; // _ca = new CellularAutomaton(_map, TileType.Wall) {CanGrowRule = CADelegates.CanGrow};
_tiles = new GameObject[_map.Columns*_map.Rows]; // _tiles = new GameObject[_map.Columns*_map.Rows];
for (uint i = 0; i < _map.Columns*_map.Rows; i++) // for (uint i = 0; i < _map.Columns*_map.Rows; i++)
{ // {
_tiles[i] = (GameObject) Instantiate(Wall, new Vector3(0, 0, 0), Quaternion.identity); // _tiles[i] = (GameObject) Instantiate(Wall, new Vector3(0, 0, 0), Quaternion.identity);
_tiles[i].SetActive(false); // _tiles[i].SetActive(false);
} // }
} }
void Update() void Update()
......
...@@ -6,6 +6,8 @@ namespace Assets.Scripts ...@@ -6,6 +6,8 @@ namespace Assets.Scripts
{ {
private Transform _pos; private Transform _pos;
public int Score = 0;
void Start() void Start()
{ {
_pos = GetComponent<Transform>(); _pos = GetComponent<Transform>();
......
...@@ -2,21 +2,24 @@ ...@@ -2,21 +2,24 @@
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using System.Collections; using System.Collections;
using Assets.Scripts;
public class SimpleEnnemy : MonoBehaviour public class SimpleEnnemy : MonoBehaviour
{ {
private Transform _position; private Transform _position;
private GameObject _player;
public float Speed = 2f; public float Speed = 2f;
void Start () void Start ()
{ {
_position = GetComponent<Transform>(); _position = GetComponent<Transform>();
_player = GameObject.FindWithTag("Player");
} }
void Update () void Update ()
{ {
_position.Translate(new Vector3(Speed * Time.deltaTime, 0, 0)); _position.Translate(new Vector3(Speed * Time.deltaTime * -1, 0, 0));
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)
{ {
...@@ -26,8 +29,8 @@ public class SimpleEnnemy : MonoBehaviour ...@@ -26,8 +29,8 @@ public class SimpleEnnemy : MonoBehaviour
void OnTriggerEnter2D(Collider2D other) void OnTriggerEnter2D(Collider2D other)
{ {
Debug.Log("Entered");
gameObject.SetActive(false); gameObject.SetActive(false);
//GetScores(); TODO: Successfully get scores from API //GetScores(); TODO: Successfully get scores from API
} }
......
using UnityEngine;
using System.Collections;
public class Spawner : MonoBehaviour
{
public GameObject BasicEnemy;
public GameObject StaticEnemy;
public GameObject Toluen;
private float _timer;
private System.Random _rand;
private float _rightBorder;
void Start ()
{
_timer = 0f;
_rand = new System.Random();
}
void Update ()
{
_timer += Time.deltaTime;
_rightBorder = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0)).x + 2;
if (_timer >= 2f)
{
Spawn();
_timer = 0f;
}
}
private void Spawn()
{
var r = _rand.Next(100);
if (r < 20)
Instantiate(Toluen, new Vector3(_rightBorder, _rand.Next(9), 0), Quaternion.identity);
else if (r < 50)
Instantiate(BasicEnemy, new Vector3(_rightBorder, _rand.Next(9), 0), Quaternion.identity);
else
Instantiate(StaticEnemy, new Vector3(_rightBorder, _rand.Next(9), 0), Quaternion.identity);
}
}
fileFormatVersion: 2
guid: f3fbc0c4389f2bd42b026337e56b2b32
timeCreated: 1477302039
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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