예제 #1
0
        public void DrawMap(Map map)
        {
            MapCanvas.Children.Clear();
            MapCanvas.Width = 32 * map.Width;
            MapCanvas.Height = 32 * map.Height;

            mapCanvasIMGs = new Image[map.Width, map.Height];
            for (int x = 0; x < map.Width; x++)
            {
                for (int y = 0; y < map.Height; y++)
                {
                    Image img = new Image
                    {
                        Width = 32,
                        Height = 32,
                        Source = this.controller.TileIMG(map.Tiles[x, y].Type),
                        Tag = new Vector2(map.Tiles[x,y].Position.X, map.Tiles[x,y].Position.Y)
                    };

                    img.MouseLeftButtonDown += this.BrushDown;
                    img.MouseLeftButtonUp += this.BrushUp;
                    img.MouseMove += this.OnDraw;
                    this.MapCanvas.Children.Add(img);
                    mapCanvasIMGs[x, y] = img;
                    Canvas.SetLeft(img, x * 32);
                    Canvas.SetTop(img, y * 32);
                }
            }
        }
예제 #2
0
    private void Awake()
    {
        PlayerData.instance.CheckInstance();

        usableMaxPoint = PlayerData.instance.GetClearedStageCount();
        if (usableMaxPoint > 12) // World2에선 StageClear해도 포인트 안 줌
            usableMaxPoint = 12;
        usablePoint = usableMaxPoint;

        animator = GetComponent<Animator>();
        main = GameObject.FindObjectOfType<Main>();

        // 포인트 배분 로드하는 부분 구현

        gaugeImages = new Image[upgradeButtons.Length, 6];
        int alreadyAllocatedPoints = 0;
        for (int i = 0; i < upgradeButtons.Length; ++i)
        {
            allocatedPoints[i] = PlayerData.instance.upgradePoint[upgradeButtons[i].name];
            alreadyAllocatedPoints += allocatedPoints[i];
            for (int j = 0; j < 6; ++j)
            {
                gaugeImages[i, j] = upgradeButtons[i].transform.FindChild("Gauge" + (j + 1).ToString()).GetComponent<Image>();
            }
            SetGauge(i, allocatedPoints[i]);
        }
        usablePoint -= alreadyAllocatedPoints;
        SetAllocateButtonInteractive(false);

        remainingPointText.text = usablePoint.ToString();
    }
예제 #3
0
        //default invaders contructor accepted the canvas and current level
        public Invaders(Canvas canvas, int lvl)
        {
            //initialize variables and grid
            createRowsAndColumns();
            invaderGrid = new Image[columns, rows];
            invaderBullets = new Image[3];
            
            isMovingLeft = invadersAreMoving = isMovingDown = toggleSprite = false;
            isShooting = true;
            isPlayerAlive = true;
            count = 0;
            speed = lvl;

            //loops to set the alien grid and images
            for (int c = 0; c < columns; c++)
            {
                for (int r = 0; r < rows; r++)
                {
                    Image invader = new Image();
                    BitmapImage bitmapSource;

                    //If the row number is smaller than 1, use this sprite
                    if (r < 1)
                    {
                        invader.Height = 24 * sizeModifier();
                        invader.Tag = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-1-2.png"));
                        bitmapSource = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-1-1.png"));
                    }
                    //If the row number is smaller than 3, use this sprite
                    else if (r < 3)
                    {
                        invader.Height = 28 * sizeModifier();
                        invader.Tag = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-2-2.png"));
                        bitmapSource = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-2-1.png"));
                    }
                    //If the row number is bigger than 3, use this sprite
                    else
                    {
                        invader.Height = 32 * sizeModifier();
                        invader.Tag = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-3-2.png"));
                        bitmapSource = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-3-1.png"));
                    }

                    //Set the x coords for selected the invader
                    Canvas.SetLeft(invader, 32 + (50 * c));
                    
                    //Set the y coords for the selected invader
                    if (rows * 32 >= Window.Current.Bounds.Height / 2) Canvas.SetTop(invader, -((rows * 32) - 64) + (50 * r));
                    else Canvas.SetTop(invader, 32 + (50 * r));

                    invader.Width = 32 * sizeModifier();
                    invader.Source = bitmapSource;

                    //add invader to the canvas and invaderGrid
                    canvas.Children.Add(invader);
                    invaderGrid[c, r] = invader;
                }
            }
        }
예제 #4
0
 public GameWindowObj(Map map)
 {
     ImageGrid = new Image[map.Height,map.Width];
     GWindow = new Window();
     GWindow.Background = System.Windows.Media.Brushes.Black;
     GameMap = map;
     RefreshGameMap.Elapsed += tick;
     GameWindow.Build(GWindow, ImageGrid, TileTypes.GetProcessedIds(GameMap), GameMap.Height, GameMap.Width);
 }
예제 #5
0
파일: Game.xaml.cs 프로젝트: Whazor/Sokoban
 public Game(Domain.Domain.Game game)
 {
     _game = game;
     InitializeComponent();
     _images = new Image[_game.Width, _game.Height];
     Height = _game.Height * 60 + 100;
     Width = _game.Width * 60 + 100;
     Redraw();
     _game.Moved += Moved;
     _game.Score += Score;
 }
 private void buildArray(Image sheet)
 {
     _xTiles = sheet.Width / _spriteWidth;
     _yTiles = sheet.Height / _spriteHeight;
     _tiles = _xTiles * _yTiles;
     _textureSheet = new Image[_xTiles,_yTiles];
     for (int x = 0; x < _xTiles; x++)
     {
         for (int y = 0; y < _yTiles; y++)
         {
             Rectangle cutRect = new Rectangle(x * _spriteWidth, y * _spriteHeight, _spriteWidth, _spriteHeight);
             _textureSheet[x, y] = (sheet as Bitmap).Clone(cutRect, System.Drawing.Imaging.PixelFormat.DontCare);
         }
     }
 }
        public MainWindow()
        {
            InitializeComponent();
            // Create the Grid
            pixelGrid.ShowGridLines = true;
            for (i = 0; i < row; i++)
            {
                pixelGrid.RowDefinitions.Add(new RowDefinition());
            }
            for (j = 0; j < column; j++)
            {
                pixelGrid.ColumnDefinitions.Add(new ColumnDefinition());
            }
            gridWidth = pixelGrid.Width;
            gridHeight = pixelGrid.Height;

            //Buttons
            closeBtn = new Button[row, column];
            pixImg = new Image[row, column];
            //image
            BitmapImage bitmap = new BitmapImage(new Uri("/Resources/audioPixel.bmp", UriKind.Relative));
            Image pixelImage = new Image();
            pixelImage.Source = bitmap;
            pixelImage.Stretch = Stretch.Fill;

            for (i = 0; i < row; i++)
            {
                for (j = 0; j < column; j++)
                {
                    //image
                    pixImg[i, j] = new Image();
                    pixImg[i, j].Source = bitmap;
                    pixImg[i, j].Stretch = Stretch.Fill;

                    //buttons
                    closeBtn[i, j] = new Button();
                    closeBtn[i, j].Height = gridHeight / row;
                    closeBtn[i, j].Width = gridWidth / column;
                    closeBtn[i, j].HorizontalAlignment = HorizontalAlignment.Center;
                    closeBtn[i, j].VerticalAlignment = VerticalAlignment.Center;
                    closeBtn[i, j].Content = pixImg[i, j];

                    pixelGrid.Children.Add(closeBtn[i, j]);
                    Grid.SetRow(closeBtn[i,j], i);
                    Grid.SetColumn(closeBtn[i,j], j);
                }
            }
        }
예제 #8
0
        public Invaders(Canvas canvas)
        {
            invaderGrid = new Image[11, 5];

            isMovingLeft = isMovingDown = toggleSprite = false;

            count = 0;

            for (int c = 0; c < 11; c++)
            {
                for (int r = 0; r < 5; r++)
                {
                    Image invader = new Image();
                    BitmapImage bitmapSource;

                    if (r < 1)
                    {
                        invader.Height = 24;
                        invader.Tag = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-1-2.png"));
                        bitmapSource = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-1-1.png"));
                    }
                    else if (r < 3)
                    {
                        invader.Height = 28;
                        invader.Tag = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-2-2.png"));
                        bitmapSource = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-2-1.png"));
                    }
                    else
                    {
                        invader.Height = 32;
                        invader.Tag = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-3-2.png"));
                        bitmapSource = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-3-1.png"));
                    }

                    Canvas.SetLeft(invader, 50 + (50 * c));
                    Canvas.SetTop(invader, 50 + (50 * r));

                    invader.Width = 32;
                    invader.Source = bitmapSource;

                    canvas.Children.Add(invader);
                    invaderGrid[c, r] = invader;
                }
            }
        }
예제 #9
0
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
            InitializeComponent();
            imagenes = new PictureBox[NUMERO_FILAS,NUMERO_COLUMNAS];
            matrizRespaldo = new Image[NUMERO_FILAS,NUMERO_COLUMNAS];
            tablero = new LogicaJuego(NUMERO_FILAS,NUMERO_COLUMNAS);

            llenarMatrizImagenes();
            mostrarCartas();
            Timer contador = new Timer();
            contador.Interval = (RETRASO_OCULTAMIENTO);
            contador.Tick += new EventHandler(contar);
            contador.Start();
        }
예제 #10
0
파일: frmRegister.cs 프로젝트: kanhar/xna
        public frmRegister()
        {
            InitializeComponent();
            myImages = new Image[9,2];
            myImages = Helper.GetRecentImages();

            myURLs = new String[9];
            myURLs = Helper.GetRecentImagesURLs();

            pb1.Image = myImages[0,0];
            pb2.Image = myImages[1,0];
            pb3.Image = myImages[2,0];
            pb4.Image = myImages[3,0];
            pb5.Image = myImages[4,0];
            pb6.Image = myImages[5,0];
            pb7.Image = myImages[6,0];
            pb8.Image = myImages[7,0];
            pb9.Image = myImages[8,0];
            Refresh();
        }
예제 #11
0
        public Image[,] InitTileGrid() {
            tileImages = new Image[vertTiles, horzTiles];
            for (int col = 0; col < horzTiles; col++) {
                ColumnDefinition coldef = new ColumnDefinition();
                coldef.Width = new GridLength(1, GridUnitType.Star);
                grid.ColumnDefinitions.Add(coldef);
            }

            for (int row = 0; row < vertTiles; row++) {
                RowDefinition rowdef = new RowDefinition();
                rowdef.Height = new GridLength(1, GridUnitType.Star);
                grid.RowDefinitions.Add(rowdef);
            }

            int tileSize = this.tileBitmap.PixelWidth / horzTiles;


            emptyCol = horzTiles - 1;
            emptyRow = vertTiles - 1;
            for (int row = 0; row < vertTiles; row++) {
                for (int col = 0; col < horzTiles; col++) {
                    if (row != emptyRow || col != emptyCol) {
                        WriteableBitmap tile = new WriteableBitmap(tileSize, tileSize);

                        for (int y = 0; y < tileSize; y++) {
                            for (int x = 0; x < tileSize; x++) {
                                int yBit = row * tileSize + y;
                                int xBit = col * tileSize + x;

                                tile.Pixels[y * tileSize + x] = this.tileBitmap.Pixels[yBit * this.tileBitmap.PixelWidth + xBit];
                            }
                        }
                        GenerateImageTile(tile, row, col);
                    }
                }
            }

            haveValidTileImages = true;

            return this.tileImages;
        }
예제 #12
0
	public void LoadMaze(int index)
	{
		cObjs = new GameObject[rows,cols];
		cImages = new Image[rows,cols];
		cColors = new int[rows,cols];
		
		currentHash = GetMaze (index);
		
		if (currentHash == null) {
			print ("maze zero is null");
			currentHash = InitializeBoardGrid ();
			SetMazeHash (currentHash);
		} else {
			scoreManager.SetBest(GetBestAttempt(currentHash));
			print("reusing maze zero");
		}
		
		SetMazeBoard (currentHash);
		
		UpdateColors ();
	}
예제 #13
0
        private unsafe void GenerateMap()
        {
            int imageWidth = (int)Math.Round(drawnMap.Source.Width);
            int imageHeight = (int)Math.Round(drawnMap.Source.Height);

            tiles = new int[imageWidth, imageHeight];
            visualTiles = new Image[imageWidth, imageHeight];

            System.Drawing.Rectangle imageRectangle = new System.Drawing.Rectangle(0, 0, imageWidth, imageHeight);

            System.Drawing.Bitmap bitmapSource = _bitmapFromSource((BitmapSource)drawnMap.Source);

            BitmapData bitmapPixels = bitmapSource.LockBits(imageRectangle, ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb);

            for (int row = 0; row < imageHeight; row++)
            {
                int* scanline = (int*)bitmapPixels.Scan0 + (row * imageWidth);

                for (int column = 0; column < imageWidth; column++)
                {
                    System.Drawing.Color savedColor = System.Drawing.Color.FromArgb(scanline[column]);

                    tiles[column, row] = savedColor.R;

                    Image newImage = new Image();
                    newImage.Source = _bitmapToSource(cachedTileFrames[tiles[column, row]]);
                    newImage.Width = cachedTileFrames[tiles[column, row]].Width;
                    newImage.Height = cachedTileFrames[tiles[column, row]].Height;
                    visualTiles[column, row] = newImage;

                    Canvas.SetLeft(newImage, column * TileDimensions.X);
                    Canvas.SetTop(newImage, row * TileDimensions.Y);
                    map.Children.Add(visualTiles[column, row]);
                }
            }

            bitmapSource.UnlockBits(bitmapPixels);
        }
예제 #14
0
    public void Init(int x, int y)
    {
        size = new Vector2(x, y);
        inventory = transform.GetComponent<GameManager>().getPlayer().GetComponent<Inventory>();
        invDispText = new Text[x,y];
        invDispImg = new Image[x,y];
        invSelectImg = new Image[x,y];

        //UnityEngine.UI.Text tempTxt;
        //UnityEngine.UI.Image tempImg;
        //UnityEngine.UI.Image tempSlt;

        for (int i = 0; i < 5; i++)
        {
            invDispImg[0, i] = invDImg[i];
            invDispText[0, i] = invDText[i];
            invSelectImg[0, i] = invSImg[i];
        }

        for (int i = 1; i < size.x; i++)
        {
            for (int j = 0; j < size.y; j++)
            {
                //tempTxt = Instantiate<UnityEngine.UI.Text>();

                invDispImg[i, j] = null;
                invDispText[i, j] = null;
                invSelectImg[i, j] = null;
            }
        }

        bkgc = invDispImg[0, 1].color;
        curselect = inventory.getPointer();
        updateSelect();
        init = true;
    }
		async private void Refresh()
		{
			screen.Children.Clear();

			if (ImageSource == null)
				return;

			BitmapImage bmp = new BitmapImage();
			bmp.SetSource(await (await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///" + ImageSource))).OpenAsync(FileAccessMode.Read));
			
			int col = (int)ActualWidth / bmp.PixelWidth + 1, row = (int)ActualHeight / bmp.PixelHeight + 1;
			images = new Image[col, row];

			for (int i = 0; i < col; ++i)
				for (int j = 0; j < row; ++j)
				{
					images[i, j] = new Image();
					images[i, j].Source = bmp;

					screen.Children.Add(images[i, j]);
					Canvas.SetLeft(images[i, j], i * bmp.PixelWidth);
					Canvas.SetTop(images[i, j], j * bmp.PixelHeight);
				}
		}
예제 #16
0
파일: Figure.cs 프로젝트: haroutunyan/Chess
        private void kingHint(ref Image[,] hints, ref int[,] matrix)
        {
            if (y < 7 && matrix[x, y + 1] != 1)
            {
                hints[x, y + 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x, y + 1].Margin  = new Thickness(x * 73, (y + 1) * 70, 0, 0);
                hints[x, y + 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x, y + 1], 1);

                matrix[x, y + 1] = 2;
            }
            if (y > 0 && matrix[x, y - 1] != 1)
            {
                hints[x, y - 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x, y - 1].Margin  = new Thickness(x * 73, (y - 1) * 70, 0, 0);
                hints[x, y - 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x, y - 1], 1);
                matrix[x, y - 1] = 2;
            }
            if (x > 0 && matrix[x - 1, y] != 1)
            {
                hints[x - 1, y].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x - 1, y].Margin  = new Thickness((x - 1) * 73, y * 70, 0, 0);
                hints[x - 1, y].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x - 1, y], 1);
                matrix[x - 1, y] = 2;
            }
            if (x < 7 && matrix[x + 1, y] != 1)
            {
                hints[x + 1, y].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x + 1, y].Margin  = new Thickness((x + 1) * 73, y * 70, 0, 0);
                hints[x + 1, y].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x + 1, y], 1);
                matrix[x + 1, y] = 2;
            }
            if (x < 7 && y < 7 && matrix[x + 1, y + 1] != 1)
            {
                hints[x + 1, y + 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x + 1, y + 1].Margin  = new Thickness((x + 1) * 73, (y + 1) * 70, 0, 0);
                hints[x + 1, y + 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x + 1, y + 1], 1);
                matrix[x + 1, y + 1] = 2;
            }
            if (x > 0 && y > 0 && matrix[x - 1, y - 1] != 1)
            {
                hints[x - 1, y - 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x - 1, y - 1].Margin  = new Thickness((x - 1) * 73, (y - 1) * 70, 0, 0);
                hints[x - 1, y - 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x - 1, y - 1], 1);
                matrix[x - 1, y - 1] = 2;
            }
            if (x > 0 && y < 7 && matrix[x - 1, y + 1] != 1)
            {
                hints[x - 1, y + 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x - 1, y + 1].Margin  = new Thickness((x - 1) * 73, (y + 1) * 70, 0, 0);
                hints[x - 1, y + 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x - 1, y + 1], 1);
                matrix[x - 1, y + 1] = 2;
            }
            if (x < 7 && y > 0 && matrix[x + 1, y - 1] != 1)
            {
                hints[x + 1, y - 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x + 1, y - 1].Margin  = new Thickness((x + 1) * 73, (y - 1) * 70, 0, 0);
                hints[x + 1, y - 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x + 1, y - 1], 1);
                matrix[x + 1, y - 1] = 2;
            }
        }
