void OnNormalMode() { if (Input.GetMouseButtonDown(0)) { isMouseMove = false; mouseDownPos = Input.mousePosition; } else if (!isMouseMove && Input.GetMouseButtonUp(0)) { SetGamePause(); int cityIdx = flagsCtrl.GetTouchCityIdx(); if (cityIdx != -1) { choiceTarget.AddCityTarget(cityIdx); SoundController.Instance.PlaySound("00038"); } for (int i = 0; i < Informations.Instance.armys.Count; i++) { if (Informations.Instance.armys[i].armyCtrl.GetTouchedFlag()) { choiceTarget.AddArmyTarget(Informations.Instance.armys[i]); SoundController.Instance.PlaySound("00038"); } } if (choiceTarget.targetList.GetCount() == 0) { ShowMainMenu(); } else { choiceTarget.Show(); } Input.ResetInputAxes(); } else if (Input.GetMouseButton(0)) { if (!isMouseMove) { Vector3 offset = mouseDownPos - Input.mousePosition; offset.Scale(scale); if (Mathf.Abs(offset.x) > 5 || Mathf.Abs(offset.y) > 5) { isMouseMove = true; mouseDownPos = Input.mousePosition; } } else { Vector3 offset = mouseDownPos - Input.mousePosition; mouseDownPos = Input.mousePosition; offset.Scale(scale); Vector3 pos = Camera.main.transform.position; pos += offset; pos.x = Mathf.Clamp(pos.x, -320, 320); pos.y = Mathf.Clamp(pos.y, -240, 240); Camera.main.transform.position = pos; } } }
// Update is called once per frame void Update() { if (Misc.GetBack()) { gameObject.SetActive(false); strCtrl.ReturnMainMode(); return; } if (Input.GetMouseButtonDown(0)) { isMouseMove = false; mouseDownPos = Input.mousePosition; } else if (!isMouseMove && Input.GetMouseButtonUp(0)) { int targetCity = flagsCtrl.GetTouchCityIdx(); if (targetCity != -1) { armyInfo.armyCtrl.SetRoute(path.GetRoute(armyInfo.armyCtrl.transform.position, targetCity)); armyInfo.armyCtrl.SetArmyRunning(); if (targetCity == armyInfo.cityFrom) { armyInfo.cityFrom = armyInfo.cityTo; } armyInfo.cityTo = targetCity; gameObject.SetActive(false); strCtrl.ReturnMainMode(); Input.ResetInputAxes(); } } else if (Input.GetMouseButton(0)) { if (!isMouseMove) { Vector3 offset = mouseDownPos - Input.mousePosition; offset.Scale(scale); if (Mathf.Abs(offset.x) > 5 || Mathf.Abs(offset.y) > 5) { isMouseMove = true; mouseDownPos = Input.mousePosition; /* * Vector3 pos = Camera.main.transform.position; * * pos += offset; * pos.x = Mathf.Clamp(pos.x, -320, 320); * pos.y = Mathf.Clamp(pos.y, -240, 240); * * Camera.main.transform.position = pos; */ } } else { Vector3 offset = mouseDownPos - Input.mousePosition; mouseDownPos = Input.mousePosition; offset.Scale(scale); Vector3 pos = Camera.main.transform.position; pos += offset; pos.x = Mathf.Clamp(pos.x, -320, 320); pos.y = Mathf.Clamp(pos.y, -240, 240); Camera.main.transform.position = pos; } } }