GameController.cs 1.26 KB
Newer Older
1 2
using Assets.Scripts.MapGeneration;
using Assets.Scripts.Utils;
Naliwe GS committed
3
using UnityEngine;
Raphael committed
4
using System;
Naliwe GS committed
5 6 7 8 9 10 11

namespace Assets.Scripts
{
    public class GameController : MonoBehaviour
    {
        public static int PoolSize = 256;

12
        public GameObject Wall;
Naliwe GS committed
13
        public GameObject BG;
14

15 16
        private Map _map;

Naliwe GS committed
17 18 19
        private Vector3 size;
        private Transform tra;
        private int mult = 1;
20

Naliwe GS committed
21 22
        void Start()
        {
Naliwe GS committed
23 24
            size = BG.GetComponent<SpriteRenderer>().sprite.bounds.size;
            tra = BG.GetComponent<Transform>();
Naliwe GS committed
25 26 27 28
        }

        void Update()
        {
29
            Camera.main.transform.Translate(new Vector3(2f*Time.deltaTime, 0, 0));
30 31 32
            var rightBorder = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width,
                Screen.height, 0)).x;
            var leftBorder = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x;
Naliwe GS committed
33

Raphael committed
34 35 36 37
            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++;
Raphael committed
38
            // _ca.Step(rightBorder);
39

Raphael committed
40
            // DrawMap(leftBorder, rightBorder);
41 42
            // Debug.Log(_map);
        }
Naliwe GS committed
43 44
    }
}