Ejemplo n.º 1
0
        public static Properties ReadFrom(System.IO.BinaryReader reader)
        {
            var result = new Properties();

            result.MaxTickCount           = reader.ReadInt32();
            result.TeamSize               = reader.ReadInt32();
            result.TicksPerSecond         = reader.ReadDouble();
            result.UpdatesPerTick         = reader.ReadInt32();
            result.LootBoxSize            = Vec2Double.ReadFrom(reader);
            result.UnitSize               = Vec2Double.ReadFrom(reader);
            result.UnitMaxHorizontalSpeed = reader.ReadDouble();
            result.UnitFallSpeed          = reader.ReadDouble();
            result.UnitJumpTime           = reader.ReadDouble();
            result.UnitJumpSpeed          = reader.ReadDouble();
            result.JumpPadJumpTime        = reader.ReadDouble();
            result.JumpPadJumpSpeed       = reader.ReadDouble();
            result.UnitMaxHealth          = reader.ReadInt32();
            result.HealthPackHealth       = reader.ReadInt32();
            int WeaponParametersSize = reader.ReadInt32();

            result.WeaponParameters = new System.Collections.Generic.Dictionary <WeaponType, WeaponParameters>(WeaponParametersSize);
            for (int i = 0; i < WeaponParametersSize; i++)
            {
                WeaponType WeaponParametersKey;
                switch (reader.ReadInt32())
                {
                case 0:
                    WeaponParametersKey = WeaponType.Pistol;
                    break;

                case 1:
                    WeaponParametersKey = WeaponType.AssaultRifle;
                    break;

                case 2:
                    WeaponParametersKey = WeaponType.RocketLauncher;
                    break;

                default:
                    throw new System.Exception("Unexpected discriminant value");
                }
                WeaponParameters WeaponParametersValue;
                WeaponParametersValue = Model.WeaponParameters.ReadFrom(reader);
                result.WeaponParameters.Add(WeaponParametersKey, WeaponParametersValue);
            }
            result.MineSize = Vec2Double.ReadFrom(reader);
            result.MineExplosionParameters = ExplosionParameters.ReadFrom(reader);
            result.MinePrepareTime         = reader.ReadDouble();
            result.MineTriggerTime         = reader.ReadDouble();
            result.MineTriggerRadius       = reader.ReadDouble();
            result.KillScore = reader.ReadInt32();
            return(result);
        }
Ejemplo n.º 2
0
        public static WeaponParameters ReadFrom(System.IO.BinaryReader reader)
        {
            if (reader == null)
            {
                throw new System.ArgumentNullException(nameof(reader));
            }

            var magazineSize        = reader.ReadInt32();
            var fireRate            = reader.ReadDouble();
            var reloadTime          = reader.ReadDouble();
            var minSpread           = reader.ReadDouble();
            var maxSpread           = reader.ReadDouble();
            var recoil              = reader.ReadDouble();
            var aimSpeed            = reader.ReadDouble();
            var bullet              = BulletParameters.ReadFrom(reader);
            var explosionParameters = reader.ReadBoolean() ? ExplosionParameters.ReadFrom(reader) : null;

            return(new WeaponParameters(magazineSize, fireRate, reloadTime, minSpread, maxSpread, recoil, aimSpeed, bullet, explosionParameters));
        }
Ejemplo n.º 3
0
        public static WeaponParameters ReadFrom(System.IO.BinaryReader reader)
        {
            var result = new WeaponParameters();

            result.MagazineSize = reader.ReadInt32();
            result.FireRate     = reader.ReadDouble();
            result.ReloadTime   = reader.ReadDouble();
            result.MinSpread    = reader.ReadDouble();
            result.MaxSpread    = reader.ReadDouble();
            result.Recoil       = reader.ReadDouble();
            result.AimSpeed     = reader.ReadDouble();
            result.Bullet       = BulletParameters.ReadFrom(reader);
            if (reader.ReadBoolean())
            {
                result.Explosion = ExplosionParameters.ReadFrom(reader);
            }
            else
            {
                result.Explosion = null;
            }
            return(result);
        }
Ejemplo n.º 4
0
        public static Properties ReadFrom(System.IO.BinaryReader reader)
        {
            if (reader == null)
            {
                throw new System.ArgumentNullException(nameof(reader));
            }

            var maxTickCount           = reader.ReadInt32();
            var teamSize               = reader.ReadInt32();
            var ticksPerSecond         = reader.ReadDouble();
            var updatesPerTick         = reader.ReadInt32();
            var lootBoxSize            = Vec2Double.ReadFrom(reader);
            var unitSize               = Vec2Double.ReadFrom(reader);
            var unitMaxHorizontalSpeed = reader.ReadDouble();
            var unitFallSpeed          = reader.ReadDouble();
            var unitJumpTime           = reader.ReadDouble();
            var unitJumpSpeed          = reader.ReadDouble();
            var jumpPadJumpTime        = reader.ReadDouble();
            var jumpPadJumpSpeed       = reader.ReadDouble();
            var unitMaxHealth          = reader.ReadInt32();
            var healthPackHealth       = reader.ReadInt32();
            var weaponParametersSize   = reader.ReadInt32();
            var weaponParameters       = new System.Collections.Generic.Dictionary <WeaponType, WeaponParameters>(weaponParametersSize);

            for (var i = 0; i < weaponParametersSize; i++)
            {
                WeaponType weaponParametersKey;
                switch (reader.ReadInt32())
                {
                case 0:
                    weaponParametersKey = WeaponType.Pistol;
                    break;

                case 1:
                    weaponParametersKey = WeaponType.AssaultRifle;
                    break;

                case 2:
                    weaponParametersKey = WeaponType.RocketLauncher;
                    break;

                default:
                    throw new System.Exception("Unexpected discriminant value");
                }

                WeaponParameters weaponParametersValue;
                weaponParametersValue = Model.WeaponParameters.ReadFrom(reader);
                weaponParameters.Add(weaponParametersKey, weaponParametersValue);
            }

            var mineSize = Vec2Double.ReadFrom(reader);
            var mineExplosionParameters = ExplosionParameters.ReadFrom(reader);
            var minePrepareTime         = reader.ReadDouble();
            var mineTriggerTime         = reader.ReadDouble();
            var mineTriggerRadius       = reader.ReadDouble();
            var killScore = reader.ReadInt32();

            return(new Properties(
                       maxTickCount,
                       teamSize,
                       ticksPerSecond,
                       updatesPerTick,
                       lootBoxSize,
                       unitSize,
                       unitMaxHorizontalSpeed,
                       unitFallSpeed,
                       unitJumpTime,
                       unitJumpSpeed,
                       jumpPadJumpTime,
                       jumpPadJumpSpeed,
                       unitMaxHealth,
                       healthPackHealth,
                       weaponParameters,
                       mineSize,
                       mineExplosionParameters,
                       minePrepareTime,
                       mineTriggerTime,
                       mineTriggerRadius,
                       killScore));
        }