예제 #17
0
        private void caricaFrame()
        {
            frame = new Image[4, frameTotali];


            frame[0, 0]  = Properties.Resources.pacman1Left;
            frame[0, 1]  = Properties.Resources.pacman2Left;
            frame[0, 2]  = Properties.Resources.pacman3Left;
            frame[0, 3]  = Properties.Resources.pacman4Left;
            frame[0, 4]  = Properties.Resources.pacman5Left;
            frame[0, 5]  = Properties.Resources.pacman6Left;
            frame[0, 6]  = Properties.Resources.pacman7Left;
            frame[0, 7]  = Properties.Resources.pacman8Left;
            frame[0, 8]  = Properties.Resources.pacman9Left;
            frame[0, 9]  = Properties.Resources.pacman10Left;
            frame[0, 10] = Properties.Resources.pacman11Left;
            frame[0, 11] = Properties.Resources.pacman12Left;
            frame[0, 12] = Properties.Resources.pacman13Left;
            frame[0, 13] = Properties.Resources.pacman14Left;


            frame[1, 0]  = Properties.Resources.pacman1Up;
            frame[1, 1]  = Properties.Resources.pacman2Up;
            frame[1, 2]  = Properties.Resources.pacman3Up;
            frame[1, 3]  = Properties.Resources.pacman4Up;
            frame[1, 4]  = Properties.Resources.pacman5Up;
            frame[1, 5]  = Properties.Resources.pacman6Up;
            frame[1, 6]  = Properties.Resources.pacman7Up;
            frame[1, 7]  = Properties.Resources.pacman8Up;
            frame[1, 8]  = Properties.Resources.pacman9Up;
            frame[1, 9]  = Properties.Resources.pacman10Up;
            frame[1, 10] = Properties.Resources.pacman11Up;
            frame[1, 11] = Properties.Resources.pacman12Up;
            frame[1, 12] = Properties.Resources.pacman13Up;
            frame[1, 13] = Properties.Resources.pacman14Up;


            frame[2, 0]  = Properties.Resources.pacman1Right;
            frame[2, 1]  = Properties.Resources.pacman2Right;
            frame[2, 2]  = Properties.Resources.pacman3Right;
            frame[2, 3]  = Properties.Resources.pacman4Right;
            frame[2, 4]  = Properties.Resources.pacman5Right;
            frame[2, 5]  = Properties.Resources.pacman6Right;
            frame[2, 6]  = Properties.Resources.pacman7Right;
            frame[2, 7]  = Properties.Resources.pacman8Right;
            frame[2, 8]  = Properties.Resources.pacman9Right;
            frame[2, 9]  = Properties.Resources.pacman10Right;
            frame[2, 10] = Properties.Resources.pacman11Right;
            frame[2, 11] = Properties.Resources.pacman12Right;
            frame[2, 12] = Properties.Resources.pacman13Right;
            frame[2, 13] = Properties.Resources.pacman14Right;


            frame[3, 0]  = Properties.Resources.pacman1Down;
            frame[3, 1]  = Properties.Resources.pacman2Down;
            frame[3, 2]  = Properties.Resources.pacman3Down;
            frame[3, 3]  = Properties.Resources.pacman4Down;
            frame[3, 4]  = Properties.Resources.pacman5Down;
            frame[3, 5]  = Properties.Resources.pacman6Down;
            frame[3, 6]  = Properties.Resources.pacman7Down;
            frame[3, 7]  = Properties.Resources.pacman8Down;
            frame[3, 8]  = Properties.Resources.pacman9Down;
            frame[3, 9]  = Properties.Resources.pacman10Down;
            frame[3, 10] = Properties.Resources.pacman11Down;
            frame[3, 11] = Properties.Resources.pacman12Down;
            frame[3, 12] = Properties.Resources.pacman13Down;
            frame[3, 13] = Properties.Resources.pacman14Down;
        }
예제 #18
0
    IEnumerator Start()
    {
        RectTransform rc = GetComponent <RectTransform>();
        Vector2       tmpPos;

        canvas = GameObject.Find("CanvasInGame");
        inventoryBackground = GetComponent <Image>();
        if (casesParent == null)
        {
            casesParent = new GameObject("inventoryCases");
            casesParent.transform.SetParent(transform);
            casesParent.AddComponent <RectTransform>();
        }
        RectTransform rcParent = casesParent.GetComponent <RectTransform>();

        rcParent.sizeDelta               = Vector2.one;
        rcParent.pivot                   = Vector2.up;
        rcParent.anchorMax               = Vector2.up;
        rcParent.anchorMin               = Vector2.up;
        rcParent.anchoredPosition        = Vector2.zero;
        casesParent.transform.localScale = Vector3.one;
        cases   = new Image[CraftManager.GetCraftManager.NbColumns, CraftManager.GetCraftManager.NbLines];
        casesGO = new GameObject[CraftManager.GetCraftManager.NbColumns, CraftManager.GetCraftManager.NbLines];
        Button button;

        for (int i = 0; i < CraftManager.GetCraftManager.NbColumns; i++)
        {
            for (int j = 0; j < CraftManager.GetCraftManager.NbLines; j++)
            {
                casesGO[i, j] = new GameObject("case " + i + " : " + j);
                RectTransform tmpRect = casesGO[i, j].AddComponent <RectTransform>();
                tmpPos = Vector2.zero;;
                casesGO[i, j].transform.SetParent(casesParent.transform);
                tmpPos.x += i * (sizeCase.x + offset.x) + offset.x + offsetBorder.x;
                tmpPos.y -= j * (sizeCase.y + offset.y) + offset.y;
                casesGO[i, j].AddComponent <Image>().sprite = caseSprite;
                tmpRect.pivot            = Vector2.up;
                tmpRect.anchorMax        = Vector2.up;
                tmpRect.anchorMin        = Vector2.up;
                tmpRect.sizeDelta        = sizeCase;
                tmpRect.anchoredPosition = tmpPos;
                tmpRect.localScale       = Vector3.one;

                GameObject tmp2 = Instantiate(casesGO[i, j]);
                tmp2.transform.SetParent(casesGO[i, j].transform);

                casesGO[i, j].SetActive(false);

                cases[i, j]       = tmp2.GetComponent <Image>();
                cases[i, j].color = Color.white;

                button = tmp2.AddComponent <Button>();
                int idCraftItem = i + j * CraftManager.GetCraftManager.NbColumns;
                button.onClick.AddListener(() => CraftItem(idCraftItem));
                tmpRect                  = tmp2.GetComponent <RectTransform>();
                tmpRect.pivot            = new Vector2(0.5f, 0.5f);
                tmpRect.anchorMax        = new Vector2(0.5f, 0.5f);
                tmpRect.anchorMin        = new Vector2(0.5f, 0.5f);
                tmpRect.sizeDelta        = sizeCase * 0.75f;
                tmpRect.anchoredPosition = Vector2.zero;
                tmpRect.localScale       = Vector3.one;

                //MouseOverCraft tmpMouseOver = tmp2.AddComponent<MouseOverCraft>();
                //tmpMouseOver.id = idCraftItem;
                //tmpMouseOver.onMouseOverEnter += MouseOverEnter;
                //tmpMouseOver.onMouseOverExit += MouseOverExit;
            }
        }
        resourcesForCraft     = new GameObject[nbMaxResourcesForCraft];
        textResourcesForCraft = new Text[nbMaxResourcesForCraft];
        for (int i = 0; i < nbMaxResourcesForCraft; i++)
        {
            resourcesForCraft[i] = Instantiate(prefabItemCraft);
            resourcesForCraft[i].transform.SetParent(resourceBackground.transform);
            RectTransform rectTransform = resourcesForCraft[i].GetComponent <RectTransform>();
            rectTransform.pivot     = Vector2.up;
            rectTransform.anchorMax = Vector2.up;
            rectTransform.anchorMin = Vector2.up;
            rectTransform.sizeDelta = sizeResourceCraft;
            resourcesForCraft[i].transform.localScale = Vector3.one;
            textResourcesForCraft[i]          = resourcesForCraft[i].GetComponentInChildren <Text>();
            textResourcesForCraft[i].fontSize = ressourcesFontSize;
            textResourcesForCraft[i].rectTransform.anchoredPosition = Vector3.down * (sizeResourceCraft + offsetResourceCraft);
            resourcesForCraft[i].SetActive(false);
        }

        selectedItem.GetComponent <RectTransform>().sizeDelta = casesGO[0, 0].GetComponent <RectTransform>().sizeDelta;

        itemsSpriteHud     = SpriteManager.GetSpriteManager.ItemsSpriteHud;
        resourcesSpriteHud = SpriteManager.GetSpriteManager.ResourcesSpriteHud;

        CraftManager.GetCraftManager.CraftOpen     += EnableCraftHud;
        CraftManager.GetCraftManager.CraftClose    += DisableCraftHud;
        CraftManager.GetCraftManager.CraftIsUpdate += UpdateCraftHud;
        posItemCraft = new Vector2();

        rc.sizeDelta = new Vector2(CraftManager.GetCraftManager.NbColumns * (sizeCase.x + offset.x) + offset.x + offsetBorder.x * 2f, 3f * (sizeCase.x + offset.x) + offset.x + offsetBorder.x * 2f);
        scrollViewRectTransform.sizeDelta = new Vector2(rc.sizeDelta.x, rc.sizeDelta.y - offsetBorder.y * 2f);
        while (CraftManager.GetCraftManager.GetRealNbLines() == 0)
        {
            yield return(null);
        }
        contentRectTransform.sizeDelta = new Vector2(contentRectTransform.sizeDelta.x, CraftManager.GetCraftManager.GetRealNbLines() * (sizeCase.y + offset.y) + offset.y);
        DisableCraftHud();
        isInitialize = true;
    }
예제 #19
0
    IEnumerator Start()
    {
        raycaster = gameObject.AddComponent <GraphicRaycaster>();
        while (InventoryManager.GetInventoryManager == null)
        {
            yield return(null);
        }
        inventoryBackground = GetComponent <Image>();
        casesParent         = new GameObject("inventoryCases");
        RectTransform rcParent = casesParent.AddComponent <RectTransform>();

        casesParent.transform.SetParent(transform);
        rcParent.sizeDelta               = Vector2.one;
        rcParent.pivot                   = Vector2.up;
        rcParent.anchorMax               = Vector2.up;
        rcParent.anchorMin               = Vector2.up;
        rcParent.anchoredPosition        = Vector2.zero;
        casesParent.transform.localScale = Vector3.one;

        //Create all cases with images and buttons
        cases = new Image[InventoryManager.GetInventoryManager.NbColumns, InventoryManager.GetInventoryManager.NbLines];
        Button button;

        for (int i = 0; i < InventoryManager.GetInventoryManager.NbColumns; i++)
        {
            for (int j = 0; j < InventoryManager.GetInventoryManager.NbLines; j++)
            {
                GameObject tmp    = new GameObject("Case " + i + " : " + j);
                Vector2    tmpPos = Vector2.zero;
                tmp.transform.parent = casesParent.transform;
                tmpPos.x            += i * (sizeCase.x + offset.x) + offset.x + offsetBorder.x;
                tmpPos.y            -= j * (sizeCase.y + offset.y) + offset.y + offsetBorder.y;
                cases[i, j]          = tmp.AddComponent <Image>();
                RectTransform tmpRect = tmp.GetComponent <RectTransform>();
                tmpRect.pivot            = Vector2.up;
                tmpRect.sizeDelta        = sizeCase;
                tmpRect.anchoredPosition = tmpPos;
                tmpRect.localScale       = Vector3.one;

                cases[i, j].sprite = caseSprite;
                cases[i, j].color  = Color.white;

                GameObject tmp2 = Instantiate(tmp);
                tmp2.transform.SetParent(tmp.transform);

                cases[i, j]       = tmp2.GetComponent <Image>();
                cases[i, j].color = Color.white;

                ClickableItem clickableItem = tmp2.AddComponent <ClickableItem>();
                clickableItem.onLeftClick += ChangeItemFromInventoryToTrade;
                button = tmp2.AddComponent <Button>();
                int index = i + j * InventoryManager.GetInventoryManager.NbColumns;
                clickableItem.id = index;
                button.onClick.AddListener(() => SelectItem(index));
                tmpRect                  = tmp2.GetComponent <RectTransform>();
                tmpRect.pivot            = new Vector2(0.5f, 0.5f);
                tmpRect.anchoredPosition = Vector2.zero;
                tmpRect.sizeDelta        = sizeCase * 0.75f;
                tmpRect.localScale       = Vector3.one;
            }
        }
        itemsSpriteHud = SpriteManager.GetSpriteManager.ItemsSpriteHud;


        //Create ItemInHand image
        canvas = GameObject.Find("CanvasInGame");
        GameObject itemInHandGameObject = new GameObject("ItemInHand");

        itemInHandGameObject.transform.SetParent(canvas.transform);
        itemInHand = itemInHandGameObject.AddComponent <Image>();
        itemInHand.rectTransform.anchorMin  = Vector2.zero;
        itemInHand.rectTransform.anchorMax  = Vector2.zero;
        itemInHand.rectTransform.sizeDelta  = sizeCase;
        itemInHand.raycastTarget            = false;
        itemInHand.rectTransform.localScale = Vector3.one;

        //add methods to delegate of inventoryManager
        InventoryManager.GetInventoryManager.InventoryOpen     += EnableInventoryHud;
        InventoryManager.GetInventoryManager.InventoryClose    += DisableInventoryHud;
        InventoryManager.GetInventoryManager.InventoryIsUpdate += UpdateInventoryHud;

        Vector2 newSize = new Vector2();

        newSize.x = InventoryManager.GetInventoryManager.NbColumns * (sizeCase.x + offset.x) + offset.x + offsetBorder.x * 2f;
        newSize.y = InventoryManager.GetInventoryManager.NbLines * (sizeCase.y + offset.y) + offset.y + offsetBorder.y * 2f;
        GetComponent <RectTransform>().sizeDelta = newSize;

        DisableInventoryHud();
        isInitialize = true;
    }
