public static RepairProperties ReadFrom(BinaryReader reader)
        {
            var result = new RepairProperties();

            result.ValidTargets = new EntityType[reader.ReadInt32()];
            for (int i = 0; i < result.ValidTargets.Length; i++)
            {
                switch (reader.ReadInt32())
                {
                case 0:
                    result.ValidTargets[i] = EntityType.Wall;
                    break;

                case 1:
                    result.ValidTargets[i] = EntityType.House;
                    break;

                case 2:
                    result.ValidTargets[i] = EntityType.BuilderBase;
                    break;

                case 3:
                    result.ValidTargets[i] = EntityType.BuilderUnit;
                    break;

                case 4:
                    result.ValidTargets[i] = EntityType.MeleeBase;
                    break;

                case 5:
                    result.ValidTargets[i] = EntityType.MeleeUnit;
                    break;

                case 6:
                    result.ValidTargets[i] = EntityType.RangedBase;
                    break;

                case 7:
                    result.ValidTargets[i] = EntityType.RangedUnit;
                    break;

                case 8:
                    result.ValidTargets[i] = EntityType.Resource;
                    break;

                case 9:
                    result.ValidTargets[i] = EntityType.Turret;
                    break;

                default:
                    throw new Exception("Unexpected tag value");
                }
            }

            result.Power = reader.ReadInt32();
            return(result);
        }
예제 #2
0
        public static EntityProperties ReadFrom(BinaryReader reader)
        {
            var result = new EntityProperties();

            result.Size              = reader.ReadInt32();
            result.BuildScore        = reader.ReadInt32();
            result.DestroyScore      = reader.ReadInt32();
            result.CanMove           = reader.ReadBoolean();
            result.PopulationProvide = reader.ReadInt32();
            result.PopulationUse     = reader.ReadInt32();
            result.MaxHealth         = reader.ReadInt32();
            result.InitialCost       = reader.ReadInt32();
            result.SightRange        = reader.ReadInt32();
            result.ResourcePerHealth = reader.ReadInt32();
            if (reader.ReadBoolean())
            {
                result.Build = BuildProperties.ReadFrom(reader);
            }
            else
            {
                result.Build = null;
            }

            if (reader.ReadBoolean())
            {
                result.Attack = AttackProperties.ReadFrom(reader);
            }
            else
            {
                result.Attack = null;
            }

            if (reader.ReadBoolean())
            {
                result.Repair = RepairProperties.ReadFrom(reader);
            }
            else
            {
                result.Repair = null;
            }

            return(result);
        }