Beispiel #1
0
    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("GameUnits"))
        {
            SweetUnits unit = other.GetComponent <SweetUnits>();
            if (unit.gameUnit == GameUnits.Cone)
            {
                unit.canPlace = true;
                switch (iceCreamFlavor)
                {
                case Flavor.Chocolate:
                    unit.onMachine = OnMachine.IceCreamChocolate;
                    break;

                case Flavor.Orange:
                    unit.onMachine = OnMachine.IceCreamOrange;
                    break;

                case Flavor.Vanila:
                    unit.onMachine = OnMachine.IceCreamVanila;
                    break;
                }
            }
        }
    }
Beispiel #2
0
 private void OnTriggerExit(Collider other)
 {
     if (other.CompareTag("GameUnits"))
     {
         SweetUnits unit = other.GetComponent <SweetUnits>();
         unit.canPlace  = false;
         unit.onMachine = OnMachine.None;
     }
 }
Beispiel #3
0
 private void OnTriggerStay(Collider other)
 {
     if (other.CompareTag("GameUnits"))
     {
         SweetUnits unit = other.GetComponent <SweetUnits>();
         unit.canPlace  = true;
         unit.onMachine = OnMachine.Trash;
     }
 }
Beispiel #4
0
 private void OnMouseDown()
 {
     if (flossLevel + 1 > maxFlossLevel)
     {
         GameObject temp  = Instantiate(candyFloss, spawnPoint, Quaternion.identity);
         SweetUnits temp2 = temp.GetComponent <SweetUnits>();
         temp2.LastPosition = temp.transform.position;
         flossLevel         = 0;
     }
 }
Beispiel #5
0
 private void OnTriggerStay(Collider other)
 {
     if (other.CompareTag("GameUnits"))
     {
         SweetUnits unit = other.GetComponent <SweetUnits>();
         if (unit.gameUnit == GameUnits.Candy)
         {
             unit.canPlace  = true;
             unit.onMachine = OnMachine.Topie;
         }
     }
 }
Beispiel #6
0
 private void OnTriggerStay(Collider other)
 {
     if (other.gameObject.CompareTag("GameUnits"))
     {
         SweetUnits unit = other.GetComponent <SweetUnits>();
         if (unit.gameUnit == GameUnits.ConeAndIceCream && coneInput == null)
         {
             unit.onMachine = OnMachine.Sprinkle;
             unit.canPlace  = true;
         }
     }
 }
Beispiel #7
0
 private void OnTriggerStay(Collider other)
 {
     if (other.CompareTag("GameUnits"))
     {
         SweetUnits unit = other.GetComponent <SweetUnits>();
         if ((requireUnit == unit.gameUnit && sugar_flavor == unit.sugar_flavor) || unit.gameUnit == GameUnits.CandyFloss)
         {
             unit.canPlace     = true;
             unit.onMachine    = OnMachine.RequireBox;
             unit.InRequireBox = gameObject;
         }
     }
 }
Beispiel #8
0
 private void OnTriggerStay(Collider other)
 {
     if (other.CompareTag("GameUnits"))
     {
         SweetUnits unit = other.GetComponent <SweetUnits>();
         if (unit.gameUnit == requireUnit)
         {
             IceCreamMachine_Making specialUnit = other.GetComponent <IceCreamMachine_Making>();
             if (specialUnit.ConeFlavor == ConeFlavor && specialUnit.IceCreamFlavor == IceCreamFlavor)
             {
                 unit.canPlace     = true;
                 unit.onMachine    = OnMachine.SpecialRequireBox;
                 unit.InRequireBox = gameObject;
             }
         }
         if (unit.gameUnit == GameUnits.CandyFloss)
         {
             unit.canPlace     = true;
             unit.onMachine    = OnMachine.SpecialRequireBox;
             unit.InRequireBox = gameObject;
         }
     }
 }
Beispiel #9
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;
    }