コード例 #1
0
ファイル: BoardControl.cs プロジェクト: nl20121974/digilone
 public BoardControl()
 {
     InitializeComponent();
     _movementDir   = Direction.None;
     _currentPlayer = MarbleColor.Black;
     _dragChain     = new List <BoardCoordinates>();
 }
コード例 #2
0
            public void Process()
            {
                if (!Valid)
                {
                    return;
                }

                HasBomb = Marbles.Any(m => m.Color == MarbleColor.BombJoker);

                var colorHash = new Dictionary <MarbleColor, int>();

                foreach (var col in AllColors)
                {
                    colorHash.Add(col, 0);
                }

                foreach (var mar in Marbles)
                {
                    var marbleColors = mar.Color.GetRegularColors();
                    foreach (var col in marbleColors)
                    {
                        colorHash[col] += 1;
                    }
                }

                if (colorHash.Count > 0)
                {
                    PrimaryColor = colorHash.OrderByDescending(e => e.Value).First().Key;
                }
            }
コード例 #3
0
        private Vector4 GetMaterialColor(MarbleColor marbleColor)
        {
            switch (marbleColor)
            {
            case MarbleColor.Red:
                return(new Vector4(1, 0, 0, 1));

            case MarbleColor.Green:
                return(new Vector4(0, 1, 0, 1));

            case MarbleColor.Blue:
                return(new Vector4(0, 0, 1, 1));

            case MarbleColor.Yellow:
                return(new Vector4(1, 1, 0, 1));

            case MarbleColor.Orange:
                return(new Vector4(1, 0.65f, 0, 1));

            case MarbleColor.White:
                return(new Vector4(1, 1, 1, 1));

            case MarbleColor.Cyan:
                return(new Vector4(0, 1, 1, 1));

            default:
                return(new Vector4(0, 0, 0, 1));
            }
        }
コード例 #4
0
        public static List <MarbleColor> GetRegularColors(this MarbleColor marbleColors)
        {
            var list = GetEnumFlags(marbleColors);

            list.Remove(MarbleColor.None);
            list.Remove(MarbleColor.ColorJoker);
            list.Remove(MarbleColor.BombJoker);
            list.Remove(MarbleColor.BombColor);
            return(list);
        }
コード例 #5
0
 public static bool ColorEquals(this MarbleColor x, MarbleColor y)
 {
     if (x == MarbleColor.Joker || y == MarbleColor.Joker)
     {
         return(true);
     }
     else
     {
         return(x == y);
     }
 }
コード例 #6
0
        private Vector4 GetMaterialColorShader(MarbleColor marbleColor)
        {
            var color    = GetMaterialColor(marbleColor);
            var addColor = new Vector4(0, 0, 0, 1);

            if (color.Xyz == Vector3.Zero)
            {
                addColor = new Vector4(0.3f, 0.3f, 0.3f, 1);
            }
            color += addColor;
            return(color * 0.5f);
        }
コード例 #7
0
 public Marble SelectByColor(MarbleColor color)
 {
     var node = dbFile.XDocument.Element("Marbles").Elements("Marble")
             .Where(x => x.Element("MarbleColor").Value == Convert.ToString(color))
             .FirstOrDefault();
     Marble obj = new Marble()
     {
         MarbleColor = node.Element("MarbleColor").Value,
         Quantity = Convert.ToInt32(node.Element("Quantity").Value)
     };
     return obj;
 }
コード例 #8
0
 public Color GetColorForMarbleColor(MarbleColor color)
 {
     return(new Dictionary <MarbleColor, Color>()
     {
         { MarbleColor.Blue, blueMaterial },
         { MarbleColor.Green, greenMaterial },
         { MarbleColor.Purple, purpleMaterial },
         { MarbleColor.Red, redMaterial },
         { MarbleColor.Yellow, yellowMaterial },
         { MarbleColor.Joker, jokerMaterial },
     }
            [color]);
 }
