Exemplo n.º 1
0
 public void RedrawField(ModelGameField field)
 {
     field.EachElement((int i, int j, bool filled) =>
     {
         int index             = j * m_Controller.Width + i;
         var element           = m_Elements[index];
         SpriteRenderer sprite = element.GetComponent <SpriteRenderer>();
         sprite.color          = filled ? Color.cyan : new Color(1f, 1f, 1f, 0.078f);
     });
 }
Exemplo n.º 2
0
        public void Start()
        {
            View = GetComponent <GameView>();

            var inputs = GetComponents <InputController>();

            for (int i = 0; i < inputs.Length; ++i)
            {
                var input = inputs[i];
                input.HorizontalMove += OnHorizontalMove;
                input.TouchClick     += OnTouchClick;
                input.InstantPlace   += OnInstantPlace;
            }

            Field = new ModelGameField
            {
                Blocks = new bool[Width * Height],
                Height = Height,
                Width  = Width
            };

            Falling         = new ModelFalling {
            };
            Falling.Events += OnPositionChange;

            // continue game
            if (Settings.CurrentLevel < 0)
            {
                State = GameState.LoadProgress;
            }

            View.BackButton.onClick.AddListener(() =>
            {
                EventManager.Instance.Events.Invoke(new ApplicationCommand
                {
                    Type = CommandType.MainMenu
                });
            });
        }