void Update() { if (Input.GetKeyDown(KeyCode.Mouse1)) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.transform != null && hit.transform.gameObject.layer == 10) { GameObject human = hit.transform.gameObject; Debug.Log(LeftMouseButtonClick); if (LeftMouseButtonClick == typeOfClick.takeControl && controlsLeft > 0) { if (dotController.takingControl(human)) { controlsLeft--; } } else if (dotController.isInstantiated && dotController.DotInControl != null && Vector3.Distance(dotController.DotInControl.transform.position, hit.transform.position) <= 15) { if (LeftMouseButtonClick == typeOfClick.giveBomb && bombsLeft > 0) { human.GetComponent <DotStatistics>().Explode(); LeftMouseButtonClick = typeOfClick.takeControl; bombsLeft--; doneSomethingBad = true; } else if (LeftMouseButtonClick == typeOfClick.givePoison && poisonsLeft > 0) { human.GetComponent <DotStatistics>().StartPoison(); LeftMouseButtonClick = typeOfClick.takeControl; poisonsLeft--; doneSomethingBad = true; } else if (LeftMouseButtonClick == typeOfClick.giveHammer && hammersLeft > 0) { human.GetComponent <DotStatistics>().HammerTime(); LeftMouseButtonClick = typeOfClick.takeControl; hammersLeft--; doneSomethingBad = true; } else if (LeftMouseButtonClick == typeOfClick.giveMatch && matchesLeft > 0) { human.GetComponent <DotStatistics>().StartFire(); LeftMouseButtonClick = typeOfClick.takeControl; matchesLeft--; doneSomethingBad = true; } else if (LeftMouseButtonClick == typeOfClick.giveShit && shitsLeft > 0) { human.GetComponent <DotStatistics>().Death(); shitsLeft--; doneSomethingBad = true; LeftMouseButtonClick = typeOfClick.takeControl; } } } if (hit.collider != null && hit.transform.gameObject.layer == 8) { GameObject house = hit.transform.gameObject; if (dotController.isInstantiated && dotController.DotInControl != null && Vector3.Distance(dotController.DotInControl.transform.position, hit.transform.position) <= 15) { if (LeftMouseButtonClick == typeOfClick.giveMatch && matchesLeft > 0) { house.GetComponent <FiredBuilding>().isGoingToFire = true; LeftMouseButtonClick = typeOfClick.takeControl; matchesLeft--; doneSomethingBad = true; } } } if (hit.transform != null && hit.transform.gameObject.layer == 4) { GameObject lake = hit.transform.gameObject; if (dotController.isInstantiated && dotController.DotInControl != null && Vector3.Distance(dotController.DotInControl.transform.position, lake.transform.position) <= 20) { if (LeftMouseButtonClick == typeOfClick.givePoison && poisonsLeft > 0) { lake.GetComponent <PoisonedLake>().isPoisoned = true; LeftMouseButtonClick = typeOfClick.takeControl; poisonsLeft--; doneSomethingBad = true; } } } if (doneSomethingBad) { doneSomethingBad = false; dotController.DotInControl.GetComponent <StatusController>().TagEnemies(); } } RaycastHit2D hito = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hito.collider != null && hito.transform.gameObject.layer == 10) { if (lasthito != null) { lasthito.transform.SetParent(null); Destroy(lasthito); } GameObject hover = (GameObject)Instantiate(hoverImage, Camera.main.ScreenToWorldPoint(Input.mousePosition), new Quaternion(0, 0, 0, 0)); hover.transform.SetParent(hito.transform); hover.transform.localPosition = new Vector3(0, 0, 0); lasthito = hover; } else if (lasthito != null) { lasthito.transform.SetParent(null); Destroy(lasthito); } }