示例#1
0
        private bool IsTooBig(CellButton button)
        {
            var ambientbuttons = getActiveAmbientButtons(button);

            foreach (var ambientbutton in ambientbuttons)
            {
                if (ambientbutton.GetValue() >= button.GetValue())
                {
                    return(false);
                }
            }
            return(true);
        }
示例#2
0
        public void ButtonClick(object sender, EventArgs e)
        {
            CellButton button         = (CellButton)sender;
            var        ambientButtons = getActiveAmbientButtons(button);

            if (ambientButtons.Count == 0 || button.GetValue() == 0)
            {
                return;
            }
            ambientButtons.Add(button);
            foreach (var item in ambientButtons)
            {
                item.DownGrade();
                ++balanceValue;
            }
            UpdateScore();
            actions.Add(ambientButtons);
            CheckEnd();
        }
示例#3
0
        public List <CellButton> getActiveAmbientButtons(CellButton button)
        {
            int x = button.coordX;
            int y = button.coordY;
            List <CellButton> ambientButtons = new List <CellButton>();

            if (button.GetValue() == 0)
            {
                return(ambientButtons);
            }
            List <(int, int)> coordsList = new List <(int, int)>
            {
                (x - 1, y - 1),
                (x, y - 1),
                (x + 1, y - 1),
                (x - 1, y),
                (x + 1, y),
                (x - 1, y + 1),
                (x, y + 1),
                (x + 1, y + 1)
            };

            foreach (var coords in coordsList)
            {
                try
                {
                    if (coords.Item1 >= 0 && coords.Item1 < 10 && coords.Item2 >= 0 && coords.Item2 < 10)
                    {
                        var but = cellButtons.Find(cell => cell.coordX == coords.Item1 && cell.coordY == coords.Item2);
                        if (but != null && but.GetValue() > 0)
                        {
                            ambientButtons.Add(but);
                        }
                    }
                }
                catch (Exception e)
                {
                    continue;
                }
            }
            return(ambientButtons);
        }