예제 #1
0
        private void ParseEvent(List <Kill> killsInFrame)
        {
            if (!reader.HasMoreElements)
            {
                return;
            }
            reader.Down();

            var eventType = reader.ReadInt();

            switch (eventType)
            {
            case 1:     //Unit added
                AddUnit();
                break;

            case 2:     //Vehile added
                AddVehicle();
                break;

            case 3:     //Change name (in-out)
                var e = new EnterExitEvent
                {
                    Time   = currentTime,
                    UnitId = reader.ReadInt()
                };
                var from = reader.ReadString();
                var to   = reader.ReadString();
                if (from.StartsWith("~"))
                {
                    e.IsEnter = true;
                    e.User    = to;
                }
                else
                {
                    e.IsEnter = false;
                    e.User    = from;
                }
                result.Events.Add(e);
                break;

            case 4:     //Kill
                var kill = new Kill()
                {
                    Time     = reader.ReadInt(),
                    KillerId = reader.ReadInt(),
                    TargetId = reader.ReadInt(),
                    Weapon   = reader.ReadString(),
                    Ammo     = reader.ReadString(),
                    Distance = reader.ReadDouble()
                };
                result.Kills.Add(kill);
                killsInFrame.Add(kill);
                break;
            }

            reader.Up();
        }
예제 #2
0
        private void PasreFrame0()
        {
            reader.Down(); // frame 0
            reader.SkipElement();
            reader.Down(); //frame 0 events

            while (reader.HasMoreElements)
            {
                reader.Down();
                var eventType = reader.ReadInt();
                switch (eventType)
                {
                case 1:     //Unit added
                    AddUnit();
                    break;

                case 2:     //Vehile added
                    AddVehicle();
                    break;

                case 3:     //Change name (in)
                    var id   = reader.ReadInt();
                    var from = reader.ReadString();
                    var to   = reader.ReadString();

                    var e = new EnterExitEvent
                    {
                        Time   = currentTime,
                        UnitId = id
                    };

                    if (from.StartsWith("~") && !to.StartsWith("~"))
                    {
                        e.IsEnter = true;
                        e.User    = to;
                    }
                    else
                    {
                        e.IsEnter = false;
                        e.User    = from;
                    }
                    result.Events.Add(e);

                    Unit unit = null;
                    if (units.TryGetValue(id, out unit))
                    {
                        units[id].Name = to;
                    }
                    break;
                }
                reader.Up();
            }
            reader.Up();
            reader.Up();
        }