예제 #1
0
    public void Awake()
    {
        var levelGenerator = new LevelGenerator(LevelInfo, Field);

        FieldProcessor = new FieldProcessor(levelInfo.FieldInfo, LevelInfo.ItemSet.ItemsCount);
        var fieldUIController = new FieldUIController(levelGenerator, FieldProcessor);

        AnimationsController.Instance.OnAnimationsFinished += FieldProcessor.CheckFields;
        AnimationsController.Instance.OnAnimationsFinished += FieldProcessor.CheckForFreeSpaces;
    }
예제 #2
0
    private void Awake()
    {
        if (Instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }

        _canvas = GetComponent <Canvas>();
    }
예제 #3
0
    void Start()
    {
        Vector2 resolution = new Vector2(Camera.main.pixelWidth, Camera.main.pixelHeight);
        FieldSize = FieldConstants.FieldSize(resolution);

        score = new ScoreModel();
        radmolePool = gameObject.GetComponent<ObjectPool>();
        fieldUIController = GameObject.FindObjectOfType<FieldUIController>() as FieldUIController;

        FieldController.DestroyedMole.AsObservable().Subscribe(_ =>
                {
                    if (gameOver) return;
                    fieldUIController.Score.Value = ++score.Score;
                });
        FieldController.GameOver.AsObservable().Subscribe(OnGameOver);

        TileController.LoadTiles();

        for (int x = (int)-FieldSize.x; x < (int)FieldSize.x + 1; x++)
        {
            for (int y = (int)-FieldSize.y; y < (int)FieldSize.y + 1; y++)
            {
                GameObject tile = GameObject.Instantiate(TilePrefab);
                TileController tileController = tile.GetComponent<TileController>();
                tile.transform.SetParent(TileRoot.transform, false);

                tile.transform.localPosition = new Vector3(x * FieldConstants.TileWidth,
                                                           y * FieldConstants.TileHeight,
                                                           0);
                tileController.Setup();
            }
        }

        StartCoroutine(SpawnMoles());
    }