예제 #1
0
 public bool CheckSuccess(ref int successPos)
 {
     for (int i = 0; i < requireBox.Length; i++)
     {
         if (requireBox[i] != null)
         {
             RequireBox temp = requireBox[i].GetComponent<RequireBox>();
             if (temp == null)
             {
                 SpecialRequireBox temp2 = requireBox[i].GetComponent<SpecialRequireBox>();
                 if (temp2.isSuccessOrder)
                 {
                     successPos = i;
                     return true;
                 }
             }
             else
             {
                 if (temp.isSuccessOrder)
                 {
                     successPos = i;
                     return true;
                 }
             }
         }
     }
     return false;
 }
예제 #2
0
 private void OnEnable()
 {
     if (obj_Destory != null)
     {
         RequireBox require = obj_Destory.GetComponent <RequireBox>();
         if (require == null)
         {
             SpecialRequireBox spRequire = obj_Destory.GetComponent <SpecialRequireBox>();
             spRequire.BeforeDestroy();
         }
         else
         {
             require.BeforeDestory();
         }
         Destroy(obj_Destory);
     }
 }
예제 #3
0
 private void OnEnable()
 {
     if (isSet)
     {
         if (stockPath.requireBox[CreateRequireIndex] == null)
         {
             if (isSpecial)
             {
                 GameObject        temp    = Instantiate(specialRequireBox, stockPath.requireBoxPos[CreateRequireIndex], Quaternion.identity);
                 SpecialRequireBox setting = temp.GetComponent <SpecialRequireBox>();
                 setting.SettingRequirement(unit, coneFlavor, iceCreamFlavor, isSprinkle, amount);
                 stockPath.requireBox[CreateRequireIndex] = temp;
             }
             else
             {
                 GameObject temp    = Instantiate(requireBox, stockPath.requireBoxPos[CreateRequireIndex], Quaternion.identity);
                 RequireBox setting = temp.GetComponent <RequireBox>();
                 setting.SetttingRequirement(unit, sugar_flavor, amount);
                 stockPath.requireBox[CreateRequireIndex] = temp;
             }
         }
         isSet = false;
     }
 }