예제 #20
0
 public void dice(Color tcol, Image image)
 {
     fcx = (image.Width - view.pad.Left) / (view.dims.Width + view.pad.Right);
     fcy = (image.Height - view.pad.Top) / (view.dims.Height + view.pad.Bottom);
     frames = new Image[fcy, fcx];
     for(int fy=0; fy<fcy; fy++)
         for(int fx = 0; fx < fcx; fx++) {
             int px = view.pad.Left + (view.dims.Width+view.pad.Right)*fx;
             int py = view.pad.Top + (view.dims.Height+view.pad.Bottom)*fy;
             Image img = GameEngine.Game.NewImage(view.dims.Width, view.dims.Height);
             frames[fy, fx] = img;
             Blitter b = new Blitter(img);
             b.BlitSubrect(image, px, py, img.Width, img.Height, 0, 0);
             img.Resolve();
             img.Alphafy(tcol);
         }
 }
예제 #21
0
                /// <summary><para>Die Funktion ruft Einzelbilder aus der Umgebung des aktuellen Satellitenbilds ab, und fügt sie zu
                /// einem Bild zusammen. Der Parameter vom Typ <see cref="Info.MapDirection"/> bestimmt die Richtung, in der
                /// die Bilder abgerufen werden. Der Wert <see cref="Info.MapDirection.Center"/> fügt alle angrenzenden Luftbilder,
                /// also 9 Einzelbilder in einer 3x3 Matrix, zu einem Bild zusammen. Die Werte <see cref="Info.MapDirection.North"/>,
                /// <see cref="Info.MapDirection.South"/>, <see cref="Info.MapDirection.West"/> und <see cref="Info.MapDirection.East"/>
                /// fügen 6 Einzelbilder in einer 2x3 bzw. 3x2 Matrix zusammen. Alle anderen Werte der <see cref="Info.MapDirection"/>-Enumeration
                /// fügen 4 Einzelbilder in einer 2x2 Matrix zusammen. Bitte beachten Sie, dass der Vorgang je nach Verbindung oder
                /// Serverauslastung längern andauern kann, und es möglicherweise zu Fehlern kommt.</para></summary>
                ///
                /// <example>Das Beispiel zeigt eine mögliche Anwendung der Methode, indem das aktuelle Satellitenbild, und alle
                /// angrenzenden Bilder (9x9 Matrix) zu einem Gesamtbild verschmolzen werden.
                /// <code>
                /// using System.Drawing;
                /// using GeoUtility.GeoSystem;
                /// Geographic geo = new Geographic(8.12345, 50.56789);
                /// MapService.Info.MapServer server = MapService.Info.MapServer.GoogleMaps;
                /// MapService map = new MapService(geo, server);
                /// map.Zoom = 18;
                /// Image imageArea = map.Image.Area(MapService.Info.MapDirection.Center);
                /// </code>
                /// </example>
                ///
                /// <param name="direction">Bestimmt die Richtung in der die Bilder zusammengefügt werden sollen.</param>
                /// <param name="extended">Wenn True, wird ein erweiterter Umgebungsbereich geladen.</param>
                /// <returns>Ein zusammengesetztes Bild vom Typ <see cref="System.Drawing.Image"/></returns>
                public Image Area(Info.MapDirection direction, bool extended)
                {
                    Image[,] array = null;
                    //MapService maps = Parent.MemberwiseClone();
                    MapService maps = new MapService(Parent.Tile);
                    int        rows, row, cols, col;

                    rows = row = cols = col = 0;

                    if (direction == Info.MapDirection.Center)
                    {
                        rows = 3;
                        cols = 3;
                        maps.Move(MapService.Info.MapDirection.Northwest, 1, true);
                    }
                    else if ((direction == Info.MapDirection.Northwest) || (direction == Info.MapDirection.Northeast) || (direction == Info.MapDirection.Southwest) || (direction == Info.MapDirection.Southeast))
                    {
                        rows = 2;
                        cols = 2;
                        if (direction == Info.MapDirection.Northwest)
                        {
                            maps.Move(MapService.Info.MapDirection.Northwest, 1, true);
                        }
                        else if (direction == Info.MapDirection.Northeast)
                        {
                            maps.Move(MapService.Info.MapDirection.North, 1, true);
                        }
                        else if (direction == Info.MapDirection.Southwest)
                        {
                            maps.Move(MapService.Info.MapDirection.West, 1, true);
                        }
                    }
                    else if ((direction == Info.MapDirection.North) || (direction == Info.MapDirection.South))
                    {
                        rows = 2;
                        cols = 3;
                        if (direction == Info.MapDirection.North)
                        {
                            maps.Move(MapService.Info.MapDirection.Northwest, 1, true);
                        }
                        else
                        {
                            maps.Move(MapService.Info.MapDirection.West, 1, true);
                        }
                    }
                    else if ((direction == Info.MapDirection.West) || (direction == Info.MapDirection.East))
                    {
                        rows = 3;
                        cols = 2;
                        if (direction == Info.MapDirection.West)
                        {
                            maps.Move(MapService.Info.MapDirection.Northwest, 1, true);
                        }
                        else
                        {
                            maps.Move(MapService.Info.MapDirection.North, 1, true);
                        }
                    }
                    if (extended == true)
                    {
                        rows += 2;
                        cols += 2;
                        maps.Move(MapService.Info.MapDirection.Northwest, 1, true);
                    }

                    array = new Image[rows, cols];
                    for (row = 0; row < rows; row++)
                    {
                        for (col = 0; col < cols; col++)
                        {
                            Image image = maps.Images.Load(true);
                            if (image == null)
                            {
                                return(null);
                            }

                            array[row, col] = image;
                            maps.Move(MapService.Info.MapDirection.East, 1, true);
                        }
                        maps.Move(MapService.Info.MapDirection.West, cols, true);
                        maps.Move(MapService.Info.MapDirection.South, 1, true);
                    }

                    return(this.Merge(array));
                }
예제 #22
0
    //Debug
    //public Text _debugText;

    // Use this for initialization
    void Start()
    {
        editMap           = new int[MAP_SIZE_Y, MAP_SIZE_X];
        generateViewImage = new Image[MAP_SIZE_Y, MAP_SIZE_X];

        //テストマップ
        //editMap = new int[MAP_SIZE_Y, MAP_SIZE_X] {
        //	{1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,3,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,14,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
        //};

        //キャンバスを持ってくる
        canvas = FindObjectOfType <Canvas>();


        //マップチップのロード
        FindObjectOfType <ResourceLoader>().LoadAll();
        mapchipSprite = ResourceLoader.GetChips(R_MapChipType.MainChip);
        holeSprite    = ResourceLoader.GetChips(R_MapChipType.Hole)[0];

        //画像の割当
        currentChip.sprite = GetMapchipFromID(selectChipID);

        //ボタンの機能を設定
        toolHandImage.GetComponent <Button>().onClick.AddListener(() => {
            ChangeEditTool(EditToolMode.Hand);
        });
        toolPenImage.GetComponent <Button>().onClick.AddListener(() => {
            ChangeEditTool(EditToolMode.Pen);
        });
        toolFillRectImage.GetComponent <Button>().onClick.AddListener(() => {
            ChangeEditTool(EditToolMode.FillRect);
        });

        for (int i = 0; i < selectableChip.Length; i++)
        {
            selectableChip[i].sprite = GetMapchipFromID(ConvertSelectChipID(i));

            //ラムダ式内にループ変数を使うために、ダミーに代入
            int d = i;
            selectableChip[i].GetComponent <Button>().onClick.AddListener(() => {
                ChangeSelectChip(d);
            });
        }

        //表示領域を生成
        for (int i = 0; i < MAP_SIZE_Y; i++)
        {
            for (int j = 0; j < MAP_SIZE_X; j++)
            {
                Image chip = Instantiate(viewChipPre).GetComponent <Image>();
                chip.gameObject.name = "[stage " + j + " " + i + " ]";
                chip.rectTransform.SetParent(viewMapArea);
                chip.rectTransform.localScale = new Vector3(1, 1, 1);

                EditModePiece piece = chip.GetComponent <EditModePiece>();
                piece.image          = chip;
                piece.chipPosition.x = j;
                piece.chipPosition.y = i;

                generateViewImage[i, j] = chip;
            }
        }

        //制限時間の表示更新
        viewTime.text = limitTime.ToString() + "sec";

        //ビューポートがおかしくなる問題を修正
        RectTransform parent = viewMapArea.parent.GetComponent <RectTransform>();

        parent.anchorMin = new Vector2(0, 0);
        parent.anchorMax = new Vector2(1, 1);

        ChangeEditTool(EditToolMode.Hand);

        //描画
        SetViewSize();
        Draw();

        //音楽を再生
        AudioManager.FadeIn(2.0f, BGMType.Select, 1, true);
    }
        private void LoadState(object navigationParameter, Dictionary <string, object> pageState)
        {
            // Unpack the navigation parameters passed from either the Main Page (singleplayer mode)
            // or the Invite Players page (singlePair, multiplayer mode).

            GamePageParameters parameters = (GamePageParameters)navigationParameter;

            if (PeerFinder.Role == PeerRole.Host)
            {
                timesToTick = Constants.PlayTime * Constants.TimeUnitsPerSecond;
            }

            gameMode = parameters.GameMode;

            if (gameMode != Constants.SinglePlayer)
            {
                // Not for single player games.

                connectedPeers = parameters.ConnectedPeers;

                // You should only have one socket if you're a client
                // Regardless, update each socket's current page to the game page
                foreach (ConnectedPeer host in connectedPeers.Keys)
                {
                    socket             = connectedPeers[host];
                    socket.currentPage = this;
                    socket.UpdateCurrentPageType();
                }

                playerCount = parameters.PlayerCount;
            }

            images = new Image[Constants.GridRows, Constants.GridColumns];
            random = new Random();

            gameTimer          = new DispatcherTimer();
            gameTimer.Interval = TimeSpan.FromMilliseconds(Constants.TimeUnit);
            gameTimer.Tick    += UpdateTimer;

            if (gameMode == Constants.SinglePlayer)
            {
                InitImages();

                timesToTick = Constants.PlayTime * Constants.TimeUnitsPerSecond;
                StartGame();
            }
            else if (gameMode == Constants.MultiPlayer)
            {
                // See what your role is.
                if (PeerFinder.Role == PeerRole.Host)
                {
                    playerList    = new Dictionary <int, string>();
                    playerList[0] = PeerFinder.DisplayName;
                    playerID      = 0;

                    int counter = 1;

                    foreach (ConnectedPeer peer in connectedPeers.Keys)
                    {
                        playerList[counter] = peer.DisplayName;
                        SendParams(connectedPeers[peer], counter);
                        counter++;
                    }

                    InitImages();
                }
            }
        }
        public CreateCustomGameForm(User user)
        {
            me = user;
            InitializeComponent();

            // Set up images to the piece replace buttons
            whiteKingButton.Image   = Images[(int)PieceEnum.WhiteKing];
            whiteQueenButton.Image  = Images[(int)PieceEnum.WhiteQueen];
            whiteRookButton.Image   = Images[(int)PieceEnum.WhiteRook];
            whiteKnightButton.Image = Images[(int)PieceEnum.WhiteKnight];
            whiteBishopButton.Image = Images[(int)PieceEnum.WhiteBishop];
            whitePawnButton.Image   = Images[(int)PieceEnum.WhitePawn];
            blackKingButton.Image   = Images[(int)PieceEnum.BlackKing];
            blackQueenButton.Image  = Images[(int)PieceEnum.BlackQueen];
            blackRookButton.Image   = Images[(int)PieceEnum.BlackRook];
            blackKnightButton.Image = Images[(int)PieceEnum.BlackKnight];
            blackBishopButton.Image = Images[(int)PieceEnum.BlackBishop];
            blackPawnButton.Image   = Images[(int)PieceEnum.BlackPawn];

            // Set up standard layout images
            Image[,] SLI =
            {
                { Images[(int)PieceEnum.BlackRook], Images[(int)PieceEnum.BlackKnight], Images[(int)PieceEnum.BlackBishop], Images[(int)PieceEnum.BlackQueen], Images[(int)PieceEnum.BlackKing], Images[(int)PieceEnum.BlackBishop], Images[(int)PieceEnum.BlackKnight], Images[(int)PieceEnum.BlackRook] },
                { Images[(int)PieceEnum.BlackPawn], Images[(int)PieceEnum.BlackPawn],   Images[(int)PieceEnum.BlackPawn],   Images[(int)PieceEnum.BlackPawn],  Images[(int)PieceEnum.BlackPawn], Images[(int)PieceEnum.BlackPawn],   Images[(int)PieceEnum.BlackPawn],   Images[(int)PieceEnum.BlackPawn] },
                { null,                             null,                               null,                               null,                              null,                             null,                               null,                               null                             },
                { null,                             null,                               null,                               null,                              null,                             null,                               null,                               null                             },
                { null,                             null,                               null,                               null,                              null,                             null,                               null,                               null                             },
                { null,                             null,                               null,                               null,                              null,                             null,                               null,                               null                             },
                { Images[(int)PieceEnum.WhitePawn], Images[(int)PieceEnum.WhitePawn],   Images[(int)PieceEnum.WhitePawn],   Images[(int)PieceEnum.WhitePawn],  Images[(int)PieceEnum.WhitePawn], Images[(int)PieceEnum.WhitePawn],   Images[(int)PieceEnum.WhitePawn],   Images[(int)PieceEnum.WhitePawn] },
                { Images[(int)PieceEnum.WhiteRook], Images[(int)PieceEnum.WhiteKnight], Images[(int)PieceEnum.WhiteBishop], Images[(int)PieceEnum.WhiteQueen], Images[(int)PieceEnum.WhiteKing], Images[(int)PieceEnum.WhiteBishop], Images[(int)PieceEnum.WhiteKnight], Images[(int)PieceEnum.WhiteRook] }
            };
            StandardLayoutImages = SLI;

            // Set up board variable
            board = new Button[, ]
            {
                { square00, square01, square02, square03, square04, square05, square06, square07 },
                { square10, square11, square12, square13, square14, square15, square16, square17 },
                { square20, square21, square22, square23, square24, square25, square26, square27 },
                { square30, square31, square32, square33, square34, square35, square36, square37 },
                { square40, square41, square42, square43, square44, square45, square46, square47 },
                { square50, square51, square52, square53, square54, square55, square56, square57 },
                { square60, square61, square62, square63, square64, square65, square66, square67 },
                { square70, square71, square72, square73, square74, square75, square76, square77 }
            };

            // Set up borders
            selectionBorders = new List <Button>()
            {
                noPieceSelected,
                whiteKingSelected, whiteQueenSelected, whiteRookSelected, whiteKnightSelected, whiteBishopSelected, whitePawnSelected,
                blackKingSelected, blackQueenSelected, blackRookSelected, blackKnightSelected, blackBishopSelected, blackPawnSelected
            };

            // Set up piece replacement buttons
            selectionButtons = new List <Button>()
            {
                noPieceButton,
                whiteKingButton, whiteQueenButton, whiteRookButton, whiteKnightButton, whiteBishopButton, whitePawnButton,
                blackKingButton, blackQueenButton, blackRookButton, blackKnightButton, blackBishopButton, blackPawnButton
            };

            // Set up button connections on board
            foreach (Button square in board)
            {
                square.Click += new System.EventHandler(this.BoardButtonClicked);
            }

            // Set all "setter" button borders to not visible
            foreach (Button selection in selectionBorders)
            {
                selection.Visible = false;
            }

            setNormalLayout(board);
            ChessUtils.Settings.Color.UpdateChessBoardColors(board);

            // Set the no piece button to selected by default
            SetSelectedBorderInvisible();
            selectedButton = PieceEnum.None;
            GetSelectedButtonBorder().Visible = true;
        }
