Пример #1
0
    void GetBelt()
    {
        bool CanInitialize = true;

        for (int i = 0; i < OutputNumber; i++)
        {
            Mover[i] = MoverDetector[i].GetComponent <ObjectAttachmentDetector>().DetectedObject;
            BeltAct TargetBeltAct = Mover[i].GetComponent <BeltAct>();

            TargetBeltAct.ModuleObject = gameObject;

            if (TargetBeltAct.PrevBelt != null)
            {
                PrevBelt        = TargetBeltAct.PrevBelt;
                PrevBeltActCall = TargetBeltAct.PrevBelt.GetComponent <BeltAct>();
                PrevBeltActCall.ModuleObject = gameObject;

                MainBeltIndex   = i;
                MainBeltActCall = TargetBeltAct;
            }

            NextBelt[i] = TargetBeltAct.NextBelt;
            if (TargetBeltAct.NextBelt == null)
            {
                CanInitialize = false;
            }
        }

        for (int i = 0; i < OutputNumber; i++)
        {
            Mover[i].GetComponent <BeltAct>().PrevBelt = PrevBelt;
        }

        isInitialized = CanInitialize;
    }
Пример #2
0
    void GetBelt()
    {
        bool CanInitialize = true;                                                                        //첫 실행 가능 여부 = true

        for (int i = 0; i < InputNumber; i++)                                                             //들어오는 벨트별로 반복
        {
            DetectedObject[i] = DetectSensor[i].GetComponent <ObjectAttachmentDetector>().DetectedObject; //센서에 감지된 오브젝트 인식
            BeltAct TargetBeltAct = DetectedObject[i].GetComponent <BeltAct>();                           //감지된 오브젝트 target으로 호출

            TargetBeltAct.ModuleObject = gameObject;                                                      //벨트의 module에 joiner 입력

            if (TargetBeltAct.NextBelt != null)                                                           //출력벨트 이후벨트 존재( = 메인벨트)
            {
                NextBelt2       = TargetBeltAct.NextBelt;                                                 //이후 벨트 호출
                NextBeltActCall = NextBelt2.GetComponent <BeltAct>();
                NextBeltActCall.ModuleObject = gameObject;                                                //이전 벨트의 모듈에 this입력

                MainBeltIndex   = i;                                                                      //이후 벨트가 연결되어 있는 벨트를 메인벨트로 선언
                MainBeltActCall = TargetBeltAct;                                                          //메인벨트스크립트 호출
            }

            PrevBelt2[i] = TargetBeltAct.PrevBelt;       //벨트에 추가
            if (TargetBeltAct.PrevBelt == null)
            {
                CanInitialize = false;                                  //이전 벨트 없으면 첫 실행 불가
            }
        }

        for (int i = 0; i < InputNumber; i++)                                //들어오는 벨트별로 반복
        {
            DetectedObject[i].GetComponent <BeltAct>().NextBelt = NextBelt2; //이후벨트 하나로 입력
        }

        isInitialized = CanInitialize;
    }
Пример #3
0
    bool CheckInstallCondition()
    {
        bool result = true;

        CheckDirection();

        if (MoverDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject != null)
        {
            BeltAct BeltActCall = MoverDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject.GetComponent <BeltAct>();
            if (BeltActCall.BeltDirection != DestroyerDirection)
            {
                result = false;
            }

            if (BeltActCall.PrevBelt != null)
            {
                if (BeltActCall.PrevBelt.GetComponent <BeltAct>().BeltDirection != DestroyerDirection)
                {
                    result = false;
                }
            }
        }

        return(result);
    }
Пример #4
0
    public BeltAct GetBeltAct()
    {
        BeltAct Result = null;

        if (Info.Type == "Belt")
        {
            Result = transform.GetChild(1).GetChild(0).gameObject.GetComponent <BeltAct>();
        }

        return(Result);
    }
