1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Assets.Scripts.MapGeneration;
using Assets.Scripts.Utils;
using UnityEngine;
using System;
namespace Assets.Scripts
{
public class GameController : MonoBehaviour
{
public static int PoolSize = 256;
public GameObject Wall;
public GameObject BG;
private Map _map;
private Vector3 size;
private Transform tra;
private int mult = 1;
void Start()
{
size = BG.GetComponent<SpriteRenderer>().sprite.bounds.size;
tra = BG.GetComponent<Transform>();
Screen.orientation = ScreenOrientation.LandscapeLeft;
}
void Update()
{
Camera.main.transform.Translate(new Vector3(4f*Time.deltaTime, 0, 0));
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*mult) - 2)) return;
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);
// DrawMap(leftBorder, rightBorder);
// Debug.Log(_map);
}
}
}