예제 #25
0
        public void gunlukResimleriDiziyeAta()
        {
            tıklandıDizilerDoldu = true;
            kayitSayisiResim     = -1;
            SqlConnection connectionResim = new SqlConnection(baglanti.ConnectionString);
            SqlCommand    cmdResim        = new SqlCommand("select count(ilanNo) from gunlukResimler where musteriTc is NULL", connectionResim);

            connectionResim.Open();
            kayitSayisiResim = Convert.ToInt32(cmdResim.ExecuteScalar());
            connectionResim.Close();
            diziElemanSayResim = kayitSayisiResim - 1;
            ///*************************************************************************
            int sayaçResim = 0;

            //int kayıtSayısı= Convert.ToInt32(cmd.ExecuteScalar());
            gunlukVerileriResimler = new Image[kayitSayisiResim, 8];
            gunlukResimİlanNoları  = new String[kayitSayisiResim];

            //ilanTarihi,metrekare,odasayısı,binayası,bulundugukat,ısıtma,esyalı,aidat,fiyat,adres,ilanNo,Tur

            SqlConnection connecResim   = new SqlConnection(baglanti.ConnectionString);
            SqlCommand    cmdResimGetir = new SqlCommand("select * from gunlukResimler where musteriTc is NULL", connecResim);

            if (connecResim.State != ConnectionState.Open)
            {
                connecResim.Open();
            }
            SqlDataReader drResim = cmdResimGetir.ExecuteReader();

            while (drResim.Read())
            {
                gunlukResimİlanNoları[sayaçResim] = drResim["ilanNo"].ToString();//1
                Byte[] data = new Byte[0];
                data = (Byte[])(drResim["resim1"]);
                MemoryStream mem = new MemoryStream(data);
                gunlukVerileriResimler[sayaçResim, 0] = Image.FromStream(mem);
                mem.Close();

                Byte[] data2 = new Byte[1];
                data2 = (Byte[])(drResim["resim2"]);
                MemoryStream mem2 = new MemoryStream(data2);
                gunlukVerileriResimler[sayaçResim, 1] = Image.FromStream(mem2);

                Byte[] data3 = new Byte[2];
                data3 = (Byte[])(drResim["resim3"]);
                MemoryStream mem3 = new MemoryStream(data3);
                gunlukVerileriResimler[sayaçResim, 2] = Image.FromStream(mem3);

                Byte[] data4 = new Byte[3];
                data4 = (Byte[])(drResim["resim4"]);
                MemoryStream mem4 = new MemoryStream(data4);
                gunlukVerileriResimler[sayaçResim, 3] = Image.FromStream(mem4);
                mem4.Close();

                Byte[] data5 = new Byte[4];
                data5 = (Byte[])(drResim["resim5"]);
                MemoryStream mem5 = new MemoryStream(data5);
                gunlukVerileriResimler[sayaçResim, 4] = Image.FromStream(mem5);


                Byte[] data6 = new Byte[5];
                data6 = (Byte[])(drResim["resim6"]);
                MemoryStream mem6 = new MemoryStream(data6);
                gunlukVerileriResimler[sayaçResim, 5] = Image.FromStream(mem6);

                Byte[] data7 = new Byte[6];
                data7 = (Byte[])(drResim["resim7"]);
                MemoryStream mem7 = new MemoryStream(data7);
                gunlukVerileriResimler[sayaçResim, 6] = Image.FromStream(mem7);

                Byte[] data8 = new Byte[7];
                data8 = (Byte[])(drResim["resim4"]);
                MemoryStream mem8 = new MemoryStream(data8);
                gunlukVerileriResimler[sayaçResim, 7] = Image.FromStream(mem8);

                sayaçResim++;
            }
            connecResim.Close();
        }
예제 #26
0
        private void btnSetWorldCoordinates_Click(object sender, EventArgs e)
        {
            string baseUrl = @"http://maps.google.com/maps/api/staticmap?zoom=19&size=635x628&sensor=false&maptype=satellite&center=";
            CultureInfo ci = new CultureInfo("en-US");
            int numx = 10;
            int numy = 10;
            satelliteImages = new Image[numx, numy];

            for (int i = 0; i < numx; ++i)
                {
                for (int j = 0; j < numy; ++j)
                    {
                    satelliteImages[i,j] = DownloadImage(baseUrl + (spinLatitude.Value - (0.001m * i)).ToString(ci) + "," + (spinLongitude.Value + (0.0017m * j)).ToString(ci));
                    if (satelliteImages[i,j] != null)
                        satelliteImages[i, j] = ResizeBitmap(new Bitmap(satelliteImages[i, j]), (int)(satelliteImages[i, j].Width * 1.739), (int)(satelliteImages[i, j].Height * 1.739));
                    }
                }
            // 				satelliteImages[0, 0] = DownloadImage(baseUrl + spinLatitude.Value.ToString(ci) + "," + spinLongitude.Value.ToString(ci));
            // 			satelliteImages[1, 0] = DownloadImage(baseUrl + (spinLatitude.Value - 0.001m).ToString(ci) + "," + spinLongitude.Value.ToString(ci));
            // 			satelliteImages[0, 1] = DownloadImage(baseUrl + spinLatitude.Value.ToString(ci) + "," + (spinLongitude.Value + 0.0017m).ToString(ci));
            // 			satelliteImages[1, 1] = DownloadImage(baseUrl + (spinLatitude.Value - 0.001m).ToString(ci) + "," + (spinLongitude.Value + 0.0017m).ToString(ci));
        }
예제 #27
0
        // initialize game panel background
        private void initGamePanelBackground()
        {
            gamePanelBackgroundMatrix = new Image[ROW_AMOUNT, COLUM_AMOUNT];
            for (int i = 0; i < ROW_AMOUNT; i++)
            {
                double y = gamePanelStartPointY + i * BLOCK_HEIGHT;
                for (int j = 0; j < COLUM_AMOUNT; j++)
                {
                    Image image = new Image();
                    image.Name = "bgImage_" + i + "_" + j;
                    double x = gamePanelStartPointX + j * BLOCK_WIDTH;
                    Thickness myThickness = new Thickness(x, y, 0, 0);
                    image.Margin = myThickness;
                    setBackgroundImageSource(image, i, j);
                    image.PointerEntered += bgImage_PointerEntered;
                    image.PointerExited += bgImage_PointerExited;
                    image.Tapped += bgImage_Tapped;
                    gameCanvas.Children.Add(image);

                    gamePanelBackgroundMatrix[i, j] = image;
                }
            }
        }
예제 #28
0
 private void Awake()
 {
     blocks = new Image[grid, grid];
     Initialize();
 }
예제 #29
0
 public void AssignImages(Image[,] imageBox)
 {
     for (int i = 0; i < 5; i++)
     {
         for (int k = 0; k < 5; k++)
         {
             if (i < 3)
             {
                 if (current[i, k] == 0)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/0.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 1)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/1.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 2)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/2.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 3)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/3.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 4)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/4.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 5)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/5.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 6)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/6.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 7)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/7.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 8)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/8.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 9)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/9.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 10)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/10.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else if (current[i, k] == 11)
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/11.PNG", UriKind.RelativeOrAbsolute));
                 }
                 else
                 {
                     imageBox[i, k].Source = new BitmapImage(new Uri("Images/12.PNG", UriKind.RelativeOrAbsolute));
                 }
             }
         }
     }
 }
예제 #30
0
    // Use this for initialization
    private void Start()
    {
        Cursor.SetCursor(pCursorSprite.texture, Vector2.zero, CursorMode.Auto);

        // Canvas
        pCanvasObject = transform.GetChild(0);

        backGrid            = pCanvasObject.Find("BackGrid").transform as RectTransform;
        originalScale       = backGrid.localScale;
        backGrid.localScale = Vector3.zero;

        // Avatars
        AvatarPG1 = pCanvasObject.Find("AvatarPG1").GetComponent <Image>();
        AvatarPG2 = pCanvasObject.Find("AvatarPG2").GetComponent <Image>();


        // Actions Tables
        pTablePG1 = pCanvasObject.Find("TablePG1");
        pTablePG2 = pCanvasObject.Find("TablePG2");

        // Cursors
        pCursorPG1 = pTablePG1.Find("CursorPG1").transform as RectTransform;
        pCursorPG2 = pTablePG2.Find("CursorPG2").transform as RectTransform;

        // Actions Icons
        vIcons = new GameObject[8];
        Transform pIcons = pCanvasObject.Find("Icons");

        for (int i = 0; i < 8; i++)
        {
            vIcons[i] = pIcons.GetChild(i).gameObject;
        }

        // Actions Slots
        // Player 1
        vActionsSlots = new Image[2, 10];
        for (int i = 0; i < 10; i++)
        {
            Image pImage = pTablePG1.transform.GetChild(i).GetComponent <Image>();
            pImage.enabled      = false;
            vActionsSlots[0, i] = pImage;
        }
        // Player 2
        for (int i = 0; i < 10; i++)
        {
            Image pImage = pTablePG2.transform.GetChild(i).GetComponent <Image>();
            pImage.enabled      = false;
            vActionsSlots[1, i] = pImage;
        }

        pStageManager = GLOBALS.StageManager;

        // Cursor spawn position

        pCursorPG1SpawnPos = pCursorPG1.localPosition;
        pCursorPG2SpawnPos = pCursorPG2.localPosition;


        // prefab Pause Menu
        pausePrefab = GameObject.Find("Pause_Menu");
        pausePrefab.SetActive(false);

        //Button Next Stage Animator
        nextStageAnimator = pCanvasObject.Find("ButtonNextStage").GetComponent <Animator>();
        if (nextStageAnimator == null)
        {
            print("noooooooo");
        }


        //Button
        buttonNextTurn = pCanvasObject.Find("ButtonNextStage");
        buttonPause    = pCanvasObject.Find("ButtonPause");
        buttonRestart  = pCanvasObject.Find("ButtonRestart");
        buttonPlay     = pCanvasObject.Find("ButtonPlay");

        {
            Button Button = pCanvasObject.Find("ButtonSelectP1").GetComponent <Button>();
            Button.onClick.RemoveAllListeners();
            Button.onClick.AddListener(() => GLOBALS.StageManager.SelectPlayer(1));
        }
        {
            Button Button = pCanvasObject.Find("ButtonSelectP2").GetComponent <Button>();
            Button.onClick.RemoveAllListeners();
            Button.onClick.AddListener(() => GLOBALS.StageManager.SelectPlayer(2));
        }

        {               // next
            Button Button = buttonNextTurn.GetComponent <Button>();
            Button.onClick.RemoveAllListeners();
            Button.onClick.AddListener(() => GLOBALS.StageManager.NextStage());
        }
        {               // pause
            Button Button = buttonPause.GetComponent <Button>();
            Button.onClick.RemoveAllListeners();
            Button.onClick.AddListener(() => GLOBALS.UI.OnPause());
        }
        {               // restart
            Button Button = buttonRestart.GetComponent <Button>();
            Button.onClick.RemoveAllListeners();
            Button.onClick.AddListener(() => GLOBALS.GameManager.RestartGame());
        }
        {               // play
            Button Button = buttonPlay.GetComponent <Button>();
            Button.onClick.RemoveAllListeners();
            Button.onClick.AddListener(() => GLOBALS.StageManager.Play());
        }



        //Button Next Stage sprite
        buttonNextTurnSprite = buttonNextTurn.GetComponent <Image>().sprite;
        buttonPauseSprite    = buttonPause.GetComponent <Image>().sprite;
        buttonRestartSprite  = buttonRestart.GetComponent <Image>().sprite;
    }
예제 #31
0
 // initialize game panel block
 private void initGamePanelBlocks()
 {
     gamePanelBlockMatrix = new Image[ROW_AMOUNT, COLUM_AMOUNT];
     int[,] gameZoneMatrix = game.getGameZoneMatrix();
     for (int i = 0; i < ROW_AMOUNT; i++)
     {
         int y = gamePanelStartPointY + i * BLOCK_HEIGHT;
         for (int j = 0; j < COLUM_AMOUNT; j++)
         {
             int x = gamePanelStartPointX + j * BLOCK_WIDTH;
             Image image = new Image();
             image.Name = "blockImage_" + i + "_" + j;
             Thickness imageThickness = new Thickness(x, y, 0, 0);
             image.Margin = imageThickness;
             int type = gameZoneMatrix[i, j];
             if (type > 0)
             {
                 setGamePanelBlockImageSourceNormal(image, type);
             }
             image.Tap += new EventHandler<GestureEventArgs>(blockTapped);
             gameCanvas.Children.Add(image);
             gamePanelBlockMatrix[i, j] = image;
         }
     }
 }
	// Use this for initialization
	public void Load (ArrayList loadParameters) {

		// Reproducimos la musica de esta pantalla
		App.thisApp.controller.audio.playMusic (eMusic.Game2_PuzzleMolas);
		
		// Asignamos los eventos de los botones
		Button buttonHome = this.transform.FindChild("PanelHome/ButtonHome").GetComponent<Button>();
		buttonHome.onClick.AddListener( () => {
			App.thisApp.controller.audio.playFX(eAudioFX.ButtonOpenHome);
			App.thisApp.view.showScreen(eScreen.Home);
		});
		Button buttonTribe = this.transform.FindChild("PanelHome/ButtonTribe").GetComponent<Button>();
		buttonTribe.onClick.AddListener( () => {
			App.thisApp.controller.audio.playFX(eAudioFX.ButtonOpenHome);
			App.thisApp.view.showScreen(eScreen.Parents);
		});
		
		
		Button button1CreateStory = this.transform.FindChild("PanelMinigames/Button1CreateStory").GetComponent<Button>();
		button1CreateStory.onClick.AddListener( () => {
			App.thisApp.controller.audio.playFX(eAudioFX.ButtonOpenGame);
			App.thisApp.view.showScreen(eScreen.S1_CreateStory);
		});		
//		Button button2PuzzleMolas = this.transform.FindChild("PanelMinigames/Button2PuzzleMolas").GetComponent<Button>();
//		button2PuzzleMolas.onClick.AddListener( () => {
//			App.thisApp.controller.audio.playFX(eAudioFX.ButtonOpenGame);
//			App.thisApp.view.showScreen(eScreen.S2_PuzzleMolas);
//		});		
		Button button3Iconography = this.transform.FindChild("PanelMinigames/Button3Iconography").GetComponent<Button>();
		button3Iconography.onClick.AddListener( () => {
			App.thisApp.controller.audio.playFX(eAudioFX.ButtonOpenGame);
			App.thisApp.view.showScreen(eScreen.S3_Iconography);
		});		
		Button button4HandicraftsAR = this.transform.FindChild("PanelMinigames/Button4HandicraftsAR").GetComponent<Button>();
		button4HandicraftsAR.onClick.AddListener( () => {
			App.thisApp.controller.audio.playFX(eAudioFX.ButtonOpenGame);
			App.thisApp.view.showScreen(eScreen.S4_HandicraftsAR);
		});
		Button button5Language = this.transform.FindChild("PanelMinigames/Button5Language").GetComponent<Button>();
		button5Language.onClick.AddListener( () => {
			App.thisApp.controller.audio.playFX(eAudioFX.ButtonOpenGame);
			App.thisApp.view.showScreen(eScreen.S5_Language);
		});

		// Board Drag
		cameraHUD = GameObject.Find ("App/View/Camera").GetComponent<Camera> ();
		board = this.transform.FindChild ("BoardTargets").GetComponent<RectTransform> ();

		// Calculamos las dimensiones del tablero
		boardBottomLeft = board.anchorMin;
		boardTopRight   = board.anchorMax;
		boardSize = new Vector2(boardTopRight.x - boardBottomLeft.x, boardTopRight.y - boardBottomLeft.y);
		tileSize  = new Vector2(boardSize.x / 5, boardSize.y / 5);

		// Cargamos la matrix de tiles
		tilesImgsMatrix   = new Image[5, 5];
		targetsImgsMatrix = new Image[5, 5];
		animalsImgsMatrix = new Image[5, 5];

		startsInfoMatrix  = new ePuzzleAnimal[5, 5];
		endsInfoMatrix    = new ePuzzleAnimal[5, 5];
		tilesInfoMatrix   = new ePuzzleAnimal[5, 5];
		animalsInfoMatrix = new ePuzzleAnimal[5, 5];

		for (int indexCol = 0; indexCol < 5; indexCol++) {
			for (int indexRow = 0; indexRow < 5; indexRow++) {

				// Cargamos los componentes Image
				tilesImgsMatrix   [indexCol, indexRow] = this.transform.FindChild ("BoardTiles/TileRow"   + indexRow + "Col" + indexCol).GetComponent<Image> ();
				targetsImgsMatrix [indexCol, indexRow] = this.transform.FindChild ("BoardTargets/TileRow" + indexRow + "Col" + indexCol).GetComponent<Image> ();
				animalsImgsMatrix [indexCol, indexRow] = this.transform.FindChild ("BoardAnimals/TileRow" + indexRow + "Col" + indexCol).GetComponent<Image> ();
			}
		}

		// Win Lose
		levelWin = false;
		boardGrid = this.transform.FindChild("BoardGrid").gameObject;
		boardTiles = this.transform.FindChild("BoardTiles").gameObject;
		boardTargets = this.transform.FindChild("BoardTargets").gameObject;
		boardAnimals = this.transform.FindChild("BoardAnimals").gameObject;
		mainMola = this.transform.FindChild("Mola").GetComponent<Image>();

		// Levels
		currentLevel = 1;

		// Cargamos el primer nivel
		loadLevel (currentLevel);
	}