Пример #5
0
    void GetBelt()
    {
        if (Mover != MoverDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject)
        {
            // If mover has been attached (or changed) and mover's direction is same as Destoryer's
            // Initialize the belt info and stop the belt
            if (MoverDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject != null)
            {
                BeltAct BeltActCallTemp = MoverDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject.GetComponent <BeltAct>();
                if (!BeltActCallTemp.ParentObject.GetComponent <InstallableObjectAct>().isInstall)
                {
                    // If detected belt is not installed
                    // Destoryer will not work
                    Mover = null;
                    if (BeltActCallTemp.BeltDirection == DestroyerDirection)
                    {
                        BeltActCallTemp.ModuleCondtion = true;
                    }
                    else
                    {
                        // If detected mover's direction is not same as Destoryer
                        // Cannot install mover
                        BeltActCallTemp.ModuleCondtion = false;
                    }
                }
                else
                {
                    if (BeltActCallTemp.BeltDirection == DestroyerDirection)
                    {
                        Mover       = MoverDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject;
                        BeltActCall = BeltActCallTemp;
                    }
                    else
                    {
                        // If detected mover's direction is not same as Destoryer
                        // Destoryer will not work
                        Mover = null;
                    }
                }
            }
            else
            {
                // If there is no mover
                // Destoryer will not work
                Mover = null;
            }
        }

        if (Mover != null)
        {
            GetPrevBelt();
        }
    }
Пример #6
0
    public void Initializing()
    {
        if (Mover == null || PrevBelt == null)
        {
            return;
        }

        BeltActCall     = Mover.GetComponent <BeltAct>();
        PrevBeltActCall = PrevBelt.GetComponent <BeltAct>();

        isInitialized = true;
    }
Пример #7
0
    // Start is called before the first frame update
    void Start()
    {
        CompanyManagerCall = GameObject.Find("CompanyManager").GetComponent <CompanyManager>();
        GoodsValueCall     = CompanyManagerCall.GetPlayerCompanyValue().GetGoodsValue().GetComponent <GoodsValue>();
        SalesValueCall     = GameObject.Find("SalesManager").GetComponent <SalesValue>();
        ObjectActCall      = gameObject.GetComponent <InstallableObjectAct>();
        Goods            = GameObject.Find("Goods");
        DummyBeltActCall = DummyBelt.GetComponent <BeltAct>();

        MoverDetector     = transform.GetChild(2).GetChild(0).GetChild(0).gameObject;
        WarehouseDetector = transform.GetChild(2).GetChild(1).GetChild(0).gameObject;

        TargetGoodsName = "None";
    }
Пример #8
0
    void GetBelt()
    {
        bool CanInitialize = true;

        NextBelt = null;
        for (int i = 0; i < InputNumber; i++)
        {
            if (MoverDetector[i].GetComponent <ObjectAttachmentDetector>().DetectedObject != null)
            {
                if (MoverDetector[i].GetComponent <ObjectAttachmentDetector>().DetectedObject.GetComponent <BeltAct>().ObjectActCall.isInstall)
                {
                    Mover[i] = MoverDetector[i].GetComponent <ObjectAttachmentDetector>().DetectedObject;
                    BeltAct TargetBeltAct = Mover[i].GetComponent <BeltAct>();
                    TargetBeltAct.ModuleObject = gameObject;

                    PrevBelt[i] = TargetBeltAct.PrevBelt;
                    if (PrevBelt[i] == null)
                    {
                        CanInitialize = false;
                    }

                    if (TargetBeltAct.NextBelt != null)
                    {
                        NextBelt      = TargetBeltAct.NextBelt;
                        MainBeltIndex = i;
                    }
                }
            }
        }

        for (int i = 0; i < InputNumber; i++)
        {
            Mover[i].GetComponent <BeltAct>().ChangeNextBelt(NextBelt);
            if (NextBelt != null)
            {
                Mover[i].GetComponent <BeltAct>().isEnd = false;
            }
        }

        if (NextBelt == null)
        {
            CanInitialize = false;
        }

        isInitialized = CanInitialize;
    }
