public void moveConveyor(float movement, XRayMachine xRayMachine) { if (bagInspectState == BagHandler.BagInspectState.NOTHING) { float xrayScanRight = xRayMachine.scanRight; float xrayScanLeft = xRayMachine.scanLeft; List <GameObject> bags = Misc.FindShallowStartsWith("Bag_"); foreach (GameObject bag in bags) { BagProperties bagProperties = bag.GetComponent <BagProperties>(); if (bagProperties.isOnConveyor) { float bagNewXPos = bag.transform.position.x + movement; GameObject triggerCube = bagProperties.contentsTriggerCube; float centerOfTriggerCube = bag.transform.position.x + triggerCube.transform.localPosition.x; float bagRightmostPos = centerOfTriggerCube + triggerCube.transform.localScale.x / 2f; float bagLeftmostPos = centerOfTriggerCube - triggerCube.transform.localScale.x / 2f; if (movement > 0 && bagRightmostPos < xrayScanLeft && bagRightmostPos + movement >= xrayScanLeft) { bagProperties.showItems(true); } else if (movement > 0 && bagLeftmostPos < xrayScanRight && bagLeftmostPos + movement >= xrayScanRight) { bagProperties.showItems(false); } else if (movement < 0 && bagLeftmostPos >= xrayScanRight && bagLeftmostPos + movement < xrayScanRight) { bagProperties.showItems(true); } else if (movement < 0 && bagRightmostPos >= xrayScanLeft && bagRightmostPos + movement < xrayScanLeft) { bagProperties.showItems(false); } if (movement > 0 && bagNewXPos > xRayMachine.xPointOfNoReturn) { bagProperties.bagFinished(); } else { if (bagProperties.bagDefinition.person.showingPassport && bagProperties.bagDefinition.person.currentX >= xRayMachine.xPointOfNoBackingBags) { bagProperties.bagDefinition.person.showPassport(false); } if (movement > 0 || (movement < 0 && bag.transform.position.x < xRayMachine.xPointOfNoBackingBags)) { bag.transform.position = new Vector3(bag.transform.position.x + movement, bag.transform.position.y, bag.transform.position.z); } } } } PubSub.publish("belt_movement", movement); } }
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 PROPAGATION onMessage(string message, object data) { if (message == "Click") { if (Game.instance.cameraXPos == 2 && !Game.instance.zoomedOutState) { Vector3 position = Vector3.zero; if (data.GetType() == typeof(Vector2)) { Vector2 posV2 = (Vector2)data; position = new Vector3(posV2.x, posV2.y); } else { position = (Vector3)data; } // Get camera Camera camera = GetComponent <Game>().gameCamera; RaycastHit hit; Ray ray = camera.ScreenPointToRay(position); if (bagInspectState == BagInspectState.NOTHING) { if (Physics.Raycast(ray, out hit)) { Debug.Log(hit.transform.gameObject.name); BagProperties clickedBagProperties = hit.transform.GetComponent <BagProperties>(); // // TODO - Can't contents be clicked directly when in a bag without lid? // if (clickedBagProperties == null) {} if (clickedBagProperties != null && !clickedBagProperties.isOpen) { clickedBagProperties.showItems(true); clickedBagProperties.animateLidState(true); clickedBagProperties.enableContentColliders(true); currentBagInspect = clickedBagProperties; bagInspectState = BagInspectState.BAG_OPEN; clickedBagProperties.resetActionOnItems(); } } } else if (bagInspectState == BagInspectState.BAG_OPEN) { // Debug.Log("Bag is open; " + BAG_CONTENTS_LAYER_MASK); bool isBagEmpty = currentBagInspect.contents.transform.childCount == 0; if (!isBagEmpty) { if (Physics.Raycast(ray, out hit, Mathf.Infinity, BAG_CONTENTS_LAYER_MASK)) { Debug.Log(hit.transform.gameObject.name); BagContentProperties clickedBagContentProperties = hit.transform.GetComponent <BagContentProperties>(); if (clickedBagContentProperties != null) { switchToGameCamera(true); clickedBagContentProperties.inspect(); Misc.AnimateBlurTo("blurCamera", Game.instance.blurCamera.GetComponent <BlurOptimized>(), 1, 3f, 2); bagInspectState = BagInspectState.ITEM_INSPECT; PubSub.publish("inspect_active"); PubSub.publish("bag_inspect_item", new InspectActionBag(currentBagInspect.id, clickedBagContentProperties, InspectUIButton.INSPECT_TYPE.UNDEFINED)); } } } else { // Bag is empty, if clicked - close it and end inspect state if (Physics.Raycast(ray, out hit)) { // Debug.Log(hit.transform.gameObject.name); BagProperties clickedBagProperties = hit.transform.GetComponent <BagProperties>(); if (clickedBagProperties == currentBagInspect) { inspectBagDone(); } } } } } } return(PROPAGATION.DEFAULT); }