当前位置: 首页>>代码示例>>C#>>正文


C# NetIncomingMessage.ReadVector2方法代码示例

本文整理汇总了C#中Lidgren.Network.NetIncomingMessage.ReadVector2方法的典型用法代码示例。如果您正苦于以下问题:C# NetIncomingMessage.ReadVector2方法的具体用法?C# NetIncomingMessage.ReadVector2怎么用?C# NetIncomingMessage.ReadVector2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lidgren.Network.NetIncomingMessage的用法示例。


在下文中一共展示了NetIncomingMessage.ReadVector2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadLine

        public static Line ReadLine(NetIncomingMessage message, bool isServer=false)
        {
            float removeAnimation = message.ReadFloat();
            Vector2 animationEnd = message.ReadVector2();
            int turn = message.ReadInt32();
            bool wasGrowing = message.ReadBoolean();
            Vector2 begin = message.ReadVector2();
            Vector2 end = message.ReadVector2();
            float thickness = message.ReadFloat();

            if (!isServer) {
                animationEnd = Constants.FromField(animationEnd);
                begin = Constants.FromField(begin);
                end = Constants.FromField(end);
            }

            Line l = new Line (begin, end);
            l.removeAnimationTime = removeAnimation;
            l.animationEnd = animationEnd;
            l.turn = turn;
            l.color = Constants.COLORS[turn];
            l.wasGrowing = wasGrowing;
            l.thickness = thickness;

            return l;
        }
开发者ID:yegorf1,项目名称:Circles,代码行数:26,代码来源:Line.cs

示例2: ReadData

 private void ReadData(AttributeTypeID Type, NetIncomingMessage Message)
 {
     switch(Type) {
         case AttributeTypeID.Float:
             Data = Message.ReadFloat();
             break;
         case AttributeTypeID.Int:
             Data = Message.ReadInt32();
             break;
         case AttributeTypeID.List:
             Console.WriteLine("AttributeSystem: List<> Type not supported on network sync");
             break;
         case AttributeTypeID.Long:
             Data = Message.ReadInt64();
             break;
         case AttributeTypeID.Rectangle:
             Data = Message.ReadRectangle();
             break;
         case AttributeTypeID.String:
             Data = Message.ReadString();
             break;
         case AttributeTypeID.Vector2:
             Data = Message.ReadVector2();
             break;
         case AttributeTypeID.Bool:
             Data = Message.ReadBoolean();
             break;
         default:
             Console.WriteLine("Invalid Attribute Type: {0}", Type.ToString());
             break;
     }
 }
开发者ID:fusspawn,项目名称:sobriety,代码行数:32,代码来源:Attribute.cs

示例3: ProjectileTransferableData

 public ProjectileTransferableData(NetIncomingMessage message)
 {
     SessionID = message.ReadInt64();
     ID = message.ReadInt32();
     IsValid = message.ReadBoolean();
     Position = message.ReadVector2();
     Angle = message.ReadFloat();
 }
开发者ID:elefantstudio-se,项目名称:xna-lidgren-multiplayer-game,代码行数:8,代码来源:ProjectileTransferableData.cs

示例4: WorkWithData

        public void WorkWithData(NetIncomingMessage inc)
        {
            int ind = inc.ReadInt32();
            EventType e = (EventType)inc.ReadByte();
            NetOutgoingMessage msg = server.CreateMessage();

            switch (e) {
                case EventType.ConnectCircles:
                    Vector2 begin = inc.ReadVector2();
                    Vector2 end = inc.ReadVector2();

                    Log(ind + " player tring to connect " + begin + " w/ " + end);

                    if (ind == CurrentTurn && Connect(begin, end)) {
                        Log("He did it");
                        msg.Write((byte)EventType.ConnectCircles);
                        msg.Write(CurrentTurn);
                        msg.Write(begin);
                        msg.Write(end);

                        SendToAll(msg);

                        if (Circle.CheckWon(CurrentField, CurrentTurn)) {
                            SendWon();
                        }

                        NextTurn();
                    } else {
                        Log("Lol no");
                        msg.Write((byte)EventType.RemoveLine);
                        Line.Write(msg, Line.ReadLine(inc, true), true);

                        SendToAll(msg);
                    }
                    break;

                case EventType.CurrentLine:
                    Line l = Line.ReadLine(inc, true);

                    msg.Write((byte)EventType.CurrentLine);
                    Line.Write(msg, l, true);
                    SendToAll(msg, inc.SenderConnection);
                    break;
            }
        }
开发者ID:yegorf1,项目名称:Circles,代码行数:45,代码来源:Lobbie.cs

示例5: Unpack

 public void Unpack(NetIncomingMessage msg)
 {
     username = msg.ReadString();
     position = msg.ReadVector2();
     sequence = msg.ReadByte();
 }
开发者ID:poemdexter,项目名称:Spire-Venture,代码行数:6,代码来源:PacketTypes.cs

