예제 #1
0
    public AircraftComponent()
    {
        AircraftSettings settings = null;

        using (var csv = new CsvHelper.CsvReader(new StreamReader("res/data/aircrafts.csv")))
        {
            csv.Configuration.HasHeaderRecord = true;
            csv.Configuration.RegisterClassMap <AircraftSettingsMap>();
            csv.Configuration.Delimiter = "\t";
            var records = csv.GetRecords <AircraftSettings>();
            foreach (var record in records)
            {
                settings = record;
            }
        }

        this.Name          = settings.Name.Replace(' ', '_');
        this.Weight        = settings.Weight;
        this.InertiaMoment = settings.InertiaMoment;
        this.Thrust        = settings.Thrust;
        this.CanardPos     = settings.CanardPos;
        this.ElevatorPos   = settings.ElevatorPos;
        this.JetPos        = settings.JetPos;
        for (int i = 0; i < 8; i++)
        {
            this.Weapons[i] = new Weapon();
        }
        this.Weapons[0].WeaponPos = settings.WeaponPos0;
        this.Weapons[1].WeaponPos = reverseX(settings.WeaponPos0);
        this.Weapons[2].WeaponPos = settings.WeaponPos1;
        this.Weapons[3].WeaponPos = reverseX(settings.WeaponPos1);
        this.Weapons[4].WeaponPos = settings.WeaponPos2;
        this.Weapons[5].WeaponPos = reverseX(settings.WeaponPos2);
        this.Weapons[6].WeaponPos = settings.WeaponPos3;
        this.Weapons[7].WeaponPos = reverseX(settings.WeaponPos3);

        this.EdgePos    = settings.EdgePos;
        this.CockpitPos = settings.CockpitPos;
        this.GunPos     = settings.GunPos;

        this.Body.CreateFromCX(string.Format("res/mesh/aircraft/{0}/{0}_Body.cx", this.Name));
        if (File.Exists(string.Format("res/mesh/aircraft/{0}/{0}_LeftCanard.cx", this.Name)))
        {
            this.LeftCanard = new GraphicsModel();
            this.LeftCanard.CreateFromCX(string.Format("res/mesh/aircraft/{0}/{0}_LeftCanard.cx", this.Name));
        }
        if (File.Exists(string.Format("res/mesh/aircraft/{0}/{0}_RightCanard.cx", this.Name)))
        {
            this.RightCanard = new GraphicsModel();
            this.RightCanard.CreateFromCX(string.Format("res/mesh/aircraft/{0}/{0}_RightCanard.cx", this.Name));
        }
        if (File.Exists(string.Format("res/mesh/aircraft/{0}/{0}_LeftElevator.cx", this.Name)))
        {
            this.LeftElevator = new GraphicsModel();
            this.LeftElevator.CreateFromCX(string.Format("res/mesh/aircraft/{0}/{0}_LeftElevator.cx", this.Name));
        }
        if (File.Exists(string.Format("res/mesh/aircraft/{0}/{0}_RightElevator.cx", this.Name)))
        {
            this.RightElevator = new GraphicsModel();
            this.RightElevator.CreateFromCX(string.Format("res/mesh/aircraft/{0}/{0}_RightElevator.cx", this.Name));
        }

        this.Texture.Create(string.Format("res/mesh/aircraft/{0}/{0}_P01.png", this.Name), Accessibility.None);
        this.NormalMapTexture.Create(string.Format("res/mesh/aircraft/{0}/{0}_N.png", this.Name), Accessibility.None);

        this.LeftSmokeGeneratorEntity = Entity.Instantiate();
        this.LeftSmokeGeneratorEntity.Attach(new TransformComponent());
        this.LeftSmokeGeneratorEntity.Attach(new StringySmokeComponent());

        this.RightSmokeGeneratorEntity = Entity.Instantiate();
        this.RightSmokeGeneratorEntity.Attach(new TransformComponent());
        this.RightSmokeGeneratorEntity.Attach(new StringySmokeComponent());
    }