// Update is called once per frame void Update() { // androidであれば無視する(暫定対応) if (Application.platform != RuntimePlatform.Android) { if (Input.GetMouseButton(0)) { if (this.pressAimPanelFlg == false && IsAimPositionInFrame(Input.mousePosition) == true) { //複数playerタグがあると意図した動作にならないので、そうするならFindGameObjects~にしてforeachで回す //また実際は、切り替えた段階でオブジェクト作成した方が効率的かも(変更フラグ立てるだけでもよいかも) //途中で変わるパターンもあって、作ってみないとわからないため保留 this.pressAimPanelFlg = true; //PCの場合はタッチID -1 固定 playerMain.StartFire(); playerMain.SetPlayerAngle(this.GetAimAngle(Input.mousePosition)); } else if (this.pressAimPanelFlg == true) { playerMain.SetPlayerAngle(this.GetAimAngle(Input.mousePosition)); this.MoveAimPanel(Input.mousePosition); } } if (Input.GetMouseButtonUp(0)) { if (this.pressAimPanelFlg == true) { this.pressAimPanelFlg = false; playerMain.EndFire(); aimPanelObject.transform.position = this.aimPanelInitialPosition; } } } if (Input.touchCount > 0) { for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); switch (touch.phase) { case TouchPhase.Began: if (this.pressAimPanelFingerId == -1 && IsAimPositionInFrame(touch.position) == true) { this.pressAimPanelFingerId = touch.fingerId; //複数playerタグがあると意図した動作にならないので、そうするならFindGameObjects~にしてforeachで回す //また実際は、切り替えた段階でオブジェクト作成した方が効率的かも(変更フラグ立てるだけでもよいかも) //途中で変わるパターンもあって、作ってみないとわからないため保留 this.pressAimPanelFlg = true; playerMain.StartFire(); playerMain.SetPlayerAngle(this.GetAimAngle(touch.position)); } break; case TouchPhase.Moved: if (this.pressAimPanelFingerId == touch.fingerId) { playerMain.SetPlayerAngle(this.GetAimAngle(touch.position)); this.MoveAimPanel(touch.position); } break; case TouchPhase.Ended: case TouchPhase.Canceled: if (this.pressAimPanelFingerId == touch.fingerId) { this.pressAimPanelFlg = false; playerMain.EndFire(); aimPanelObject.transform.position = this.aimPanelInitialPosition; // -1 で FingerId を初期化する this.pressAimPanelFingerId = -1; } break; default: break; } } } }