예제 #33
0
        private void SplitButton_Click(object sender, EventArgs e)
        {
            if (sourceImage == null)
            {
                return;
            }

            //Calc Grid dimensions
            Point dims = new Point();
            dims.X = (int)Math.Ceiling(sourceImage.Width / SplitWidth);
            dims.Y = (int)Math.Ceiling(sourceImage.Height / SplitHeight);

            pieces = new Image[dims.Y, dims.X];

            //Split Image
            for (int y = 0; y < dims.Y; y++)
            {
                for (int x = 0; x < dims.X; x++)
                {
                    pieces[y,x] = new Bitmap((int)SplitWidth, (int)SplitHeight);
                    var g = Graphics.FromImage(pieces[y,x]);
                    g.DrawImage(sourceImage, new Rectangle(0, 0, (int)SplitWidth, (int)(SplitHeight)), new Rectangle(x * (int)SplitWidth, y * (int)SplitHeight, (int)SplitWidth, (int)SplitHeight), GraphicsUnit.Pixel);
                    g.Dispose();
                }
            }
            SplitImageBox.Invalidate();
        }
예제 #34
0
 public void SetBoardImageArray(Image[,] images)
 {
     _boardImageArray = images;
 }
예제 #35
0
    // Start is called before the first frame update
    void Start()
    {
        // init
        dotNum        = myPosX = myPosY = playingHit = afterHit = 0;
        status        = Common.STATUS.NORMAL;
        timeElapsed   = 0;
        numDictionary = new Dictionary <char, int>
        {
            [Common.MAP_T1]    = 0,
            [Common.MAP_T2]    = 0,
            [Common.MAP_BLOCK] = 0
        };
        posDictionary = new Dictionary <char, int[, ]>
        {
            [Common.MAP_T1]    = new int[Common.MAX_T1_NUM, 2],
            [Common.MAP_T2]    = new int[Common.MAX_T2_NUM, 2],
            [Common.MAP_BLOCK] = new int[Common.MAX_BLOCK_NUM, 2]
        };
        foreach (char key in posDictionary.Keys)
        {
            for (int i = 0; i < posDictionary[key].GetLength(0); i++)
            {
                posDictionary[key][i, 0] = -1;
                posDictionary[key][i, 1] = -1;
            }
        }
        action   = false;
        sceneMap = new char[Common.WIDTH, Common.HEIGHT, 2];
        objScene = new Image[Common.WIDTH, Common.HEIGHT];
        objHit   = new List <Image>();

        // hi score & score
        highScore = PlayerPrefs.GetInt(Common.SAVEDATA_HISH_SCORE, 0);
        DisplayScore();

        // scene
        scene          = PlayerPrefs.GetInt(Common.SAVEDATA_START_SCENE, 1);
        textSence.text = $"{scene}";

        // time
        time          = Common.INITIAL_TIME;
        textTime.text = $"{time}";

        // sptites
        objDictionary = new Dictionary <char, Sprite>();
        objDictionary[Common.MAP_MY]    = spriteMyd;
        objDictionary[Common.MAP_WALL]  = spriteWall;
        objDictionary[Common.MAP_BLOCK] = spriteBlock;
        objDictionary[Common.MAP_DOT]   = spriteDot;
        objDictionary[Common.MAP_T1]    = spriteT1;
        objDictionary[Common.MAP_T2]    = spriteT2;

        // left my number
        for (int i = 0; i < leftMyNumber - 1; i++)
        {
            Display(Common.MAP_MY, Common.X_BAR_2ND + 1 + i * 2, 1);
        }

        // outer wall
        for (int i = 0; i < Common.WIDTH; i++)
        {
            Display(Common.MAP_WALL, i, 0);
            Display(Common.MAP_WALL, i, 3);
            Display(Common.MAP_WALL, i, Common.HEIGHT - 1);
        }
        for (int i = 1; i <= 2; i++)
        {
            Display(Common.MAP_WALL, 0, i);
            Display(Common.MAP_WALL, Common.X_BAR_1ST, i);
            Display(Common.MAP_WALL, Common.X_BAR_2ND, i);
            Display(Common.MAP_WALL, Common.WIDTH - 1, i);
        }
        for (int i = 4; i < Common.HEIGHT; i++)
        {
            Display(Common.MAP_WALL, 0, i);
            Display(Common.MAP_WALL, Common.WIDTH - 1, i);
        }

        // inner map
        for (int i = 0; i < Common.INNER_HIGHT; i += 2)
        {
            for (int j = 0; j < Common.INNER_WIDTH; j += 2)
            {
                Display(Common.sceneData[scene - 1, i / 2][j / 2], j, i, true);
            }
        }

        // hide unnecessary texts and adjust screen
        textGameOver.SetActive(false);
        textCongratulations.SetActive(false);
        AdjustScreen(true);
    }
예제 #36
0
    protected void Awake()
    {
        gridSpace = transform.Find("GridSpace") as RectTransform;

        var size = 100;
        var grid = new Grid2D(size, size);

        grid[5, 5].Weight = float.MaxValue;
        grid[5, 6].Weight = float.MaxValue;
        grid[5, 7].Weight = float.MaxValue;
        grid[5, 8].Weight = float.MaxValue;
        grid[5, 9].Weight = float.MaxValue;
        grid[5, 10].Weight = float.MaxValue;
        grid[5, 11].Weight = float.MaxValue;
        grid[5, 12].Weight = float.MaxValue;
        grid[5, 13].Weight = float.MaxValue;
        grid[5, 14].Weight = float.MaxValue;

        grid[15, 5].Weight = float.MaxValue;
        grid[15, 6].Weight = float.MaxValue;
        grid[15, 7].Weight = float.MaxValue;
        grid[15, 8].Weight = float.MaxValue;
        grid[15, 9].Weight = float.MaxValue;
        grid[15, 10].Weight = float.MaxValue;
        grid[15, 11].Weight = float.MaxValue;
        grid[15, 12].Weight = float.MaxValue;
        grid[15, 13].Weight = float.MaxValue;
        grid[15, 14].Weight = float.MaxValue;

        grid[5, 15].Weight = float.MaxValue;
        grid[6, 15].Weight = float.MaxValue;
        grid[7, 15].Weight = float.MaxValue;
        grid[8, 15].Weight = float.MaxValue;
        grid[9, 15].Weight = float.MaxValue;
        grid[10, 15].Weight = float.MaxValue;
        grid[11, 15].Weight = float.MaxValue;
        grid[12, 15].Weight = float.MaxValue;
        grid[13, 15].Weight = float.MaxValue;
        grid[14, 15].Weight = float.MaxValue;
        grid[15, 15].Weight = float.MaxValue;

        //grid[5,  4].Weight = float.MaxValue;
        //grid[6,  4].Weight = float.MaxValue;
        //grid[7,  4].Weight = float.MaxValue;
        //grid[8,  4].Weight = float.MaxValue;
        //grid[9,  4].Weight = float.MaxValue;
        //grid[10, 4].Weight = float.MaxValue;
        //grid[11, 4].Weight = float.MaxValue;
        //grid[12, 4].Weight = float.MaxValue;
        //grid[13, 4].Weight = float.MaxValue;
        //grid[14, 4].Weight = float.MaxValue;
        //grid[15, 4].Weight = float.MaxValue;

        tiles = new Image[size, size];

        gridSpace.gameObject.AddComponent<Selectable>();

        Vector2 anchorMin, anchorMax;
        for (int i = 0; i < size; i++)
        {
            anchorMin.x = ((float)i / size);
            anchorMax.x = ((float)(i + 1) / size);

            for (int j = 0; j < size; j++)
            {
                anchorMin.y = ((float)j / size);
                anchorMax.y = ((float)(j + 1) / size);

                var obj = new GameObject(string.Format("Node [{0},{1}]", i, j));
                obj.transform.SetParent(gridSpace);

                var trans = obj.AddComponent<RectTransform>();
                trans.anchorMin = anchorMin;
                trans.anchorMax = anchorMax;
                trans.offsetMax = Vector2.zero;
                trans.offsetMin = Vector2.zero;
                trans.localScale = Vector3.one;

                var image = obj.AddComponent<Image>();
                image.color = (Color.blue * anchorMax.x + Color.red * (1 - anchorMax.x)) * anchorMax.y +
                              (Color.yellow * anchorMax.x + Color.green * (1 - anchorMax.x)) * (1 - anchorMax.y);

                var c = 1f / (grid[i, j].Weight);
                image.color = new Color(c, c, c, 1);

                tiles[i, j] = image;
            }
        }

        var search = new Fringe(Grid2D.HeuristicManhattan2);
        var searchA = new AStar(Grid2D.HeuristicManhattan2);
        var start = grid[14, 5];
        var end = grid[90, 90];

        tiles[start.X, start.Y].color = Color.blue + Color.white * .5f;
        tiles[end.X, end.Y].color = Color.yellow + Color.white * .5f;

        //StartCoroutine(search.AdvanceFrontier(start, end, () => {
        //    foreach (Node node in search.mappedNodes.Keys)
        //        if (node != start && node != end)
        //            tiles[node.X, node.Y].color = Color.red + Color.white * .5f;

        //    foreach (Node node in search.frontier)
        //        if (node != start && node != end)
        //            tiles[node.X, node.Y].color = Color.green + Color.white * .5f;

        //    return StartCoroutine(WaitKeyDown(KeyCode.None));
        //}));

        // astar

        var beforea = System.DateTime.Now;
        var pathA = searchA.FindPath(start, end);
        var aftera = System.DateTime.Now;

        Debug.Log((aftera - beforea).Milliseconds);

        //foreach (Node2D node in searchA.mappedNodes.Keys)
        //    if (node != start && node != end)
        //        tiles[node.X, node.Y].color = Color.red + Color.white * .5f;

        //foreach (Node2D node in searchA.frontier)
        //    if (node != start && node != end)
        //        tiles[node.X, node.Y].color = Color.green + Color.white * .5f;

        //foreach (Node2D node in pathA)
        //    if (node != start && node != end)
        //        tiles[node.X, node.Y].color = Color.magenta + Color.white * .5f;

        // fringe

        var before = System.DateTime.Now;
        var path = search.FindPath(start, end);
        var after = System.DateTime.Now;

        Debug.Log((after - before).Milliseconds);

        foreach (Node2D node in search.cache.Keys)
            if (node != start && node != end)
                tiles[node.X, node.Y].color = Color.red + Color.white * .5f;

        foreach (Node2D node in search.fringe)
            if (node != start && node != end)
                tiles[node.X, node.Y].color = Color.green + Color.white * .5f;

        foreach (Node2D node in path)
            if (node != start && node != end)
                tiles[node.X, node.Y].color = Color.magenta + Color.white * .5f;

        //StartCoroutine(search.FindInteractive(start, end, () =>
        //{
        //    foreach (Node2D node in search.cache.Keys)
        //        if (node != start && node != end)
        //            tiles[node.X, node.Y].color = Color.red + Color.white * .5f;

        //    foreach (Node2D node in search.fringe)
        //        if (node != start && node != end)
        //            tiles[node.X, node.Y].color = Color.green + Color.white * .5f;

        //    foreach (Node2D node in search.pathInteractive)
        //        if (node != start && node != end)
        //            tiles[node.X, node.Y].color = Color.magenta + Color.white * .5f;

        //    return StartCoroutine(WaitKeyDown(KeyCode.None));
        //}));
    }
예제 #37
0
        void NewGame()
        {
            GameGrid.Children.Clear();
            GameGrid.RowDefinitions.Clear();
            GameGrid.ColumnDefinitions.Clear();
            Image[,] images = null;
            switch (currentLevel)
            {
            case Level.Easy:
                GameGrid.Height = 356;
                GameGrid.Width  = GameGrid.Height;
                width           = 9;
                height          = 9;
                allBombCount    = 10;
                break;

            case Level.Middle:
                GameGrid.Height = 356;
                GameGrid.Width  = GameGrid.Height;
                width           = 16;
                height          = 16;
                allBombCount    = 40;
                break;

            case Level.Hard:
                GameGrid.Width  = 618;
                GameGrid.Height = GameGrid.Width * 16 / 30;
                width           = 16;
                height          = 30;
                allBombCount    = 99;
                break;

            default:
                break;
            }
            images = new Image[width, height];
            for (int i = 0; i < width; i++)
            {
                GameGrid.RowDefinitions.Add(new RowDefinition());
            }
            for (int j = 0; j < height; j++)
            {
                GameGrid.ColumnDefinitions.Add(new ColumnDefinition());
            }
            map = new Cell[width, height];
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    map[i, j]    = new Cell(i, j);
                    images[i, j] = new Image()
                    {
                        Source  = map[i, j].ExtImage,
                        Stretch = Stretch.Fill,
                        Tag     = map[i, j]
                    };
                    images[i, j].MouseUp += image_MouseUp;
                    GameGrid.Children.Add(images[i, j]);
                    Grid.SetRow(images[i, j], i);
                    Grid.SetColumn(images[i, j], j);
                }
            }
            Reset(true);
        }
