Exemple #1
0
 public static void PlayBoss()
 {
     FondSonore.Stop();
     MediaPlayer.Volume = volume;
     MediaPlayer.Play(Boss);
     MediaPlayer.IsRepeating = false;
 }
Exemple #2
0
        public static void Initialize()
        {
            for (int i = 0; i < Unites.Length; i++)
            {
                Unites[i] = new List <Unite> {
                };
                Items[i]  = new List <Item> {
                };
                Waves[i]  = new List <Wave> {
                };
                Effets[i] = new List <Effet> {
                };
                Worlds[i] = new World(Vector2.Zero);
            }

            // Chargement des textures : Pack de texture (Contient toutes les sprites des unites et des sorts)
            PackTexture.Initialize(SceneHandler.content);

            // Chargement sons
            PackSon.Initialize(SceneHandler.content);
            FondSonore.Load(SceneHandler.content);

            // On initialise la carte avec les tuiles
            OuvrirMap("level1");
            OuvrirMap("level2");
            OuvrirMap("level3");
            OuvrirMap("level4");

            // Creation du joueur et du champion
            Map.world = Worlds[0]; // pas très propre mais marche

            // Ici on chargera les infos du champion via un fichier texte, en attendant...

            // Chargement des items et waves
            InitLevels();
        }
Exemple #3
0
        public static void Update(GameTime GT)
        {
            Outil.RemoveDeadBodies(unites);
            gametime = GT;
            // Debug les unites qui attaquent des unites mortes
            foreach (Unite u in unites)
            {
                // affiche la barre des sorts des unités attaquant un champion
                if (u.uniteAttacked != null && u.uniteAttacked.isAChamp)
                {
                    u.Drawlife = true;
                }
                if (u.uniteAttacked != null && !unites.Contains((Unite)u.uniteAttacked))
                {
                    u.uniteAttacked = null;
                }
            }
            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].InInventory)
                {
                    items.RemoveAt(i);
                }
            }

            // Dit si on a gagné , que toutes les vagues sont finies



            if (OnaWin && SceneHandler.level == "level4")
            {
                PackMap.joueurs[0].Interface.Win = true;
            }
            foreach (Joueur j in PackMap.joueurs)
            {
                if (j.champion.PositionTile == new Vector2(97, 8) || j.champion.PositionTile == new Vector2(97, 7) || j.champion.PositionTile == new Vector2(97, 9))
                {
                    if (SceneHandler.level == "level1")
                    {
                        foreach (Joueur j2 in PackMap.joueurs)
                        {
                            j2.champion.PositionTile  = new Vector2(3, 20);
                            j2.champion.ObjectifListe = new List <Noeud> {
                            };
                            j2.camera.Position        = new Vector2(0, 200);
                        }
                        SceneHandler.ResetGameplay("level2");
                    }
                }
                if (j.champion.PositionTile == new Vector2(129, 11) || j.champion.PositionTile == new Vector2(129, 12) || j.champion.PositionTile == new Vector2(129, 13))
                {
                    if (SceneHandler.level == "level2")
                    {
                        foreach (Joueur j2 in PackMap.joueurs)
                        {
                            j2.champion.PositionTile  = new Vector2(2, 17);
                            j2.champion.ObjectifListe = new List <Noeud> {
                            };
                            j2.camera.Position        = new Vector2(0, 200);
                        }
                        SceneHandler.ResetGameplay("level3");
                    }
                }

                if (j.champion.PositionTile == new Vector2(128, 29) || j.champion.PositionTile == new Vector2(128, 30) || j.champion.PositionTile == new Vector2(128, 31) || j.champion.PositionTile == new Vector2(128, 32))
                {
                    if (SceneHandler.level == "level3")
                    {
                        foreach (Joueur j2 in PackMap.joueurs)
                        {
                            j2.champion.PositionTile  = new Vector2(12, 15);
                            j2.champion.ObjectifListe = new List <Noeud> {
                            };
                            j2.camera.Position        = new Vector2(0, 200);
                            FondSonore.PlayBoss();
                        }
                        SceneHandler.ResetGameplay("level4");
                    }
                }
            }
        }
