public bool AddMixableToMixture(DropZoneObjectHandler mixtureObject, DraggableObjectBehavior draggedObject) { if (!mixturePool.ContainsKey(mixtureObject.MixtureItem.GetItemId())) { Debug.LogError("Mixture " + mixtureObject.MixtureItem.GetItemId() + " is not registered"); return(false); } if (!savedMixtures.ContainsKey(mixtureObject.MixtureItem)) { savedMixtures.Add(mixtureObject.MixtureItem, new List <SimulationMixableBehavior>()); } //draggedObject.MixtureItem.Parent = mixtureObject.MixtureItem; if (mixtureObject.MixtureItem.AutoMix) { //MixableItem savedMixture = mixturePool[mixtureObject.MixtureItem.GetItemId()]; //savedMixture.doMixAction(savedMixtures[mixtureObject.GetHashCode()], mixtureObject); if (mixtureObject.MixtureItem.DoMix(savedMixtures[mixtureObject.MixtureItem], mixtureObject, draggedObject)) { savedMixtures[mixtureObject.MixtureItem].Add(draggedObject.MixtureItem); } } else { savedMixtures[mixtureObject.MixtureItem].Add(draggedObject.MixtureItem); } return(true); }
protected override void Attach(DraggableObjectBehavior draggableObject) { var holder = GetHolder(draggableObject.Type); var objectTransform = draggableObject.transform; objectTransform.SetParent(holder); snappingAnimation.Snap(objectTransform); }
protected override void Detach(DraggableObjectBehavior draggableObject) { var objectTransform = draggableObject.transform; objectTransform.SetParent(DetachHolder); snappingAnimation.Snap(objectTransform, () => { objectTransform.SetParent(null); draggableObject.SetPhysicsActive(true); draggableObject.SetDraggableState(true); }); }
protected override void Detach(DraggableObjectBehavior draggableObject) { foreach (var itemPair in itemsMap) { if (itemPair.Value == draggableObject) { itemPair.Key.OnUp -= OnPointerOnItemUpHandler; FreeItem(itemPair.Key); itemsMap.Remove(itemPair.Key); return; } } }
public void Setup(DraggableObjectBehavior draggedObject) { this.moveToFinalPosition = true; // create a copy of the behavior data class for an independent access if (draggedObject.GetComponent <SimulationScrollButton>() != null) { this.MixtureItem = (SimulationMixableBehavior)Activator.CreateInstance(draggedObject.MixtureItem.GetType(), draggedObject.MixtureItem); } else { this.MixtureItem = draggedObject.MixtureItem; } SetIcon(this.MixtureItem.icon); }
protected override void Attach(DraggableObjectBehavior draggableObject) { var item = GetFreeItem(); var holder = GetHolder(draggableObject.Type); HoldItem(item, holder); if (freeItems.Contains(item)) { freeItems.Remove(item); } itemsMap[item] = draggableObject; item.OnUp += OnPointerOnItemUpHandler; item.Init(draggableObject.Icon); item.Show(); }
protected abstract void Detach(DraggableObjectBehavior draggableObject);
public override bool DoMix(List <SimulationMixableBehavior> otherMixables, DropZoneObjectHandler dropZoneObject, DraggableObjectBehavior draggedObject = null) { if (draggedObject != null) { if (draggedObject.MixtureItem.GetType() == typeof(Ruler)) { ModalPanel.Instance.ShowModalOK("Ruler", "The height of the coin stack is 2.05 cm. Diaemeter is 2.30cm"); } } return(false); }
public override bool DoMix(List <SimulationMixableBehavior> otherMixables, DropZoneObjectHandler dropZoneObject, DraggableObjectBehavior draggedObject = null) { if (draggedObject != null) { if (draggedObject.MixtureItem.GetType() == typeof(Coins)) { ModalPanel.Instance.ShowModalOK("Electronic Balance", "The coins weigh 60 grams"); } else if (draggedObject.MixtureItem.GetType() == typeof(Cylinder)) { Water water = SimulationMixtureManager.instance.GetSavedMixtures(draggedObject.MixtureItem).FirstOrDefault(m => m.GetType() == typeof(Water)) as Water; if (water != null) { ModalPanel.Instance.ShowModalOK("Electronic Balance", "This weighs " + (water.Volume + 35) + " grams"); } else { ModalPanel.Instance.ShowModalOK("Electronic Balance", "This weighs 34.9 grams"); } } } return(false); }
public override bool DoMix(List <SimulationMixableBehavior> otherMixables, DropZoneObjectHandler dropZoneObject, DraggableObjectBehavior draggedObject = null) { if (draggedObject != null) { if (LabOneManager.ActivePart == LabOneManager.LabPart.PartA) { if (draggedObject.MixtureItem.GetType() == typeof(Water)) { if (otherMixables.Find(m => m.GetType() == draggedObject.MixtureItem.GetType()) == null) { // first time water ImageAnimationManager.Instance.ShowAnimation(16); draggedObject.SetRemoveOnEnd(); return(true); } else { ModalPanel.Instance.ShowModalOK("Duplicate", "Only one of this item can be added"); } } else if (draggedObject.MixtureItem.GetType() == typeof(Sand)) { if ((otherMixables.Find(m => m.GetType() == typeof(Water)) != null)) { if (otherMixables.Find(m => m.GetType() == typeof(Chalk)) == null) { if (otherMixables.Find(m => m.GetType() == draggedObject.MixtureItem.GetType()) == null) { // first time water ImageAnimationManager.Instance.ShowAnimation(12); draggedObject.SetRemoveOnEnd(); return(true); } else { ModalPanel.Instance.ShowModalOK("Duplicate", "Only one of this item can be added"); } } else { ModalPanel.Instance.ShowModalOK("Limit", "Only one compound can be mixed with water"); } } else { ModalPanel.Instance.ShowModalOK("No Water", "Water not yet added. Please add water first on the beaker"); } } else if (draggedObject.MixtureItem.GetType() == typeof(Chalk)) { if ((otherMixables.Find(m => m.GetType() == typeof(Water)) != null)) { if (otherMixables.Find(m => m.GetType() == typeof(Sand)) == null) { if (otherMixables.Find(m => m.GetType() == draggedObject.MixtureItem.GetType()) == null) { // first time water draggedObject.SetRemoveOnEnd(); return(true); } else { ModalPanel.Instance.ShowModalOK("Duplicate", "Only one of this item can be added"); } } else { ModalPanel.Instance.ShowModalOK("Limit", "Only one compound can be mixed with water"); } } else { ModalPanel.Instance.ShowModalOK("No Water", "Water not yet added. Please add water first on the beaker"); } } else if (draggedObject.MixtureItem.GetType() == typeof(Beaker)) { if (otherMixables.Find(m => m.GetType() == typeof(Water)) != null) { if (otherMixables.Find(m => m.GetType() == typeof(Sand)) != null) { ModalPanel.Instance.ShowModalOK("Result", "The supernatant liquid is clear"); } else if (otherMixables.Find(m => m.GetType() == typeof(Chalk)) != null) { ModalPanel.Instance.ShowModalOK("Result", "The supernatant liquid is opaque"); } else { ModalPanel.Instance.ShowModalOK("Result", "This is just water"); } } else { ModalPanel.Instance.ShowModalOK("No liquid", "No liquid to transfer between beakers"); } } } } return(false); }
public override bool DoMix(List <SimulationMixableBehavior> otherMixables, DropZoneObjectHandler dropZoneObject, DraggableObjectBehavior draggedObject = null) { if (draggedObject != null) { if (draggedObject.MixtureItem.GetType() == typeof(MicroTestTube)) { // mixing some test tubes if (!hasTestTube) { hasTestTube = true; this.icon = Resources.Load <Sprite>("Simulation/Lab5/Equipments/Rack-Tube"); dropZoneObject.SetIcon(this.icon); draggedObject.SetRemoveOnEnd(); return(true); } else { ShowNoDuplicateError(draggedObject.MixtureItem); } } else if (hasTestTube) { // do performance stuffs if (draggedObject.MixtureItem.GetType() == typeof(Water) || draggedObject.MixtureItem.GetType() == typeof(Kerosene)) { if (otherMixables.Find(m => m.itemName == draggedObject.MixtureItem.itemName) == null) { // first time water draggedObject.SetRemoveOnEnd(); return(true); } else { ShowNoDuplicateError(draggedObject.MixtureItem); } } else if (draggedObject.MixtureItem.GetType() == typeof(SodiumChloride) || draggedObject.MixtureItem.GetType() == typeof(Naphthalene) || draggedObject.MixtureItem.GetType() == typeof(SodiumChloride) || draggedObject.MixtureItem.GetType() == typeof(EthylAlcohol) || draggedObject.MixtureItem.GetType() == typeof(CoconutOil)) { if (otherMixables.Count(m => m.itemName == draggedObject.MixtureItem.itemName) < 2) { // first time nacl draggedObject.SetRemoveOnEnd(); return(true); } else { ModalPanel.Instance.ShowModalOK("Max Amount", "Only a maximum of two of this material can be added"); } } } else { ModalPanel.Instance.ShowModalOK("Test Tube Required", "Need a test tube to put this material. Please add a test tube first."); } } else { if (LabFiveManager.instance.ActivePart == LabFiveManager.LabPart.PartA) { if (otherMixables.Count(m => m.GetType() == typeof(SodiumChloride)) == 2 && otherMixables.Count(m => m.GetType() == typeof(Naphthalene)) == 2 && otherMixables.Find(m => m.GetType() == typeof(Water)) != null && otherMixables.Find(m => m.GetType() == typeof(Kerosene)) != null) { ModalPanel.Instance.ShowModalOK("Result", "Sodium chloride dissolved in water but not in kerosene. Naphthalene dissolved in kerosene but not in water. Proceeding to Part B", () => { LabFiveManager.instance.MoveToPartB(); }); } else { ModalPanel.Instance.ShowModalOK("Incomplete Materials", "Not enough materials to stir. Please add all materials required."); } } else { if (otherMixables.Count(m => m.GetType() == typeof(EthylAlcohol)) == 2 && otherMixables.Count(m => m.GetType() == typeof(CoconutOil)) == 2 && otherMixables.Find(m => m.GetType() == typeof(Water)) != null && otherMixables.Find(m => m.GetType() == typeof(Kerosene)) != null) { ModalPanel.Instance.ShowModalOK("Result", "Ethyl Alcohol dissolved in water but not in kerosene. Coconut Oil dissolved in kerosene but not in water.", () => { LabFiveManager.instance.Finish(); }); } else { ModalPanel.Instance.ShowModalOK("Incomplete Materials", "Not enough materials to stir. Please add all materials required."); } } } return(false); }
public override bool DoMix(List <SimulationMixableBehavior> otherMixables, DropZoneObjectHandler dropZoneObject, DraggableObjectBehavior draggedObject = null) { if (draggedObject != null) { if (draggedObject.MixtureItem.GetType() == typeof(TestTube)) { // mixing some test tubes if (!hasTestTube) { hasTestTube = true; this.icon = Resources.Load <Sprite>("Simulation/Lab4/Equipments/RackTube"); dropZoneObject.SetIcon(this.icon); draggedObject.SetRemoveOnEnd(); return(true); } else { ModalPanel.Instance.ShowModalOK("Has Test Tube", "This rack already have test tubes"); } } else if (hasTestTube) { if (draggedObject.MixtureItem.GetType() == typeof(AmmoniumHydroxide) || draggedObject.MixtureItem.GetType() == typeof(HydrochloricAcid)) { if (otherMixables.Find(m => m.GetType() == typeof(HydrochloricAcid) && m.GetType() == typeof(AmmoniumHydroxide)) == null) { draggedObject.SetRemoveOnEnd(); return(true); } else { ModalPanel.Instance.ShowModalOK("Single Sample", "You can only put one sample for this test tube"); } } } else { ModalPanel.Instance.ShowModalOK("No Test Tube", "This item cannot be added. Try adding a test tube first"); } } return(false); }
public virtual bool DoMix(List <SimulationMixableBehavior> otherMixables, DropZoneObjectHandler dropZoneObject, DraggableObjectBehavior draggedObject = null) { return(true); }
public override bool DoMix(List <SimulationMixableBehavior> otherMixables, DropZoneObjectHandler dropZoneObject, DraggableObjectBehavior draggedObject = null) { if (draggedObject != null) { if (draggedObject.MixtureItem.GetType() == typeof(Coins)) { if (otherMixables.Find(m => m.GetType() == typeof(Water)) != null) { if (otherMixables.Find(m => m.GetType() == draggedObject.MixtureItem.GetType()) == null) { // first time water ImageAnimationManager.Instance.ShowAnimation(83); draggedObject.SetRemoveOnEnd(); return(true); } else { ModalPanel.Instance.ShowModalOK("Duplicate Item", "You can only put one kind of this item inside the cylinder"); } } else { ModalPanel.Instance.ShowModalOK("No Water", "Add water first before putting the coins"); } } else if (draggedObject.MixtureItem.GetType() == typeof(Water)) { if (otherMixables.Find(m => m.GetType() == draggedObject.MixtureItem.GetType()) == null) { // first time water draggedObject.SetRemoveOnEnd(); return(true); } else { ModalPanel.Instance.ShowModalOK("Duplicate Item", "You can only put one kind of this item inside the cylinder"); } } else if (draggedObject.MixtureItem.GetType() == typeof(Thermometer)) { var w = otherMixables.Find(m => m.GetType() == typeof(Water)); if (w != null) { if ((w as Water).Volume == 50) { ImageAnimationManager.Instance.ShowAnimation(87); } else { ImageAnimationManager.Instance.ShowAnimation(88); } ModalPanel.Instance.ShowModalOK("Temperature", "The temperature is 25.0C"); } else { ModalPanel.Instance.ShowModalOK("Temperature", "Nothing to measure here"); } } } else { if (otherMixables.Find(m => m.GetType() == typeof(Water)) == null) { ModalPanel.Instance.ShowModalOK("Current Volume", "There is no water"); } else if (otherMixables.Find(m => m.GetType() == typeof(Coins)) == null) { ModalPanel.Instance.ShowModalOK("Current Volume", "The water is currently at 50 mL"); } else { ModalPanel.Instance.ShowModalOK("Current Volume", "The water is currently at 59 mL"); } } return(false); }