示例#1
0
 public void SetChecker(Checker c)
 {
     user = c.user;
     SLocation = StatusLocation.Yes;
     IsChecker = c;
     IsChecker.IndexLocation = IndexLocation;
 }
示例#2
0
        /// <summary>
        /// Ініціювати розрахунок.
        /// </summary>
        /// <param name="ch"></param>
        public void Initialize(Checker ch)
        {
            ch.Clear();
            focusChecher = ch;

            if (ch.status == Status.Queen)
            {
                route = ch.RouteDown; Step_2_ToQueen(11);
                route = ch.RouteLeft; Step_2_ToQueen(9);
                route = ch.RouteRight; Step_2_ToQueen(-11);
                route = ch.RouteUp; Step_2_ToQueen(-9);
            }
            else
            {
                if (ch.user == User.Right)
                {
                    route = ch.RouteDown; Step_3_(11, Find.FreeOrEnemy);
                    route = ch.RouteLeft; Step_3_(9, Find.FreeOrEnemy);
                    route = ch.RouteRight; Step_3_(-11, Find.Enemy);
                    route = ch.RouteUp; Step_3_(-9, Find.Enemy);
                }
                else
                {
                    route = ch.RouteDown; Step_3_(11, Find.Enemy);
                    route = ch.RouteLeft; Step_3_(9, Find.Enemy);
                    route = ch.RouteRight; Step_3_(-11, Find.FreeOrEnemy);
                    route = ch.RouteUp; Step_3_(-9, Find.FreeOrEnemy);
                }
            }
        }
示例#3
0
        public void InitializeChecker(Checker c)
        {
            user = c.user;
            SLocation = StatusLocation.Yes;
            IsChecker = c;
            IsChecker.IndexLocation = IndexLocation;

            Canvas.SetTop(IsChecker.ThisChecker, Canvas.GetTop(ThisLocation));
            Canvas.SetLeft(IsChecker.ThisChecker, Canvas.GetLeft(ThisLocation));
        }
示例#4
0
 private void c_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (selectedChecker != (sender as FrameworkElement).Tag as Checker)
     {
         if (selectedChecker != null) selectedChecker.AnimationSelected.Stop();
         selectedChecker = (sender as FrameworkElement).Tag as Checker;
         selectedChecker.AnimationSelected.Begin();
     }
 }
示例#5
0
        public MainWindow()
        {
            InitializeComponent();
            _x.Visibility = System.Windows.Visibility.Visible;

            callback.ClientConnected += (s, e) =>
            {
                if (e._Message.Identify == 1) namePlayer2.Content = e._Message.Name;
                else namePlayer1.Content = e._Message.Name;
                    start.IsEnabled = true;
                    wait.Content = "Гру можна розпочинати!";
            };

            callback.ClientStepped += (s, e) =>
            {
                listAction.Clear();
                selectedChecker = allLocation[e.Index].IsChecker;
                listAction.Add(e.Step);
                Step_2_();

                if (selectedChecker.user == User.Left) InitializeRight();
                else InitializeLeft();
            };

            callback.ClientMessaged += (s, e) =>
            {
                TextBlock t = new TextBlock() { Text = e._Message.Name + "[" + e._Message.Data.TimeOfDay + "]: " + e._Message };
                t.TextWrapping = TextWrapping.Wrap;

                if (e._Message.Identify != message.Identify) { t.Foreground = Brushes.Blue; t.Margin = new Thickness() { Left = 35, Right = 10, Top = 10 }; boxMessage.Children.Add(t); }
                else { t.Foreground = Brushes.Green; t.Margin = new Thickness() { Left = 10, Right = 10, Top = 10 }; boxMessage.Children.Add(t); }
            };

            callback.ClientDisconnected += (s, e) =>
            {
                if (CurrentStatusGame == StatusGame.Play) { serverIsDown.Visibility = System.Windows.Visibility.Visible; chanel.RemoveUser(message); eventPlay.Text = "Гравець покинув гру!"; }
                else if (CurrentStatusGame == StatusGame.WaitPlayer)
                {
                    start.IsEnabled = false;
                    if (e._Message.Identify == 1) namePlayer2.Content = "-----_--";
                    else namePlayer1.Content = "-----_--";
                    wait.Content = "Очікування граця!";
                }
            };

            callback.Run += () =>
            {
                //InitializeRight();

                if (!leftChecker[0].ThisChecker.IsEnabled)
                {
                    for (byte i = 0; i < rightChecker.Count; i++)
                    {
                        rightChecker[i].ThisChecker.IsEnabled = false;
                    }
                }

                player_1.Content = namePlayer1.Content;
                player_2.Content = namePlayer2.Content;

                waitPlayer.Visibility = System.Windows.Visibility.Hidden;
                mainMenu.Visibility = System.Windows.Visibility.Hidden;
                CurrentStatusGame = StatusGame.Play;
               
            };
        }
