Exemplo n.º 1
0
    //场景关键点信息
    #region Create_SceneInfo
    public void Create_SceneInfo(ref ParametersList1 PL, out KeyPositionsData KPD)
    {
        RollerConveyor_Parameter RCP = PL.RCP;
        HighStoreShelf_Parameter HP  = PL.HP;
        MultiHighBay_Parameter   MHP = PL.MHP;
        KeyPositionsData         KP  = new KeyPositionsData();

        KP.HighBaysNum = MHP.Num;//高架库数目

        //Vector3[] LiftTransferPositions = new Vector3[]
        KP.HighValues      = new float[] { RCP.RCHigh, RCP.RCHigh - 0.1f };//两种输送线高度
        KP.ConveyorLengths = new float[2] {
            RCP.RCLength, HP.Size.x * 2 + MHP.HookupDistance + MHP.TunnelWidth - RCP.RCWidth
        };
        KP.EnterPosition = new Vector3((KP.ConveyorLengths[1] + RCP.RCWidth - HP.Size.x), RCP.RCHigh - 0.1f, -RCP.RCWidth / 2);//入口处坐标
        float[] ConveyorLinesValues = new float[(MHP.Num + 1) / 2];
        float[] PilerLinesValues    = new float[(MHP.Num + 1) / 2];

        for (int i = 0; i < (MHP.Num + 1) / 2; i++)
        {
            ConveyorLinesValues[i] = -(-RCP.RCWidth / 2 + (2 * i + 1) * HP.Size.x + i * MHP.TunnelWidth + i * MHP.HookupDistance);
            PilerLinesValues[i]    = -(MHP.TunnelWidth / 2 + i * (MHP.TunnelWidth + MHP.HookupDistance) + (2 * i + 1) * HP.Size.x);
        }
        KP.ConveyorLinesValues = ConveyorLinesValues; //每条入库输送线的X值
        //KP.ConveyorLinesLength = 3 * RCP.RCLength;//入库输送线的长度
        KP.ConveyorWidth    = RCP.RCWidth;            //输送线宽度
        KP.PilerLinesValues = PilerLinesValues;       //每条堆垛机线路的X值
        Vector3[] HighBaysPositions = new Vector3[MHP.Num];
        for (int i = 0; i < MHP.Num; i++)
        {
            float TempValue = HP.Size.x / 2 + i * HP.Size.x + ((i + 1) / 2) * MHP.TunnelWidth + (i / 2) * MHP.HookupDistance;
            HighBaysPositions[i] = new Vector3(-TempValue, 0, -(RCP.RCWidth + 2 * RCP.RCLength));
        }
        KP.HighBaysPositions = HighBaysPositions; //高架库的坐标
        KP.CargoSize         = PL.CargoSize;      //货物尺寸

        StorePositions StorePositions = new StorePositions();

        float[] StoreFloorPositions  = new float[HP.FloorsNum];
        float[] StoreColumnPositions = new float[HP.ColumnsNum];
        float   TempValue1           = 0;

        for (int i = 0; i < HP.FloorsNum; i++)
        {
            TempValue1            += HP.FloorsHigh[i];
            StoreFloorPositions[i] = TempValue1;
        }
        for (int j = 0; j < HP.ColumnsNum; j++)
        {
            StoreColumnPositions[j] = -(HP.ColumnWidth / 2 + (j + 1) * HP.ColumnWidth);
        }
        float[] StorePlacePosition = { HP.ColumnWidth / 4, -HP.ColumnWidth / 4 };
        StorePositions.StoreFloorPositions  = StoreFloorPositions;
        StorePositions.StoreColumnPositions = StoreColumnPositions;
        StorePositions.StorePlacePosition   = StorePlacePosition;
        KP.StorePositions = StorePositions;//高架库仓位坐标信息
        //货物入口坐标(相对于设备)
        KP.CargoEnterPosition = new Vector3(0, KP.HighValues[0], KP.ConveyorLengths[0]);
        KPD = KP;
    }
