GameObject CreateNewPlate() { GameObject prefab = Resources.Load("PlatePlayer", typeof(GameObject)) as GameObject; GameObject newPlate = Instantiate(prefab); Rigidbody newRb = newPlate.GetComponent <Rigidbody>(); PlateController newCont = newPlate.GetComponent <PlateController>(); newRb.mass = rb.mass * increaseFactor; newCont.force = force * increaseFactor; newCont.downForce = downForce * increaseFactor; newRb.isKinematic = true; newPlate.transform.SetParent(transform.parent); int[] leftOrRight = { -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1 }; int randLeftOrRight = Random.Range(0, 11); Debug.Log(randLeftOrRight); float randPos = Random.Range(1f, 3f); newPlate.transform.localPosition = new Vector3(randPos * leftOrRight[randLeftOrRight], newPlate.transform.localPosition.y, 0f); newPlate.transform.localPosition += new Vector3(0f, transform.localPosition.y, 0f); newRb.isKinematic = false; newCont.startUpdate = true; return(newPlate); }
/// <summary> /// Creates the plate controller in runtime. /// </summary> public void CreatePlateController() { gameObject.AddComponent <PlateController> (); plateContr = gameObject.GetComponent <PlateController>(); plateContr.AddPlates(FindObjectsOfType(typeof(PressurePlate)) as PressurePlate[]); }
void OnTriggerExit2D(Collider2D collision) { PlateController plate = collision.gameObject.GetComponent <PlateController>(); if (plate != null) { targets.Remove(plate); } }
void OnTriggerEnter2D(Collider2D collision) { PlateController plate = collision.GetComponent <PlateController>(); if (plate != null) { plate.CompleteOrder(); } }
void Interact() { if (!holdingPlate) { int layerMask = ~(1 << 8); RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up, interactDistance, layerMask); if (hit) { Pickup(hit.collider.gameObject); plateController = hit.collider.gameObject.GetComponent <PlateController>(); } } }
void CheckToss() { if (holdingPlate) { if (Input.GetKeyDown(KeyCode.Space)) { preparingToss = true; plateController.throwDir = throwDir; plateController.BeginTossProcedure(); plateController = null; // pickedObject = null; // WalkToGetFood(); } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { //MessageBoxResult msResult = MessageBox.Show("确认保存么", "系统提示", MessageBoxButton.YesNo, MessageBoxImage.Information); //if (msResult == MessageBoxResult.No) //{ // return; //} ReagentsAndSuppliesConsumptionController consumptionController = new ReagentsAndSuppliesConsumptionController(); ReagentAndSuppliesController reagentController = new ReagentAndSuppliesController(); PlateController plateController = new PlateController(); foreach (PlateBase plate in ViewPlates) { if (plate.ItemType == 101 && (plate.DisplayName.EndsWith("1") || plate.DisplayName.EndsWith("2"))) { string plateName = ""; if (plate.DisplayName.EndsWith("1")) { plateName = PlateName.DWPlate1; } if (plate.DisplayName.EndsWith("2")) { plateName = PlateName.DWPlate2; } plateController.UpdateBarcode(plateName, 0, SessionInfo.PraperRotation.RotationID, plate.Barcode); } ReagentAndSupply reagent = new ReagentAndSupply(); if ((isFirstRotation) || (!isFirstRotation && (plate.ItemType >= 100 && plate.ItemType < 200))) { reagent.ItemID = WanTaiObjectService.NewSequentialGuid(); reagent.BarCode = plate.Barcode; reagent.ItemType = plate.ItemType; reagent.ExperimentID = SessionInfo.ExperimentID; reagent.ConfigurationItemID = plate.ConfigurationItemID; reagentController.AddReagentAndSupplies(reagent); } else { reagent.ItemID = new ReagentAndSuppliesController().GetReagentID(SessionInfo.ExperimentID, plate.BarcodePrefix); if (reagent.ItemID == Guid.Empty) { reagent.ItemID = WanTaiObjectService.NewSequentialGuid(); reagent.BarCode = plate.Barcode; reagent.ItemType = plate.ItemType; reagent.ExperimentID = SessionInfo.ExperimentID; reagent.ConfigurationItemID = plate.ConfigurationItemID; reagentController.AddReagentAndSupplies(reagent); } } ReagentsAndSuppliesConsumption calcReagentConsumption = new ReagentsAndSuppliesConsumption(); calcReagentConsumption.ItemID = WanTaiObjectService.NewSequentialGuid(); if (plate.ActualSavedVolume > 0) { calcReagentConsumption.Volume = plate.ActualSavedVolume; } else { calcReagentConsumption.Volume = plate.NeedVolume; } calcReagentConsumption.UpdateTime = DateTime.Now; calcReagentConsumption.ExperimentID = SessionInfo.ExperimentID; calcReagentConsumption.RotationID = SessionInfo.PraperRotation.RotationID; calcReagentConsumption.VolumeType = ConsumptionType.Need; calcReagentConsumption.ReagentAndSupplieID = reagent.ItemID; consumptionController.AddConsumption(calcReagentConsumption); ReagentsAndSuppliesConsumption scanReagentConsumption = new ReagentsAndSuppliesConsumption(); scanReagentConsumption.ItemID = WanTaiObjectService.NewSequentialGuid(); scanReagentConsumption.UpdateTime = DateTime.Now; scanReagentConsumption.ExperimentID = SessionInfo.ExperimentID; scanReagentConsumption.RotationID = SessionInfo.PraperRotation.RotationID; scanReagentConsumption.VolumeType = ConsumptionType.FirstAdd; if (reagent.ItemType == DiTiType.DiTi200 || reagent.ItemType == DiTiType.DiTi1000) { scanReagentConsumption.Volume = plate.FirstAddVolume * 96; } else { scanReagentConsumption.Volume = plate.FirstAddVolume; } scanReagentConsumption.ReagentAndSupplieID = reagent.ItemID; consumptionController.AddConsumption(scanReagentConsumption); } btnScan.IsEnabled = false; btnManual.IsEnabled = false; btnSave.IsEnabled = false; btnNext.IsEnabled = true; btnSupplies.IsEnabled = false; btnReagent.IsEnabled = false; btnTestItem.IsEnabled = false; SessionInfo.NextButIndex = 3; ////MessageBox.Show("保存成功!", "系统提示"); }
/// <summary> /// Interaction implementation for different types of InteractableObject's . /// Takes the GameObject of the InteractableObject. /// </summary> /// <param name="obj">InteractableObject GameObject is passed here.</param> private void Interaction(GameObject obj) { IInteractableObject interactingObject = obj.GetComponent <IInteractableObject> ( ); switch (interactingObject._ObjectType) { ///Interaction with Garbage Bin. If Player's inventory has something, set it to null. case InteractableObjects.Garbage: if (GetPlayerInventoryEmpty( )) { return; } RefreshInventory( ); break; ///Interaction with Chopping Board case InteractableObjects.ChoppingBoard: if (obj.tag != "Setup" + _playerModel._playerID.ToString( )) { return; } _choppingBoardControl = obj.GetComponent <ChoppingBoardController> (); ChoppingBoardInteraction( ); break; ///Interaction with Plate. case InteractableObjects.Plate: if (obj.tag != "Setup" + _playerModel._playerID.ToString( )) { return; } _plateControl = obj.GetComponent <PlateController> ( ); PlateInteraction( ); break; ///Interaction with Veggies A B C D E & F. case InteractableObjects.Veggies: if (GetPlayerInventoryFull( )) { return; } Veggie veg = obj.GetComponent <Veggie>(); _playerModel._inventory.Add(veg); _playerView.DisplayInventory(_playerModel._inventory.ToArray()); break; ///Interaction with customer's seat. ///Serves the order to the customer then empties the player inventory. case InteractableObjects.Seat: if (GetPlayerInventoryEmpty( )) { return; } SeatController seatController = obj.GetComponent <SeatController> ( ); seatController.ServeOrder(_playerModel._inventory.ToArray(), _playerModel._playerID); RefreshInventory( ); break; ///Interaction with Pickup. case InteractableObjects.Pickup: PickupController pickup = obj.GetComponent <PickupController> ( ); if (!pickup.IsPlayerEligible(_playerModel._playerID)) { return; } PickupInteraction(pickup.GetPickupType( )); Destroy(obj.gameObject); break; default: break; } }
// Start is called before the first frame update void Start() { roastController = transform.GetComponent <RoastController>(); plateController = GameObject.Find("Plate").GetComponent <PlateController>(); gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); }
public void SetPlate(PlateController plate) { this.plate = plate; }