示例#6
0
        private Checker CreateChecker(Status st, User us, Image ch)
        {
            var v = new Checker(st, us, ch);
            // Бот
            if (us == User.Right)
                v.Step_Completed = async (s, e) =>
                {
                    if (temp && leftChecker.Count > 0)
                    {
                        await Task.Run(() => { Thread.Sleep(300); });

                        InitializeLeft();

                        List<Tuple<int, int>> l;
                        bot.Run(leftChecker, out selectedChecker, out l);
                        Step_1_Findet(l);

                        InitializeRight();
                    }
                };

            v.CreateAnimationDeath(Canvas.GetLeft(kill), Canvas.GetTop(kill));
            if (us == User.Right) rightChecker.Add(v); else leftChecker.Add(v);
            return v;
        }
示例#7
0
        private void Step_2_()
        {
            var delChecker = selectedChecker.user == User.Left ? rightChecker : leftChecker;

            step.Inlines.Add(new Run() { Foreground = Brushes.Blue, Text = "Move -> " + allLocation[selectedChecker.IndexLocation].ThisLocation.ToolTip });

            for (byte i = 0; i < listAction[0].Count; i++)
            {
                if (listAction[0][i].Item2 != -1)
                {
                    //step.Text += "Death-> " + AllLocation.Index(listAction[0][i].Item2).ThisLocation.ToolTip;
                    step.Inlines.Add(new Run() { Foreground = Brushes.Red, Text = "\n   Death-> " + allLocation[listAction[0][i].Item2].ThisLocation.ToolTip });
                    delChecker.Remove(allLocation[listAction[0][i].Item2].IsChecker);

                    allLocation[listAction[0][i].Item2].Clear();
                    allLocation[listAction[0][i].Item2].IsChecker.AnimationDeath.Begin();
                }
            }
            // Old location
            allLocation[selectedChecker.IndexLocation].Clear(); // Поле є вільне.
            // New location
            allLocation[listAction[0].Last().Item1].SetChecker(selectedChecker);
            // Edit Checker
            //AllLocation.Index(selectedChecker.IndexLocation).MoveChecker();
            selectedChecker.BeginAnimationMove(Canvas.GetLeft(allLocation[selectedChecker.IndexLocation].ThisLocation), Canvas.GetTop(allLocation[selectedChecker.IndexLocation].ThisLocation));

            // Створення королеви. 
            CreateQueen(allLocation[selectedChecker.IndexLocation]);

            step.Inlines.Add(new Run() { Foreground = Brushes.Blue, Text = "\nStep   -> " + allLocation[selectedChecker.IndexLocation].ThisLocation.ToolTip + "\n---------------\n" });
            stepScrol.ScrollToEnd();

            selectedChecker.AnimationSelected.Stop();
            selectedChecker = null;// Після ходу обнуляємо вибрану фігуру.

            if (leftChecker.Count == 0 || rightChecker.Count == 0)
            {
                serverIsDown.Visibility = System.Windows.Visibility.Visible; eventPlay.Text = "This is End!";
            }
        }
