コード例 #1
0
        void Ecouter()
        {
            UdpClient listener = new UdpClient(Port);

            listener.EnableBroadcast = true;
            IPEndPoint client = new IPEndPoint(IPAddress.Any, Port);

            while (true)
            {
                byte[] data = listener.Receive(ref client);
                if (client.Address.ToString() != "127.0.0.1")
                {
                    object c = Serializer.GetObjectFromBytes <object>(data);

                    if (c is PlayerInfo)
                    {
                        PlayerInfo cam = c as PlayerInfo;
                        Console.WriteLine("Données reçues en provenance de {0} : {1}.", client.Address, client.Port);
                        if (JoueurDeux == null)
                        {
                            JoueurDeux = new Player(Jeu, "Superboy", "Default Take", "Lambent_Femal", 1, new Vector3(-MathHelper.PiOver2, 0, 0), new Vector3(-5, 0.5f, -5), 15f, "jump", "landing", "walk", "walk_slow", PlayerIndex.One, false, 5001, "");
                            Jeu.Components.Add(JoueurDeux);
                        }
                        JoueurDeux.Position         = cam.Position;
                        JoueurDeux.PreviousPosition = cam.PreviousPosition;
                        JoueurDeux.Rotation         = cam.Rotation;
                    }
                    if (c is ZombieInfo)
                    {
                        ZombieInfo z = c as ZombieInfo;
                        if (z.ShouldCreate)
                        {
                            BandeDeZombies.Add(new Zombie(Game, z.NomModèle, z.ÉchelleInitiale, z.Position, z.NomTexture, z.Rotation, z.IntervalleMAJ, z.Grognement, z.NomAnim, z.Vitesse, z.Numéro));
                        }
                        else
                        {
                            BandeDeZombies[z.Numéro].Rotation = z.Rotation;
                            BandeDeZombies[z.Numéro].Position = z.Position;
                        }
                    }
                    if (c is ObjetTournoyantInfo)
                    {
                        ObjetTournoyantInfo o = c as ObjetTournoyantInfo;
                        if (o.ShouldCreate)
                        {
                            Clé = new ObjetTournoyant(Jeu, "key", 0.01f, o.Rotation, o.Position, 1 / 60f, Port, "", false);
                            Game.Components.Add(Clé);
                        }
                        else if (o.ShouldRemove)
                        {
                            Game.Components.Remove(Clé);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public override void Update(GameTime gameTime)
        {
            float TempsÉcoulé = (float)gameTime.ElapsedGameTime.TotalSeconds;

            TempsÉcouléDepuisMAJ += TempsÉcoulé;

            if (EstEnMarche)
            {
                AnimationPlayer.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);
            }
            else
            {
                AnimationPlayer.Update(new TimeSpan(0, 0, 0), true, Matrix.Identity);
            }

            if (TempsÉcouléDepuisMAJ >= IntervalleMAJ)
            {
                EffectuerMiseÀJour();
                TempsÉcouléDepuisMAJ = 0;
            }

            CalculerMatriceMonde();

            #region Sons
            if (Entend())
            {
                if (Vector3.Distance(Position, PositionJoueurAttaqué) < 1)
                {
                    Volume = VOLUME_FAIBLE;
                }

                else
                {
                    Volume = VOLUME_FAIBLE / Vector3.Distance(Position, PositionJoueurAttaqué);
                }

                GestionSons.Play(Grognement, true, Volume);
            }

            else
            {
                GestionSons.PauseSoundEffect(Grognement);
            }

            #endregion

            //ShouldDraw = CaméraJeu.Frustum.Intersects(ZoneCollision) && (Vector3.Distance(Position, CaméraJeu.Position) <= 15 * Delta.X);

            ZombieInfo z = new ZombieInfo(Position, Rotation, NuméroIdentification, NomModèle, Échelle, NomTexture, IntervalleMAJ, Grognement, NB_PAS, NomAnim);
            base.Update(gameTime);
        }