/** * シュート */ private void OnScreenShot(Player.ColorType colorType, Vector3 position) { // シュート音再生 AudioSource audioSource = GetComponent <AudioSource>(); audioSource.PlayOneShot(SE_Shoot); // シュートしたプレイヤーのエントリー gameDirector.PlayerEntry(colorType); // カウントダウン開始していなければ if (Timer.gameObject.activeSelf == false) { // タイトル非表示 TitleArea.SetActive(false); // タイマーON Timer.gameObject.SetActive(true); } var index = (int)colorType; Ray ray = Camera.main.ScreenPointToRay(Camera.main.WorldToScreenPoint(position)); //Ray ray = new Ray(position, Camera.main.transform.forward); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit)) { InkSplashShaderBehavior script = hit.collider.gameObject.GetComponent <InkSplashShaderBehavior>(); if (null != script) { script.PaintOn(hit.textureCoord, SplashImages[index]); } } }
/** * Update is called once per frame */ void Update() { // counter更新 if (canCount && playSeconds >= 0f) { playSeconds -= Time.deltaTime; if (playSeconds < 1f) { playSeconds = 0f; gameDirector.Action(GameActionEvent.EventType.ChaserModeCountEnd); canCount = false; StartCoroutine(GameEnd()); } UpdateCounter((int)playSeconds); } // 着席モードでRキーで位置トラッキングをリセットする if (Input.GetKeyDown(KeyCode.R)) { SteamVR.instance.hmd.ResetSeatedZeroPose(); } // デバッグ用 マウス操作 var mousePos = Input.mousePosition; mousePos.z = 0.1f; var point = Camera.main.ScreenToWorldPoint(mousePos); gameDirector.HoverScreen(Player.ColorType.Pink, point); if (Input.GetMouseButtonDown(0)) { gameDirector.ShotScreen(Player.ColorType.Pink, point); Ray ray = Camera.main.ScreenPointToRay(Camera.main.WorldToScreenPoint(point)); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit)) { InkSplashShaderBehavior script = hit.collider.gameObject.GetComponent <InkSplashShaderBehavior>(); if (null != script && canCount) { var colorType = Player.ColorType.Pink; var index = (int)colorType; script.PaintOn(hit.textureCoord, SplashImages[index]); string hitTag = hit.collider.tag; gameDirector.AddScore(colorType); int score = gameDirector.GetScore(colorType); Scores[index].text = String.Format("{0}", score); } } } }
/** * スクリーンシュート */ private void OnScreenShot(Player.ColorType colorType, Vector3 position) { var index = (int)colorType; AudioSource audioSource = GetComponent <AudioSource>(); audioSource.PlayOneShot(SE_Shot); Ray ray = Camera.main.ScreenPointToRay(Camera.main.WorldToScreenPoint(position)); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit, scopeRange, InkedRayrMask)) { // 敵にヒット InkSplashShaderBehavior script = hit.collider.gameObject.GetComponent <InkSplashShaderBehavior>(); if (null != script && canCount) { script.PaintOn(hit.textureCoord, SplashImages[index]); SpScene3People hitscript = hit.collider.gameObject.GetComponentInParent <SpScene3People>(); HitpointHandler hitpointHandler = hit.collider.gameObject.GetComponentInParent <HitpointHandler>(); if (hitscript != null) { if (hitpointHandler != null) { hitpointHandler.Hit(); if (hitpointHandler.isDie()) { hitscript.DieOn(); } } else { hitscript.DieOn(); } } string hitTag = hit.collider.tag; gameDirector.AddScore(colorType); int score = gameDirector.GetScore(colorType); Scores[index].text = String.Format("{0}", score); } } }