示例#1
0
文件: Map.cs 项目: Paphos/CarbonCube
        public void Draw(List <Player> players)
        {
            Rectangle destRect = Camera.ComputePixelRectangleFromWorld(Vector2.Zero, new Vector2(mWidth, mHeight), new Vector2(0f, 1f));

            Game1.sSpriteBatch.Draw(mImage, destRect, Color.White);

            for (int y = 0; y < mHeight; y++)
            {
                for (int x = 0; x < mWidth; x++)
                {
                    switch (mapArray[x, y].Type)
                    {
                    case TypeElement.Mur:
                        DrawableRectangle.DrawCase(new Case(x, y), Color.Black);
                        break;

                    case TypeElement.Téléporteur:
                        DrawableRectangle.DrawCase(new Case(x, y), GameManager.CouleurTéléporteur, Color.White);
                        break;

                    case TypeElement.MurPlayer:
                        foreach (Player p in players)
                        {
                            if (p.mNumero == mapArray[x, y].Numero)
                            {
                                DrawableRectangle.DrawCase(new Case(x, y), p.mCouleurMur);
                                break;
                            }
                        }
                        break;
                    }
                }
            }
        }
示例#2
0
文件: Map.cs 项目: Paphos/CarbonCube
        public void DrawAccessible(Player p)
        {
            if (p.Mode == PlayerMode.Deplacement && p.CasesAccessibles != null)
            {
                List <Case> listeCasesAccessibles = p.CasesAccessibles.ToList();
                listeCasesAccessibles.Remove(p.Case);

                foreach (Case c in listeCasesAccessibles)
                {
                    if (this[c].Type != TypeElement.Téléporteur)
                    {
                        DrawableRectangle.DrawCase(c, GameManager.CouleurAccessibles);
                    }
                    else
                    {
                        DrawableRectangle.DrawCase(c, GameManager.CouleurTéléporteur, GameManager.CouleurAccessibles);
                    }
                }
            }

            if (p.Mode == PlayerMode.Coincé && p.CasesPourTeleportation != null)
            {
                DrawPlacementPlayer(p.CasesPourTeleportation);
            }
        }
示例#3
0
文件: Map.cs 项目: Paphos/CarbonCube
 public void DrawPlacementPlayer(List <Case> CasesPlacementPlayers)
 {
     if (CasesPlacementPlayers != null)
     {
         foreach (Case c in CasesPlacementPlayers)
         {
             if (this[c].Type != TypeElement.Téléporteur)
             {
                 DrawableRectangle.DrawCase(c, GameManager.CouleurPlacement);
             }
             else
             {
                 throw new Exception("La liste CasesPlacementPlayers ne doit pas contenir de téléporteur (Téléporteur:" + c + ")");
             }
         }
     }
 }
示例#4
0
        public void DrawPlayer()
        {
            if (mBlinkTime == 0)
            {
                mBlinkState = (mBlinkState + 1) % 2;
            }

            if (mBlinkState == 0)
            {
                mBlinkTime = (mBlinkTime + 1) % sBlinkDelay0;
                DrawableRectangle.DrawCase(Case, mCouleur);
            }
            else
            {
                mBlinkTime = (mBlinkTime + 1) % sBlinkDelay1;
                DrawableRectangle.DrawCase(Case, mCouleurBlink);
            }
        }
示例#5
0
文件: HUD.cs 项目: Paphos/CarbonCube
        static public void Draw()
        {
            if (GM == null)
            {
                throw new Exception("HUD: La fonction SetGameManager doit avoir été appelée au moins au fois avant la fonction Draw");
            }

            DrawableRectangle.DrawRectangle(Vector2.Zero, new Vector2(1f, 0.07f), Color.Black);

            #region affichage des messages

            FontSupport.PrintStatus(25, "  " + mMessagePermanent, mColorMsgPermanent);
            if (mMessageTmpFrame < mMessageTmpDisplayTime)
            {
                mMessageTmpFrame++;
                FontSupport.PrintStatus(24, "  " + mMessageTmp, Color.Black);
            }
            #endregion

            if (GM.mState == GameState.CreationDeLaMap)
            {
                FontSupport.PrintStatus(2, "          -- Creation de la map --", Color.DarkBlue);

                FontSupport.PrintStatusPixelPosition(40, (int)(Game1.sGraphics.PreferredBackBufferHeight * 0.95f),
                                                     "[Clic gauche] Placer un mur    [Clic droit] Placer un teleporteur    [Entree] Terminer", Color.White);
            }

            if (GM.mState == GameState.PlacementPlayers)
            {
                FontSupport.PrintStatus(2, "          -- Placement des joueurs -- (Distance de securite : " + GameRules.Sécurité + " cases)", Color.DarkRed);

                FontSupport.PrintStatusPixelPosition(40, (int)(Game1.sGraphics.PreferredBackBufferHeight * 0.95f),
                                                     "[Clic gauche] Placer un joueur sur une case rose      [Entree] Terminer / Commencer le jeu", Color.White);
            }

            if (GM.mState == GameState.Jeu || GM.mState == GameState.FinDuJeu)
            {
                if (GM.mState == GameState.Jeu)
                {
                    FontSupport.PrintStatus(2, "          -- Partie en cours --", Color.Black);
                }
                else
                {
                    FontSupport.PrintStatus(2, "          -- PARTIE TERMINEE --", Color.Black);
                }
                int espacement = Game1.sGraphics.PreferredBackBufferWidth / (GM.Players.Count + 1);

                for (int i = 0; i < GM.Players.Count; i++)
                {
                    string vies = " ";
                    if (GM.Players[i].mVies >= 0)
                    {
                        for (int v = GameRules.Vies; v > 0; v--)
                        {
                            if (v > GM.Players[i].mVies)
                            {
                                vies += "[X]";
                            }
                            else
                            {
                                vies += "[O]";
                            }
                        }
                    }
                    else
                    {
                        vies += "est mort !";
                    }

                    FontSupport.PrintStatusPixelPosition((int)(espacement * (i + 0.5f)),
                                                         (int)(Game1.sGraphics.PreferredBackBufferHeight * 0.95f),
                                                         GM.Players[i].mNom + vies,
                                                         GM.Players[i].Couleur);
                }
            }
        }
