// Use this for initialization
    void Start()
    {
        _controller = GetComponent <IndicatorController>();

        _index = GameController.Instance.enteredHouse;
        _controller.houseIndex = _index;

        Camera camera = Camera.main;
        float  height = camera.orthographicSize * 2;
        float  width  = height * camera.aspect;

        for (int i = 0; i < floors.Count; i++)
        {
            floors[i].transform.position = new Vector3(0, i * height, 0);
            float floorWidth = floors[i].GetComponent <BoxCollider>().size.x;

            float scale = 1.0f;
            if (floorWidth > width * 0.8f)
            {
                scale = ((width * 0.8f) / floorWidth);
            }

            floors[i].transform.localScale = new Vector3(scale, scale, 1);
        }

        ChangeFloors(0);

        if (_index != -1)
        {
            if (GameController.Instance.houses != null && GameController.Instance.houses[_index].indicator != null)
            {
                _controller.EnableIndicator(GameController.Instance.houses[_index].indicator);
            }
        }
    }
Beispiel #2
0
    void Start()
    {
        if (GameController.Instance.gameState == GameController.GameState.MENU)
        {
            GameController.Instance.StartGame();
        }

        _houses = new List <GameObject>();

        if (GameController.Instance.cameraPosition == Vector3.zero)
        {
            Camera camera          = Camera.main;
            float  screenHeight    = 2f * camera.orthographicSize;
            float  screenWidth     = screenHeight * camera.aspect;
            float  screenWidthHalf = screenWidth / 2.0f;

            this.transform.position = new Vector3(-5.0f + screenWidthHalf, camera.orthographicSize - 0.25f, -10.0f);
            GameController.Instance.cameraPosition = this.transform.position;
        }
        else
        {
            this.transform.position = GameController.Instance.cameraPosition;
        }

        for (int i = 0; i < GameController.Instance.houses.Count; i++)
        {
            GameObject house = Instantiate(GameController.Instance.houses[i].prefab, Vector3.zero, Quaternion.identity);
            _houses.Add(house);
            float width = house.GetComponent <Collider>().bounds.size.x;
            house.transform.position = new Vector3(_streetWidth + (width / 2.0f), 0, 0);
            IndicatorController indicatorController = house.GetComponent <IndicatorController>();
            indicatorController.houseIndex = i;
            if (GameController.Instance.houses[i].indicator != null)
            {
                indicatorController.EnableIndicator(GameController.Instance.houses[i].indicator);
            }
            _streetWidth += width;
        }

        float sidewalkWidth = -5;

        while (sidewalkWidth <= _streetWidth + 5)
        {
            Instantiate(sidewalk, new Vector3(sidewalkWidth, -0.125f, -2.0f), Quaternion.identity);
            sidewalkWidth += 10;
        }
    }