Пример #9
0
    bool CheckInstallCondition()
    {
        bool Result = true;

        CheckDirection();

        int NextBeltCount = 0;

        for (int i = 0; i < InputNumber; i++)
        {
            if (MoverDetector[i].GetComponent <ObjectAttachmentDetector>().DetectedObject != null)
            {
                BeltAct TargetBeltAct = MoverDetector[i].GetComponent <ObjectAttachmentDetector>().DetectedObject.GetComponent <BeltAct>();
                if (TargetBeltAct.BeltDirection != ProcessorDirection)
                {
                    Result = false;
                    break;
                }

                if (TargetBeltAct.PrevBelt != null)
                {
                    if (TargetBeltAct.PrevBelt.GetComponent <BeltAct>().BeltDirection != ProcessorDirection)
                    {
                        Result = false;
                        break;
                    }
                }
            }
            else
            {
                Result = false;
                break;
            }
        }

        if (NextBeltCount > InputNumber)
        {
            Result = false;
        }

        return(Result);
    }
Пример #10
0
    bool CheckInstallCondition()
    {
        bool result = true;

        CheckDirection();

        if (MoverDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject != null)
        {
            BeltAct PrevBeltActCall = MoverDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject.GetComponent <BeltAct>();
            if (PrevBeltActCall.BeltDirection - DoorDirection != 2 && PrevBeltActCall.BeltDirection - DoorDirection != -2)
            {
                result = false;
            }
        }

        if (WarehouseDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject == null)
        {
            result = false;
        }

        return(result);
    }
Пример #11
0
 void GetPrevBelt()
 {
     if (PrevBelt != PrevBeltDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject)
     {
         // If previous belt has been attached (or changed) and prev belt's direction is same as processor's
         // Initialize the belt info and stop the belt
         if (PrevBeltDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject != null)
         {
             BeltAct BeltActCall = PrevBeltDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject.GetComponent <BeltAct>();
             if (!BeltActCall.ParentObject.GetComponent <InstallableObjectAct>().isInstall)
             {
                 // If detected belt is not installed
                 // Processor will not work
                 PrevBelt = null;
             }
             else
             {
                 if (BeltActCall.BeltDirection == Mover.GetComponent <BeltAct>().BeltDirection)
                 {
                     PrevBelt = PrevBeltDetector.GetComponent <ObjectAttachmentDetector>().DetectedObject;
                 }
                 else
                 {
                     // If detected belt's direction is not same as Mover
                     // Processor will not work
                     PrevBelt = null;
                 }
             }
         }
         else
         {
             // If there is no previous belt
             // Processor will not work
             PrevBelt = null;
         }
     }
 }
Пример #12
0
    void SetCurrentJoinIndex()
    {
        if (AddonObject == null)
        {
            for (int i = 0; i < DetectedObject.Length; i++) //출력 벨트 내에서 반복
            {
                int Nextindex = CurrentJoinIndex + i;       //개수 내에서 반복
                if (Nextindex >= DetectedObject.Length)     //
                {
                    Nextindex -= DetectedObject.Length;
                }


                BeltAct indexBeltActCall = DetectedObject[Nextindex].GetComponent <BeltAct>();   //출력벨트

                if (Nextindex == MainBeltIndex)                                                  //바뀔 벨트가 메인벨트
                {
                    BeltAct nextIndexBeltActCall = NextBelt[Nextindex].GetComponent <BeltAct>(); //*+ : 출력벨트 배열과 센서에 탐지된 벨트 배열 목록이 동일한가?
                    if (indexBeltActCall.GoodsOnBelt == null)                                    //바뀔벨트에 물품 없음
                    {
                        if (nextIndexBeltActCall.GoodsOnBelt == null)
                        {
                            CurrentJoinIndex = Nextindex;           //벨트 변경
                            CanProceed       = true;                //진행 가능
                            return;
                        }
                        else                                        //다음벨트에 물품 있음
                        {
                            if (!nextIndexBeltActCall.isStop)       //다음 벨트 진행중
                            {
                                CurrentJoinIndex = Nextindex;
                                CanProceed       = true;
                                return;
                            }
                        }
                    }
                    else
                    {
                        if (!indexBeltActCall.isStop)
                        {
                            if (!nextIndexBeltActCall.isStop)
                            {
                                CurrentJoinIndex = Nextindex;
                                CanProceed       = true;
                                return;
                            }
                        }
                    }
                }
                else                                                                    //메인벨트 아님
                {
                    if (indexBeltActCall.GoodsOnBelt == null)                           //물품 없음
                    {
                        CurrentJoinIndex = Nextindex;
                        CanProceed       = true;
                        return;
                    }
                    else                                                                //물품 있음
                    {
                        if (!indexBeltActCall.isStop)                                   //출력 벨트 멈추지 않았음
                        {
                            CurrentJoinIndex = Nextindex;
                            CanProceed       = true;
                            return;
                        }
                    }
                }
            }
            CanProceed = false;
            return;
        }
        else                                                                                   //애드온 존재
        {
            if (DetectedObject[CurrentJoinIndex].GetComponent <BeltAct>().GoodsOnBelt == null) //현재 벨트에 물품 없으면 진행 가능
            {
                CanProceed = true;
                return;
            }
            else
            {
                CanProceed = false;
                return;
            }
        }
    }