示例6: Read

 public void Read(NetIncomingMessage msg)
 {
     this.PlayerCount = msg.ReadInt32();
     this.Players = new Dictionary<long, Player>();
     for (int i = 0; i < this.PlayerCount; i++)
     {
         long RUI = msg.ReadInt64();
         Vector2 position = msg.ReadVector2();
         Player player = new Player(RUI, playerTexture, new Color(msg.ReadByte(), msg.ReadByte(), msg.ReadByte()));
         player.Position = position;
         this.Players.Add(RUI, player);
     }
 }
开发者ID:shadowfox,项目名称:shapeshooter,代码行数:13,代码来源:Messages.cs

示例7: Read

            public static MsgSpawnPacket Read(NetIncomingMessage packet)
            {
                Byte slot = packet.ReadByte();
                Vector2 position = packet.ReadVector2();
                Single rotation = packet.ReadSingle();

                return new MsgSpawnPacket(slot, position, rotation);
            }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:8,代码来源:Messages.cs

示例8: UpdateFromMovementInput

        public void UpdateFromMovementInput(NetIncomingMessage MovementPacket)
        {
            Vector2 Vector = MovementPacket.ReadVector2();
            if (Vector != IdleDirection) { //If We Moved Update
                Location += (Vector * 3);
                NetOutgoingMessage MovementBroadCast = NetworkManager.Server.CreateMessage();
                MovementBroadCast.Write((byte)MessageTypes.ActorMovement);
                MovementBroadCast.Write(ID);
                MovementBroadCast.WriteVector2(Location);
                NetworkManager.Server.SendToAll(MovementBroadCast, NetDeliveryMethod.Unreliable);
            }

            if (Vector != LastDirection) {
                NetOutgoingMessage Message = NetworkManager.Server.CreateMessage();
                Message.Write((byte)MessageTypes.ActorAnimate);
                Message.Write(ID);
                Message.Write(GetAnimationForDirection(Vector));
                Message.Write(true);
                NetworkManager.Server.SendToAll(Message, NetDeliveryMethod.ReliableOrdered);
            }

            LastDirection = Vector;
            PostMovement(MovementPacket.SenderConnection);
        }
开发者ID:fusspawn,项目名称:sobriety,代码行数:24,代码来源:PlayerClient.cs

示例9: RecievedPlayerShipPosition

        private void RecievedPlayerShipPosition( byte playerNumber, NetIncomingMessage msg )
        {
            Player playerRecieved = GetPlayerByPlayerNumber ( playerNumber );

            if ( playerRecieved != null )
            {
                //Local client knows of this player. Update it.
                Vector2 position = msg.ReadVector2 ( );
                float rotationangle = msg.ReadFloat ( );
                Vector2 direction = msg.ReadVector2 ( );
                Vector2 velocity = msg.ReadVector2 ( );
                playerRecieved.ship.UpdateRemotePosition ( position, rotationangle, direction, velocity );

                _client.Recycle ( msg );
            }
            else
            {
                //Local client does not know about this player. Add it to the other players list.
                RequestInfoAboutPlayer ( playerNumber );
            }
        }
开发者ID:aalcutt,项目名称:DeepSpaceWar,代码行数:21,代码来源:NetworkGameDataManager.cs

示例10: WorkWithData

        private void WorkWithData(NetIncomingMessage msg)
        {
            EventType e = (EventType)msg.ReadByte();

            switch (e) {
                case EventType.GameStarted:
                    int i = msg.ReadInt32();

                    PlayerIndex = i;

                    if (OnGameStarted != null) {
                        OnGameStarted(i);
                    }
                    break;

                case EventType.ConnectCircles:
                    if (OnConnectCircles != null) {
                        OnConnectCircles(msg.ReadInt32(), msg.ReadVector2(), msg.ReadVector2());
                    }
                    break;

                case EventType.NextTurn:
                    if (OnNextTurn != null) {
                        OnNextTurn(msg.ReadInt32());
                    }
                    break;

                case EventType.RemoveLine:
                    if (OnRemoveLine != null) {
                        OnRemoveLine(Line.ReadLine(msg));
                    }
                    break;

                case EventType.OnWon:
                    if (OnWon != null) {
                        OnWon(msg.ReadInt32());
                    }
                    Disconnect();
                    break;

                case EventType.CurrentLine:
                    if (OnCurrentLineChanged != null)    {
                        OnCurrentLineChanged(Line.ReadLine(msg));
                    }
                    break;

                case EventType.Disconnected:
                    if (OnDisconnect != null) {
                        OnDisconnect(msg.ReadString());
                    }
                    break;
            }
        }
开发者ID:yegorf1,项目名称:Circles,代码行数:53,代码来源:LinesClient.cs

示例11: Decode

 /// <summary>
 /// The decode.
 /// </summary>
 /// <param name="im">
 /// The im.
 /// </param>
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt64();
     this.MessageTime = im.ReadDouble();
     this.Position = im.ReadVector2();
     this.Velocity = im.ReadVector2();
     this.FiredByPlayer = im.ReadBoolean();
     this.FiredById = im.ReadInt64();
 }
开发者ID:dsummerfield,项目名称:multiplayer-example,代码行数:15,代码来源:ShotFiredMessage.cs

