예제 #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        lps         = this.gameObject.GetComponent <ShowEquipState>().equipmentState as LiftPartState;
        speed       = lps.deliverSpeed;
        direction   = lps.deliverDirection;
        liftPattern = lps.liftPattern;
        //让该设备上所有的货物都运动
        List <GameObject> cargoList = new List <GameObject>();

        FindExtension.FindGameObjectsWithTagRecursive(this.gameObject, "Cargo", ref cargoList);
        if (lps.workState == State.On)
        {
            //顶升已经抬升,移动货物到传送带
            if (LiftPart.transform.localPosition == TargetPosition2)
            {
                if (cargoList.Count > 0)
                {
                    foreach (GameObject cargo in cargoList)
                    {
                        cargo.transform.localPosition += direction * speed * Time.deltaTime;
                    }
                }
                else
                {
                    liftPattern = LiftPattern.down;//没有货物,顶升开始下降
                }
            }
            //抬升(入库)
            if (liftPattern == LiftPattern.up)
            {
                //抬升到1
                LiftPart.transform.localPosition = Vector3.MoveTowards(LiftPart.transform.localPosition, TargetPosition2, speed * Time.deltaTime);
                if (LiftPart.transform.localPosition == TargetPosition2)
                {
                    liftPattern = LiftPattern.off;
                }
            }
            //下降(出库)
            else if (liftPattern == LiftPattern.down)
            {
                LiftPart.transform.localPosition = Vector3.MoveTowards(LiftPart.transform.localPosition, TargetPosition1, speed * Time.deltaTime);
                if (LiftPart.transform.localPosition == TargetPosition1)
                {
                    liftPattern = LiftPattern.off;
                }
            }
        }
    }
예제 #2
0
    private Vector3 TargetPosition2; //抬升后的高度
    // Use this for initialization
    void Start()
    {
        lps       = this.gameObject.GetComponent <ShowEquipState>().equipmentState as LiftPartState;
        speed     = lps.deliverSpeed;
        direction = lps.deliverDirection;

        LiftPart = this.gameObject;
        //temphigh是LiftPart需要抬升的高度
        float temphigh = GlobalVariable.KPD.HighValues[0] - GlobalVariable.KPD.HighValues[1];

        TargetPosition1 = LiftPart.transform.localPosition;
        TargetPosition2 = TargetPosition1;
        //抬升后的高度
        TargetPosition2.y = TargetPosition1.y + temphigh;
        speed             = 0.8f;
    }
예제 #3
0
    //初始化所有设备的状态信息
    private void initializeEquipState()
    {
        //赋值
        //双向输送线
        for (int i = 0; i < PilerNums; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                BiConveyorState biConveyorState = new BiConveyorState();
                biConveyorState.kind             = GlobalVariable.biConveyorName;
                biConveyorState.index            = (i + 1) + "_" + (j + 1);
                biConveyorState.workState        = State.Off;
                biConveyorState.facilityState    = FacilityState.Normal;
                biConveyorState.deliverDirection = new Vector3(0, 0, 1);
                biConveyorState.deliverSpeed     = Speed;
                biConveyorState.isExcusive       = Exclusive.No;
                GameObject.Find(biConveyorState.kind + biConveyorState.index).GetComponent <ShowEquipState>().equipmentState = biConveyorState;
            }
        }
        //单向输送线
        for (int i = 0; i < PilerNums + 4; i++)
        {
            UniConveyorState uniConveyorState = new UniConveyorState();
            uniConveyorState.kind      = GlobalVariable.uniConveyorName;
            uniConveyorState.index     = (i + 1) + "";
            uniConveyorState.workState = State.Off;
            if (i == 0)//初始化第一个设备ON
            {
                uniConveyorState.workState = State.On;
            }
            uniConveyorState.facilityState = FacilityState.Normal;

            //退出的三个输送线
            if (i < PilerNums + 1)
            {
                uniConveyorState.deliverDirection = new Vector3(0, 0, 1);
            }
            else
            {
                uniConveyorState.deliverDirection = new Vector3(0, 0, 1);
            }
            uniConveyorState.deliverSpeed = Speed;
            uniConveyorState.isExcusive   = Exclusive.No;
            GameObject.Find(uniConveyorState.kind + uniConveyorState.index).GetComponent <ShowEquipState>().equipmentState = uniConveyorState;
        }
        //顶升移载机
        for (int i = 0; i < PilerNums + 1; i++)
        {
            LiftTransferState liftTransferState = new LiftTransferState();
            liftTransferState.kind             = GlobalVariable.liftTransferName;
            liftTransferState.index            = (i + 1) + "";
            liftTransferState.workState        = State.Off;
            liftTransferState.facilityState    = FacilityState.Normal;
            liftTransferState.deliverDirection = new Vector3(-1, 0, 0);
            liftTransferState.deliverSpeed     = Speed;
            liftTransferState.isExcusive       = Exclusive.No;
            //顶升部分
            LiftPartState liftPartState = new LiftPartState();
            liftPartState.kind             = GlobalVariable.liftPartName;
            liftPartState.index            = (i + 1) + "";
            liftPartState.workState        = State.Off;
            liftPartState.facilityState    = FacilityState.Normal;
            liftPartState.deliverDirection = new Vector3(0, 1, 0); //默认抬升
            liftPartState.deliverSpeed     = Speed / 30;           //顶升的抬升速度是1/30
            liftPartState.isExcusive       = Exclusive.Yes;
            liftPartState.liftPattern      = LiftPattern.up;
            GameObject.Find(liftTransferState.kind + liftTransferState.index).GetComponent <ShowEquipState>().equipmentState = liftTransferState;
            GameObject.Find(liftPartState.kind + liftPartState.index)
            .GetComponent <ShowEquipState>().equipmentState = liftPartState;
        }
    }