Пример #13
0
    //올바르게 설치되었는지 여부 출력 함수
    bool CheckInstallCondition()
    {
        bool result        = true;
        int  NextBeltCount = 0;
        int  NextBeltIndex = -1;    //들어오는 2개 벨트중 이후벨트가 연결되어있는 벨트 인덱스

        CheckDirection();

        for (int i = 0; i < InputNumber; i++)                                                                   //들어오는 벨트마다
        {
            GameObject DetectedBelt = DetectSensor[i].GetComponent <ObjectAttachmentDetector>().DetectedObject; //부착된 오브젝트 불러오기(벨트)
            if (DetectedBelt != null)                                                                           //연결된 벨트 오브젝트 있음
            {
                BeltAct BeltActCall = DetectedBelt.GetComponent <BeltAct>();                                    // 벨트 오브젝트 스크립트 불러오기

                if (BeltActCall.BeltDirection != JoinerDirection)                                               //1. 방향 다르면 실패
                {
                    result = false;
                    break;
                }

                if (BeltActCall.NextBelt != null)                   //2. 연결된 벨트의 이후 벨트 존재 => Joiner 이전에 연결되어있던 벨트 존재
                {
                    if (NextBeltCount > 0)                          //2-1.이후 벨트가 이미 세팅되어있으면 => 이후 벨트가 2개 이상시 실패
                    {
                        result        = false;
                        NextBeltIndex = -1;
                        break;
                    }

                    //연결된 벨트 이후 벨트 1개
                    BeltAct NextBeltAct = BeltActCall.NextBelt.GetComponent <BeltAct>(); //이후 벨트 스크립트

                    if (NextBeltAct.BeltDirection != JoinerDirection)                    //이후 벨트 방향 확인
                    {
                        result = false;
                        break;
                    }

                    if (NextBeltAct.NextBelt != null)                                                       //이후 벨트의 이후 벨트 존재
                    {
                        if (NextBeltAct.PrevBelt.GetComponent <BeltAct>().BeltDirection != JoinerDirection) //방향 확인
                        {
                            result = false;
                            break;
                        }
                    }

                    NextBeltIndex = i;
                    NextBeltCount++;
                }
            }
            else        //연결된 벨트 없음
            {
                result = false;
                break;
            }
        }

        if (NextBeltIndex != -1)        //이후벨트 연결된게 있음
        {
            Transform StructCarrier = ObjectActCall.StructObject.transform.parent;
            string    StructName    = "Joiner" + InputNumber.ToString() + "-" + NextBeltIndex.ToString();
            if (ObjectActCall.StructObject.name != StructName)
            {
                GameObject newStruct = GameObject.Instantiate(Resources.Load <GameObject>("GameSystem/InstallableObject/Struct/" + StructName), StructCarrier);
                newStruct.name = StructName;
                Destroy(ObjectActCall.StructObject);
                ObjectActCall.StructObject = newStruct;
            }
        }
        else                            //
        {
            result = false;
        }

        return(result);
    }