コード例 #9
0
        public Marble(MarbleColor color)
        {
            Color = color;
            var colors = color.GetRegularColors();

            if (colors.Count == 2)
            {
                Color1 = colors[0];
                Color2 = colors[1];
            }
            else
            {
                Color1 = color;
                Color2 = color;
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: DOSSTONED/testPrograms
        public MarbleTable Click5()
        {
            MarbleTable ret = new MarbleTable();

            ret.table = this.table.ToArray();
            MarbleColor tmp = ret.table[1];

            // 1-4-9-10-6-2
            ret.table[1]  = ret.table[2];
            ret.table[2]  = ret.table[6];
            ret.table[6]  = ret.table[10];
            ret.table[10] = ret.table[9];
            ret.table[9]  = ret.table[4];
            ret.table[4]  = tmp;

            ret.CurrentSequence = this.CurrentSequence + "Click5--";
            return(ret);
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: DOSSTONED/testPrograms
        public MarbleTable Click14()
        {
            MarbleTable ret = new MarbleTable();

            ret.table = this.table.ToArray();
            MarbleColor tmp = ret.table[9];

            // 9-13-17-18-15-10
            ret.table[9]  = ret.table[10];
            ret.table[10] = ret.table[15];
            ret.table[15] = ret.table[18];
            ret.table[18] = ret.table[17];
            ret.table[17] = ret.table[13];
            ret.table[13] = tmp;

            ret.CurrentSequence = this.CurrentSequence + "Click14--";
            return(ret);
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: DOSSTONED/testPrograms
        public MarbleTable Click10()
        {
            MarbleTable ret = new MarbleTable();

            ret.table = this.table.ToArray();
            MarbleColor tmp = ret.table[5];

            // 5-9-14-15-11-6
            ret.table[5]  = ret.table[6];
            ret.table[6]  = ret.table[11];
            ret.table[11] = ret.table[15];
            ret.table[15] = ret.table[14];
            ret.table[14] = ret.table[9];
            ret.table[9]  = tmp;

            ret.CurrentSequence = this.CurrentSequence + "Click10--";
            return(ret);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: DOSSTONED/testPrograms
        public MarbleTable Click13()
        {
            MarbleTable ret = new MarbleTable();

            ret.table = this.table.ToArray();
            MarbleColor tmp = ret.table[8];

            // 8-12-16-17-14-9
            ret.table[8]  = ret.table[9];
            ret.table[9]  = ret.table[14];
            ret.table[14] = ret.table[17];
            ret.table[17] = ret.table[16];
            ret.table[16] = ret.table[12];
            ret.table[12] = tmp;

            ret.CurrentSequence = this.CurrentSequence + "Click13--";
            return(ret);
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: DOSSTONED/testPrograms
        public MarbleTable Click4()
        {
            MarbleTable ret = new MarbleTable();

            ret.table = this.table.ToArray();
            MarbleColor tmp = ret.table[0];

            // 0-3-8-9-5-1
            ret.table[0] = ret.table[1];
            ret.table[1] = ret.table[5];
            ret.table[5] = ret.table[9];
            ret.table[9] = ret.table[8];
            ret.table[8] = ret.table[3];
            ret.table[3] = tmp;

            ret.CurrentSequence = this.CurrentSequence + "Click4--";
            return(ret);
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: DOSSTONED/testPrograms
        public MarbleTable Click9()
        {
            MarbleTable ret = new MarbleTable();

            ret.table = this.table.ToArray();
            MarbleColor tmp = ret.table[4];

            // 4-8-13-14-10-5
            ret.table[4]  = ret.table[5];
            ret.table[5]  = ret.table[10];
            ret.table[10] = ret.table[14];
            ret.table[14] = ret.table[13];
            ret.table[13] = ret.table[8];
            ret.table[8]  = tmp;

            ret.CurrentSequence = this.CurrentSequence + "Click9--";
            return(ret);
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: DOSSTONED/testPrograms
        public MarbleTable Click8()
        {
            MarbleTable ret = new MarbleTable();

            ret.table = this.table.ToArray();
            MarbleColor tmp = ret.table[3];

            // 3-7-12-13-9-4
            ret.table[3]  = ret.table[4];
            ret.table[4]  = ret.table[9];
            ret.table[9]  = ret.table[13];
            ret.table[13] = ret.table[12];
            ret.table[12] = ret.table[7];
            ret.table[7]  = tmp;

            ret.CurrentSequence = this.CurrentSequence + "Click8--";
            return(ret);
        }
コード例 #17
0
        public bool AddRows(MarbleColor marbleColor, int outputQuantity)
        {
            try
            {
                int index = -1;
                //Find row 
                foreach (DataGridViewRow item in dataGridView.Rows)
                {
                    if (item.Cells[1].Value.ToString().Equals(Convert.ToString(marbleColor)))
                    {
                        index = item.Index;
                        break;
                    }
                }

                if(index != -1)
                {
                    //If row exist, update quantity
                    dataGridView.Rows[index].Cells[2].Value = outputQuantity;
                }
                else
                {
                    //If have no rows, create it
                    index = dataGridView.Rows.Add(new Bitmap(1, 1), marbleColor, outputQuantity, "Waiting");

                    //Set Color for Cells
                    dataGridView.Rows[index].Cells[3].Style.ForeColor = Color.Orange;          
                }       
               
                //Check quantity = 0 or not, if quantity == 0, remove row
                if(outputQuantity == 0)
                {
                    dataGridView.Rows.RemoveAt(index);
                }
            }
            catch
            {
                return false;
            }
            return true;
        }
コード例 #18
0
ファイル: BoardControl.cs プロジェクト: nl20121974/digilone
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (_board == null || e.Button != MouseButtons.Left || _dragChain.Count == 0)
            {
                return;
            }
            List <Marble> marbles = new List <Marble>();

            foreach (BoardCoordinates coord in _dragChain)
            {
                Marble m = _board.GetMarble(coord, true);
                m.IsSelected = false;
                marbles.Add(m);
            }
            if (_board.DoMove(marbles, _movementDir))
            {
                _currentPlayer = (MarbleColor)((((byte)_currentPlayer) + 1) % 2);
            }
            _dragChain.Clear();
            _movementDir = Direction.None;
            Invalidate();
        }
コード例 #19
0
ファイル: Rules.cs プロジェクト: tobster-de/Digilone
        /// <summary>
        /// Determines if a turn of a player may be valid
        /// </summary>
        /// <param name="selected"></param>
        /// <param name="direction"></param>
        /// <returns></returns>
        public static bool MoveIsValid(Board board, List <Marble> selected, Direction direction)
        {
            if (direction == Direction.None)
            {
                return(false);
            }
            MoveType mt = DetermineMoveType(selected, direction);

            if (mt == MoveType.Line)
            {
                MarbleColor        currentPlayer = selected[0].Color;
                List <MarbleColor> moveline      = new List <MarbleColor>();
                foreach (Marble m in selected)
                {
                    moveline.Add(m.Color);
                }
                Marble next = selected[selected.Count - 1];
                while (next != null)
                {
                    next = board.GetMarble(NextCoordinates(next.Coordinates, direction), true);
                    if (next != null)
                    {
                        moveline.Add(next.Color);
                    }
                }
                int i = 0, mcol = 0, hcol = 0, ncol = 0;
                while (i < moveline.Count && moveline[i] == currentPlayer)
                {
                    mcol++;
                    i++;
                }
                while (i < moveline.Count && moveline[i] != currentPlayer)
                {
                    hcol++;
                    i++;
                }
                while (i < moveline.Count && moveline[i] == currentPlayer)
                {
                    ncol++;
                    i++;
                }
                // move max. three own marbles; push fewer amount of enemy marbles than own
                // and have no other own marbles behind them
                return(mcol <= 3 && mcol > hcol && ncol == 0);
            }
            else if (mt == MoveType.Broad)
            {
                // move max. three marbles; all destination slots must be free
                bool free = selected.Count < 4;
                if (free)
                {
                    foreach (Marble m in selected)
                    {
                        ICoordinates dest = NextCoordinates(m.Coordinates, direction);
                        free = free && board.GetMarble(dest, true) == null;
                    }
                }
                return(free);
            }
            return(false);
        }
コード例 #20
0
 public Marble SelectByColor(MarbleColor color)
 {
     return repository.SelectByColor(color);
 }
コード例 #21
0
 public Marble(MarbleColor color1, MarbleColor color2)
 {
     Color1 = color1;
     Color2 = color2;
     Color  = color1 | Color2;
 }
コード例 #22
0
 /// <summary>
 /// Create a new marble object
 /// </summary>
 /// <param name="color">Color of the marble</param>
 /// <param name="coordinates">Coordinates to place the marble</param>
 public Marble(MarbleColor color, ICoordinates coordinates)
 {
     Color       = color;
     Coordinates = coordinates;
     //IsOut = Rules.MarbleIsOut(coordinates);
 }
コード例 #23
0
 public void SetMarbleColor(MarbleColor color)
 {
     BroadcastMessage(SetMarbleColorColor, GetColorForMarbleColor(color));
 }
コード例 #24
0
 public void SetMarbleColor(MarbleColor color)
 {
     this.marbleColor = color;
 }
コード例 #25
0
 public void SetColor(MarbleColor newColor)
 {
     this.color = newColor;
     BroadcastMessage(SetMarbleColorMessage, newColor);
 }
コード例 #26
0
ファイル: Board.cs プロジェクト: tobster-de/Digilone
 /// <summary>
 /// Add a marble
 /// </summary>
 /// <param name="color">Color of the new marble</param>
 /// <param name="coordinates">Coordinates of the new marble</param>
 public void NewMarble(MarbleColor color, ICoordinates coordinates)
 {
     _marbles.Add(new Marble(color, coordinates));
 }
コード例 #27
0
        public bool UpdateRows(MarbleColor marbleColor, int outputQuantity)
        {
            try
            {
                int index = -1;
                //Find row 
                foreach (DataGridViewRow item in dataGridView.Rows)
                {
                    if (item.Cells[1].Value.ToString().Equals(Convert.ToString(marbleColor)))
                    {
                        index = item.Index;
                        break;
                    }
                }
                //Find no rows
                if (index == -1)
                {
                    return false;
                }
                else
                {
                    //If has row then update
                    dataGridView.Rows[index].Cells[2].Value = outputQuantity;
                }

                //Check finish
                if (outputQuantity == 0)
                {
                    dataGridView.Rows[index].Cells[0].Value = PSSC.App.Properties.Resources.SymbolCheck1;
                    dataGridView.Rows[index].Cells[3].Value = "Success";
                    dataGridView.Rows[index].Cells[3].Style.ForeColor = Color.Lime;
                }
                else
                {
                    dataGridView.Rows[index].Cells[0].Value = new Bitmap(1, 1);
                    dataGridView.Rows[index].Cells[3].Value = "Waiting";

                    //Set Color for Cells
                    dataGridView.Rows[index].Cells[3].Style.ForeColor = Color.Orange;   
                }
            }
            catch
            {
                return false;
            }
            return true;
        }
コード例 #28
0
 public void SetMarbleColor(MarbleColor color)
 {
     BroadcastMessage(SetMarbleColorMaterialMessage, GetMaterialForColor(color));
 }