【废弃存档】检测线路连接

RobotInc_线路合法性检测

线路需按照类型12345顺序排列,且必须有0开始,5结束,返回true  

 

  public void StartCheckLine() //按照一定顺序,检测线路前后链接是否正确,目前停用

    {
        print("start to check the line!");
        if (startId != -1) {
            ProdLinePart startPart = curLinePartList.Find(item => item.itemId == startId); //找到线路core部位作为起始位置
            print("find start part, and it's id is " + startPart.itemId+", and it's type is " + startPart.type+", and it's outid is " + startPart.outId); 
            if (CheckProdLine(startPart, 1))
            {
                //secceedPanel.SetActive(true);
                print("succeed!");
            }
            else
            {
                failToBuildPanel.SetActive(true);
            }
        }
        else
        {
            print("no core built");
        }
    }


    bool CheckProdLine(ProdLinePart curEndPart, int curLineType)
    {
        print("------start to check-----" + curEndPart.itemId + " , " + curLineType);
        if(curEndPart.type == 5 ) //如果到了结束part,检测
        {
            if(curLineType > 1)
            {
                print("it's over!");
                return true;
            }
        }
        else //当前part非结束part
        {
            if (curEndPart.outId != -1)
            {
                print("current part out id is not -1");
                ProdLinePart nextPart = curLinePartList.Find(item => item.itemId == curEndPart.outId);
                print("find next part in list is " + nextPart.itemId);
                if (curEndPart.type == 0)
                {
                    print("current item is a transfer");
                    if (nextPart.type == 0)
                    {
                        print("next part is also a transfer");
                        return CheckProdLine(nextPart, curLineType);
                    }
                    else
                    {
                        print("next part is not a transfer");
                        if (curLineType < nextPart.type) //机器必须按照顺序的做法
                        {
                            print(" current type is " + curLineType + " , and next type is " + nextPart.type);
                            curLineType = nextPart.type;
                            return CheckProdLine(nextPart, curLineType);
                        }
                    }
                }
                else // current part type != 0
                {
                    if (nextPart.type == 0)
                    {
                        return CheckProdLine(nextPart, curLineType);
                    }
                }
            }  
        }
        return false;
    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值