示例#1
0
        public override void UpdateSort()
        {
            Positions.Clear();
            if (TickCurrent == 0)
            {
                rayon = 1;
                Point = ConvertUnits.ToDisplayUnits(unite.body.Position);
            }
            rayon += 0.1f;
            // On ajoute les explosions
            for (double i = 0; i < 2 * Math.PI; i += 0.25f)
            {
                Positions.Add(Point / 32 + new Vector2((float)Math.Cos(i), (float)Math.Sin(i)) * rayon);
            }
            // On verifie les degats sur les unités de la map
            foreach (Vector2 v in Positions)
            {
                foreach (Unite u in Map.unites)
                {
                    float distance = Outil.DistancePoints(v, u.PositionTile);
                    if (u != unite && !u.isAChamp && distance <= Portée)
                    {
                        u.Vie -= (int)(unite.Puissance * ratio + 3 - u.DefenseMagique);
                        //u.color = Color.Red;
                    }

                    /*else
                     *  u.color = Color.White;*/
                }
            }
            //sonSort.Play();
        }
示例#2
0
 public Projectile(Unite tireur, Unite target)
 {
     Sprite   = tireur.ProjectileSprite;
     Position = ConvertUnits.ToDisplayUnits(tireur.body.Position);
     Tireur   = tireur;
     Target   = target;
     Vitesse  = 14;
     Timer    = (int)Outil.DistanceUnites(tireur, target) / Vitesse;
 }
示例#3
0
 public override void UpdateSort()
 {
     foreach (Unite u in Map.unites)
     {
         float distance = Outil.DistancePoints(this.Point, u.PositionTile);
         if (u != unite && !u.isAChamp && distance <= Portée)
         {
             u.Vie -= (int)(unite.Puissance * ratio - u.DefenseMagique);
             //u.color = Color.Red;
         }
     }
 }
示例#4
0
 public override void UpdateSort()
 {
     foreach (Unite u in Map.unites)
     {
         if (u != unite && Outil.DistanceUnites(unite, u) <= 500)
         {
             u.uniteAttacked = null;
             u.ObjectifListe.Clear();
             u.body.LinearVelocity = new Vector2((float)Math.Cos(Outil.AngleUnites(u, unite)), (float)Math.Sin(Outil.AngleUnites(u, unite))) * 100;
         }
     }
 }
示例#5
0
        protected override void IA(List <Unite> unitsOnMap)
        {
            if (!isAtRange)
            {
                if (Outil.DistanceUnites(Outil.GetJoueur(Client.id).champion, this) <= 600)
                {
                    isAtRange = true;
                }
            }
            if (isAtRange)
            {
                if (!timer.IsRunning)
                {
                    timer.Start();
                }

                if (timer.Elapsed.Seconds < 1)
                {
                    color = Color.Red;
                }

                if (timer.Elapsed.Seconds > 1 && timer.Elapsed.Seconds < 8)
                {
                    if (IsCastable(0))
                    {
                        for (int i = 0; i < spellsUpdate.Count; i++)
                        {
                            if (spellsUpdate[i].idSort == 45)
                            {
                                spellsUpdate.RemoveAt(i);
                            }
                        }
                        ((NovaDeFeu)spells[0]).Positions.Clear();
                        Cast(spells[0], Vector2.Zero, null);
                        ObjectifListe.Clear();
                        color = Color.White;
                    }
                    uniteAttacked = null;
                }
                else
                {
                    spellsUpdate.Clear();
                    uniteAttacked = Outil.GetJoueur(Client.id).champion;
                    if (timer.Elapsed.Seconds > 11)
                    {
                        timer.Reset();
                    }
                }
            }
        }
示例#6
0
        public byte[] Serialize()
        {
            ASCIIEncoding   ascii     = new ASCIIEncoding();
            MemoryStream    stream    = new MemoryStream();
            BinaryFormatter formatter = new BinaryFormatter();

            // Definition du contenu
            Player p     = new Player();
            Joueur Local = Outil.GetJoueur(Client.id);

            // Pathfinding
            if (Mooved)
            {
                p.Mooved = true;
                List <Noeud> chemin = PathFinding.TrouverChemin(champion.PositionTile, ObjectifPoint, Map.Taille, new List <Unite> {
                }, Map.unitesStatic, false);
                p.objectifPointX = chemin[chemin.Count - 1].Position.X;
                p.objectifPointY = chemin[chemin.Count - 1].Position.Y;
                Mooved           = false;
            }

            // Unité visé
            p.idUniteAttacked = Local.champion.idUniteAttacked;

            p.LastDeath = Serveur.LastDead;
            // Unit dernierement morte selon le serveur
            SendSpell(p);

            // meme map?
            p.level = SceneHandler.level;

            if (lastItemUsed != -1)
            {
                p.LastItemUsed = lastItemUsed;
                lastItemUsed   = -1;
            }
            if (lastStuffUsed != -1)
            {
                p.LastStuffUsed = lastStuffUsed;
                lastStuffUsed   = -1;
            }

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

            return(buffer);
        }