Пример #14
0
    void GetDistributeIndex()
    {
        if (AddonObject == null)
        {
            for (int i = 0; i < Mover.Length; i++)
            {
                int index = DistributeIndex + i;
                if (index >= Mover.Length)
                {
                    index -= Mover.Length;
                }

                BeltAct indexBeltActCall = Mover[index].GetComponent <BeltAct>();

                if (index == MainBeltIndex)
                {
                    BeltAct nextIndexBeltActCall = NextBelt[index].GetComponent <BeltAct>();
                    if (indexBeltActCall.GoodsOnBelt == null)
                    {
                        if (nextIndexBeltActCall.GoodsOnBelt == null)
                        {
                            DistributeIndex = index;
                            CanProceed      = true;
                            return;
                        }
                        else
                        {
                            if (!nextIndexBeltActCall.isStop)
                            {
                                DistributeIndex = index;
                                CanProceed      = true;
                                return;
                            }
                        }
                    }
                    else
                    {
                        if (!indexBeltActCall.isStop)
                        {
                            if (!nextIndexBeltActCall.isStop)
                            {
                                DistributeIndex = index;
                                CanProceed      = true;
                                return;
                            }
                        }
                    }
                }
                else
                {
                    if (indexBeltActCall.GoodsOnBelt == null)
                    {
                        DistributeIndex = index;
                        CanProceed      = true;
                        return;
                    }
                    else
                    {
                        if (!indexBeltActCall.isStop)
                        {
                            DistributeIndex = index;
                            CanProceed      = true;
                            return;
                        }
                    }
                }
            }
            CanProceed = false;
            return;
        }
        else
        {
            if (Mover[DistributeIndex].GetComponent <BeltAct>().GoodsOnBelt == null)
            {
                CanProceed = true;
                return;
            }
            else
            {
                CanProceed = false;
                return;
            }
        }
    }
Пример #15
0
    bool CheckInstallCondition()
    {
        bool result        = true;
        int  PrevBeltCount = 0;
        int  PrevBeltIndex = -1;

        CheckDirection();

        for (int i = 0; i < OutputNumber; i++)
        {
            GameObject Mover = MoverDetector[i].GetComponent <ObjectAttachmentDetector>().DetectedObject;
            if (Mover != null)
            {
                BeltAct BeltActCall = Mover.GetComponent <BeltAct>();
                if (BeltActCall.BeltDirection != DistributorDirection)
                {
                    result = false;
                    break;
                }

                if (BeltActCall.PrevBelt != null)
                {
                    if (PrevBeltCount > 0)
                    {
                        result        = false;
                        PrevBeltIndex = -1;
                        break;
                    }

                    BeltAct PrevBeltAct = BeltActCall.PrevBelt.GetComponent <BeltAct>();
                    if (PrevBeltAct.BeltDirection != DistributorDirection)
                    {
                        result = false;
                        break;
                    }

                    if (PrevBeltAct.PrevBelt != null)
                    {
                        if (PrevBeltAct.PrevBelt.GetComponent <BeltAct>().BeltDirection != DistributorDirection)
                        {
                            result = false;
                            break;
                        }
                    }

                    PrevBeltIndex = i;
                    PrevBeltCount++;
                }
            }
            else
            {
                result = false;
                break;
            }
        }

        if (PrevBeltIndex != -1)
        {
            Transform StructCarrier = ObjectActCall.StructObject.transform.parent;
            string    StructName    = "Divider" + OutputNumber.ToString() + "-" + PrevBeltIndex.ToString();
            if (ObjectActCall.StructObject.name != StructName)
            {
                GameObject newStruct = GameObject.Instantiate(Resources.Load <GameObject>("GameSystem/InstallableObject/Struct/" + StructName), StructCarrier);
                newStruct.name = StructName;
                Destroy(ObjectActCall.StructObject);
                ObjectActCall.StructObject = newStruct;
            }
        }
        else
        {
            result = false;
        }

        return(result);
    }