Beispiel #1
0
    public PROPAGATION onMessage(string message, object data)
    {
        if (message == "inspect_rotate")
        {
            Vector3 move = (Vector3)data;

            bool  isPillBottleWithLiquid = BagContentProperties.currentInspectedItem.category == "pills";
            bool  restrictMovementSpeed  = isPillBottleWithLiquid;
            float movementAmount         = move.magnitude;
            if (restrictMovementSpeed && movementAmount > MAX_ROTATION_MOMENTUM)
            {
                move *= (MAX_ROTATION_MOMENTUM / movementAmount);
            }

            float rotX = move.x * ROTATION_SPEED * Mathf.Deg2Rad;
            float rotY = move.y * ROTATION_SPEED * Mathf.Deg2Rad;

            transform.Rotate(Game.instance.gameCamera.transform.rotation * Vector3.up, -rotX, Space.World);
            transform.Rotate(Vector3.right, rotY, Space.World);
        }
        else if (message == "inspect_action")
        {
            InspectUIButton.INSPECT_TYPE action = (InspectUIButton.INSPECT_TYPE)data;
            actionTaken = action;
            PersonBagDefinition currentBagDefinition = BagHandler.instance.currentBagInspect.bagDefinition;

            // Send signal about action taken for this istem
            PubSub.publish("bag_inspect_item", new InspectActionBag(BagHandler.instance.currentBagInspect.id, BagContentProperties.currentInspectedItem, action));

            if (action == InspectUIButton.INSPECT_TYPE.TRASHCAN)
            {
                currentBagDefinition.removedItems.Add(currentInspectedItem);
                throwAway();
            }
            else if (action == InspectUIButton.INSPECT_TYPE.OK)
            {
                acceptItem();
            }
            else if (action == InspectUIButton.INSPECT_TYPE.MANUAL_INSPECT)
            {
                manualInspectTrayNumber = BagContentProperties.manualInspectTrayCounter;
                sendItemToManualInspect();
            }
            else if (action == InspectUIButton.INSPECT_TYPE.MANUAL_INSPECT_NEW)
            {
                manualInspectTrayNumber = ++BagContentProperties.manualInspectTrayCounter;
                sendItemToManualInspect(false);
            }
            else if (action == InspectUIButton.INSPECT_TYPE.POLICE)
            {
                currentBagDefinition.removedItems.Add(currentInspectedItem);
                callPolice();
            }
        }

        return(PROPAGATION.DEFAULT);
    }
    public IEnumerator packAndDropBag(Vector3 bagDropPosition, PersonBagDefinition bagDefinition, List <BagContentProperties> toBePlacedInTrays, Person person)
    {
        createBag(INIT_BAG_POINT, bagDefinition.bagRandomSeed);
        yield return(placeItems(toBePlacedInTrays, person, bagDefinition.bagRandomSeed));

        yield return(shuffleBag());

        yield return(closeLid());

        // yield return fillLiquidBottles(currentBagPlacing);

        currentBagPlacing.showItems(false);

        currentBagPlacing.bagDefinition = bagDefinition;
        currentBagPlacing.bagType       = BagProperties.TYPE.DEFAULT;
        bagDefinition.addBag(currentBagPlacing);

        // Set teddybear color
        person.setTeddyBearColor(currentBagPlacing);

        dropBag(bagDropPosition);
    }
 public Coroutine packBagAndDropIt(Vector3 bagDropPosition, PersonBagDefinition bagDefinition, List <BagContentProperties> toBePlacedInTrays, Person person)
 {
     return(StartCoroutine(packAndDropBag(bagDropPosition, bagDefinition, toBePlacedInTrays, person)));
 }
    public void createTrayWithContents(Vector3 dropPosition, List <BagContentProperties> items, PersonBagDefinition bagDefinition)
    {
        if (items != null && items.Count > 0)
        {
            GameObject    bagGameObject = Instantiate(tray, dropPosition, Quaternion.identity);
            BagProperties bagProperties = bagGameObject.GetComponent <BagProperties> ();
            bagGameObject.transform.position = new Vector3(dropPosition.x, dropPosition.y + bagProperties.halfBagHeight, dropPosition.z);

            currentBagPlacing           = bagProperties;
            bagProperties.bagDefinition = bagDefinition;
            bagProperties.bagType       = BagProperties.TYPE.TRAY_AFTER_INSPECT;
            bagDefinition.addBag(bagProperties);

            moveBagsAsideForTray(bagGameObject.GetComponent <BagProperties>());
            StartCoroutine(placeItemsInBagAndDrop(currentBagPlacing, items, bagDefinition.bagRandomSeed));

            // TODO - Need shuffle

            activeBags.Add(bagProperties);
        }
    }