示例#7
0
 public void Update(List <Unite> unites) // Appelé quand l'objet est sur la Map
 {
     foreach (Unite u in unites)
     {
         if (u.isAChamp && Outil.DistancePoints(Position, u.PositionTile) <= 32 && !InInventory)
         {
             if (u.Inventory.Count + 1 <= u.InventoryCapacity)
             {
                 unite = u;
                 u.Inventory.Add(this);
                 InInventory = true; // retire l'objet de la carte et l'ajoute a l'inventaire de l'unité proche
                 Effet(u);
             }
         }
     }
 }
示例#8
0
        public bool SpeakToPNJ() // Renvoie si on parle a un PNJ, et modifie l'UI si c'est le cas
        {
            // Stoque les PNJ pres du joueurs dans une liste
            List <Unite> result = Map.unites.Where(i => Outil.DistanceUnites(i, champion) <= 64 && i.isApnj).ToList();

            PNJSelected = (result.Count > 0) ? result[0] : null; // prend le premier et le met dans la variable PNJSelected

            if (PNJSelected != null)                             // Si on est assez proche du PNJ, on draw le dialogue
            {
                Interface.DrawDialogue = Outil.DistancePoints(champion.PositionTile, PNJSelected.PositionTile) <= 46;
            }
            else
            {
                Interface.DrawDialogue = false;
            }
            return(Interface.DrawDialogue);
        }
示例#9
0
        public bool CurseurCheck() // Renvoie vrai si le curseur est sur un méchant :p
        {
            Vector2 ObjectifPoint = new Vector2(camera.Position.X + Interface.mouse.X, camera.Position.Y + Interface.mouse.Y) / Map.TailleTiles;

            ObjectifPoint = new Vector2((int)ObjectifPoint.X, (int)ObjectifPoint.Y);

            foreach (Unite u in Map.unites)
            {
                if (!u.isAChamp && Outil.DistancePoints(ObjectifPoint, u.PositionTile) <= 32)
                {
                    Interface.CurseurOffensif = true;
                    return(true);
                }
            }

            Interface.CurseurOffensif = false;
            return(false);
        }
示例#10
0
        public override void UpdateSort()
        {
            if (TickCurrent == 0)
            {
                rayon = 0.1f;
                Point = ConvertUnits.ToDisplayUnits(unite.body.Position);
            }
            rayon += 0.0001f;
            // On ajoute les explosions
            if (TickCurrent > 0 && TickCurrent % 3 == 0)
            {
                Positions.Add(Point / 32);
            }
            // Update de la position
            for (int i = 0; i < Positions.Count; i++)
            {
                Positions[i] += new Vector2((float)Math.Cos(i + 1) * rayon, (float)Math.Sin(i + 1) * rayon);
            }

            if (TickCurrent == Ticks - 1)
            {
                rayon = 0.1f;
                Point = ConvertUnits.ToDisplayUnits(unite.body.Position);
            }
            // On verifie les degats sur les unités de la map
            foreach (Vector2 v in Positions)
            {
                foreach (Unite u in Map.unites)
                {
                    float distance = Outil.DistancePoints(v, u.PositionTile);
                    if (u != unite && distance <= Portée)
                    {
                        u.Vie  -= (int)(unite.Puissance * ratio + 1 - u.DefenseMagique);
                        u.color = Color.Red;
                    }
                    else
                    {
                        u.color = Color.White;
                    }
                }
            }
            sonSort.Play();
        }
示例#11
0
        public bool DonnerOrdreAttaquer()
        {
            Vector2 ObjectifPoint = new Vector2(camera.Position.X + Interface.mouse.X, camera.Position.Y + Interface.mouse.Y) / Map.TailleTiles;

            ObjectifPoint = new Vector2((int)ObjectifPoint.X, (int)ObjectifPoint.Y);
            foreach (Unite u in Map.unites)
            {
                if (!u.isAChamp && !u.isApnj && Outil.DistancePoints(ObjectifPoint, u.PositionTile) <= 60)
                {
                    champion.uniteAttacked = u;
                    List <Noeud> chemin = PathFinding.TrouverChemin(champion.PositionTile, ObjectifPoint, Map.Taille, new List <Unite> {
                    }, Map.unitesStatic, false);
                    if (chemin != null)
                    {
                        champion.ObjectifListe = chemin;
                    }
                    return(true);
                }
            }
            return(false);
        }