Exemplo n.º 2
0
    //创建仓库场景
    #region Create_Scene
    public void Create_Scene(ParametersList1 PL, PositionsList POL, string Path)
    {
        HighStoreShelf_Parameter HP  = PL.HP;
        MultiHighBay_Parameter   MHP = PL.MHP;
        RollerConveyor_Parameter RCP = PL.RCP;
        float      TempValue1        = RCP.RCLength;
        float      TempValue2        = RCP.RCWidth;
        float      TempValue3        = TempValue2 - HP.Size.x;
        GameObject WarehouseScene    = new GameObject(); WarehouseScene.name = Name;//创建场景
        //存放货物
        GameObject Cargos = new GameObject();

        Cargos.name = "Cargos"; Cargos.transform.parent = WarehouseScene.transform;
        Cargos.transform.localPosition = new Vector3(0, 0, 0);
        //添加地面
        GameObject obj    = (GameObject)Resources.Load("Scene/Dimian");
        GameObject dimian = Instantiate(obj);
        float      Width  = HP.Size.z + 8 * RCP.RCLength;

        dimian.transform.localScale    = new Vector3(Width, 0.1f, Width);
        dimian.transform.parent        = WarehouseScene.transform;
        dimian.transform.localPosition = new Vector3(-(Width / 2 - RCP.RCLength * 4), -0.05f, -(Width / 2 - 2 * RCP.RCLength));
        //添加入口滚筒输送机
        GameObject               EnterRollerConveyor = new GameObject();
        RollerConveyorType       type = RollerConveyorType.Intact;
        RollerConveyor_Parameter RCP2 = new RollerConveyor_Parameter();

        RCP2          = PL.RCP; RCP2.RCHigh = RCP2.RCHigh - 0.1f;
        RCP2.RCLength = enterRollerLength;//长度自定义
        //RCP2.RCLength = PL.HP.Size.x * 2 + PL.MHP.HookupDistance + PL.MHP.TunnelWidth - RCP2.RCWidth;
        RollerConveyor.Create_RollerConveyor(RCP2, EnterRollerConveyor, type);
        EnterRollerConveyor.name             = "EnterRollerConveyor";
        EnterRollerConveyor.transform.parent = WarehouseScene.transform;
        EnterRollerConveyor.transform.Rotate(0, -90, 0);
        EnterRollerConveyor.transform.localPosition = new Vector3((RCP2.RCLength + TempValue3), 0, -TempValue2 / 2);
        //添加入口顶升移栽机
        LiftTransferParameter LTP = new LiftTransferParameter();

        LTP.High         = PL.RCP.RCHigh - 0.1f;
        LTP.Width        = PL.RCP.RCWidth;
        LTP.RollerRadius = PL.RCP.RollerRadius;
        LTP.GearDiameter = PL.RCP.RollerRadius * 2;
        GameObject enterLiftTransfer = new GameObject();

        LiftTransfer1.CreateLiftTransfer(enterLiftTransfer, ref LTP);
        enterLiftTransfer.name             = "EnterLiftTransfer";
        enterLiftTransfer.transform.parent = WarehouseScene.transform;
        float tempEnterX = RCP2.RCLength - (PL.HP.Size.x - LTP.Width) + LTP.Width / 2;//入口顶升的X坐标

        enterLiftTransfer.transform.localPosition = new Vector3(tempEnterX, 0, -TempValue2 / 2);
        //添加入口皮带输送机
        GameObject EnterBeltConveyors = new GameObject(); EnterBeltConveyors.name = "EnterBeltConveyors";

        Create_EnterBeltConveyors(PL, EnterBeltConveyors);
        EnterBeltConveyors.transform.parent        = WarehouseScene.transform;
        EnterBeltConveyors.transform.localPosition = new Vector3(tempEnterX, 0, 0);
        //添加顶升移载机设备
        GameObject LiftTransferGroup = new GameObject(); LiftTransferGroup.name = "LiftTransferGroup";

        Create_LiftTransferGroup(PL, LiftTransferGroup);
        LiftTransferGroup.transform.parent        = WarehouseScene.transform;
        LiftTransferGroup.transform.localPosition = new Vector3(0, 0, -TempValue2 / 2);
        //添加滚筒输送机(垂直于高架库方向)
        GameObject RollerConveyorGroup = new GameObject(); RollerConveyorGroup.name = "RollerConveyorGroup";

        Create_RollerConveyorGroup(PL, RollerConveyorGroup);
        RollerConveyorGroup.transform.parent        = WarehouseScene.transform;
        RollerConveyorGroup.transform.localPosition = new Vector3(0, 0, -TempValue2 / 2);
        //添加皮带输送机(平行于高架库方向)
        GameObject BeltConveyorGroup = new GameObject(); BeltConveyorGroup.name = "BeltConveyorGroup";

        Create_BeltConveyorGroup(PL, BeltConveyorGroup);
        BeltConveyorGroup.transform.parent        = WarehouseScene.transform;
        BeltConveyorGroup.transform.localPosition = new Vector3(0, 0, -TempValue2);
        //为场景添加高架库设备
        GameObject HighBays1 = new GameObject(); HighBays1.name = "HighBayGroup";

        HighBay2.Create_HighBays(HP, MHP, HighBays1);
        HighBays1.transform.parent        = WarehouseScene.transform;
        HighBays1.transform.localPosition = new Vector3(0, 0, -(3 * TempValue1 + TempValue2));
        //为场景添加堆垛机设备
        GameObject PilerGroup = new GameObject(); PilerGroup.name = "PilerGroup";

        Create_Pilers(PL, PilerGroup);
        PilerGroup.transform.parent        = WarehouseScene.transform;
        PilerGroup.transform.localPosition = new Vector3(0, 0, -(TempValue1 + TempValue2));
        //添加出口滚筒输送机
        GameObject ExitRollerConveyor    = new GameObject();
        RollerConveyor_Parameter exitRCP = PL.RCP;

        exitRCP.RCLength = exitRollerLength; exitRCP.RCHigh = PL.RCP.RCHigh - 0.1f;
        RollerConveyor.Create_RollerConveyor(exitRCP, ExitRollerConveyor, RollerConveyorType.Intact);
        ExitRollerConveyor.name             = "ExitRollerConveyor";
        ExitRollerConveyor.transform.parent = WarehouseScene.transform;
        int   j         = (PL.MHP.Num + 1) / 2 - 1;
        float tempExitX = -PL.HP.Size.x - j * (PL.HP.Size.x * 2 + PL.MHP.HookupDistance + PL.MHP.TunnelWidth);

        ExitRollerConveyor.transform.Rotate(0, -90, 0);
        ExitRollerConveyor.transform.localPosition = new Vector3(tempExitX, 0, -TempValue2 / 2);
        //添加出口顶升移栽机
        GameObject ExitLiftTransfer = new GameObject();

        ExitLiftTransfer.name = "ExitLiftTransfer";
        LiftTransfer1.CreateLiftTransfer(ExitLiftTransfer, ref LTP);
        ExitLiftTransfer.transform.parent = WarehouseScene.transform;
        tempExitX = tempExitX - exitRollerLength - LTP.Width / 2;
        ExitLiftTransfer.transform.localPosition = new Vector3(tempExitX, 0, -TempValue2 / 2);
        //添加出口皮带输送线
        GameObject ExitBeltConveyors = new GameObject();

        ExitBeltConveyors.name = "ExitBeltConveyors";
        Create_ExitBeltConveyors(PL, ExitBeltConveyors);
        ExitBeltConveyors.transform.parent        = WarehouseScene.transform;
        ExitBeltConveyors.transform.localPosition = new Vector3(tempExitX, 0, 0);
        //给场景添加Message
        WarehouseScene.AddComponent <ShowKeyPositionData>();
        ShowKeyPositionData ShowKeyData = WarehouseScene.GetComponent <ShowKeyPositionData>();
        KeyPositionsData    KPD         = new KeyPositionsData();

        //float[] HighValues = { 1.2f, 1.1f };
        //SI.HighValues = HighValues;
        Create_SceneInfo(ref PL, out KPD);
        ShowKeyData.KeyPositionsData = KPD;
        //Debug.Log(KPD.ConveyorLengths);
        //WarehouseScene.AddComponent<SceneData>();
        //SceneData SD = WarehouseScene.GetComponent<SceneData>();
        //Information sd = new Information(); sd.Name = "Name"; sd.Num = 2;
        ////WarehouseScene.GetComponent<SceneData>().
        //SD.IN = sd;
        GameObject Cargo = new GameObject(); Cargo.name = "Cargo";

        Cargo1.Create_Cargo(KPD.CargoSize, Cargo);
        //SD.IN.Num = 2; SD.IN.Name = "A";
        //输出场景
        MyClass.CreatePrefab(WarehouseScene, Path);
        MyClass.CreatePrefab(Cargo, path2 + Cargo.name);

        //根据参数预创建一个存储状态面板
        //GameObject StorageStateInterface = new GameObject();
        //StorageStateInterface.name = "StorageStateInterface";
        BinsPanel.Ajustment(MHP.Num, HP.FloorsNum, HP.ColumnsNum);
        BinsPanel.Ajustment2(MHP.Num, HP.FloorsNum, HP.ColumnsNum);
        //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().CreatePrefab(StorageStateInterface, path2 +"Simulation/" +StorageStateInterface.name);
    }