示例#1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
示例#2
0
        public void Update(GameTime gametime, Game1 game)
        {
            foreach (Unite unit in list_unite)
                unit.Update(gametime, game);

            foreach (Ville ville in list_ville)
                ville.Update(game);
        }
示例#3
0
文件: Unite.cs 项目: kylox/MLPproject
 public Unite(Joueur joueur, Vector2 position, Type_unite type, Map map, Game1 game)
 {
     this.Game = game;
     this.Joueur = joueur;
     this.Type = type;
     IsMoved = false;
     rd = new Random();
     switch (Type)
     {
         case Type_unite.legere:
             Attaque = 8;
             Defense = 5;
             Vitesse = 2;
             Pv = 10;
             Sprite = TexturePack.TilesUnites[0]; // mettre la texure 
             break;
         case Type_unite.rapide:
             Attaque = 3;
             Defense = 2;
             Vitesse = 4;
             pv = 8;
             Sprite = TexturePack.TilesUnites[1]; //mettre texutre
             break;
         case Type_unite.lourde:
             Attaque = 10;
             Defense = 8;
             Vitesse = 1;
             Pv = 15;
             Sprite = TexturePack.TilesUnites[2]; // mettre texture
             break;
     }
     this.Position.X = map.Origine.X + position.X;
     this.Position.Y = map.Origine.Y + position.Y;
     this.Map = map;
     this.IsSelected = false;
 }
示例#4
0
文件: Unite.cs 项目: kylox/MLPproject
 public void Update(GameTime gametime, Game1 game)
 {
     // On va permettre la selection de l'unité
     #region selection + deplacement
     if (game.Phase == Phase_de_jeu.deplacement)
     {
         if ((Data.mouseState.LeftButton == ButtonState.Pressed) && (Data.prevMouseState.LeftButton != ButtonState.Pressed))
         {
             if (MouseOnTile())
             {
                 Map.GetTile((int)Position.X - Map.Origine.X, (int)Position.Y - Map.Origine.Y).SetColor(selectionColor);
                 IsSelected = true;
             }
             else
             {
                 Map.GetTile((int)Position.X - Map.Origine.X, (int)Position.Y - Map.Origine.Y).SetColor(defaultColor);
                 IsSelected = false;
             }
         }
         if ((Data.mouseState.RightButton == ButtonState.Pressed) && (Data.prevMouseState.RightButton != ButtonState.Pressed))
         {
             if (IsSelected && !IsMoved)
             {
                 bool tupeux = false;
                 int ixe = (int)Math.Abs(Data.mouseState.X - (Data.mouseState.X % 32) - 10 - Position.X);
                 int ygrec = (int)Math.Abs(Data.mouseState.Y - (Data.mouseState.Y % 32) - 8 - Position.Y);
                 switch (Type)
                 {
                     case Type_unite.legere:
                         tupeux = (ixe / 32 <= 2) && (ygrec / 32 <= 2)
                             && Is_inbounds(new Vector2(Data.mouseState.X, Data.mouseState.Y));
                         break;
                     case Type_unite.rapide:
                         tupeux = (ixe / 32 <= 4) && (ygrec / 32 <= 4)
                             && Is_inbounds(new Vector2(Data.mouseState.X, Data.mouseState.Y));
                         break;
                     case Type_unite.lourde:
                         tupeux = (ixe / 32 <= 1) && (ygrec / 32 <= 1)
                            && Is_inbounds(new Vector2(Data.mouseState.X, Data.mouseState.Y));
                         break;
                 }
                 if (tupeux)
                 {
                     Map.GetTile((int)Position.X - Map.Origine.X, (int)Position.Y - Map.Origine.Y).SetColor(defaultColor);
                     Deplacement(TilePos(new Point(Data.mouseState.X, Data.mouseState.Y)));
                     Map.GetTile((int)Position.X - Map.Origine.X, (int)Position.Y - Map.Origine.Y).SetColor(selectionColor);
                     IsMoved = true;
                 }
             }
         }
     }
     #endregion
 }