示例#12
0
        public void Suivre(Unite unite)
        {
            List <Unite> liste = new List <Unite> {
            };
            double distance    = Outil.DistanceUnites(this, unite);
            bool   ok          = distance > Portee * Map.TailleTiles.X;

            if (ok)
            {
                foreach (Unite u in Map.unites)
                {
                    if (Outil.DistanceUnites(this, u) <= 1 * Map.TailleTiles.X)
                    {
                        if (u != unite && u != this)
                        {
                            liste.Add(u);
                        }
                    }
                }

                suivreactuel = 0;
                List <Noeud> chemin = PathFinding.TrouverChemin(PositionTile, unite.PositionTile, Map.Taille, liste, Map.unitesStatic, false);
                if (chemin != null)
                {
                    ObjectifListe = chemin;
                    ObjectifListe.RemoveAt(0);
                }
                else
                {
                    ObjectifListe.Clear();
                    body.LinearVelocity = Vector2.Zero;
                }
            }
            else
            {
                suivreactuel++;
            }
        }
示例#13
0
        public void Pop(GameTime GT)
        {
            if (id == 0) // si on commence a pop , on assisgne un id à la vague
            {
                id = GT.TotalGameTime.TotalMilliseconds;
            }

            bool NextWave = true;

            foreach (Unite u in Map.unites)
            {
                if (u.idWave == id) // Si il y'a encore des unités de la vague précédente, on ne pop rien
                {
                    NextWave = false;
                    break;
                }
            }
            // Sinon on pop
            if (NextWave && unites.Count > 0)
            {
                Map.waveNumber++;
                while (unites[0].Count != 0)           // Tant qu'il y'a des unités a pop
                {
                    foreach (Vector2 v in PointsSpawn) // on les dispatche sur les points de spawn
                    {
                        if (unites[0].Count != 0)
                        {
                            if (unites[0][0] is Cavalier)
                            {
                                Map.unites.Add(new Cavalier(v, unites[0][0].Level));
                            }
                            else if (unites[0][0] is Grunt)
                            {
                                Map.unites.Add(new Grunt(v, unites[0][0].Level));
                            }
                            else if (unites[0][0] is Archer)
                            {
                                Map.unites.Add(new Archer(v, unites[0][0].Level));
                            }
                            else if (unites[0][0] is Troll)
                            {
                                Map.unites.Add(new Troll(v, unites[0][0].Level));
                            }
                            else if (unites[0][0] is Demon)
                            {
                                Map.unites.Add(new Demon(v, unites[0][0].Level));
                            }
                            else if (unites[0][0] is Ogre)
                            {
                                Map.unites.Add(new Ogre(v, unites[0][0].Level));
                            }
                            else if (unites[0][0] is Odin)
                            {
                                Map.unites.Add(new Odin(v, unites[0][0].Level));
                            }
                            else if (unites[0][0] is Voleur)
                            {
                                Map.unites.Add(new Voleur(v, unites[0][0].Level));
                            }
                            else
                            {
                                throw new Exception("Modif la wave!");
                            }

                            // Fait attaquer l'unité la plus proche
                            if (!Map.unites[Map.unites.Count - 1].isAChamp && !Map.unites[Map.unites.Count - 1].isApnj)
                            {
                                float distanceInit = 9000;
                                Unite focus        = null;
                                foreach (Unite u in Map.unites)
                                {
                                    float distance = 0;

                                    if (u.isAChamp && (distance = Outil.DistanceUnites(Map.unites[Map.unites.Count - 1], u)) <= distanceInit)
                                    {
                                        distanceInit = distance;
                                        focus        = u;
                                    }
                                }
                                Map.unites[Map.unites.Count - 1].uniteAttacked = focus;
                            }

                            //Map.unites[Map.unites.Count - 1].uniteAttacked = focus;
                            Map.unites[Map.unites.Count - 1].idWave = id;
                            unites[0].RemoveAt(0);
                        }
                        else // Si il y'a moins d'unité que de points de spawn, on arrete
                        {
                            break;
                        }
                    }
                }
                unites.RemoveAt(0);
                Map.nombreDeVaguesPop++;
            }
        }
示例#14
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");
                    }
                }
            }
        }
