Exemplo n.º 1
0
        //poruka od servera
        private void HandleUpdateLocation(UpdateLocation x)
        {
            var msg = new MakeMove(x.Avatar, x.NewX, x.NewY, x.Direction);

            gameRenderingActor.Tell(msg);
        }
Exemplo n.º 2
0
        private void HandleMakeMove(MakeMove x)
        {
            PictureBox avatar    = (PictureBox)Program.myForm.Controls.Find(key: x.AvatarName, searchAllChildren: false).FirstOrDefault();
            int        x_old     = avatar.Location.X;
            int        y_old     = avatar.Location.Y;
            string     direction = x.Direction;
            Image      pic       = null;
            var        location  = new System.Drawing.Point(x.NewX, x.NewY);

            if ((string)avatar.Tag == "pacman0")
            {
                switch (direction)
                {
                case "left":
                    pic = Resources.right;
                    break;

                case "right":
                    pic = Resources.left;
                    break;

                case "up":
                    pic = Resources.up;
                    break;

                case "down":
                    pic = Resources.down;
                    break;
                }
            }
            else
            {
                switch (direction)
                {
                case "left":
                    pic = Resources.right2;
                    break;

                case "right":
                    pic = Resources.left2;
                    break;

                case "up":
                    pic = Resources.up2;
                    break;

                case "down":
                    pic = Resources.down2;
                    break;
                }
            }
            avatar.Image    = pic;
            avatar.Location = location;

            foreach (var wall in _allWalls)
            {
                if (avatar.Bounds.IntersectsWith(wall.Bounds))
                {
                    location        = new System.Drawing.Point(x_old, y_old);
                    avatar.Location = location;
                }
            }
        }