예제 #38
0
파일: LobbyMgr.cs 프로젝트: beuoon/FILO
    private void Start()
    {
        argosSystem      = UICanvas.transform.Find("ArgosSystem").gameObject;
        athenaSystem     = UICanvas.transform.Find("AthenaSystem").gameObject;
        eagisSystem      = UICanvas.transform.Find("EagisSystem").gameObject;
        futureTechSystem = UICanvas.transform.Find("FutureTechSystem").gameObject;

        Transform Btns = UICanvas.transform.Find("Btns");

        argosBtn     = Btns.Find("ArgosBtn").GetComponent <Image>();
        athenaBtn    = Btns.Find("AthenaBtn").GetComponent <Image>();
        messengerBtn = Btns.Find("MessengerBtn").GetComponent <Image>();
        techBtn      = Btns.Find("TechBtn").GetComponent <Image>();

        debriefing        = athenaSystem.transform.Find("Debriefing").gameObject;
        operatorInfos     = athenaSystem.transform.Find("OperatorInfo").gameObject;
        operatorLeftInfo  = operatorInfos.transform.Find("LeftInfo").gameObject;
        operatorRightInfo = operatorInfos.transform.Find("RightInfo").gameObject;
        banners           = athenaSystem.transform.Find("SelectBanner").gameObject;

        operatorProfileImage = operatorLeftInfo.transform.Find("ProfileImage").GetComponent <Image>();
        operatorNameText     = operatorLeftInfo.transform.Find("OperatorName").GetComponent <Text>();
        operatorBodyText     = operatorLeftInfo.transform.Find("OperatorBody").GetComponent <Text>();
        operatorSpecialText  = operatorLeftInfo.transform.Find("OperatorSpecial").GetComponent <Text>();

        hpText          = operatorRightInfo.transform.Find("HP").GetComponent <Text>();
        o2Text          = operatorRightInfo.transform.Find("O2").GetComponent <Text>();
        useO2Text       = operatorRightInfo.transform.Find("UseO2").GetComponent <Text>();
        recorveryO2Text = operatorRightInfo.transform.Find("RecorveryO2").GetComponent <Text>();

        selectToolUI = operatorInfos.transform.Find("SelectTool").gameObject;
        selectAbilUI = operatorInfos.transform.Find("SelectAbility").gameObject;

        techDevUI  = futureTechSystem.transform.Find("TechDev").gameObject;
        techTestUI = futureTechSystem.transform.Find("TechTest").gameObject;

        // 도구
        info_toolImages = new Image[2] {
            operatorRightInfo.transform.Find("Tool0").Find("Tool").GetComponent <Image>(),
            operatorRightInfo.transform.Find("Tool1").Find("Tool").GetComponent <Image>()
        };
        select_toolImages = new Image[2] {
            selectToolUI.transform.Find("ToolImage0").Find("Tool").GetComponent <Image>(),
            selectToolUI.transform.Find("ToolImage1").Find("Tool").GetComponent <Image>()
        };
        select_toolTexts = new Text[2] {
            selectToolUI.transform.Find("ToolText0").GetComponent <Text>(),
            selectToolUI.transform.Find("ToolText1").GetComponent <Text>()
        };
        select_toolInfos = new Text[2] {
            selectToolUI.transform.Find("SelectedToolInfo").Find("ToolInfo0").GetComponent <Text>(),
            selectToolUI.transform.Find("SelectedToolInfo").Find("ToolInfo1").GetComponent <Text>()
        };
        for (int i = 0; i < 2; i++)
        {
            select_toolTexts[i].color = NORMAL_COLOR;
        }

        // 특성
        CrossPrefab      = Resources.Load <GameObject>("Prefabs/UI/Cross");
        SmallCrossPrefab = Resources.Load <GameObject>("Prefabs/UI/SmallCross");

        info_abilImages   = new Image[4];
        select_abilTitles = new Text[4];
        select_abilTexts  = new Text[4];
        select_abilImages = new Image[4, 2];
        select_abilLines  = new Image[4, 2];

        for (int i = 0; i < 4; i++)
        {
            info_abilImages[i]   = operatorRightInfo.transform.Find(string.Format("Abil{0}", i)).GetComponent <Image>();
            select_abilTitles[i] = selectAbilUI.transform.Find("SelectedAbilInfo").Find(string.Format("Abil{0}", i)).GetComponent <Text>();
            select_abilTexts[i]  = selectAbilUI.transform.Find("SelectedAbilInfo").Find(string.Format("AbilInfo{0}", i)).GetComponent <Text>();

            for (int j = 0; j < 2; j++)
            {
                select_abilImages[i, j] = selectAbilUI.transform.Find("AbilTree").Find(string.Format("AbilImage{0}-{1}", i, j)).GetComponent <Image>();
                select_abilLines[i, j]  = selectAbilUI.transform.Find("AbilTree").Find(string.Format("AbilLine{0}-{1}", i, j)).GetComponent <Image>();

                int level = i, index = j;
                select_abilImages[i, j].GetComponent <Button>().onClick.AddListener(() => ChangeAbility(level, index));
            }

            // 미클리어 레벨 특성 X 표시
            if (!gameData.IsCleared(i))
            {
                Instantiate(CrossPrefab, info_abilImages[i].transform.position, Quaternion.identity, info_abilImages[i].transform);
                Instantiate(SmallCrossPrefab, select_abilImages[i, 0].transform.position, Quaternion.identity, select_abilImages[i, 0].transform);
                Instantiate(SmallCrossPrefab, select_abilImages[i, 1].transform.position, Quaternion.identity, select_abilImages[i, 1].transform);
            }
        }
        for (int i = 0; i < 3; i++)
        {
            Image select_abilCenterLine = selectAbilUI.transform.Find("AbilTree").Find(string.Format("AbilLine{0}", i)).GetComponent <Image>();
            select_abilCenterLine.color = (gameData.IsCleared(i + 1)) ? HIGHLIGHT_COLOR : NORMAL_COLOR;
        }


        btnImages = new Sprite[12];

        btnImages[0]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/01.Argos_Non select");
        btnImages[1]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/01.Argos_Non select_notice");
        btnImages[2]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/01.Argos_select");
        btnImages[3]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/02.Athena_Non select");
        btnImages[4]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/02.Athena_Non select_notice");
        btnImages[5]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/02.Athena_select");
        btnImages[6]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/03.Messenger_Non select");
        btnImages[7]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/03.Messenger_Non select_notice");
        btnImages[8]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/03.Messenger_select");
        btnImages[9]  = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/04.Technology_Non select");
        btnImages[10] = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/04.Technology_Non select_notice");
        btnImages[11] = Resources.Load <Sprite>("Sprite/LobbyScene/Icon/04.Technology_select");

        profileImages = new Sprite[4];

        profileImages[0] = Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Athena-02_Operator Information-profile-01");
        profileImages[1] = Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Athena-02_Operator Information-profile-02");
        profileImages[2] = Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Athena-02_Operator Information-profile-03");
        profileImages[3] = Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Athena-02_Operator Information-profile-04");

        toolSprites = new Dictionary <Tool, Sprite>();
        toolSprites.Add(Tool.FIREWALL, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/ToolIcon/Firewall1"));
        toolSprites.Add(Tool.FIRE_EX, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/ToolIcon/FireExtinguisher1"));
        toolSprites.Add(Tool.FLARE, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/ToolIcon/Flare1"));
        toolSprites.Add(Tool.O2_CAN, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/ToolIcon/OxygenRespirator1"));
        toolSprites.Add(Tool.STICKY_BOMB, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/ToolIcon/StickyBomb1"));

        abilitySprites = new Dictionary <Ability, Sprite>();
        abilitySprites.Add(Ability.None, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Athena-02_Operator Information-Icon box"));
        abilitySprites.Add(Ability.Cardio, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Cardio"));
        abilitySprites.Add(Ability.DoubleHeart, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Double heart"));
        abilitySprites.Add(Ability.EquipMini, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Equipment miniaturization"));
        abilitySprites.Add(Ability.Fitness, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Fitness"));
        abilitySprites.Add(Ability.IntervalTrain, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Interval training"));
        abilitySprites.Add(Ability.MacGyver, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/MacGyver"));
        abilitySprites.Add(Ability.Nightingale, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Nightingale"));
        abilitySprites.Add(Ability.OxygenTank, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Oxygen tank"));
        abilitySprites.Add(Ability.PartsLightweight, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Parts lightweight"));
        abilitySprites.Add(Ability.RedundancyOxygen, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Redundancy Oxygen"));
        abilitySprites.Add(Ability.Refuel, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Refuel"));
        abilitySprites.Add(Ability.ReinforceParts, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Reinforce parts"));
        abilitySprites.Add(Ability.SteelBody, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Steel body"));
        abilitySprites.Add(Ability.SurvivalPriority, Resources.Load <Sprite>("Sprite/LobbyScene/02_Athena_System/02_Operator Information/Icon/Survival Priority"));

        currentSystemIndex = 0;
        currentSystem      = argosSystem;
        currentSystemBtn   = argosBtn;

        eagisTalks = new GameObject[4];
        for (int i = 0; i < eagisTalks.Length; i++)
        {
            eagisTalks[i] = eagisSystem.transform.Find("Talk" + i).Find("Talks").gameObject;
        }
        currentEagisTalk    = eagisTalks[0];
        eagisTalkerNameText = eagisSystem.transform.Find("TalkerName").GetComponent <Text>();
    }
예제 #39
0
        private void caricaFrame(string tipoDiFantasma)
        {
            frame       = new Image[4, 6];
            afraidFrame = new Image[2, 6];
            eyes        = new Image[4];

            if (tipoDiFantasma == "blinky")
            {
                frame[0, 0] = Properties.Resources.blinky1Left;
                frame[0, 1] = Properties.Resources.blinky2Left;
                frame[0, 2] = Properties.Resources.blinky3Left;
                frame[0, 3] = Properties.Resources.blinky4Left;
                frame[0, 4] = Properties.Resources.blinky5Left;
                frame[0, 5] = Properties.Resources.blinky6Left;

                frame[1, 0] = Properties.Resources.blinky1Up;
                frame[1, 1] = Properties.Resources.blinky2Up;
                frame[1, 2] = Properties.Resources.blinky3Up;
                frame[1, 3] = Properties.Resources.blinky4Up;
                frame[1, 4] = Properties.Resources.blinky5Up;
                frame[1, 5] = Properties.Resources.blinky6Up;

                frame[2, 0] = Properties.Resources.blinky1Right;
                frame[2, 1] = Properties.Resources.blinky2Right;
                frame[2, 2] = Properties.Resources.blinky3Right;
                frame[2, 3] = Properties.Resources.blinky4Right;
                frame[2, 4] = Properties.Resources.blinky5Right;
                frame[2, 5] = Properties.Resources.blinky6Right;


                frame[3, 0] = Properties.Resources.blinky1Down;
                frame[3, 1] = Properties.Resources.blinky2Down;
                frame[3, 2] = Properties.Resources.blinky3Down;
                frame[3, 3] = Properties.Resources.blinky4Down;
                frame[3, 4] = Properties.Resources.blinky5Down;
                frame[3, 5] = Properties.Resources.blinky6Down;
            }
            else
            if (tipoDiFantasma == "clyde")
            {
                frame[0, 0] = Properties.Resources.clyde1Left;
                frame[0, 1] = Properties.Resources.clyde2Left;
                frame[0, 2] = Properties.Resources.clyde3Left;
                frame[0, 3] = Properties.Resources.clyde4Left;
                frame[0, 4] = Properties.Resources.clyde5Left;
                frame[0, 5] = Properties.Resources.clyde6Left;

                frame[1, 0] = Properties.Resources.clyde1Up;
                frame[1, 1] = Properties.Resources.clyde2Up;
                frame[1, 2] = Properties.Resources.clyde3Up;
                frame[1, 3] = Properties.Resources.clyde4Up;
                frame[1, 4] = Properties.Resources.clyde5Up;
                frame[1, 5] = Properties.Resources.clyde6Up;

                frame[2, 0] = Properties.Resources.clyde1Right;
                frame[2, 1] = Properties.Resources.clyde2Right;
                frame[2, 2] = Properties.Resources.clyde3Right;
                frame[2, 3] = Properties.Resources.clyde4Right;
                frame[2, 4] = Properties.Resources.clyde5Right;
                frame[2, 5] = Properties.Resources.clyde6Right;

                frame[3, 0] = Properties.Resources.clyde1Down;
                frame[3, 1] = Properties.Resources.clyde2Down;
                frame[3, 2] = Properties.Resources.clyde3Down;
                frame[3, 3] = Properties.Resources.clyde4Down;
                frame[3, 4] = Properties.Resources.clyde5Down;
                frame[3, 5] = Properties.Resources.clyde6Down;
            }
            else
            if (tipoDiFantasma == "inky")
            {
                frame[0, 0] = Properties.Resources.inky1Left;
                frame[0, 1] = Properties.Resources.inky2Left;
                frame[0, 2] = Properties.Resources.inky3Left;
                frame[0, 3] = Properties.Resources.inky4Left;
                frame[0, 4] = Properties.Resources.inky5Left;
                frame[0, 5] = Properties.Resources.inky6Left;

                frame[1, 0] = Properties.Resources.inky1Up;
                frame[1, 1] = Properties.Resources.inky2Up;
                frame[1, 2] = Properties.Resources.inky3Up;
                frame[1, 3] = Properties.Resources.inky4Up;
                frame[1, 4] = Properties.Resources.inky5Up;
                frame[1, 5] = Properties.Resources.inky6Up;

                frame[2, 0] = Properties.Resources.inky1Right;
                frame[2, 1] = Properties.Resources.inky2Right;
                frame[2, 2] = Properties.Resources.inky3Right;
                frame[2, 3] = Properties.Resources.inky4Right;
                frame[2, 4] = Properties.Resources.inky5Right;
                frame[2, 5] = Properties.Resources.inky6Right;

                frame[3, 0] = Properties.Resources.inky1Down;
                frame[3, 1] = Properties.Resources.inky2Down;
                frame[3, 2] = Properties.Resources.inky3Down;
                frame[3, 3] = Properties.Resources.inky4Down;
                frame[3, 4] = Properties.Resources.inky5Down;
                frame[3, 5] = Properties.Resources.inky6Down;
            }
            else
            if (tipoDiFantasma == "pinky")
            {
                frame[0, 0] = Properties.Resources.pinky1Left;
                frame[0, 1] = Properties.Resources.pinky2Left;
                frame[0, 2] = Properties.Resources.pinky3Left;
                frame[0, 3] = Properties.Resources.pinky4Left;
                frame[0, 4] = Properties.Resources.pinky5Left;
                frame[0, 5] = Properties.Resources.pinky6Left;

                frame[1, 0] = Properties.Resources.pinky1Up;
                frame[1, 1] = Properties.Resources.pinky2Up;
                frame[1, 2] = Properties.Resources.pinky3Up;
                frame[1, 3] = Properties.Resources.pinky4Up;
                frame[1, 4] = Properties.Resources.pinky5Up;
                frame[1, 5] = Properties.Resources.pinky6Up;

                frame[2, 0] = Properties.Resources.pinky1Right;
                frame[2, 1] = Properties.Resources.pinky2Right;
                frame[2, 2] = Properties.Resources.pinky3Right;
                frame[2, 3] = Properties.Resources.pinky4Right;
                frame[2, 4] = Properties.Resources.pinky5Right;
                frame[2, 5] = Properties.Resources.pinky6Right;

                frame[3, 0] = Properties.Resources.pinky1Down;
                frame[3, 1] = Properties.Resources.pinky2Down;
                frame[3, 2] = Properties.Resources.pinky3Down;
                frame[3, 3] = Properties.Resources.pinky4Down;
                frame[3, 4] = Properties.Resources.pinky5Down;
                frame[3, 5] = Properties.Resources.pinky6Down;
            }

            afraidFrame[0, 0] = Properties.Resources.afraidGhost1;
            afraidFrame[0, 1] = Properties.Resources.afraidGhost2;
            afraidFrame[0, 2] = Properties.Resources.afraidGhost3;
            afraidFrame[0, 3] = Properties.Resources.afraidGhost4;
            afraidFrame[0, 4] = Properties.Resources.afraidGhost5;
            afraidFrame[0, 5] = Properties.Resources.afraidGhost6;

            afraidFrame[1, 0] = Properties.Resources.afraidGhostEnd1;
            afraidFrame[1, 1] = Properties.Resources.afraidGhostEnd2;
            afraidFrame[1, 2] = Properties.Resources.afraidGhostEnd4;
            afraidFrame[1, 3] = Properties.Resources.afraidGhostEnd5;
            afraidFrame[1, 4] = Properties.Resources.afraidGhostEnd5;
            afraidFrame[1, 5] = Properties.Resources.afraidGhostEnd6;

            eyes[0] = Properties.Resources.eyesLeft;
            eyes[1] = Properties.Resources.eyesUp;
            eyes[2] = Properties.Resources.eyesRight;
            eyes[3] = Properties.Resources.eyesDown;
        }
예제 #40
0
 public Graphics(Grid _bGridMain, int [,] _numbers, Image [,] _imageGrid)
 {
     bGridMain = _bGridMain;
     numbers   = _numbers;
     imageGrid = _imageGrid;
 }
예제 #41
0
파일: Figure.cs 프로젝트: haroutunyan/Chess
        private void queenHint(ref Image[,] hints, ref int[,] matrix)
        {
            int  k = y;
            bool t = false;

            while (k < 7 && matrix[x, k + 1] != 1)
            {
                if (matrix[x, k + 1] == -1)
                {
                    t = true;
                }

                hints[x, k + 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x, k + 1].Margin  = new Thickness(x * 73, (k + 1) * 70, 0, 0);
                hints[x, k + 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x, k + 1], 1);
                matrix[x, k + 1] = 2;

                if (t)
                {
                    break;
                }

                k++;
            }
            k = y;
            t = false;
            while (k > 0 && matrix[x, k - 1] != 1)
            {
                if (matrix[x, k - 1] == -1)
                {
                    t = true;
                }

                hints[x, k - 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[x, k - 1].Margin  = new Thickness(x * 73, (k - 1) * 70, 0, 0);
                hints[x, k - 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[x, k - 1], 1);
                matrix[x, k - 1] = 2;

                if (t)
                {
                    break;
                }

                k--;
            }
            k = x;
            t = false;
            while (k > 0 && matrix[k - 1, y] != 1)
            {
                if (matrix[k - 1, y] == -1)
                {
                    t = true;
                }

                hints[k - 1, y].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[k - 1, y].Margin  = new Thickness((k - 1) * 73, y * 70, 0, 0);
                hints[k - 1, y].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[k - 1, y], 1);
                matrix[k - 1, y] = 2;

                if (t)
                {
                    break;
                }

                k--;
            }
            k = x;
            t = false;

            while (k < 7 && matrix[k + 1, y] != 1)
            {
                if (matrix[k + 1, y] == -1)
                {
                    t = true;
                }

                hints[k + 1, y].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[k + 1, y].Margin  = new Thickness((k + 1) * 73, y * 70, 0, 0);
                hints[k + 1, y].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[k + 1, y], 1);
                matrix[k + 1, y] = 2;

                if (t)
                {
                    break;
                }

                k++;
            }
            k = x;
            int j = y;

            t = false;
            while (k < 7 && j < 7 && matrix[k + 1, j + 1] != 1)
            {
                if (matrix[k + 1, j + 1] == -1)
                {
                    t = true;
                }

                hints[k + 1, j + 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[k + 1, j + 1].Margin  = new Thickness((k + 1) * 73, (j + 1) * 70, 0, 0);
                hints[k + 1, j + 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[k + 1, j + 1], 1);
                matrix[k + 1, j + 1] = 2;

                if (t)
                {
                    break;
                }
                k++;
                j++;
            }
            k = x;
            j = y;
            t = false;
            while (k > 0 && j > 0 && matrix[k - 1, j - 1] != 1)
            {
                if (matrix[k - 1, j - 1] == -1)
                {
                    t = true;
                }

                hints[k - 1, j - 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[k - 1, j - 1].Margin  = new Thickness((k - 1) * 73, (j - 1) * 70, 0, 0);
                hints[k - 1, j - 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[k - 1, j - 1], 1);
                matrix[k - 1, j - 1] = 2;

                if (t)
                {
                    break;
                }

                k--;
                j--;
            }
            k = x;
            j = y;
            t = false;
            while (k > 0 && j < 7 && matrix[k - 1, j + 1] != 1 && t == false)
            {
                if (matrix[k - 1, j + 1] == -1)
                {
                    t = true;
                }

                hints[k - 1, j + 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[k - 1, j + 1].Margin  = new Thickness((k - 1) * 73, (j + 1) * 70, 0, 0);
                hints[k - 1, j + 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[k - 1, j + 1], 1);
                matrix[k - 1, j + 1] = 2;

                if (t)
                {
                    break;
                }

                k--;
                j++;
            }
            k = x;
            j = y;
            t = false;
            while (k < 7 && j > 0 && matrix[k + 1, j - 1] != 1)
            {
                if (matrix[k + 1, j - 1] == -1)
                {
                    t = true;
                }

                hints[k + 1, j - 1].Source  = new BitmapImage(new Uri("hint.png", UriKind.Relative));
                hints[k + 1, j - 1].Margin  = new Thickness((k + 1) * 73, (j - 1) * 70, 0, 0);
                hints[k + 1, j - 1].Stretch = System.Windows.Media.Stretch.Fill;
                Panel.SetZIndex(hints[k + 1, j - 1], 1);
                matrix[k + 1, j - 1] = 2;

                if (t)
                {
                    break;
                }
                k++;
                j--;
            }
        }
예제 #42
0
파일: Renderer.cs 프로젝트: Kolky/open3mod
        /// <summary>
        /// Populate _hudImages
        /// </summary>
        private void LoadHudImages()
        {
            if (_hudImages != null)
            {
                return;
            }

            _hudImages = new Image[PrefixTable.Length, 3];              
            for (var i = 0; i < _hudImages.GetLength(0); ++i)
            {
                for (var j = 0; j < _hudImages.GetLength(1); ++j)
                {
                    _hudImages[i, j] = ImageFromResource.Get(PrefixTable[i] + PostFixTable[j] + ".png");
                }
            }

            _hudBar = ImageFromResource.Get("open3mod.Images.HUDBar.png");
        }
        ////////////////
        //DO NOT TOUCH//
        ////////////////
        /// <summary>
        /// Initializes a new instance of the MainWindow class.
        /// </summary>
        public MainWindow()
        {
            // one sensor is currently supported
            this.kinectSensor = KinectSensor.GetDefault();

            // get the coordinate mapper
            this.coordinateMapper = this.kinectSensor.CoordinateMapper;

            // get the depth (display) extents
            FrameDescription frameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;

            // get size of joint space
            this.displayWidth  = frameDescription.Width;
            this.displayHeight = frameDescription.Height;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // a bone defined as a line between two joints
            this.bones = new List <Tuple <JointType,
                                          JointType> >();

            // Torso
            this.bones.Add(new Tuple <JointType, JointType>(JointType.Head, JointType.Neck));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.Neck, JointType.SpineShoulder));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineShoulder, JointType.SpineMid));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineMid, JointType.SpineBase));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderRight));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderLeft));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineBase, JointType.HipRight));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.SpineBase, JointType.HipLeft));

            // Right Arm
            this.bones.Add(new Tuple <JointType, JointType>(JointType.ShoulderRight, JointType.ElbowRight));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.ElbowRight, JointType.WristRight));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.WristRight, JointType.HandRight));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.HandRight, JointType.HandTipRight));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.WristRight, JointType.ThumbRight));

            // Left Arm
            this.bones.Add(new Tuple <JointType, JointType>(JointType.ShoulderLeft, JointType.ElbowLeft));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.ElbowLeft, JointType.WristLeft));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.WristLeft, JointType.HandLeft));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.HandLeft, JointType.HandTipLeft));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.WristLeft, JointType.ThumbLeft));

            // Right Leg
            this.bones.Add(new Tuple <JointType, JointType>(JointType.HipRight, JointType.KneeRight));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.KneeRight, JointType.AnkleRight));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.AnkleRight, JointType.FootRight));

            // Left Leg
            this.bones.Add(new Tuple <JointType, JointType>(JointType.HipLeft, JointType.KneeLeft));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.KneeLeft, JointType.AnkleLeft));
            this.bones.Add(new Tuple <JointType, JointType>(JointType.AnkleLeft, JointType.FootLeft));

            // populate body colors, one for each BodyIndex
            this.bodyColors = new List <Pen>();

            this.bodyColors.Add(new Pen(Brushes.Red, 6));
            this.bodyColors.Add(new Pen(Brushes.Orange, 6));
            this.bodyColors.Add(new Pen(Brushes.Green, 6));
            this.bodyColors.Add(new Pen(Brushes.Blue, 6));
            this.bodyColors.Add(new Pen(Brushes.Indigo, 6));
            this.bodyColors.Add(new Pen(Brushes.Violet, 6));

            // set IsAvailableChanged event notifier
            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            this.kinectSensor.Open();

            // set the status text
            this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText;

            // Create the drawing group we'll use for drawing
            this.drawingGroup = new DrawingGroup();

            // Create an image source that we can use in our image control
            this.imageSource = new DrawingImage(this.drawingGroup);

            // use the window object as the view model in this simple example
            this.DataContext = this;

            // initialize the components (controls) of the window
            this.InitializeComponent();

            //dynamically add a grid

            uniGrid.Rows    = numGridRows;
            uniGrid.Columns = numGridCols;
            //rows left->right
            rectArray = new Rectangle[numGridRows, numGridCols];
            imgArray  = new Image[numGridRows, numGridCols];
            Image temp_img;

            for (int rr = 0; rr < numGridRows; rr++)
            {
                for (int cc = 0; cc < numGridCols; cc++)
                {
                    rectArray[rr, cc] = new Rectangle()
                    {
                        Stroke = System.Windows.Media.Brushes.Black,
                        // Height = (int)(gridHeight / numGridRows),
                        //Width = (int)(gridWidth / numGridRows),
                    };
                    temp_img = new Image();
                    BitmapImage bm = new BitmapImage();
                    bm.BeginInit();
                    bm.UriSource = new Uri("", UriKind.Relative);
                    bm.EndInit();
                    temp_img.Source  = bm;
                    imgArray[rr, cc] = temp_img;
                    uniGrid.Children.Add(rectArray[rr, cc]);
                    uniImgGrid.Children.Add(imgArray[rr, cc]);
                }
            }

            //student storage initialization
            gridArray = new int[numGridRows, numGridCols];
            int delay = 30 * 8;

            zeroGridArray();

            WaterGotHit = System.Windows.Media.Brushes.Gray;
            ShipGotHit  = System.Windows.Media.Brushes.Red;
            ShipDead    = System.Windows.Media.Brushes.Black;

            isPlayerOneHandClosed  = false;
            hasPlayerOneHandOpened = false;

            playerOneHandLocation = new Point();

            delayFrames  = -1;
            isGameOver   = false;
            waitingOnBot = false;

            playerOneTrackingId      = 0;
            needsAllocationPlayerOne = true;
            clearBoard();
        }
