GameController.cs 1.33 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>();
Raphael committed
25
            Screen.orientation = ScreenOrientation.LandscapeLeft;
Naliwe GS committed
26 27 28 29
        }

        void Update()
        {
Raphael committed
30
            Camera.main.transform.Translate(new Vector3(4f*Time.deltaTime, 0, 0));
31 32 33
            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
34

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

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