示例#5
0
文件: Ville.cs 项目: kylox/MLPproject
        public void Update(Game1 game)
        {
            
            if (game.Phase == Phase_de_jeu.ravitaillement)
            {
                #region selection de la ville
                if ((Data.mouseState.LeftButton == ButtonState.Pressed) && (Data.prevMouseState.LeftButton != ButtonState.Pressed))
                {
                    if (MouseOnTile())
                    {
                        Map.GetTile((int)Position.X - Map.Origine.X, (int)Position.Y - Map.Origine.Y).SetColor(selectionColor);
                        IsSelected = true;
                    }
                    else
                    {
                        Map.GetTile((int)Position.X - Map.Origine.X, (int)Position.Y - Map.Origine.Y).SetColor(defaultColor);
                        IsSelected = false;
                    }
                }
                #endregion
                #region creation nouvelle unité
                if (IsSelected && Isplayable) //permet de passer en mode posage d'unité 
                {
                    foreach (string S in type_unite)
                    {
                        if ((Data.mouseState.RightButton == ButtonState.Pressed) && (Data.prevMouseState.RightButton != ButtonState.Pressed)
                            && new Rectangle(Data.mouseState.X, Data.mouseState.Y, 1, 1).Intersects(new Rectangle(0, 250 + 10, 100, 5)))
                        {
                            creation = true;
                            y = 250;
                        }
                        if ((Data.mouseState.RightButton == ButtonState.Pressed) && (Data.prevMouseState.RightButton != ButtonState.Pressed)
                            && new Rectangle(Data.mouseState.X, Data.mouseState.Y, 1, 1).Intersects(new Rectangle(0, 300 + 10, 100, 5)))
                        {
                            creation = true;
                            y = 300;

                        }
                        if ((Data.mouseState.RightButton == ButtonState.Pressed) && (Data.prevMouseState.RightButton != ButtonState.Pressed)
                            && new Rectangle(Data.mouseState.X, Data.mouseState.Y, 1, 1).Intersects(new Rectangle(0, 350 + 10, 100, 5)))
                        {
                            creation = true;
                            y = 350;
                        }
                    }
                }

                if (creation && (Data.mouseState.LeftButton == ButtonState.Pressed) && (Data.prevMouseState.LeftButton != ButtonState.Pressed) && Isplayable)//pose l'unité ! 
                {
                    switch (y)
                    {
                        case 250:

                            if (Math.Abs(Data.mouseState.X - Position.X) <= 32 * 2 && (Math.Abs(Data.mouseState.Y - Position.Y) <= 32 * 2))
                            {
                                Joueur.Unites.Add(new Unite(Joueur, position_unite(new Vector2(Data.mouseState.X, Data.mouseState.Y)), Type_unite.legere, Map, game));
                                Joueur.Argent -= 100;
                                break;
                            }
                            break;
                        case 300:
                            if (Math.Abs(Data.mouseState.X - Position.X) <= 32 * 2 && (Math.Abs(Data.mouseState.Y - Position.Y) <= 32 * 2))
                            {
                                Joueur.Unites.Add(new Unite(Joueur, position_unite(new Vector2(Data.mouseState.X, Data.mouseState.Y)), Type_unite.rapide, Map, game));
                                Joueur.Argent -= 200;
                                break;
                            }
                            break;
                        case 350:
                            if (Math.Abs(Data.mouseState.X - Position.X) <= 32 * 2 && (Math.Abs(Data.mouseState.Y - Position.Y) <= 32 * 2))
                            {
                                Joueur.Unites.Add(new Unite(Joueur, position_unite(new Vector2(Data.mouseState.X, Data.mouseState.Y)), Type_unite.lourde, Map, game));
                                Joueur.Argent -= 300;
                                break;
                            }
                            break;
                    }
                    Isplayable = false;
                }

                #endregion
            }
        }