コード例 #1
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);
        }
コード例 #2
0
        public static BuildProperties ReadFrom(BinaryReader reader)
        {
            var result = new BuildProperties();

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

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

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

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

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

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

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

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

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

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

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

            if (reader.ReadBoolean())
            {
                result.InitHealth = reader.ReadInt32();
            }
            else
            {
                result.InitHealth = null;
            }

            return(result);
        }