private void Update() { if (BuildMenu.IsOpened) { GunMenuLock = true; } //Shoot Water if (!IsDead && Input.GetMouseButton(0) && (UnlimitedWater || WaterSupply > 0) && !GunMenuLock) { //Shoot Vector3 direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position; float angle = Mathf.Atan2(direction.y, direction.x); angle *= Mathf.Rad2Deg; angle += AngleAdjustment; Watergun.gameObject.transform.rotation = Quaternion.Euler(Vector3.forward * angle); AnimationController.WalkDirection(direction); if (!Watergun.IsActive()) { Watergun.Activate(); } if (!UnlimitedWater) { WaterSupply -= ShootCostPerSecond * Time.deltaTime; } } //Stop Water if (Input.GetMouseButtonUp(0) || WaterSupply <= 0 || IsDead) { Watergun.Deactivate(); GunMenuLock = false; } //Place Earth if (Input.GetMouseButtonDown(1) && Earth > 0 && !IsDead) { Vector3Int pos = Obstacles.WorldToCell(transform.position); if (Obstacles.GetTile(pos) == null && FlowerEarth.GetTile(pos) == null) { FlowerEarth.SetTile(pos, EarthTile); Earth--; FlowerEarth.RefreshAllTiles(); } } //Open Build Menu if (Input.GetKeyDown(KeyCode.Space) && !IsDead) { Vector3Int pos = FlowerEarth.WorldToCell(transform.position); if (Obstacles.GetTile(pos) == null && FlowerEarth.GetTile(pos) != null) { BuildMenu.Activate(); } } }