Beispiel #1
0
        public MoteurJeu(MoteurSysteme moteurSysteme)
        {
            this.moteurSysteme = moteurSysteme;

            camera = new Vector2(550, 100);

            user = new EvenementUtilisateur();

            carte = new Carte(moteurSysteme.carteArray, camera, 64, 64, 32, 16);

            gui = new Interface(carte, moteurSysteme);
        }
Beispiel #2
0
        public void Update(EvenementUtilisateur user)
        {
            if ((boutonModeSelection.IsHover(user.mouseState) && user.isLeftClick()) || user.IsKeyUsed(Keys.S))
            {
                outilSelect = 'S';
                boutonModeSelection.isSelect = true;
                boutonModePoint.isSelect = false;
            }

            if ((boutonModePoint.IsHover(user.mouseState) && user.isLeftClick()) || user.IsKeyUsed(Keys.P))
            {
                outilSelect = 'P';
                boutonModePoint.isSelect = true;
                boutonModeSelection.isSelect = false;
            }

            if ((boutonAddLayer.IsHover(user.mouseState) && user.isLeftClick()) || user.IsKeyUsed(Keys.A))
                carte.AddLayer(tuileSelect);

            if ((boutonRemoveLayer.IsHover(user.mouseState) && user.isLeftClick()) || user.IsKeyUsed(Keys.R))
                carte.RemoveLayer();

            if ((boutonUpLayer.IsHover(user.mouseState) && user.isLeftClick()) || user.IsKeyUsed(Keys.Q))
                carte.UpRect(tuileSelect);

            if ((boutonDownLayer.IsHover(user.mouseState) && user.isLeftClick()) || user.IsKeyUsed(Keys.S))
                carte.DownRect();

            if ((boutonAddDim.IsHover(user.mouseState) && user.isLeftClick()) || user.IsKeyUsed(Keys.N))
                carte.AddDim(new Vector2(carte.tuileArray.GetLength(0) + 1, carte.tuileArray.GetLength(1) + 1));

            if ((boutonSave.IsHover(user.mouseState) && user.isLeftClick()) || (user.IsKeyUsed(Keys.S) && user.keyboardState.IsKeyDown(Keys.LeftControl)))
                moteurSysteme.SauvegarderCarte(carte.tuileArray, Environment.CurrentDirectory + @"\carte1.txt");

            if (user.isLeftClick())
            {
                if (user.mouseState.X > positionPalette.X && user.mouseState.X < positionPalette.X + 4 * 48 &&
                    user.mouseState.Y > positionPalette.Y + 15 && user.mouseState.Y < positionPalette.Y + 15 + 4 * 48)
                {
                    tuileSelect.X = (int)(user.mouseState.X - positionPalette.X) / 48;
                    tuileSelect.Y = (int)(user.mouseState.Y - positionPalette.Y - 15) / 33;

                    tuileSelect.X = tuileSelect.X + tuileSelect.Y * 4;
                    tuileSelect.Y = 0;
                }
            }
        }
Beispiel #3
0
        public void Update(GameTime gameTime, Vector2 camera, EvenementUtilisateur user, Vector2 typeSelect, char outilSelect)
        {
            this.camera = camera;

            SetTuileHover(new Vector2(user.mouseState.X, user.mouseState.Y));

            if (outilSelect == 'P')
            {
                if (tuileHover.X < tuileArray.GetLength(0) && tuileHover.Y < tuileArray.GetLength(1))
                    rectSelect = new Rectangle((int)tuileHover.X, (int)tuileHover.Y, 1, 1);

                if (user.isLeftClick())
                    AddLayer(typeSelect);
                else if (user.isRightClick())
                    RemoveLayer();

                /*if (user.mouseState.LeftButton == ButtonState.Pressed)
                    if (tuileHover.X < tuileArray.GetLength(0) && tuileHover.Y < tuileArray.GetLength(1))
                        columnSelect = tuileHover;*/

                /*if (user.IsKeyUsed(Keys.Enter) && user.keyboardState.IsKeyDown(Keys.LeftShift) && tuileArray[(int)tuileHover.X, (int)tuileHover.Y].Count > 0)
                    tuileArray[(int)tuileHover.X, (int)tuileHover.Y].RemoveAt(tuileArray[(int)tuileHover.X, (int)tuileHover.Y].Count - 1);
                else if (user.IsKeyUsed(Keys.Enter))
                    tuileArray[(int)tuileHover.X, (int)tuileHover.Y].Add(new Tuile(tuileHover, typeSelect, false, 0));*/

                /*if ((user.IsKeyUsed(Keys.Up) || user.isLeftClick() || user.isMouseWheelUp()) && tuileArray[(int)columnSelect.X, (int)columnSelect.Y].Count < 20)
                {
                    tuileArray[(int)columnSelect.X, (int)columnSelect.Y].Add
                        (new Tuile(columnSelect, typeSelect, false, tuileArray[(int)columnSelect.X, (int)columnSelect.Y].Count));
                }*/

                /*if ((user.IsKeyUsed(Keys.Down) || user.isRightClick() || user.isMouseWheelDown()) && tuileArray[(int)columnSelect.X, (int)columnSelect.Y].Count > 0)
                    tuileArray[(int)columnSelect.X, (int)columnSelect.Y].RemoveAt(tuileArray[(int)columnSelect.X, (int)columnSelect.Y].Count - 1);
                */

                /*if (user.IsKeyUsed(Keys.Right))
                    tuileSelect.ChangerPositionSource(1);

                if (user.IsKeyUsed(Keys.Left))
                    tuileSelect.ChangerPositionSource(-1);

                if (user.IsKeyUsed(Keys.Tab) && user.keyboardState.IsKeyDown(Keys.LeftShift))
                    tuileSelect = tuileArray[(int)tuileSelect.position.X, (int)tuileSelect.position.Y][0];
                else if (user.IsKeyUsed(Keys.Tab))
                    tuileSelect = tuileArray[(int)tuileSelect.position.X, (int)tuileSelect.position.Y][1];*/

                /*if (user.isMouseWheelUp())
                {
                    foreach (Tuile tuile in tuileArray[(int)tuileHover.X, (int)tuileHover.Y])
                        if (tuile.hauteur < 9)
                            tuile.hauteur++;
                }
                else if (user.isMouseWheelDown())
                    foreach (Tuile tuile in tuileArray[(int)tuileHover.X, (int)tuileHover.Y])
                        if (tuile.hauteur > 0)
                            tuile.hauteur--;*/
            }
            else if (outilSelect == 'S')
            {
                if (user.mouseState.LeftButton == ButtonState.Pressed && !inSelect)
                {
                    initialPos = tuileHover;
                    inSelect = true;
                }

                if (inSelect)
                {
                    if (tuileHover.X < initialPos.X)// || tuileHover.Y < initialPos.Y)
                        initialPos.X = tuileHover.X;

                    rectSelect = new Rectangle((int)initialPos.X, (int)initialPos.Y,
                                               (int)Math.Abs(tuileHover.X - initialPos.X) + 1, (int)Math.Abs(tuileHover.Y - initialPos.Y) + 1);
                }

                if (user.mouseState.LeftButton == ButtonState.Released && inSelect)
                    inSelect = false;

                if (rectSelect.X + rectSelect.Width > tuileArray.GetLength(0))// pour ne pas sortir de la map
                    rectSelect.Width = tuileArray.GetLength(0) - rectSelect.X;

                if (rectSelect.Y + rectSelect.Height > tuileArray.GetLength(1))
                    rectSelect.Height = tuileArray.GetLength(1) - rectSelect.Y;
            }
        }