示例#6
0
        public void DrawGame()
        {
            mMap.Draw(Players);

            if (mState == GameState.CreationDeLaMap)
            {
                if (mMap[CaseSelectionnée] != null && mMap[CaseSelectionnée].Type == TypeElement.Vide)
                {
                    DrawableRectangle.DrawCase(CaseSelectionnée, Color.Gray);
                }
            }

            if (mState == GameState.PlacementPlayers)
            {
                mMap.DrawPlacementPlayer(CasesPlacementPlayers);

                foreach (Player p in Players)
                {
                    p.DrawPlayer();
                    FontSupport.PrintStatusAt(p.Position + new Vector2(0.3f, 0.9f), p.mInitiales, Color.Black);
                }

                if (mMap[CaseSelectionnée] != null && mMap[CaseSelectionnée].Type == TypeElement.Vide)
                {
                    DrawableRectangle.DrawCase(CaseSelectionnée, Color.Gray);
                }
            }

            if (mState == GameState.Jeu)
            {
                mMap.DrawAccessible(PlayersEnJeu[mIndexPlayer]);

                foreach (Player p in PlayersEnJeu)
                {
                    p.DrawPlayer();
                    FontSupport.PrintStatusAt(p.Position + new Vector2(0.3f, 0.9f), p.mInitiales, Color.Black);
                }

                #region Draw Path (en vert foncé)
                if (PlayersEnJeu[mIndexPlayer].Mode == PlayerMode.Deplacement)
                {
                    List <Case> path = new List <Case>();
                    if (PlayersEnJeu[mIndexPlayer].CasesAccessibles != null && PlayersEnJeu[mIndexPlayer].CasesAccessibles.Contains(CaseSelectionnée))
                    {
                        path = PlayersEnJeu[mIndexPlayer].CasesAccessibles.PathTo(CaseSelectionnée);
                        foreach (Case c in path)
                        {
                            if (c != PlayersEnJeu[mIndexPlayer].Case)
                            {
                                if (mMap[c].Type == TypeElement.Téléporteur)
                                {
                                    DrawableRectangle.DrawCase(c, CouleurPath, CouleurAccessibles);
                                }
                                else
                                {
                                    DrawableRectangle.DrawCase(c, CouleurPath);
                                }
                            }
                        }
                    }
                }
                if (PlayersEnJeu[mIndexPlayer].Mode == PlayerMode.Coincé && mMap[CaseSelectionnée] != null && PlayersEnJeu[mIndexPlayer].CasesPourTeleportation.Contains(CaseSelectionnée))
                {
                    DrawableRectangle.DrawCase(CaseSelectionnée, Color.DarkSalmon);
                }
                #endregion
            }


            if (mState == GameState.FinDuJeu)
            {
                PlayersEnJeu[0].DrawPlayer();
                FontSupport.PrintStatusAt(PlayersEnJeu[0].Position + new Vector2(0.3f, 0.9f), PlayersEnJeu[0].mInitiales, Color.Black);
            }

            HUD.Draw();

            #region du debug
            string isMurPlayer = (mMap[CaseSelectionnée] != null) ? (mMap[CaseSelectionnée].Type == TypeElement.MurPlayer).ToString() : "null";
            string dansList    = "nope";
            if (PlayersEnJeu != null && PlayersEnJeu.Count > 0 && mIndexPlayer < PlayersEnJeu.Count)
            {
                dansList = (PlayersEnJeu[mIndexPlayer].CasesPourTeleportation != null) ? PlayersEnJeu[mIndexPlayer].CasesPourTeleportation.Contains(CaseSelectionnée).ToString() : "null";
            }
            #endregion
            FontSupport.PrintStatus(1, " [ZQSD/Molette] Bouger camera     | Case = " + CaseSelectionnée + " | isMurPlayer? " + isMurPlayer + " | dansList? " + dansList, Color.Gray);
            //FontSupport.PrintStatus(1, "Camera.Width : " + Camera.Width + " | Camera.Height : " + Camera.Height);
        }