示例12: UpdateFromPacket

        public static void UpdateFromPacket(NetIncomingMessage Message)
        {
            long ActorID = Message.ReadInt64();

            if (!DrawableActors.ContainsKey(ActorID))
                return;

            DrawableActors[ActorID].Location = Message.ReadVector2();
        }
开发者ID:fusspawn,项目名称:sobriety,代码行数:9,代码来源:ActorManager.cs

示例13: Decode

 public void Decode(NetIncomingMessage im)
 {
     this.Target = im.ReadVector2();
 }
开发者ID:kflo,项目名称:Battleship2,代码行数:4,代码来源:VectorMessage.cs

示例14: SpawnActor

        public static void SpawnActor(NetIncomingMessage Message)
        {
            ObjectTypes ActorType = (ObjectTypes)Message.ReadInt32();
            switch (ActorType) {
                case ObjectTypes.PlayerActor:
                    #region Player
                    var ID = Message.ReadInt64();
                    var Sex = Message.ReadByte();
                    var Location = Message.ReadVector2();

                    switch(Sex) {
                        case 0:
                            AnimatedActor Actor = new AnimatedActor(new SpriteSheet(
                                GameClient.ContentManager.Load<Texture2D>("Natkuma"),
                                40, 60));

                            Actor.RegisterAnimation("WalkNorth", new List<int>() { 23, 24, 25, 26, 27, 26, 25, 24, 23, 32, 31, 30, 29, 28, 29, 30, 31, 32 });
                            Actor.RegisterAnimation("WalkEast", new List<int>() { 10, 3, 4, 5, 6, 7, 8, 9 });
                            Actor.RegisterAnimation("WalkSouth", new List<int>() { 34, 35, 36, 37, 38, 37, 36, 35, 34, 43, 42 ,41, 40, 39, 40, 41, 42, 43 });
                            Actor.RegisterAnimation("WalkWest", new List<int>() { 11, 18, 17, 16, 15, 14, 13, 12 });
                            Actor.PlayAnimation("WalkEast", true);

                            Actor.ID = ID;
                            Actor.Sex = Sex;
                            Actor.Location = Location;
                            Actor.Scale = 1;
                            if (!DrawableActors.ContainsKey(Actor.ID))
                                DrawableActors.Add(Actor.ID, Actor);
                            else
                                Console.WriteLine("Error: Avatar Already Added for Key {0}", Actor.ID);
                            break;
                        case 1:
                            AnimatedActor ActorFem = new AnimatedActor(new SpriteSheet(
                                GameClient.ContentManager.Load<Texture2D>("Malice"),
                                40, 60));

                            ActorFem.RegisterAnimation("WalkNorth", new List<int>() { 35, 36, 37, 38, 39, 40, 39, 38, 37, 36, 35, 41, 42, 43, 44, 45, 44, 43, 42, 41 });
                            ActorFem.RegisterAnimation("WalkEast", new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
                            ActorFem.RegisterAnimation("WalkSouth", new List<int>() { 23, 24, 25, 26, 27, 28, 27, 26, 25, 24, 23, 29, 30, 31, 32, 33 });
                            ActorFem.RegisterAnimation("WalkWest", new List<int>() { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 });
                            ActorFem.PlayAnimation("WalkEast", true);

                            ActorFem.ID = ID;
                            ActorFem.Sex = Sex;
                            ActorFem.Location = Location;
                            ActorFem.Scale = 1;
                            if (!DrawableActors.ContainsKey(ActorFem.ID))
                                DrawableActors.Add(ActorFem.ID, ActorFem);
                            else {
                                DrawableActors[ActorFem.ID] = ActorFem;
                            }
                          break;
                        default:
                            Console.WriteLine("Error: Invalid Sex Type: {0}", Sex);
                            break;
                    }
                    break;
                    #endregion
                case ObjectTypes.Tree:
                    #region Tree
                    Tree T = new Tree(Message);
                    if (!DrawableActors.ContainsKey(T.ID))
                        DrawableActors.Add(T.ID, T);
                    else {
                        DrawableActors[T.ID] = T;
                    }
                    break;
                    #endregion
                case ObjectTypes.Rock:
                    Rock R = new Rock(Message);
                    if (!DrawableActors.ContainsKey(R.ID))
                        DrawableActors.Add(R.ID, R);
                    else
                        DrawableActors[R.ID] = R;

                    break;
                default:
                    Console.WriteLine("Unknown ActorType Creation: {0}", ActorType);
                    break;
            }
        }
开发者ID:fusspawn,项目名称:sobriety,代码行数:81,代码来源:ActorManager.cs

示例15: Decode

 /// <summary>
 /// The decode.
 /// </summary>
 /// <param name="im">
 /// The im.
 /// </param>
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt64();
     this.MessageTime = im.ReadDouble();
     this.Position = im.ReadVector2();
     this.Velocity = im.ReadVector2();
     this.Rotation = im.ReadSingle();
 }
开发者ID:dsummerfield,项目名称:multiplayer-example,代码行数:14,代码来源:UpdateAsteroidStateMessage.cs


注:本文中的Lidgren.Network.NetIncomingMessage.ReadVector2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。