示例#15
0
        public override void Update(List <Unite> unitsOnMap, List <Effet> effets)
        {
            Animer();
            Deplacer();
            TestMort(effets);
            Debug();
            // Update l'IA
            if (!isAChamp)
            {
                IA(unitsOnMap);
            }

            // Pour Update et Draw les sorts
            try
            {
                foreach (Spell s in spellsUpdate)
                {
                    s.Update();
                }
            }
            catch
            {
            }
            // Retire les sorts qui sont finis
            for (int i = 0; i < spellsUpdate.Count; i++)
            {
                if (!spellsUpdate[i].Activated)
                {
                    spellsUpdate.RemoveAt(i);
                }
            }
            // Pour Update et Draw les items de l'inventaire
            foreach (Item i in Inventory)
            {
                if (i.Activated)
                {
                    i.spell.Update();
                }
            }
            // Pour Update les projectiles
            ProjectileUpdate();
            // On ajoute du mana
            ManaUpdate();
            // On Update l'inventaire de l'unité
            InventoryUpdate();
            // On rafraichit la propriete suivante, elle est juste indicative et n'affecte pas le draw, mais le pathfinding
            PositionTile = new Vector2((int)(ConvertUnits.ToDisplayUnits(body.Position.X) / Map.TailleTiles.X), (int)(ConvertUnits.ToDisplayUnits(body.Position.Y) / Map.TailleTiles.Y));
            // Refresh l'attaque et le pathfinding correspondant
            if (uniteAttacked != null)
            {
                Attaquer(uniteAttacked);
            }
            else
            if (OlduniteAttacked != null && ObjectifListe.Count == 0 && IsRanged)     // si l'unité se déplacait pour tirer
            {
                uniteAttacked = OlduniteAttacked;
            }

            // Fait attaquer l'unité la plus proche
            if (!isAChamp && !isApnj && uniteAttacked != null)
            {
                float distanceInit = 9000;
                Unite focus        = null;
                foreach (Unite u in Map.unites)
                {
                    float distance = 0;

                    if (u.isAChamp && (distance = Outil.DistanceUnites(this, u)) <= distanceInit)
                    {
                        distanceInit = distance;
                        focus        = u;
                    }
                }
                uniteAttacked = focus;
            }

            // Reseau
            UpdateReseau();
        }
示例#16
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;
        }
示例#17
0
        public virtual void Attaquer(Unite unite)
        {
            float calcul = Outil.DistanceUnites(this, unite) - (26 * (unite.largeurPhysique + this.largeurPhysique) / 2);

            if (calcul >= Portee * Map.TailleTiles.X)
            {
                Suivre(unite);
            }
            else
            {
                if (CanAttack)
                {
                    if (!uniteAttacked.isInvisible)
                    {
                        OlduniteAttacked = uniteAttacked;
                        ObjectifListe.Clear();
                        body.LinearVelocity = Vector2.Zero;
                        // Fait regarder l'unité vers l'unité attaqué
                        if (Animation.Count == 0)
                        {
                            FlipH = false;
                            float angle = Outil.AngleUnites(this, unite);

                            if (angle >= Math.PI / 4 && angle <= 3 * Math.PI / 4)
                            {
                                direction = Direction.Haut;
                            }
                            else if (angle >= -3 * Math.PI / 4 && angle <= -Math.PI / 4)
                            {
                                direction = Direction.Bas;
                            }
                            else if (angle >= -Math.PI / 4 && angle <= Math.PI / 4)
                            {
                                direction = Direction.Gauche;
                                FlipH     = true;
                            }
                            else
                            {
                                direction = Direction.Droite;
                            }
                        }

                        if (Map.gametime.TotalGameTime.TotalMilliseconds - LastAttack > Vitesse_Attaque * 1000) // Si le cooldown est fini
                        {
                            LastAttack = (float)Map.gametime.TotalGameTime.TotalMilliseconds;                   // On met à jour "l'heure de la dernière attaque"
                            // projectile
                            if (IsRanged)                                                                       // Si l'unité attaque à distance, on creer un projectile, sinon on attaque direct
                            {
                                Projectile = new Projectile(this, uniteAttacked);
                            }
                            else
                            {
                                if (Dommages - unite.Defense <= 0) // Si armure > Dommages , degats = 1
                                {
                                    // On ne prend en compte les degats que si on est en local autrement ils sont effectués via le serveur

                                    unite.Vie -= 1;
                                }
                                else
                                {
                                    unite.Vie -= Dommages - unite.Defense;
                                }
                            }
                            // son
                            effetUniteAttaque.Play();

                            // Fait regarder l'unité vers l'unité attaqué et l'anime

                            AnimationCurrent = AnimationLimite;
                            FlipH            = false;
                            float angle = Outil.AngleUnites(this, unite);

                            if (angle >= Math.PI / 4 && angle <= 3 * Math.PI / 4)
                            {
                                direction = Direction.Haut;
                                Animation = packAnimation.AttaquerHaut();
                            }
                            else if (angle >= -3 * Math.PI / 4 && angle <= -Math.PI / 4)
                            {
                                direction = Direction.Bas;
                                Animation = packAnimation.AttaquerBas();
                            }
                            else if (angle >= -Math.PI / 4 && angle <= Math.PI / 4)
                            {
                                direction = Direction.Gauche;
                                FlipH     = true;
                                Animation = packAnimation.AttaquerDroite();
                            }
                            else
                            {
                                direction = Direction.Droite;
                                Animation = packAnimation.AttaquerDroite();
                            }
                        }
                    }
                }
            }
        }
示例#18
0
 public void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(Sprite, Position, null, Color.White, Outil.AngleUnites(Target, Tireur), new Vector2(Sprite.Width / 2, Sprite.Height / 2), 1f, SpriteEffects.None, 0);
 }
