Ejemplo n.º 1
0
        /// <summary>
        /// loads all coins spaces into the board.
        /// </summary>
        /// <param name="save">Save point</param>
        public void Load(SaveGame save)
        {
            GridWidth  = (int)save.GridSize.Width;
            GridHeight = (int)save.GridSize.Height;

            for (int i = 0; i < save.CoinGrid.Length; i++)
            {
                if (save.CoinGrid[i] == null)
                {
                    save.CoinGrid[i] = new CoinType[GridHeight];
                }
            }
            coinGrid = save.CoinGrid;

            coinTosser.Delete();
            for (int x = 0; x < GridWidth; x++)
            {
                for (int y = 0; y < GridHeight; y++)
                {
                    if (save.CoinGrid[x][y] != CoinType.None)
                    {
                        coinTosser.Create(save.CoinGrid[x][y], GridSize);
                        coinTosser.Move(new Point(x, y + 1), GridSize, TimeSpan.FromMilliseconds(250));
                    }
                }
            }
            EnemyAI = new AI(ref coinGrid, new Size(GridWidth, GridHeight), random.Next());
            EnemyAI.LocationRecieved += GameConnection_LocationRecieved;
            coinTosser.BlueTurn      += CoinTosser_BlueTurn;

            coinTosser.Create(save.Turn, GridSize);
        }
Ejemplo n.º 2
0
        private void LoadPreview()
        {
            var coinTosser = new CoinTosser(Preview);

            Size gs     = Save.GridSize;
            Size rgs    = new Size(Preview.Width / Save.GridSize.Width, Preview.Height / Save.GridSize.Height);
            Size rrgs   = new Size(Preview.Width, Preview.Height);
            var  source = new BitmapImage(new Uri("pack://siteoforigin:,,,/Images/boardSegment.png"));

            for (int x = 0; x < gs.Width; x++)
            {
                for (int y = 0; y < gs.Height; y++)
                {
                    {
                        Image img = new Image()
                        {
                            Source = source,
                            Width  = rgs.Width,
                            Height = rgs.Height
                        };
                        Preview.Children.Add(img);
                        Canvas.SetLeft(img, x * rgs.Width);
                        Canvas.SetTop(img, y * rgs.Height);
                        SetZIndex(img, 2);
                    }
                }
            }

            for (int x = 0; x < gs.Width; x++)
            {
                for (int y = 0; y < gs.Height; y++)
                {
                    if (Save.CoinGrid[x][y] != CoinType.None)
                    {
                        coinTosser.Create(Save.CoinGrid[x][y], rgs);
                        coinTosser.Move(new Point(x, y), rgs, TimeSpan.FromMilliseconds(250));
                    }
                }
            }
        }