コード例 #1
0
ファイル: Client.cs プロジェクト: DrPandemic/EraParadox
		public StateUpdateEventArgs(NetBuffer msg) : base(msg)
		{
			EntitiesUpdatedState = new List<StateUpdateData>();
			RemarkableEvents = new List<RemarkableEventData>();

			LastAcknowledgedActionID = msg.ReadUInt64();
			Time = msg.ReadDouble();
			Vec2 velocity = new Vec2(msg.ReadFloat(), msg.ReadFloat());
			byte nbClients = msg.ReadByte();
			for (byte i = 0; i < nbClients; ++i) {
				ulong id = msg.ReadUInt64();
				Vec2 pos = new Vec2(msg.ReadFloat(), msg.ReadFloat());
				ChampionAnimation anim = (ChampionAnimation)msg.ReadByte();
				bool facingLeft = msg.ReadBoolean();

				EntitiesUpdatedState.Add(new StateUpdateData(id, pos, velocity, anim, facingLeft));
			}
			while (msg.Position != msg.LengthBits) {
				ServerCommand cmd = (ServerCommand)msg.ReadByte();
				RemarkableEventData data = null;
				switch (cmd) {
					case ServerCommand.SpellCast:
						data = new SpellCastEventData(
							msg.ReadUInt64(),
							msg.ReadUInt64(),
							(SpellTypes)msg.ReadByte(),
							msg.ReadFloat(),
							new Vec2(msg.ReadFloat(), msg.ReadFloat()),
							new Vec2(msg.ReadFloat(), msg.ReadFloat()),
							TimeSpan.FromSeconds(msg.ReadFloat()),
							msg.ReadFloat(),
							msg.ReadFloat());
						break;

					case ServerCommand.SpellDisappear:
						data = new SpellDisappearEventData(msg.ReadUInt64());
						break;

					case ServerCommand.StatsChanged:
						data = new StatsChangedEventData(msg.ReadUInt64(), msg.ReadFloat());
						break;

					case ServerCommand.ChampionDied:
						data = new ChampionDiedEventData(msg.ReadUInt64(),
						                                 msg.ReadUInt64(),
						                                 msg.ReadUInt32(), msg.ReadUInt32(), msg.ReadUInt32(), msg.ReadUInt32(),
						                                 TimeSpan.FromSeconds(msg.ReadUInt16()));
						break;

					case ServerCommand.StructureStatsChanged:
						data = new StructureStatsChangedEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
						                                          (StructureTypes)msg.ReadByte(),
						                                          msg.ReadFloat());
						break;

					case ServerCommand.StructureDestroyed:
						data = new StructureDestroyedEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
						                                       (StructureTypes)msg.ReadByte());
						break;

					case ServerCommand.EndOfGame:
						data = new EndOfGameEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right);
						break;

					case ServerCommand.TowerPreparingToShoot:
						data = new TowerPreparingToShootEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
						                                          (StructureTypes)msg.ReadByte());
						break;

					default:
						Debug.Fail("Unknown server command when updating (unknown remarkable event)");
						break;
				}
				if (data != null) {
					RemarkableEvents.Add(data);
				}
			}
		}
コード例 #2
0
ファイル: Client.cs プロジェクト: DrPandemic/EraParadox
        public StateUpdateEventArgs(NetBuffer msg) : base(msg)
        {
            EntitiesUpdatedState = new List <StateUpdateData>();
            RemarkableEvents     = new List <RemarkableEventData>();

            LastAcknowledgedActionID = msg.ReadUInt64();
            Time = msg.ReadDouble();
            Vec2 velocity  = new Vec2(msg.ReadFloat(), msg.ReadFloat());
            byte nbClients = msg.ReadByte();

            for (byte i = 0; i < nbClients; ++i)
            {
                ulong             id         = msg.ReadUInt64();
                Vec2              pos        = new Vec2(msg.ReadFloat(), msg.ReadFloat());
                ChampionAnimation anim       = (ChampionAnimation)msg.ReadByte();
                bool              facingLeft = msg.ReadBoolean();

                EntitiesUpdatedState.Add(new StateUpdateData(id, pos, velocity, anim, facingLeft));
            }
            while (msg.Position != msg.LengthBits)
            {
                ServerCommand       cmd  = (ServerCommand)msg.ReadByte();
                RemarkableEventData data = null;
                switch (cmd)
                {
                case ServerCommand.SpellCast:
                    data = new SpellCastEventData(
                        msg.ReadUInt64(),
                        msg.ReadUInt64(),
                        (SpellTypes)msg.ReadByte(),
                        msg.ReadFloat(),
                        new Vec2(msg.ReadFloat(), msg.ReadFloat()),
                        new Vec2(msg.ReadFloat(), msg.ReadFloat()),
                        TimeSpan.FromSeconds(msg.ReadFloat()),
                        msg.ReadFloat(),
                        msg.ReadFloat());
                    break;

                case ServerCommand.SpellDisappear:
                    data = new SpellDisappearEventData(msg.ReadUInt64());
                    break;

                case ServerCommand.StatsChanged:
                    data = new StatsChangedEventData(msg.ReadUInt64(), msg.ReadFloat());
                    break;

                case ServerCommand.ChampionDied:
                    data = new ChampionDiedEventData(msg.ReadUInt64(),
                                                     msg.ReadUInt64(),
                                                     msg.ReadUInt32(), msg.ReadUInt32(), msg.ReadUInt32(), msg.ReadUInt32(),
                                                     TimeSpan.FromSeconds(msg.ReadUInt16()));
                    break;

                case ServerCommand.StructureStatsChanged:
                    data = new StructureStatsChangedEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
                                                              (StructureTypes)msg.ReadByte(),
                                                              msg.ReadFloat());
                    break;

                case ServerCommand.StructureDestroyed:
                    data = new StructureDestroyedEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
                                                           (StructureTypes)msg.ReadByte());
                    break;

                case ServerCommand.EndOfGame:
                    data = new EndOfGameEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right);
                    break;

                case ServerCommand.TowerPreparingToShoot:
                    data = new TowerPreparingToShootEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
                                                              (StructureTypes)msg.ReadByte());
                    break;

                default:
                    Debug.Fail("Unknown server command when updating (unknown remarkable event)");
                    break;
                }
                if (data != null)
                {
                    RemarkableEvents.Add(data);
                }
            }
        }