예제 #1
0
    // Load a contrail based on the current group name
    private BaseShip_Contrail LoadContrail(ConfigFile Info, String GroupName)
    {
        // Ignore if not contrail
        if(GroupName.ToLower().StartsWith("contrail") == false)
            return null;

        // Alloc a new contrail
        BaseShip_Contrail Contrail = new BaseShip_Contrail();

        // Get color, width, and ship position
        Vector3 ContrailColor = Info.GetKey_Vector3(GroupName, "Color");
        float ContrailWidth = Info.GetKey_Float(GroupName, "Width");
        Contrail.ContrailShipPos = Info.GetKey_Vector2(GroupName, "Pos");

        // Initialize the contrail objects
        Contrail.ContrailObject = new GameObject("Contrail");
        Contrail.Contrail = Contrail.ContrailObject.AddComponent("LineRenderer") as LineRenderer;
        Contrail.Contrail.material = new Material(Shader.Find("Particles/Additive"));//("Particles/Additive"));
        Contrail.Contrail.SetColors(new Color(ContrailColor.x, ContrailColor.y, ContrailColor.z), Color.clear);
        Contrail.Contrail.SetWidth(ContrailWidth, 2.0f);
        Contrail.Contrail.SetVertexCount(BaseShip_Contrail.ContrailLength - 1); // -1 since we are lerp-ing
        Contrail.ContrailPoints = new Vector2[BaseShip_Contrail.ContrailLength];
        Contrail.ContrailTime = 0.0f;

        // Reset trail
        SetPos(ShipPosition);

        // All done!
        return Contrail;
    }