示例#19
0
 public void Update()
 {
     Position += new Vector2((float)Math.Cos(Outil.AngleUnites(Target, Tireur)), (float)-Math.Sin(Outil.AngleUnites(Tireur, Target))) * Vitesse;
     Timer--;
 }
示例#20
0
        public static void Unserialize(int IdDuJoueur, byte[] buffer)
        {
            // Traitement
            BinaryFormatter formatter = new BinaryFormatter();
            MemoryStream    stream    = new MemoryStream(buffer);

            stream.Position = 0;
            // mettre un try catch
            Player player = (Player)formatter.Deserialize(stream);

            if (Outil.GetJoueur(IdDuJoueur) != null && player.level == SceneHandler.level)
            {
                Joueur joueur = Outil.GetJoueur(IdDuJoueur);
                // Pathfinding
                if (player.Mooved)
                {
                    List <Noeud> path = PathFinding.TrouverChemin(joueur.champion.PositionTile, new Vector2(player.objectifPointX, player.objectifPointY), Map.Taille, Map.unites, Map.unitesStatic, true);
                    if (path != null)
                    {
                        joueur.champion.ObjectifListe = path;
                    }
                    else
                    {
                        joueur.champion.ObjectifListe.Clear();
                    }
                }
                // Unité ciblé
                if (player.idUniteAttacked != 0)
                {
                    foreach (Unite u in Map.unites)
                    {
                        if (u.id == player.idUniteAttacked)
                        {
                            joueur.champion.uniteAttacked = u;
                        }
                    }
                }
                else
                {
                    joueur.champion.uniteAttacked = null;
                }
                // Sorts
                if (player.idSortCast != 0)
                {
                    Unite        u = joueur.champion;
                    List <Spell> toutLesSpellsPossibles = new List <Spell> {
                        new Explosion(u), new Soin(u), new Invisibilite(u), new FurieSanguinaire(u), new Polymorphe(u), new Tempete(u)
                    };

                    foreach (Spell s in toutLesSpellsPossibles)
                    {
                        if (s.idSort == player.idSortCast)
                        {
                            s.Point = new Vector2(player.pointSortX, player.pointSortY);
                            if (player.idUniteCibleCast != 0)
                            {
                                foreach (Unite un in Map.unites)
                                {
                                    if (un.id == player.idUniteCibleCast)
                                    {
                                        s.UniteCible = un;
                                    }
                                }
                            }
                            joueur.champion.Cast(s, new Vector2(player.pointSortX, player.pointSortY), s.UniteCible, true);
                            break;
                        }
                    }
                }
                // Clear morts
                foreach (Unite u in Map.unites)
                {
                    foreach (byte b in player.LastDeath)
                    {
                        if (u.id == b)
                        {
                            u.Vie = 0;
                            break;
                        }
                    }
                }
                try
                {
                    Unite   u = joueur.champion;
                    Vector2 v = Vector2.Zero;

                    List <Item> items = new List <Item> {
                        new PotionDeVie(u, v), new PotionDeMana(u, v)
                    };
                    List <Stuff> stuffs = new List <Stuff> {
                        new BottesDacier(u, v), new Epaulieres(u, v), new EpeeSolari(u, v), new GantsDeDevotion(u, v), new HelmetPurple(u, v), new RingLionHead(u, v)
                    };
                    // Utilisation inventaire
                    // Objets
                    if (player.LastItemUsed != -1)
                    {
                        bool found = false;
                        // On regarde si il est dans l'inventaire
                        for (int i = 0; i < joueur.champion.Inventory.Count; i++)
                        {
                            if (joueur.champion.Inventory[i].id == player.LastItemUsed)
                            {
                                joueur.champion.Inventory[i].Utiliser();
                                found = true;
                                break;
                            }
                        }
                        // Sinon on l'ajoute
                        if (!found)
                        {
                            foreach (Item i in items)
                            {
                                if (i.id == player.LastItemUsed)
                                {
                                    joueur.champion.Inventory.Add(i);
                                    joueur.champion.Inventory[joueur.champion.Inventory.Count - 1].Utiliser();
                                }
                            }
                        }
                    }

                    // Stuff
                    if (player.LastStuffUsed != -1)
                    {
                        bool found = false;
                        // On regarde si il est dans l'inventaire
                        for (int i = 0; i < joueur.champion.Inventory.Count; i++)
                        {
                            if (joueur.champion.Inventory[i].id == player.LastStuffUsed)
                            {
                                ((Stuff)joueur.champion.Inventory[i]).Equiper();
                                found = true;
                                break;
                            }
                        }
                        // Sinon on l'ajoute
                        if (!found)
                        {
                            foreach (Stuff s in stuffs)
                            {
                                if (s.id == player.LastStuffUsed)
                                {
                                    joueur.champion.Inventory.Add(s);
                                    ((Stuff)joueur.champion.Inventory[joueur.champion.Inventory.Count - 1]).Equiper();
                                }
                            }
                        }
                    }
                }
                catch
                {
                    // On sait jamais
                }
            }
        }