示例#8
0
文件: II.cs 项目: Namey/Chacker_old
        public void Run(List<Checker> lc, out Checker c, out List<Tuple<int, int>> f_step)
        {
            temp = 0;
            countEnemy = 0;

            for (int v = 0; v < lc.Count; v++)
            {
                ch = lc[v];
                Expanded(ch.RouteDown);
                Expanded(ch.RouteLeft);
                Expanded(ch.RouteRight);
                Expanded(ch.RouteUp);
            }

            if (listAct.Count > 0)
            {
                if (listAct.Count == 1)
                {
                    f_step = listAct.Last().Item2;
                    c = listAct.Last().Item1;
                }
                else
                {
                    list.Clear();
                    bool isStep = true;

                    for (int i = 0; i < listAct.Count; i++)
                    {
                        if (Step_1_(listAct[i].Item2.Last().Item1 + 11, 11) && Step_1_(listAct[i].Item2.Last().Item1 - 11, -11))// true - якщо не скраю
                        {
                            if (Step_2_(listAct[i].Item2.Last().Item1 + 11, listAct[i].Item2.Last().Item1) + Step_2_(listAct[i].Item2.Last().Item1 - 11, listAct[i].Item2.Last().Item1) == 1)// true - якщо ворог-вильно/вильно-ворог
                            {
                                isStep = false;
                            }
                            else if (Step_2_(listAct[i].Item2.Last().Item1 + 9, listAct[i].Item2.Last().Item1) + Step_2_(listAct[i].Item2.Last().Item1 - 9, listAct[i].Item2.Last().Item1) == 1)// true - якщо ворог-вильно/вильно-ворог
                            {
                                isStep = false;
                            }
                        }

                        if (isStep)
                        {
                            list.Add(listAct[i]);
                        }

                        isStep = true;
                    }

                    if (list.Count > 0)
                    {
                        int r = rand.Next(list.Count) - 1;
                        r = r < 0 ? 0 : r;
                        c = list[r].Item1;
                        f_step = list[r].Item2;
                    }
                    else
                    {
                        int r = rand.Next(listAct.Count) - 1;
                        r = r < 0 ? 0 : r;
                        c = listAct[r].Item1;
                        f_step = listAct[r].Item2;
                    }
                }
            }
            else
            {
                bool isStep = true;

                for (int i = 0; i < list.Count; i++)
                {
                    if (Step_1_(list[i].Item2.Last().Item1 + 11, 11) && Step_1_(list[i].Item2.Last().Item1 - 11, -11))// true - якщо не скраю
                    {
                        if (Step_2_(list[i].Item2.Last().Item1 + 11, list[i].Item2.Last().Item1) + Step_2_(list[i].Item2.Last().Item1 - 11, list[i].Item2.Last().Item1) == 1)// true - якщо ворог-вильно/вильно-ворог
                        {
                            isStep = false;
                        }
                        else if (Step_2_(list[i].Item2.Last().Item1 + 9, list[i].Item2.Last().Item1) + Step_2_(list[i].Item2.Last().Item1 - 9, list[i].Item2.Last().Item1) == 1)// true - якщо ворог-вильно/вильно-ворог
                        {
                            isStep = false;
                        }
                    }

                    if (isStep)
                    {
                        listAct.Add(list[i]);
                    }

                    isStep = true;
                }

                if (listAct.Count > 0)
                {
                    int r = rand.Next(listAct.Count) - 1;
                    r = r < 0 ? 0 : r;
                    c = listAct[r].Item1;
                    f_step = listAct[r].Item2;
                }
                else
                {
                    int r = rand.Next(list.Count) - 1;
                    r = r < 0 ? 0 : r;
                    c = list[r].Item1;
                    f_step = list[r].Item2;
                }
            }
            list.Clear();
            listAct.Clear();
        }
示例#9
0
 public Location(User us, byte index, Checker ch, FrameworkElement loc)
 { SLocation = StatusLocation.Yes; user = us; IsChecker = ch; ThisLocation = loc; IndexLocation = index; CreateAnimationkMove(); }