void Update() { Ray ray = viewCamera.ScreenPointToRay(Input.mousePosition); Plane groundPlane = new Plane(Vector3.up, Vector3.zero); float rayDistance; if (groundPlane.Raycast(ray, out rayDistance)) { Vector3 point = ray.GetPoint(rayDistance); LookAt(point); } if (Input.GetButton("Shoot")) { gunController.OnTriggerHold(); } if (Input.GetButtonUp("Shoot")) { gunController.OnTriggerRelease(); } if (Input.GetButtonDown("Change Weapon")) { gunController.ChangeGun(); } if (Input.GetButton("Reload")) { gunController.equippedGun.GetComponent <Gun>().ForceReload(); } if (Input.GetButtonDown("Fire2")) { gunController.ChangeFireMode(); } }
void ChangeGun(int gunIndex, PlayerGunType type) { GunController.ChangeGun(gunIndex, type); }
void OnGUI() { if (!isShowPick) { return; } var topleft = Camera.main.ViewportToScreenPoint(new Vector3(0.35f, 0.2f, 0)); var size = Camera.main.ViewportToScreenPoint(new Vector3(0.3f, 0.4f)); var area = new Rect( topleft.x, topleft.y, size.x, size.y); GUILayout.BeginArea(area, "", "box"); { GUILayout.BeginHorizontal(); { //GUILayout.FlexibleSpace(); var labelStyle = new GUIStyle(GUI.skin.GetStyle("label")); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.fontSize = 30; GUILayout.Label( "銃を拾った!", labelStyle); //GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal("box", GUILayout.MinHeight(100)); { GUILayout.BeginVertical(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("左手に装備")) { GunController.ChangeGun(0, gun.Type); KillMe(); } GUILayout.FlexibleSpace(); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); { GUILayout.FlexibleSpace(); IconDrawer.Instance.DrawGun(gun); GUILayout.FlexibleSpace(); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("右手に装備")) { GunController.ChangeGun(1, gun.Type); KillMe(); } GUILayout.FlexibleSpace(); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); var buttonStyle = new GUIStyle(GUI.skin.GetStyle("button")); buttonStyle.fontSize = 16; if (GUILayout.Button("いらない", buttonStyle, GUILayout.MinHeight(50))) { isShowPick = false; //BroadcastAll("OnPickWindowClose"); PauseCounter.Instance.Decrement(); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } GUILayout.EndArea(); ToolTip(); }