public override void Interact(Clicker clicker) { base.Interact(clicker); if (clicker as Shard) { RaycastHit info; beaker.collider.enabled = true; if (beaker.collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out info, Camera.main.farClipPlane)) { if (!selectedShards.Contains(clicker as Shard)) { selectedShards.Add(clicker as Shard); } clicker.transform.position = Camera.main.ScreenPointToRay(Input.mousePosition).GetPoint(info.distance + 0.14f); } else { selectedShards.Remove(clicker as Shard); MoveToReset component = clicker.gameObject.AddComponent <MoveToReset>(); component.end = clicker.startPosition; component.start = clicker.transform.position; component.time = 0.5f; } beaker.collider.enabled = false; currentVolume = 0; foreach (Shard shard in selectedShards) { currentVolume += shard.volume; } beaker.transform.Find("Water").localScale = new Vector3(1, 1, Mathf.Min(1 + currentVolume / 20f, 2)); } else if (clicker == furnace) { if (currentVolume == correctVolume) { Item ball = Instantiate(ballBearing, Vector3.zero, Quaternion.identity) as Item; ball.name = "Bearing"; parentManager.Interact(ball); furnace.manager = null; foreach (Shard shard in shards) { Destroy(shard.gameObject); } Destroy(this); } else { GameObject.FindGameObjectWithTag("GameController").GetComponent <GameGUI>().message = "Not the correct volume. Try again."; AudioSource.PlayClipAtPoint(wrongClip, beaker.transform.position); } } }
public override void Interact(Clicker clicker) { base.Interact(clicker); if (clicker as Shard) { RaycastHit info; beaker.collider.enabled = true; if (beaker.collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out info, Camera.main.farClipPlane)) { if (!selectedShards.Contains(clicker as Shard)) { selectedShards.Add(clicker as Shard); } clicker.transform.position = Camera.main.ScreenPointToRay(Input.mousePosition).GetPoint(info.distance + 0.14f); if (!learned) { LearnedItem item = Instantiate(learnedItem) as LearnedItem; item.message = "Eureka!\n\nYou just learned Archimedes' principle for displacement of volume.\n\n" + "Archimedes was a Greek philosophist who lived during the third century BCE. Perhaps he is best known " + "for proposing a method for computing the volume of arbitrarily shaped bodies through displacement. In this " + "experiment, observe how the water level changes as you put more items into the flask."; GameObject.FindGameObjectWithTag("GameController").GetComponent <InventoryManager>().Interact(item); learned = true; AudioSource.PlayClipAtPoint(successClip, beaker.transform.position); } } else { selectedShards.Remove(clicker as Shard); MoveToReset component = clicker.gameObject.AddComponent <MoveToReset>(); component.end = clicker.startPosition; component.start = clicker.transform.position; component.time = 0.5f; } beaker.collider.enabled = false; currentVolume = 0; foreach (Shard shard in selectedShards) { currentVolume += shard.volume; } beaker.transform.Find("Water").localScale = new Vector3(1, 1, 1 + currentVolume / 20f); } }