예제 #44
0
        public override void Load()
        {
            listCoordMur     = RemplissageDeCord(Properties.Resources.Murcoord, listCoordMur);
            listCoordEnnemis = RemplissageDeCord(Properties.Resources.EnnemisCoord, listCoordEnnemis);
            listCoordPapier  = RemplissageDeCord(Properties.Resources.papierCoord, listCoordPapier);
            string[] aStrNomPapier = new string[7] {
                "pbPapier1", "pbPapier2", "pbPapier3", "pbPapier4", "pbPapier5", "pbPapier6", "pbSac"
            };

            //pour le joueur et les ennemi j'utilise un système de "ghost"
            //normalement la hitbox serait légèrement plus grande que l'image affichée
            //car cette dernière ne remplis pas toute la box.
            //alors je réduis la taille du joueur/ennemi , c'est ce qui sera sa hitbox effective
            //et j'affiche l'image dans une autre picturebox qui la suivra, son "ghost"

            //ici on initialise le joueur avec son "Ghost"
            pbJoueur.Size     = new System.Drawing.Size(23, 26);
            pbJoueur.Location = new System.Drawing.Point(98, 231);

            pbGhostJoueur.Size     = new System.Drawing.Size(29, 32);
            pbGhostJoueur.Location = new System.Drawing.Point(95, 228);
            //pbJoueur.BackColor = Color.Crimson; //utile pour afficher la hitbox pour le débuggage
            pbJoueur.Visible        = false;
            pbGhostJoueur.Image     = aSpriteJoueur[EtatSpriteJoueur, 1];
            pbGhostJoueur.BackColor = Color.Transparent;
            Controls.Add(pbJoueur);
            Controls.Add(pbGhostJoueur);

            //on va donc assigner toute les coordonnées contenues dans le fichier XML grâce à cette méthode
            aPBMurs = RemplissageProprietePictureBox(aPBMurs, listCoordMur);
            foreach (PictureBox mur in aPBMurs)
            {
                Controls.Add(mur);
            }

            //ici on initialise les ennemis et on lie leurs "ghost"
            aPBEnnemis = RemplissageProprietePictureBox(aPBEnnemis, listCoordEnnemis);
            connexionSpriteHitboxEnnemi();
            int iEnnemis = 0;

            foreach (PictureBox ennemi in aPBEnnemis)
            {
                Image[,] aSpriteEnnemi         = SelectionSet(iEnnemis);
                aPBGhostEnnemi[iEnnemis].Image = aSpriteEnnemi[aEtatSpriteEnnemi[iEnnemis], 1];
                Controls.Add(ennemi);
                Controls.Add(aPBGhostEnnemi[iEnnemis]);
                iEnnemis++;
            }

            //ici on initialise les papiers
            aPBPapier = RemplissageProprietePictureBox(aPBPapier, listCoordPapier);
            int iNomPapier = 0;

            foreach (PictureBox papier in aPBPapier)
            {
                aPBPapier[iNomPapier].Name  = aStrNomPapier[iNomPapier];
                aPBPapier[iNomPapier].Image = aSpriteSac[iNomPapier];
                iNomPapier++;
                Controls.Add(papier);
            }

            //ici on modifie le dernier sac pour le faire disparaître momentanéement
            aPBPapier[6].Enabled   = false;
            aPBPapier[6].Visible   = false;
            aPBPapier[6].BackColor = Color.Transparent;

            timer1.Start();
            timerSpriteEnnemi.Start();
            //on demarre le timer d'animation du joueur sur un keypress
        }
예제 #45
0
 // initialize game panel beans
 private void initGamePanelBeans()
 {
     gamePanelBeanMatrix = new Image[ROW_AMOUNT, COLUM_AMOUNT];
     int[,] gameZoneMatrix = game.getGameZoneMatrix();
     for (int i = 0; i < ROW_AMOUNT; i++)
     {
         double y = gamePanelStartPointY + i * BLOCK_HEIGHT;
         for (int j = 0; j < COLUM_AMOUNT; j++)
         {
             int type = gameZoneMatrix[i, j];
             if (type != 0)
             {
                 Image image = new Image();
                 image.Name = "beanImage_" + i + "_" + j;
                 double x = gamePanelStartPointX + j * BLOCK_WIDTH;
                 Thickness myThickness = new Thickness(x, y, 0, 0);
                 image.Margin = myThickness;
                 setBeanImageSource(image, type);
                 gameCanvas.Children.Add(image);
                 gamePanelBeanMatrix[i, j] = image;
             }
         }
     }
 }
예제 #46
0
	public void NewMaze()
	{
		cObjs = new GameObject[rows,cols];
		cImages = new Image[rows,cols];
		cColors = new int[rows,cols];

		currentHash = InitializeBoardGrid ();

		if (currentHash == null) {
			Debug.LogError ("Generated null maze");
		}

		SetMazeHash (currentHash);
		SetMazeBoard (currentHash);
		UpdateColors ();
	}