示例#21
0
        public void Draw()
        {
            int hauteurBarre = 30;

            MouseState m = SceneEngine2.BaseScene.mouse;

            // Affichage de l'équipement
            if (DrawEquipement)
            {
                spritebatch.Draw(Equipement, new Vector2(EquipementPosition.X, EquipementPosition.Y) + joueur.camera.Position, Color.White);
                foreach (Item i in joueur.champion.Stuff)
                {
                    Vector2 marge = new Vector2(7, 5);
                    Vector2 P     = new Vector2(EquipementPosition.X, EquipementPosition.Y) + joueur.camera.Position + marge;
                    switch (i.type)
                    {
                    case Type.Casque: P += CasquePosition;
                        break;

                    case Type.Epaulieres: P += EpaulieresPosition;
                        break;

                    case Type.Gants: P += GantsPosition;
                        break;

                    case Type.Plastron: P += PlastronPosition;
                        break;

                    case Type.Anneau: P += AnneauPosition;
                        break;

                    case Type.Bottes: P += BottesPosition;
                        break;

                    case Type.Arme: P += ArmePosition;
                        break;
                    }
                    spritebatch.Draw(i.Icone, P, Color.White);
                }
            }
            // Si on fait glisser déposer
            if (IsDrag)
            {
                spritebatch.Draw(ItemSelected.Icone, new Vector2(mouse.X, mouse.Y) + joueur.camera.Position, Color.White);
            }

            // Textes
            Text life = new Text("Life"), attack = new Text("Attack"), armor = new Text("Armor"), selectPoint = new Text("SelectPoint"), selectUnit = new Text("SelectUnit"), manaText = new Text("Mana"), levelText = new Text("Level"); // définition des mots traduisibles

            // Affichage du dialogue avec les PNJ
            if (DrawDialogue)
            {
                if (DrawDialogue != OldDrawDialogue) // Si on va pres du pnj ( et que l'on ne l'etait pas avant)
                {
                    MaxChar = 0;                     // On reset tout
                    dialogue.Clear();
                    foreach (Text t in joueur.PNJSelected.Dialogue)
                    {
                        dialogue.Add(t);
                    }
                }

                if (dialogue.Count() > 0) // Si le dialogue est en cours on le draw
                {
                    string strDiag         = dialogue[0].get();
                    string strDraw         = "";
                    int    HeightBDialogue = 200;
                    int    tailleCadre     = 150;
                    int    margeCadre      = 100;
                    spritebatch.Draw(PackTexture.Dialogue, new Rectangle((int)joueur.camera.Position.X + margeCadre, (int)joueur.camera.Position.Y + height - HeightBDialogue, width - 2 * margeCadre, HeightBDialogue), Color.White);
                    spritebatch.Draw(Portrait, new Rectangle((int)joueur.camera.Position.X + margeCadre, (int)joueur.camera.Position.Y + height - tailleCadre, tailleCadre, tailleCadre), Color.White);
                    spritebatch.Draw(joueur.PNJSelected.Portrait, new Rectangle((int)joueur.camera.Position.X + width - tailleCadre - margeCadre, (int)joueur.camera.Position.Y + height - tailleCadre, tailleCadre, tailleCadre), Color.White);
                    Text l1 = new Text(joueur.champion.ToString().Split(new char[1] {
                        '.'
                    })[1]);
                    string l2 = joueur.PNJSelected.ToString().Split(new char[1] {
                        '.'
                    })[2];
                    spritebatch.DrawString(gamefont, l1.get(), new Vector2(3 * margeCadre / 2 - gamefont.MeasureString(l1.get()).X / 2, height - HeightBDialogue) + joueur.camera.Position, Color.BurlyWood);
                    spritebatch.DrawString(gamefont, l2, new Vector2(width - 3 * margeCadre / 2 - gamefont.MeasureString(l2).X / 2, height - HeightBDialogue) + joueur.camera.Position, Color.BurlyWood);

                    for (int i = 0; i < MaxChar && i < strDiag.Count(); i++)
                    {
                        strDraw += strDiag[i];
                    }


                    MaxChar++;
                    spritebatch.DrawString(gamefont, Outil.Normalize((width - 2 * (margeCadre + tailleCadre)) / 13, strDraw), new Vector2(margeCadre + tailleCadre, height - HeightBDialogue / 2 - tailleCadre / 2) + joueur.camera.Position, Color.BurlyWood);
                }
            }
            if (dialogue.Count() > 0) // Si le dialogue est en cours on cache l'UI
            {
                DrawUI = !DrawDialogue;
            }
            else // Sinon si c'est fini on l'affiche
            {
                DrawUI = true;
            }

            if (DrawUI)
            {
                string str = " " + life.get() + " : " + joueur.champion.Vie + " / " + joueur.champion.VieMax + "\n "
                             + manaText.get() + " : " + joueur.champion.Mana + " / " + joueur.champion.ManaMax + "\n "
                             + attack.get() + " : " + joueur.champion.Dommages + "\n "
                             + armor.get() + " : " + joueur.champion.Defense + " / " + joueur.champion.DefenseMagique + "\n "
                             + levelText.get() + " : " + joueur.champion.Level + "\n ";

                // Fond bas gauche noir
                spritebatch.Draw(blank, new Rectangle((int)joueur.camera.Position.X, (int)joueur.camera.Position.Y + height - CadrePosition.Height, CadrePosition.Width, CadrePosition.Height), Color.Black);
                // Portrait
                spritebatch.Draw(Portrait, new Vector2(PortraitPosition.X, PortraitPosition.Y) + joueur.camera.Position, Color.White);

                int margeGaucheVie = 75, margeGaucheMana = 100, longueurBarre = 150;
                // Affichage de la barre de vie
                spritebatch.Draw(blank, new Rectangle((int)joueur.camera.Position.X + CadrePosition.X + margeGaucheVie, (int)joueur.camera.Position.Y + CadrePosition.Y + CadrePosition.Height - (int)gamefont.MeasureString(str).Y, (int)(((float)joueur.champion.Vie / (float)(joueur.champion.VieMax)) * longueurBarre), hauteurBarre), Color.Green);
                // Affichage de la barre de mana
                spritebatch.Draw(blank, new Rectangle((int)joueur.camera.Position.X + CadrePosition.X + margeGaucheMana, (int)joueur.camera.Position.Y + CadrePosition.Y + CadrePosition.Height - (int)gamefont.MeasureString(str).Y + (int)gamefont.MeasureString("char").Y, (int)(((float)joueur.champion.Mana / (float)(joueur.champion.ManaMax)) * longueurBarre), hauteurBarre), new Color(0, 0, 178));
                // Affichage de la barre d'XP
                int xpToDraw = (int)(((float)joueur.champion.XP / (float)(joueur.champion.Level * 1000)) * CadrePosition.Width);
                if (xpToDraw != 0)
                {
                    spritebatch.Draw(blank, new Rectangle((int)joueur.camera.Position.X + CadrePosition.X, (int)joueur.camera.Position.Y + CadrePosition.Y + CadrePosition.Height - hauteurBarre, xpToDraw, hauteurBarre), Color.IndianRed);
                }
                else
                {
                    spritebatch.Draw(blank, new Rectangle((int)joueur.camera.Position.X + CadrePosition.X, (int)joueur.camera.Position.Y + CadrePosition.Y + CadrePosition.Height - hauteurBarre, 1, hauteurBarre), Color.IndianRed);
                }

                // Affichage du texte
                // Nom du personnage
                Text strUnit = new Text(joueur.champion.ToString().Split(new char[1] {
                    '.'
                })[1]);
                spritebatch.DrawString(gamefont, strUnit.get(), new Vector2(CadrePosition.X + CadrePosition.Width - gamefont.MeasureString(strUnit.get()).X / 2 - Portrait.Width / 2, CadrePosition.Y) + joueur.camera.Position, Color.White);

                spritebatch.DrawString(gamefont, str, new Vector2(CadrePosition.X, CadrePosition.Y + 25) + joueur.camera.Position, Color.White);
                string xp = joueur.champion.XP.ToString() + " / " + joueur.champion.Level * 1000;
                spritebatch.DrawString(gamefont, xp, new Vector2(CadrePosition.X + CadrePosition.Width / 2 - gamefont.MeasureString(xp).X / 2, CadrePosition.Y + CadrePosition.Height - hauteurBarre - 2) + joueur.camera.Position, Color.White);

                // Affichage de la barre des sorts
                spritebatch.Draw(BarreDesSorts, new Rectangle(BarreDesSortsPosition.X + (int)joueur.camera.Position.X, BarreDesSortsPosition.Y + (int)joueur.camera.Position.Y, BarreDesSortsPosition.Width, BarreDesSortsPosition.Height), null, Color.White, 0, new Vector2(BarreDesSorts.Width / 2, 0), SpriteEffects.None, 1);
                // Affichage des spells
                for (int i = 0; i < joueur.champion.spells.Count; i++)
                {
                    if (Map.gametime != null)
                    {
                        Color color;
                        if (joueur.champion.IsCastable(i))
                        {
                            color = Color.White;
                        }
                        else
                        {
                            color = Color.Red;
                        }
                        spritebatch.Draw(joueur.champion.spells[i].SpriteBouton, new Vector2(BarreDesSortsPosition.X - 130 + i * (32 + 3), BarreDesSortsPosition.Y + 8) + joueur.camera.Position, color);
                    }
                }
                // Affichage de l'aide des sorts
                for (int i = 0; i < joueur.champion.spells.Count; i++)
                {
                    if (SourisHoverSpellCheck(i))
                    {
                        int    widthCadre  = 250;
                        int    heightCadre = 100;
                        string nomDuSort   = new Text(joueur.champion.spells[i].ToString()).get();
                        // Le cadre noir, le nom du sort, la description
                        spritebatch.Draw(blank, new Rectangle((int)joueur.camera.Position.X + BarreDesSortsPosition.X - widthCadre / 2, (int)joueur.camera.Position.Y + BarreDesSortsPosition.Y - 100, widthCadre, heightCadre), Color.Black);
                        spritebatch.DrawString(spellfont, Outil.Normalize(30, joueur.champion.spells[i].DescriptionSpell()), new Vector2((int)joueur.camera.Position.X + BarreDesSortsPosition.X - widthCadre / 2, (int)joueur.camera.Position.Y + BarreDesSortsPosition.Y - 120 + 25), Color.White);
                        spritebatch.DrawString(spellfont, nomDuSort, new Vector2((int)joueur.camera.Position.X + BarreDesSortsPosition.X - spellfont.MeasureString(nomDuSort).X / 2, (int)joueur.camera.Position.Y + BarreDesSortsPosition.Y - 120), Color.White);
                    }
                }
            }

            // Sac
            if (DrawSac)
            {
                spritebatch.Draw(Sac, new Vector2(SacPosition.X, SacPosition.Y) + joueur.camera.Position, Color.White);
                // Affichage des items
                int     x     = 0;
                int     j     = 0;
                Vector2 marge = new Vector2(8, 8); // marge de l'inventaire
                foreach (Item it in joueur.champion.Inventory)
                {
                    if (!it.Activated)
                    {
                        spritebatch.Draw(it.Icone, new Vector2(SacPosition.X, SacPosition.Y) + joueur.camera.Position + marge + new Vector2((32 + 7) * x, (32 + 7) * j), Color.White);
                    }
                    x++;
                    if (x >= TailleSac.X)
                    {
                        x = 0;
                        j++;
                    }
                }
            }

            string str2 = selectPoint.get();
            string str3 = selectUnit.get();

            // Selections d'unités et de points
            if (DrawSelectPoint)
            {
                spritebatch.DrawString(gamefont, str2, new Vector2(BarreDesSortsPosition.X - gamefont.MeasureString(str2).X / 2, BarreDesSortsPosition.Y - BarreDesSorts.Height) + joueur.camera.Position, Color.White);
            }
            if (DrawSelectUnit)
            {
                spritebatch.DrawString(gamefont, str3, new Vector2(BarreDesSortsPosition.X - gamefont.MeasureString(str2).X / 2, BarreDesSortsPosition.Y - BarreDesSorts.Height) + joueur.camera.Position, Color.White);
            }

            if (isWriting)
            {
                spritebatch.Draw(blank,
                                 new Rectangle((int)joueur.camera.Position.X + widthFondNoir + 10, (int)joueur.camera.Position.Y + CrystalGateGame.graphics.GraphicsDevice.Viewport.Height - heightFondNoir,
                                               CrystalGateGame.graphics.GraphicsDevice.Viewport.Width - widthFondNoir * 2 - 20, 30),
                                 new Color(0, 0, 0, 127));
                spritebatch.DrawString(gamefont, message, joueur.camera.Position + new Vector2(widthFondNoir, CrystalGateGame.graphics.GraphicsDevice.Viewport.Height - heightFondNoir), Color.White);
            }

            if (messageRecu != "")
            {
                spritebatch.DrawString(gamefont, messageRecu, joueur.camera.Position +
                                       positionChat, Color.White);
            }

            // Timer
            spritebatch.DrawString(gamefont, tempsDeJeuActuel, new Vector2(joueur.camera.Position.X + width - gamefont.MeasureString(tempsDeJeuActuel).X - 5, joueur.camera.Position.Y + 4), Color.Black);

            // Compteur de vagues
            spritebatch.DrawString(gamefont, compteurDeVague, new Vector2(joueur.camera.Position.X + width - gamefont.MeasureString(compteurDeVague).X - 5, gamefont.MeasureString(tempsDeJeuActuel).Y + joueur.camera.Position.Y + 4), Color.Black);

            // Erreur reseau
            if (Error)
            {
                spritebatch.DrawString(gamefont, new Text("Error1").get(), joueur.camera.Position, Color.White);
            }
            // Curseur
            spritebatch.Draw(CurseurOffensif ? CurseurRouge : Curseur, new Vector2(joueur.camera.Position.X + m.X, joueur.camera.Position.Y + m.Y), Color.White);

            OldDrawDialogue = DrawDialogue;
        }