Example #1
0
        private void Callback_MoveEvent(Position position, string login)
        {
            FruitControl fruitControl = fruitControls.First(el => el.Tag.ToString() == login);

            Canvas.SetLeft(fruitControl, position.X);
            Canvas.SetTop(fruitControl, position.Y);
        }
Example #2
0
        private void Callback_DisconnectedEvent(string login)
        {
            FruitControl fruitControl = fruitControls.First(el => el.Tag.ToString() == login);

            if (currRoom is StartRoom)
            {
                (currRoom as StartRoom).canvas.Children.Remove(fruitControl);
            }
            if (currRoom is KitchenRoon)
            {
                (currRoom as KitchenRoon).canvas.Children.Remove(fruitControl);
            }
            if (currRoom is BathRoom)
            {
                (currRoom as BathRoom).canvas.Children.Remove(fruitControl);
            }
            if (currRoom is MasterRoom)
            {
                (currRoom as MasterRoom).canvas.Children.Remove(fruitControl);
            }
            if (currRoom is MedBayRoom)
            {
                (currRoom as MedBayRoom).canvas.Children.Remove(fruitControl);
            }

            fruitControls.Remove(fruitControl);
        }
Example #3
0
        public KitchenRoon(FruitControl fruitControl, List <FruitControl> fruitControls)
        {
            InitializeComponent();

            this.fruitControl  = fruitControl;
            this.fruitControls = fruitControls;

            canvas.Children.Add(fruitControl);
            foreach (var item in fruitControls)
            {
                canvas.Children.Add(item);
            }
        }
Example #4
0
        public WindowGame(UserDTO user, string game, string character)
        {
            InitializeComponent();

            tbCode.Text = game;

            callback.Count = 100;

            callback.PlayerDiedEvent       += Callback_PlayerDiedEvent;
            callback.MeImposterEvent       += Callback_MeImposterEvent;
            callback.NewDayEvent           += Callback_NewDayEvent;
            callback.GameStartEvent        += Callback_GameStartEvent;
            callback.PlayerChangedEvent    += Callback_PlayerChangedEvent;
            callback.DisconnectedEvent     += Callback_DisconnectedEvent;
            callback.StateEvent            += Callback_StateEvent;
            callback.MoveEvent             += Callback_MoveEvent;
            callback.NewPlayerArrivedEvent += Callback_NewPlayerArrivedEvent;

            elevenDays_GameServiceClient = new ElevenDays_GameServiceClient(new System.ServiceModel.InstanceContext(callback));

            elevenDays_GameServiceClient.StartByGameID(game, user, character);

            this.user      = user;
            this.game      = game;
            this.character = character;

            for (int i = 0; i < elevenDays_GameServiceClient.GetPlayersCount(game); i++)
            {
                string   str      = elevenDays_GameServiceClient.GetPlayerString(game, i);
                string   charact  = elevenDays_GameServiceClient.GetPlayerFruit(game, i);
                Position position = elevenDays_GameServiceClient.GetPlayerPosition(game, i);
                if (str != user.Login)
                {
                    Callback_NewPlayerArrivedEvent(position, str, charact, "chill");
                }
            }

            fruitControl = new FruitControl($"Images/{character}Ch2.png", new Position()
            {
                X = 0, Y = 0
            }, user.Login);
            fruitControl.Tag = user.Login;

            currRoom          = new StartRoom(fruitControl, fruitControls);
            fruitControl.Room = "chill";
            dockpanel.Children.Add((currRoom as StartRoom));

            elevenDays_GameServiceClient.GameBeginCheckAsync(game);
        }
Example #5
0
        private void Callback_NewPlayerArrivedEvent(Position position, string login, string character, string room)
        {
            FruitControl fruitControl = new FruitControl($"Images/{character}Ch2.png", position, login);

            fruitControl.Tag = login;

            fruitControl.Room = room;

            if (room == "chill")
            {
                if (currRoom is StartRoom)
                {
                    (currRoom as StartRoom).canvas.Children.Add(fruitControl);
                }
            }
            if (room == "kitchen")
            {
                if (currRoom is KitchenRoon)
                {
                    (currRoom as KitchenRoon).canvas.Children.Add(fruitControl);
                }
            }
            if (room == "bath")
            {
                if (currRoom is BathRoom)
                {
                    (currRoom as BathRoom).canvas.Children.Add(fruitControl);
                }
            }
            if (room == "maist")
            {
                if (currRoom is MasterRoom)
                {
                    (currRoom as MasterRoom).canvas.Children.Add(fruitControl);
                }
            }
            if (room == "medbay")
            {
                if (currRoom is MedBayRoom)
                {
                    (currRoom as MedBayRoom).canvas.Children.Add(fruitControl);
                }
            }

            fruitControls.Add(fruitControl);
        }
