Beispiel #1
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            if (_inputEnabled)
            {
                if (DrawScene != null)
                {
                    foreach (Drawable d in DrawScene.Items)
                    {
                        if (d is AbstractField)
                        {
                            if (d.TestAgainst(e.Location))
                            {
                                AbstractField dd = d as AbstractField;
                                if (_clickEven)
                                {
                                    if (DrawScene.PossibleTargets[_mouseClicked1].Contains <int>(dd.Number))
                                    {
                                        _mouseClicked2 = dd.Number;
                                        _clickEven     = false;
                                        LightType      = LightTypeEnum.None;
                                        SendMoveToPlayer();
                                    }
                                    else
                                    {
                                        _mouseClicked1 = -1;
                                        _mouseClicked2 = -1;
                                        _clickEven     = false;
                                        LightType      = LightTypeEnum.Source;
                                    }
                                }
                                else
                                {
                                    if (DrawScene.PossibleSources.Contains <int>(dd.Number))
                                    {
                                        _mouseClicked1 = dd.Number;
                                        LightType      = LightTypeEnum.Target;
                                        _clickEven     = !_clickEven;
                                    }
                                }

                                break;
                            }
                        }
                    }
                }
            }
            base.OnMouseClick(e);
        }
Beispiel #2
0
        public static AbstractField[] GetInitialFields()
        {
            AbstractField[] f = new AbstractField[27];

            for (int i = 0; i < 24; ++i)
            {
                f[i] = Field.MakeField(i);
            }

            f[C.WhiteBand] = Band.MakeBand(PColor.White);
            f[C.BlackBand] = Band.MakeBand(PColor.Black);
            f[C.Nowhere]   = Nowhere.GetNowhere();

            f[0].WhiteStones  = 2;
            f[5].BlackStones  = 5;
            f[7].BlackStones  = 3;
            f[11].WhiteStones = 5;
            f[12].BlackStones = 5;
            f[16].WhiteStones = 3;
            f[18].WhiteStones = 5;
            f[23].BlackStones = 2;

            return(f);
        }
Beispiel #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            g.Clear(C.BackgroundColor);
            //g.FillRectangle(C.BandBrush, new Rectangle(6*C.FieldSize, 0, 2*C.FieldSize, 12*C.FieldSize));

            if (DrawScene != null)
            {
                g.FillRectangle(C.BandBrush, new Rectangle(6 * C.FieldSize, 0, 2 * C.FieldSize, 12 * C.FieldSize));

                switch (LightType)
                {
                case LightTypeEnum.None:
                    foreach (Drawable d in DrawScene.Items)
                    {
                        d.Draw(g);
                    }
                    break;

                case LightTypeEnum.Source:
                    foreach (Drawable d in DrawScene.Items)
                    {
                        if (d is AbstractField)
                        {
                            AbstractField dd = d as AbstractField;
                            if (DrawScene.PossibleSources.Contains <int>(dd.Number))
                            {
                                dd.DrawWithLight(g, C.SourceLight);
                            }
                            else
                            {
                                dd.Draw(g);
                            }
                        }
                        else
                        {
                            d.Draw(g);
                        }
                    }
                    break;

                case LightTypeEnum.Target:
                {
                    int[] targets;
                    if (DrawScene.PossibleTargets.ContainsKey(_mouseClicked1))
                    {
                        targets = DrawScene.PossibleTargets[_mouseClicked1];
                    }
                    else
                    {
                        targets = new int[0];
                    }

                    foreach (Drawable d in DrawScene.Items)
                    {
                        if (d is AbstractField)
                        {
                            AbstractField dd = d as AbstractField;
                            if (targets.Contains <int>(dd.Number))
                            {
                                dd.DrawWithLight(g, C.TargetLight);
                            }
                            else
                            {
                                dd.Draw(g);
                            }
                        }
                        else
                        {
                            d.Draw(g);
                        }
                    }
                }
                break;
                }

                if (MouseOver != null)
                {
                    g.DrawRectangle(C.SelectionPen, MouseOver.Rect);
                    Invalidate(MouseOver.OverRect);
                }
            }


            base.OnPaint(e);
        }