예제 #4
0
    private void Update()
    {
        if (gameController.isGameStart)
        {
            if (!pause.isPause)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(ray, out hit))
                    {
                        if (hit.collider.gameObject.CompareTag("GameUnits"))
                        {
                            ObjectToMove  = hit.collider.gameObject;
                            objCenter     = ObjectToMove.transform.position;
                            clickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                            offset        = clickPosition - objCenter;
                            isDrag        = true;
                        }
                    }
                }
                if (Input.GetMouseButton(0))
                {
                    if (isDrag)
                    {
                        clickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                        newObjCenter  = clickPosition - offset;
                        ObjectToMove.transform.position = new Vector3(newObjCenter.x, newObjCenter.y, objCenter.z);
                    }
                }
                if (Input.GetMouseButtonUp(0))
                {
                    isDrag = false;
                    if (ObjectToMove != null)
                    {
                        SweetUnits unit = ObjectToMove.GetComponent <SweetUnits>();
                        if (unit.canPlace)
                        {
                            switch (unit.onMachine)
                            {
                            case OnMachine.Candy:
                                if (candyMachine.Add())
                                {
                                    unit.PlaceObject();
                                }
                                else
                                {
                                    unit.ToLastPostion();
                                }
                                break;

                            case OnMachine.Topie:
                                if (topieMachine.Add())
                                {
                                    unit.PlaceObject();
                                }
                                else
                                {
                                    unit.ToLastPostion();
                                }
                                break;

                            case OnMachine.PopPop:
                                if (popMachine.Add())
                                {
                                    unit.PlaceObject();
                                }
                                else
                                {
                                    unit.ToLastPostion();
                                }
                                break;

                            case OnMachine.IceCreamChocolate:
                                IceCreamMachine chochoc = chocolateMachine.GetComponent <IceCreamMachine>();
                                if (chochoc.canPlace)
                                {
                                    chochoc.coneInput = ObjectToMove;
                                    chochoc.Add();
                                    chochoc.AddConeFlavor(ObjectToMove.GetComponent <Cone>().flavor);
                                    ObjectToMove.GetComponent <Cone>().PlaceOnMachine(chochoc.OnMachinePoint);
                                    chochoc.canPlace        = false;
                                    coneMachine.canSuccess  = true;
                                    coneMachine.spawnObject = null;
                                }
                                else
                                {
                                    unit.ToLastPostion();
                                }
                                break;

                            case OnMachine.IceCreamVanila:
                                IceCreamMachine Vanivani = vanilaMachine.GetComponent <IceCreamMachine>();
                                if (Vanivani.canPlace)
                                {
                                    Vanivani.coneInput = ObjectToMove;
                                    Vanivani.Add();
                                    Vanivani.AddConeFlavor(ObjectToMove.GetComponent <Cone>().flavor);
                                    ObjectToMove.GetComponent <Cone>().PlaceOnMachine(Vanivani.OnMachinePoint);
                                    Vanivani.canPlace       = false;
                                    coneMachine.canSuccess  = true;
                                    coneMachine.spawnObject = null;
                                }
                                else
                                {
                                    unit.ToLastPostion();
                                }
                                break;

                            case OnMachine.IceCreamOrange:
                                IceCreamMachine Oror = orangeMachine.GetComponent <IceCreamMachine>();
                                if (Oror.canPlace)
                                {
                                    Oror.coneInput = ObjectToMove;
                                    Oror.Add();
                                    Oror.AddConeFlavor(ObjectToMove.GetComponent <Cone>().flavor);
                                    ObjectToMove.GetComponent <Cone>().PlaceOnMachine(Oror.OnMachinePoint);
                                    Oror.canPlace           = false;
                                    coneMachine.canSuccess  = true;
                                    coneMachine.spawnObject = null;
                                }
                                else
                                {
                                    unit.ToLastPostion();
                                }
                                break;

                            case OnMachine.Trash:
                                unit.PlaceObject();
                                trash.MinusMoney(ObjectToMove.GetComponent <SweetUnits>().gameUnit);
                                break;

                            case OnMachine.RequireBox:
                                if (unit.InRequireBox != null)
                                {
                                    if (unit.GetComponent <CandyFloss>() != null)
                                    {
                                        RequireBox requireBoxtemp = unit.InRequireBox.GetComponent <RequireBox>();
                                        unit.PlaceObject();
                                        requireBoxtemp.FinishRequireBox();
                                    }
                                    RequireBox requireBox = unit.InRequireBox.GetComponent <RequireBox>();
                                    unit.PlaceObject();
                                    requireBox.AddProductToRequireBox();
                                }
                                break;

                            case OnMachine.SpecialRequireBox:
                                if (unit.InRequireBox != null)
                                {
                                    if (unit.GetComponent <CandyFloss>() != null)
                                    {
                                        SpecialRequireBox requireBoxtemp = unit.InRequireBox.GetComponent <SpecialRequireBox>();
                                        unit.PlaceObject();
                                        requireBoxtemp.FinishRequireBox();
                                    }
                                    SpecialRequireBox requireBox = unit.InRequireBox.GetComponent <SpecialRequireBox>();
                                    unit.PlaceObject();
                                    requireBox.AddProductToRequireBox();
                                }
                                break;

                            case OnMachine.Sprinkle:
                                if (sprinkleMachine.Add())
                                {
                                    sprinkleMachine.coneInput = ObjectToMove;
                                    ObjectToMove.GetComponent <IceCreamMachine_Making>().PlaceOnMachine(sprinkleMachine.OnMachinePoint);
                                }
                                else
                                {
                                    unit.ToLastPostion();
                                }
                                break;
                            }
                        }
                        else
                        {
                            unit.ToLastPostion();
                        }
                        ObjectToMove = null;
                    }
                }
            }
        }
        audioSource.mute = isMute;
    }