Example #6
0
 public bool IsContactWithPhysElements(FruitControl fruitControl, int top, int left)
 {
     foreach (var item in canvas.Children)
     {
         if (item is Border)
         {
             if ((item as Border).Tag.ToString() == "phys")
             {
                 //MessageBox.Show($"{Canvas.GetLeft(fruitControl)}/{fruitControl.Width}/{Canvas.GetLeft((item as Border))}/{(item as Border).Width}||{Canvas.GetTop(fruitControl)}/{Canvas.GetTop((item as Border))}/{(item as Border).Height}/{fruitControl.Height}");
                 if ((Canvas.GetLeft(fruitControl) + fruitControl.Width + left > Canvas.GetLeft((item as Border)) &&
                      Canvas.GetLeft(fruitControl) + left < Canvas.GetLeft((item as Border)) + (item as Border).Width) &&
                     (Canvas.GetTop(fruitControl) + top < Canvas.GetTop((item as Border)) + (item as Border).Height &&
                      Canvas.GetTop(fruitControl) + fruitControl.Height + top >= Canvas.GetTop((item as Border))))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Example #7
0
        private void Callback_StateEvent(string state, string login, string charact)
        {
            FruitControl fruitControl = fruitControls.First(el => el.Tag.ToString() == login);

            string img = "";

            if (state == "StayRight")
            {
                img = $"Images/{charact}Ch2.png";
            }
            if (state == "StayLeft")
            {
                img = $"Images/{charact}Ch1.png";
            }
            else
            {
                img = $"Images/{charact}Ch2.png";
            }

            fruitControl.imgBrush.ImageSource = new BitmapImage(new Uri(img, UriKind.Relative));
        }
Example #8
0
        public string CheckOnCloseContact(FruitControl fruitControl)
        {
            //door1.BorderThickness = new Thickness(0);
            door2.BorderThickness = new Thickness(0);
            door3.BorderThickness = new Thickness(0);
            door4.BorderThickness = new Thickness(0);

            //double xD1 = Canvas.GetLeft(door1), yD1 = Canvas.GetTop(door1);
            double xD2 = Canvas.GetLeft(door2), yD2 = Canvas.GetTop(door2);
            double xD3 = Canvas.GetLeft(door3), yD3 = Canvas.GetTop(door3);
            double xD4 = Canvas.GetLeft(door4), yD4 = Canvas.GetTop(door4);

            double xF = Canvas.GetLeft(fruitControl), yF = Canvas.GetTop(fruitControl);

            //if (xF <= xD1 + 200 && yF <= yD1 + 200 && yF >= yD1 - 300)
            //{
            //    door1.BorderThickness = new Thickness(5);
            //    return door1.Tag.ToString();
            //}

            if (xF >= xD3 - 200 && xF <= xD3 + 300 && yF <= yD3 + 200)
            {
                door3.BorderThickness = new Thickness(5);
                return(door3.Tag.ToString());
            }
            else if (xF >= xD2 - 300 && yF <= yD2 + 300 && yF >= yD2 - 300)
            {
                door2.BorderThickness = new Thickness(5);
                return(door2.Tag.ToString());
            }
            else if (xF >= xD4 - 300 && xF <= xD4 + 300 && yF >= yD4 - 400)
            {
                door4.BorderThickness = new Thickness(5);
                return(door4.Tag.ToString());
            }
            return("");
        }
Example #9
0
 private bool IsCloseContact(FruitControl fruitControl, FruitControl item)
 {
     return(Canvas.GetLeft(fruitControl) > Canvas.GetLeft(item) - 100 && Canvas.GetLeft(fruitControl) < Canvas.GetLeft(item) + 100 + item.Width && Canvas.GetTop(fruitControl) > Canvas.GetTop(item) - 100 && Canvas.GetTop(fruitControl) < Canvas.GetTop(item) + 100 + item.Height);
 }
Example #10
0
        private void Callback_PlayerChangedEvent(string login, string room)
        {
            FruitControl fruitControl = fruitControls.First(el => el.Tag.ToString() == login);

            fruitControl.Room = room;

            if (currRoom is StartRoom && room != "chill")
            {
                if ((currRoom as StartRoom).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as StartRoom).canvas.Children.Remove(fruitControl);
                }
            }
            if (currRoom is KitchenRoon && room != "kitchen")
            {
                if ((currRoom as KitchenRoon).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as KitchenRoon).canvas.Children.Remove(fruitControl);
                }
            }
            if (currRoom is BathRoom && room != "bath")
            {
                if ((currRoom as BathRoom).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as BathRoom).canvas.Children.Remove(fruitControl);
                }
            }
            if (currRoom is MasterRoom && room != "maist")
            {
                if ((currRoom as MasterRoom).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as MasterRoom).canvas.Children.Remove(fruitControl);
                }
            }
            if (currRoom is MedBayRoom && room != "medbay")
            {
                if ((currRoom as MedBayRoom).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as MedBayRoom).canvas.Children.Remove(fruitControl);
                }
            }

            if (currRoom is StartRoom && room == "chill")
            {
                if (!(currRoom as StartRoom).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as StartRoom).canvas.Children.Add(fruitControl);
                }
            }

            if (currRoom is KitchenRoon && room == "kitchen")
            {
                if ((currRoom as KitchenRoon).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as KitchenRoon).canvas.Children.Add(fruitControl);
                }
            }

            if (currRoom is BathRoom && room == "bath")
            {
                if (!(currRoom as BathRoom).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as BathRoom).canvas.Children.Add(fruitControl);
                }
            }

            if (currRoom is MasterRoom && room == "maist")
            {
                if ((currRoom as MasterRoom).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as MasterRoom).canvas.Children.Add(fruitControl);
                }
            }

            if (currRoom is MedBayRoom && room == "medbay")
            {
                if (!(currRoom as MedBayRoom).canvas.Children.Contains(fruitControl))
                {
                    (currRoom as MedBayRoom).canvas.Children.Add(fruitControl);
                }
            }
        }