예제 #47
0
 /// <summary><para>Die überladene Funktion <see cref="Merge(Image[,])"/> verschmilzt mehrere Bilder, und gibt ein
 /// Bild als Typ <see cref="System.Drawing.Image"/> zurück. Die Bilder werden in einem Image-Array übergeben.
 /// Der erste Index bezeichnet die Zeilen, der zweite Index die Spalten der Bildermatrix.
 /// In dieser Methode sollten die Bilder in der Höhe und Breite den Standardmaßen eines Satellitenbilds entsprechen (256 Pixel).
 /// Prinzipiell ist die Anzahl der Zeilen und Spalten des Arrays nicht beschränkt, beachten Sie aber dennoch den
 /// Speicherbedarf. Die <see cref="System.Drawing.Image"/>-Objekte in dem Array können auch <strong>null</strong> sein.
 /// Die Einzelbilder im Array sollten jeweils die gleiche Breite und Höhe haben. Beispiel siehe
 /// <see cref="Merge(Image[,], Rectangle)"/>.</para></summary>
 ///
 /// <param name="array">Ein Array aus <see cref="System.Drawing.Image"/>-Objekten in der Form Image[Zeilen, Spalten].</param>
 /// <returns>Ein verschmolzenes <see cref="System.Drawing.Image"/>-Objekt.</returns>
 public Image Merge(Image[,] array)
 {
     return(Merge(array, new Rectangle(0, 0, TILE_SIZE, TILE_SIZE)));
 }
        private void LoadState(object navigationParameter, Dictionary<string, object> pageState)
        {
            // Unpack the navigation parameters passed from either the Main Page (singleplayer mode)
            // or the Invite Players page (singlePair, multiplayer mode).

            GamePageParameters parameters = (GamePageParameters)navigationParameter;

            if (PeerFinder.Role == PeerRole.Host)
            {
                timesToTick = Constants.PlayTime * Constants.TimeUnitsPerSecond;
            }

            gameMode = parameters.GameMode;

            if (gameMode != Constants.SinglePlayer)
            {
                // Not for single player games.

                connectedPeers = parameters.ConnectedPeers;

                // You should only have one socket if you're a client
                // Regardless, update each socket's current page to the game page
                foreach (ConnectedPeer host in connectedPeers.Keys)
                {
                    socket = connectedPeers[host];
                    socket.currentPage = this;
                    socket.UpdateCurrentPageType();
                }

                playerCount = parameters.PlayerCount;
            }

            images = new Image[Constants.GridRows, Constants.GridColumns];
            random = new Random();

            gameTimer = new DispatcherTimer();
            gameTimer.Interval = TimeSpan.FromMilliseconds(Constants.TimeUnit);
            gameTimer.Tick += UpdateTimer;

            if (gameMode == Constants.SinglePlayer)
            {
                InitImages();

                timesToTick = Constants.PlayTime * Constants.TimeUnitsPerSecond;
                StartGame();
            }
            else if (gameMode == Constants.MultiPlayer)
            {
                // See what your role is.
                if (PeerFinder.Role == PeerRole.Host)
                {
                    playerList = new Dictionary<int, string>();
                    playerList[0] = PeerFinder.DisplayName;
                    playerID = 0;

                    int counter = 1;

                    foreach (ConnectedPeer peer in connectedPeers.Keys)
                    {
                        playerList[counter] = peer.DisplayName;
                        SendParams(connectedPeers[peer], counter);
                        counter++;
                    }

                    InitImages();
                }
            }
        }
예제 #49
0
 public int [] Move(PlayerMatrix enemyMatrix, Image[,] enemyGameBoard, bool approved, int x, int y, ImageBuilder builder)
 {
     int[] tab;
     tab = strategy.Move(enemyMatrix, enemyGameBoard, approved, x, y, builder);
     return(tab);
 }
예제 #50
0
 // initialize game panel background
 private void initGamePanelBackground()
 {
     gamePanelBackgroudMatrix = new Image[ROW_AMOUNT, COLUM_AMOUNT];
     for (int i = 0; i < ROW_AMOUNT; i++)
     {
         int y = gamePanelStartPointY + i * BLOCK_HEIGHT;
         for (int j = 0; j < COLUM_AMOUNT; j++)
         {
             int x = gamePanelStartPointX + j * BLOCK_WIDTH;
             Image image = new Image();
             image.Name = "bgImage_" + i + "_" + j;
             Thickness imageThickness = new Thickness(x, y, 0, 0);
             image.Margin = imageThickness;
             image.Source = bgBlock.Source;
             gameCanvas.Children.Add(image);
             gamePanelBackgroudMatrix[i, j] = image;
         }
     }
 }
예제 #51
0
 public abstract int[] Move(PlayerMatrix enemyMatrix, Image[,] enemyGameBoard, bool approved, int x, int y, ImageBuilder builder);
예제 #52
0
 public override int[] Move(PlayerMatrix enemyMatrix, Image[,] enemyGameBoard, bool approved, int x, int y, ImageBuilder builder)
 {
     int[] tab = new int[2];
     if (y < 9)
     {
         enemyMatrix.playerMatrix[x, y] -= 1000;
         y++;
         enemyMatrix.playerMatrix[x, y] += 1000;
         if (enemyMatrix.playerMatrix[x, y] == 1000 || enemyMatrix.playerMatrix[x, y] == 1009 || enemyMatrix.playerMatrix[x, y] == 1001 || enemyMatrix.playerMatrix[x, y] == 1003 || enemyMatrix.playerMatrix[x, y] == 1005 || enemyMatrix.playerMatrix[x, y] == 1007)
         {
             builder.BuildWaterPointer();
             enemyGameBoard[x, y].Source = builder.GetImage().Source;
         }
         if (enemyMatrix.playerMatrix[x, y] == 1123)
         {
             builder.BuildMissPointer();
             enemyGameBoard[x, y].Source = builder.GetImage().Source;
         }
         if (enemyMatrix.playerMatrix[x, y] == 1321)
         {
             builder.BuildShipPointer();
             enemyGameBoard[x, y].Source = builder.GetImage().Source;
         }
         if (enemyMatrix.playerMatrix[x, y] == 1999)
         {
             builder.BuildHitPointer();
             enemyGameBoard[x, y].Source = builder.GetImage().Source;
         }
         if (enemyMatrix.playerMatrix[x, y - 1] == 123)
         {
             builder.BuildMiss();
             enemyGameBoard[x, y - 1].Source = builder.GetImage().Source;
         }
         if (enemyMatrix.playerMatrix[x, y - 1] == 321)
         {
             builder.BuildShipHit();
             enemyGameBoard[x, y - 1].Source = builder.GetImage().Source;
         }
         if (enemyMatrix.playerMatrix[x, y - 1] == 999)
         {
             builder.BuildHit();
             enemyGameBoard[x, y - 1].Source = builder.GetImage().Source;
         }
         if (enemyMatrix.playerMatrix[x, y - 1] == 0 || enemyMatrix.playerMatrix[x, y - 1] == 9 || enemyMatrix.playerMatrix[x, y - 1] == 1 || enemyMatrix.playerMatrix[x, y - 1] == 3 || enemyMatrix.playerMatrix[x, y - 1] == 5 || enemyMatrix.playerMatrix[x, y - 1] == 7)
         {
             builder.BuildWather();
             enemyGameBoard[x, y - 1].Source = builder.GetImage().Source;
         }
         if (enemyMatrix.playerMatrix[x, y] == 1000 || enemyMatrix.playerMatrix[x, y] == 1009 || enemyMatrix.playerMatrix[x, y] == 1001 || enemyMatrix.playerMatrix[x, y] == 1003 || enemyMatrix.playerMatrix[x, y] == 1005 || enemyMatrix.playerMatrix[x, y] == 1007)
         {
             tab[0] = y;
             tab[1] = 1;
             return(tab);
         }
         else
         {
             tab[0] = y;
             tab[1] = 0;
             return(tab);
         }
     }
     if (enemyMatrix.playerMatrix[x, y] == 1000 || enemyMatrix.playerMatrix[x, y] == 1009 || enemyMatrix.playerMatrix[x, y] == 1001 || enemyMatrix.playerMatrix[x, y] == 1003 || enemyMatrix.playerMatrix[x, y] == 1005 || enemyMatrix.playerMatrix[x, y] == 1007)
     {
         tab[0] = y;
         tab[1] = 1;
         return(tab);
     }
     else
     {
         tab[0] = y;
         tab[1] = 0;
         return(tab);
     }
 }
예제 #53
0
 private ImageProvider()
 {
     _image = Properties.Resources.cards_sheet;
     _imageArray = new Image[4, 14];
 }
예제 #54
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _numberMatrix       = new int[3, 3];
            _croppedImageMatrix = new Image[3, 3];

            var source = new BitmapImage(
                new Uri(DefaultFileName, UriKind.RelativeOrAbsolute));

            var h = (int)source.PixelHeight;
            var w = (int)source.PixelWidth;


            if (h > w)
            {
                double ratio         = h / (double)square_length;
                double ratio_preview = h / (double)preview_length;

                h_cropped         = (int)(h / ratio);
                w_cropped         = (int)(w / ratio);
                h_cropped_preview = (int)(h / ratio_preview);
                w_cropped_preview = (int)(w / ratio_preview);
                padding_X         = (square_length - w_cropped) / 2;
                padding_Y         = 0;
            }
            else
            {
                double ratio         = w / (double)square_length;
                double ratio_preview = w / (double)preview_length;

                h_cropped         = (int)(h / ratio);
                w_cropped         = (int)(w / ratio);
                h_cropped_preview = (int)(h / ratio_preview);
                w_cropped_preview = (int)(w / ratio_preview);
                padding_X         = 0;
                padding_Y         = (square_length - h_cropped) / 2;
            }


            previewImage.Width  = w_cropped_preview;
            previewImage.Height = h_cropped_preview;
            previewImage.Source = source;



            // Bat dau cat thanh 9 manh

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (!((i == 2) && (j == 2)))
                    {
                        //Debug.WriteLine($"Len = {len}");
                        var rect       = new Int32Rect(j * w / 3, i * h / 3, w / 3, h / 3);
                        var cropBitmap = new CroppedBitmap(source,
                                                           rect);

                        var cropImage = new Image();
                        cropImage.Stretch = Stretch.Fill;
                        cropImage.Width   = w_cropped / 3;
                        cropImage.Height  = h_cropped / 3;
                        cropImage.Source  = cropBitmap;
                        canvas.Children.Add(cropImage);
                        Canvas.SetLeft(cropImage, startX + padding_X + j * (w_cropped / 3 + 2));
                        Canvas.SetTop(cropImage, startY + padding_Y + i * (h_cropped / 3 + 2));



                        cropImage.MouseLeftButtonDown      += CropImage_MouseLeftButtonDown;
                        cropImage.PreviewMouseLeftButtonUp += CropImage_PreviewMouseLeftButtonUp;


                        _croppedImageMatrix[i, j] = cropImage;
                        _numberMatrix[i, j]       = 3 * i + j + 1;
                    }
                }
            }

            saveButton.IsEnabled    = false;
            refreshButton.IsEnabled = false;
        }
예제 #55
0
 private ImageProvider()
 {
     _image = Application.Properties.Resources.pieces;
     _imageArray = new Image[2, 6];
 }
예제 #56
0
        private static Level LoadLevel(string data, GameControl gc, Image[,] iset)
        {
            data = data.Replace("\r", "");
            Level level = new Level(gc);
            int   row   = 0;
            int   key   = 0;

            foreach (String s in data.Split("\n".ToCharArray()))
            {
                for (int i = 0; i < s.Length; i++)
                {
                    if (s.ToCharArray()[i] == '1')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[0, 0]));
                    }
                    if (s.ToCharArray()[i] == '2')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[1, 0]));
                    }
                    if (s.ToCharArray()[i] == '3')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[2, 0]));
                    }
                    if (s.ToCharArray()[i] == '4')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[3, 0]));
                    }
                    if (s.ToCharArray()[i] == '5')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[4, 0]));
                    }
                    if (s.ToCharArray()[i] == '6')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[5, 0]));
                    }
                    if (s.ToCharArray()[i] == '7')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[6, 0]));
                    }
                    if (s.ToCharArray()[i] == '8')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[7, 0]));
                    }
                    if (s.ToCharArray()[i] == '9')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[8, 0]));
                    }
                    if (s.ToCharArray()[i] == 'Q')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[0, 8]));
                    }
                    if (s.ToCharArray()[i] == 'W')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[1, 8]));
                    }
                    if (s.ToCharArray()[i] == 'E')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[2, 8]));
                    }
                    if (s.ToCharArray()[i] == 'R')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[3, 8]));
                    }
                    if (s.ToCharArray()[i] == 'S')
                    {
                        level.AddSprite(new FloorTile(new Point(i * 128, row * 128), key, iset[0, 9]));
                    }
                    if (s.ToCharArray()[i] == 'B')
                    {
                        level.AddSprite(new BounceTile(new Point(i * 128, row * 128), key, iset[6, 8]));
                    }
                    if (s.ToCharArray()[i] == 'C')
                    {
                        level.AddSprite(new SpikeTile(new Point(i * 128, row * 128), key, iset[7, 8]));
                    }
                    if (s.ToCharArray()[i] == 'D')
                    {
                        level.AddSprite(new Door(new Point(i * 128, row * 128), key, iset[5, 8], iset[4, 8]));
                    }
                    if (s.ToCharArray()[i] == 'p')
                    {
                        level.AddSprite(new Donut(new Point(i * 128, row * 128), key));
                    }
                    key++;
                }
                row++;
            }
            return(level);
        }
예제 #57
0
 private void OnEnable()
 {
     universe     = new int[Row, Col];
     buttonImages = new Image[Row, Col];
 }
예제 #58
0
        public CrossZeroGame()
        {
            Title      = "Tic-Tac-Toe Game";
            crossZeros = new Dictionary <Image, int>();
            playground = new Grid()
            {
                HeightRequest = 375
            };

            for (int i = 0; i < GRID_COLUMNS_ROWS_NUM; i++)
            {
                playground.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                playground.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }

            boxPosition = new Image[3, 3];
            for (int i = 0; i < GRID_COLUMNS_ROWS_NUM; i++)
            {
                for (int j = 0; j < GRID_COLUMNS_ROWS_NUM; j++)
                {
                    box = new Image {
                        HeightRequest   = 125,
                        BackgroundColor = Color.FromHex("#0099FF")
                    };
                    playground.Children.Add(box, i, j);
                    boxPosition[i, j] = box;
                    var tap = new TapGestureRecognizer();
                    tap.Tapped += CrossOrZeroTapped;
                    box.GestureRecognizers.Add(tap);
                }
            }

            currentTurn = new Label()
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                FontSize                = 30,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center
            };

            winStatus = new Label()
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                FontSize                = 30,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center
            };

            resetGameButton = new Button()
            {
                Text = "Reset Game",
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            StackLayout buttonsLayout = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Children    = { resetGameButton }
            };

            StackLayout stackLayout = new StackLayout()
            {
                Children = { currentTurn, winStatus, playground, buttonsLayout }
            };

            Content = stackLayout;
            resetGameButton.Clicked += ResetButtonClicked;
            GetFirstPlayer();
        }
        /// <summary>
        /// Clears the map canvas and fills it with sprites for the specified map.
        /// </summary>
        /// <param name="map">Map to show.</param>
        public void UpdateMapCanvas(Map map)
        {
            // Remove old images.
            this.MapCanvas.Children.Clear();

            // Set canvas size.
            this.MapCanvas.Width = map.Width * TileSizeInPixels;
            this.MapCanvas.Height = map.Height * TileSizeInPixels;

            this.canvasImages = new Image[map.Width, map.Height];

            for (var x = 0; x < map.Width; x++)
            {
                for (var y = 0; y < map.Height; y++)
                {
                    var mapTile = map[x, y];

                    // Add new image to canvas.
                    var image = new Image
                        {
                            Width = TileSizeInPixels,
                            Height = TileSizeInPixels,
                            Source = this.controller.GetTileImage(mapTile.Type),
                            Tag = new Vector2I(x, y)
                        };

                    this.MapCanvas.Children.Add(image);

                    this.canvasImages[x, y] = image;

                    // Set image position.
                    Canvas.SetLeft(image, x * TileSizeInPixels);
                    Canvas.SetTop(image, y * TileSizeInPixels);

                    // Register image event handlers.
                    image.MouseLeftButtonDown += this.OnBrushDown;
                    image.MouseLeftButtonUp += this.OnBrushUp;
                    image.MouseMove += this.OnTileClicked;
                }
            }

            this.ResetStatusText();
        }
예제 #60
0
파일: Map.cs 프로젝트: Deeeja/OrbScape
 public Map()
 {
     map = new Image[4, 9];
     FillMap();
 }