예제 #1
0
        void SendSpell(Player p)
        {
            if (champion.isCasting)
            {
                Unite u = 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 == spell.idSort)
                    {
                        p.idSortCast = s.idSort;
                        p.pointSortX = champion.pointCible.X;
                        p.pointSortY = champion.pointCible.Y;
                        if (SelectedUnit != null)
                            p.idUniteCibleCast = SelectedUnit.id;
                        break;
                    }
                champion.isCasting = false;
                champion.pointCible = Vector2.Zero;
            }
        }
예제 #2
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;
        }