// Use this for initialization
    void Start()
    {
        BiConveyorState bcs = this.gameObject.GetComponent <ShowEquipState>().equipmentState as BiConveyorState;

        speed     = bcs.deliverSpeed;
        direction = bcs.deliverDirection;
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        BiConveyorState bcs = this.gameObject.GetComponent <ShowEquipState>().equipmentState as BiConveyorState;

        speed     = bcs.deliverSpeed;
        direction = bcs.deliverDirection;
        //让该设备上所有的货物都运动
        List <GameObject> cargoList = new List <GameObject>();

        FindExtension.FindGameObjectsWithTagRecursive(this.gameObject, "Cargo", ref cargoList);
        if (bcs.workState == State.On)
        {
            foreach (GameObject cargo in cargoList)
            {
                cargo.transform.localPosition += direction * speed * Time.deltaTime;
            }
        }
    }
Esempio n. 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;
        }
    }