Exemple #4
0
        public void Update(List <Unite> unites)
        {
            if (!champion.Mort)
            {
                Interface.mouse = Mouse.GetState();
                Interface.key   = Keyboard.GetState();
                // Pour cibler un point pour un sort
                if (Interface.mouse.LeftButton == ButtonState.Pressed && Interface.Oldmouse.LeftButton == ButtonState.Released && InWaitingPoint)
                {
                    champion.pointCible       = new Vector2((int)((camera.Position.X + Interface.mouse.X) / 32), (int)((camera.Position.Y + Interface.mouse.Y) / 32));
                    InWaitingPoint            = false;
                    Interface.DrawSelectPoint = false;
                    champion.Cast(spell, champion.pointCible, SelectedUnit);
                }
                // Pour cibler une unité pour un sort
                if (Interface.mouse.LeftButton == ButtonState.Pressed && Interface.Oldmouse.LeftButton == ButtonState.Released && InWaitingUnit)
                {
                    Vector2 point = new Vector2((int)((camera.Position.X + Interface.mouse.X) / 32), (int)((camera.Position.Y + Interface.mouse.Y) / 32));

                    foreach (Unite u in Map.unites)
                    {
                        if (u != champion && !u.isApnj && Outil.DistancePoints(point, u.PositionTile) <= 46)
                        {
                            SelectedUnit = u;
                        }
                    }

                    if (SelectedUnit != null)
                    {
                        champion.Cast(spell, champion.pointCible, SelectedUnit);
                    }

                    InWaitingUnit            = false;
                    Interface.DrawSelectUnit = false;
                }

                // Pour se déplacer
                if (Interface.mouse.RightButton == ButtonState.Pressed && !DonnerOrdreAttaquer() && (SourisHoverInventory() && !Interface.DrawSac || !SourisHoverInventory()) && (SourisHoverEquipement() && !Interface.DrawEquipement || !SourisHoverEquipement()))
                {
                    DonnerOrdreDeplacer();
                }

                if (!Interface.isWriting) // Si on écrit pas on peut utiliser les raccourcis clavier
                {
                    // Pour attaquer un point
                    if (Interface.key.IsKeyDown(Keys.A))
                    {
                        DonnerOrdreAttaquerPoint();
                    }
                    // Pour arreter les déplacements
                    if (Interface.key.IsKeyDown(Keys.S))
                    {
                        DonnerOrdreStop();
                    }
                    // Pour se teleporter!
                    if (Interface.key.IsKeyDown(Keys.T) && Interface.Oldkey.IsKeyUp(Keys.T) && CrystalGateGame.isTest)
                    {
                        if (SceneHandler.level == "level1")
                        {
                            FondSonore.PlayBoss();
                            SceneHandler.ResetGameplay("level4");
                        }
                        else
                        {
                            SceneHandler.ResetGameplay("level1");
                        }
                    }

                    // Pour afficher/cacher le sac
                    if (Interface.key.IsKeyDown(Keys.B) && Interface.Oldkey.IsKeyUp(Keys.B) || Interface.key.IsKeyDown(Keys.I) && Interface.Oldkey.IsKeyUp(Keys.I))
                    {
                        Interface.DrawSac = !Interface.DrawSac;
                    }
                    // Pour afficher/cacher le sac
                    if (Interface.key.IsKeyDown(Keys.C) && Interface.Oldkey.IsKeyUp(Keys.C))
                    {
                        Interface.DrawEquipement = !Interface.DrawEquipement;
                    }
                }

                // Pour lancer un sort
                if (Interface.key.IsKeyDown(Keys.D1) && Interface.Oldkey.IsKeyUp(Keys.D1) && champion.spells.Count > 0 || Interface.SourisClickSpellCheck(0) && champion.spells.Count > 0)
                {
                    spell = champion.spells[0];
                    if (champion.IsCastable(0))
                    {
                        if (champion.spells[0].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D2) && Interface.Oldkey.IsKeyUp(Keys.D2) && champion.spells.Count > 1 || Interface.SourisClickSpellCheck(1) && champion.spells.Count > 1)
                {
                    spell = champion.spells[1];
                    if (champion.IsCastable(1))
                    {
                        if (champion.spells[1].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D3) && Interface.Oldkey.IsKeyUp(Keys.D3) && champion.spells.Count > 2 || Interface.SourisClickSpellCheck(2) && champion.spells.Count > 2)
                {
                    spell = champion.spells[2];
                    if (champion.IsCastable(2))
                    {
                        if (champion.spells[2].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D4) && Interface.Oldkey.IsKeyUp(Keys.D4) && champion.spells.Count > 3 || Interface.SourisClickSpellCheck(3) && champion.spells.Count > 3)
                {
                    spell = champion.spells[3];
                    if (champion.IsCastable(3))
                    {
                        if (champion.spells[3].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D5) && Interface.Oldkey.IsKeyUp(Keys.D5) && champion.spells.Count > 4 || Interface.SourisClickSpellCheck(4) && champion.spells.Count > 4)
                {
                    spell = champion.spells[4];
                    if (champion.IsCastable(4))
                    {
                        if (champion.spells[4].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        if (champion.spells[4].NeedAUnit)
                        {
                            Interface.DrawSelectUnit = true;
                            InWaitingUnit            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D6) && Interface.Oldkey.IsKeyUp(Keys.D6) && champion.spells.Count > 5 || Interface.SourisClickSpellCheck(5) && champion.spells.Count > 5)
                {
                    spell = champion.spells[5];
                    if (champion.IsCastable(5))
                    {
                        if (champion.spells[5].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        if (champion.spells[5].NeedAUnit)
                        {
                            Interface.DrawSelectUnit = true;
                            InWaitingUnit            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
            }
            // Pour verifier si on parle a un pnj
            SpeakToPNJ();
            // Pour déplacer la caméra
            CameraUpdate();
            Interface.Update();
            UpdateReseau();
            CurseurCheck();
            Interface.Oldmouse = Interface.mouse;
            Interface.Oldkey   = Interface.key;
        }
Exemple #5
0
        public static void Receive()
        {
            try
            {
                Started = true;
                while (true)
                {
                    // Réception du header
                    byte[] buffer = new byte[4];
                    client.Receive(buffer);
                    int header = BitConverter.ToInt32(buffer, 0);

                    if (header == 42)
                    {
                        // Réception de l'ID du client
                        byte[] buffer1 = new byte[4];
                        client.Receive(buffer1);
                        int IdDuJoueur = BitConverter.ToInt32(buffer1, 0);

                        // De la taille
                        byte[] buffer2 = new byte[4];
                        client.Receive(buffer2);
                        int messageLength = BitConverter.ToInt32(buffer2, 0);

                        //Des données
                        byte[] buffer3 = new byte[messageLength];
                        client.Receive(buffer3);
                        // On deserialise et modifie le joueur
                        Unserialize(IdDuJoueur, buffer3);
                    }
                    else if (header == 1) // On reçoit un joueur
                    {
                        // De la taille
                        byte[] buffer2 = new byte[4];
                        client.Receive(buffer2);
                        int messageLength = BitConverter.ToInt32(buffer2, 0);

                        //Des données
                        byte[] buffer3 = new byte[messageLength];
                        client.Receive(buffer3);

                        BinaryFormatter formatter = new BinaryFormatter();
                        MemoryStream    stream    = new MemoryStream(buffer3);
                        stream.Position = 0;

                        Players j = (Players)formatter.Deserialize(stream);
                        if (j.id - 1 == joueursConnectes.Count || joueursConnectes.Count == 0)
                        {
                            joueursConnectes.Add(j);
                        }
                        else
                        {
                            joueursConnectes[j.id - 1] = j;
                        }
                    }
                    else if (header == 2) // On reçoit un message du chat
                    {
                        // De la taille
                        byte[] buffer2 = new byte[4];
                        client.Receive(buffer2);
                        int messageLength = BitConverter.ToInt32(buffer2, 0);

                        //Des données
                        byte[] buffer3 = new byte[messageLength];
                        client.Receive(buffer3);

                        BinaryFormatter formatter = new BinaryFormatter();
                        MemoryStream    stream    = new MemoryStream(buffer3);
                        stream.Position = 0;

                        Message m = (Message)formatter.Deserialize(stream);
                        m.dateEnvoi = EffetSonore.time.Elapsed;
                        discution.Add(m);
                    }
                    else if (header == 3)
                    {
                        SceneHandler.ResetGameplay();
                        SceneHandler.gameState = GameState.Gameplay;
                        FondSonore.Play();
                        GamePlay.timer.Restart();
                    }
                    else
                    {
                        // header incorrect
                    }
                }
            }
            catch
            {
                SceneHandler.coopConnexionScene.Error     = true;
                SceneHandler.championSelectionScene.Error = true;
            }
        }
Exemple #6
0
        public void Update()
        {
            CadrePosition         = new Rectangle(0, height - heightFondNoir, widthFondNoir, heightFondNoir);
            PortraitPosition      = new Rectangle(CadrePosition.X + CadrePosition.Width - Portrait.Width, CadrePosition.Y + 50, Portrait.Width, Portrait.Height);
            SacPosition           = new Rectangle(width - Sac.Width, height - Sac.Height, Sac.Width, Sac.Height);
            EquipementPosition    = new Rectangle(width / 2 - Equipement.Width / 2, height / 2 - Equipement.Height / 2, Equipement.Width, Equipement.Height);
            BarreDesSortsPosition = new Rectangle(width / 2, height - BarreDesSorts.Height, BarreDesSorts.Width, BarreDesSorts.Height);

            UtiliserInventaire();
            DesequiperUpdate();
            // Timer et vagues
            if (SceneEngine2.GamePlay.timer.Elapsed.Seconds < 10)
            {
                tempsDeJeuActuel = SceneEngine2.GamePlay.timer.Elapsed.Minutes.ToString() + ":0" + SceneEngine2.GamePlay.timer.Elapsed.Seconds.ToString();
            }
            else
            {
                tempsDeJeuActuel = SceneEngine2.GamePlay.timer.Elapsed.Minutes.ToString() + ":" + SceneEngine2.GamePlay.timer.Elapsed.Seconds.ToString();
            }

            compteurDeVague = Map.nombreDeVaguesPop.ToString() + "/" + Map.nombreDeVagues.ToString();

            if (SceneEngine2.BaseScene.keyboardState.IsKeyDown(Keys.Enter) &&
                SceneEngine2.BaseScene.oldKeyboardState.IsKeyUp(Keys.Enter) &&
                SceneEngine2.CoopConnexionScene.isOnlinePlay)
            {
                if (isWriting && message != "")
                {
                    Message envoi = new Message(EffetSonore.time.Elapsed, Client.ownPlayer.name + " : " + message);

                    // On s'envoit
                    MemoryStream    stream    = new MemoryStream();
                    BinaryFormatter formatter = new BinaryFormatter();

                    formatter.Serialize(stream, envoi);
                    byte[] buffer = new byte[stream.Length];
                    stream.Position = 0;
                    stream.Read(buffer, 0, buffer.Length);

                    // Envoi
                    Client.Send(buffer, 2);
                    message   = "";
                    isWriting = false;
                }
                else
                {
                    isWriting = !isWriting;
                }
            }
            if (!SceneEngine2.CoopConnexionScene.isOnlinePlay)
            {
                isWriting = false;
            }

            if (isWriting)
            {
                SaisirTexte(ref message);
            }

            if (dialogue.Count > 0)                                          // pour passer les dialogues
            {
                if (key.IsKeyDown(Keys.Enter) && Oldkey.IsKeyUp(Keys.Enter)) // Si on est a la fin de la replique, on passe a la suivante.
                {
                    dialogue.RemoveAt(0);
                    MaxChar = 0;
                }
            }

            messageRecu = "";
            for (int i = 0; i < Client.discution.Count; i++)
            {
                if (Client.discution[i].dateEnvoi + new TimeSpan(0, 0, 10) < EffetSonore.time.Elapsed)
                {
                    Client.discution.RemoveAt(i);
                    i--;
                }
                else
                {
                    messageRecu += "\n" + Client.discution[i].message;
                }
            }
            positionChat = new Vector2(widthFondNoir, CrystalGateGame.graphics.GraphicsDevice.Viewport.Height - heightFondNoir - gamefont.MeasureString(messageRecu).Y - 50);

            if (Win)
            {
                FondSonore.Stop();
                SceneEngine2.SceneHandler.gameState = SceneEngine2.GameState.Victory;
            }
            else if (Lost)
            {
                FondSonore.Stop();
                SceneEngine2.SceneHandler.gameState = SceneEngine2.GameState.Defeat;
            }
        }