// Update is called once per frame void Update() { if (dlg.Active == true) { return; } if (birdEye.enabled == true) { int i = Enumerable.Range(1, 2).FirstOrDefault(v => Input.GetMouseButtonDown(v - 1)); if (i != 0) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity)) { Blocks.BlockObj target = blocks.Find(hit.collider.gameObject); if (i == 2 && target != null) { blocks.RemoveBlock(target); } else if (i == 1 && gameObject == hit.collider.gameObject) { int[] index = blocks.GetBlockIndexXZ(hit.point); blocks.CreateBlock(index [0], index [1]); } } } } timer += Time.deltaTime; timerText.GetComponent <Text>().text = timer.ToString("0.0"); }
// Update is called once per frame void Update() { if (dlg.Active == true) { return; } // グローバル視点のときだけ壁が作れるようになる処理 if (birdEye.enabled == true) { // クリック処理 この処理はあやふや int i = Enumerable.Range(1, 2).FirstOrDefault(v => Input.GetMouseButtonDown(v - 1)); if (i != 0) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity)) { Blocks.BlockObj target = blocks.Find(hit.collider.gameObject); if (i == 2 && target != null) { // 少し追いつけてないかもしれないFindメソッドから何が取られているかが明確じゃない blocks.RemoveBlock(target); reRoute = true; } //以下のgameObjectはfloorにアタッチしているためフロアが入っていることになる else if (i == 1 && gameObject == hit.collider.gameObject) { int[] index = blocks.GetBlockIndexXZ(hit.point); blocks.CreateBlock(index[0], index[1]); reRoute = true; } } } } timer += Time.deltaTime; timerText.GetComponent <Text>().text = timer.ToString("0.0"); foreach (var item in items) { if (false == item.Value.Next(Time.deltaTime)) { item.Value.End(); } } // Debug.Log(blocks.xz2i(objPositions[enemyName])); // プレイヤーからゴールまでの経路を指定している // objPositions[playerName]がずっと初期値のままだから変わらない // 教材のミスがあるっぽい // List<int> route = blocks.Solve(blocks.xz2i(objPositions[playerName]), blocks.xz2i(objPositions[goalName])); // routeRenderer.Render(route, i => blocks.GetBlockPosition(i)); }
// Update is called once per frame void Update() { if (dlg.Active == true) { return; } /* * List<int> route = blocks.Solve(blocks.xz2i(objPositions[playerName]), blocks.xz2i(objPositions[goalName])); * routeRenderer.Render(route, i => blocks.GetBlockPosition(i)); */ if (birdEye.enabled == true) { int i = Enumerable.Range(1, 2).FirstOrDefault(v => Input.GetMouseButtonDown(v - 1)); if (i != 0) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity)) { Blocks.BlockObj target = blocks.Find(hit.collider.gameObject); if (i == 2 && target != null) { blocks.RemoveBlock(target); reRoute = true; } else if (i == 1 && gameObject == hit.collider.gameObject) { int[] index = blocks.GetBlockIndexXZ(hit.point); blocks.CreateBlock(index[0], index[1]); reRoute = true; } } } } timer += Time.deltaTime; timerText.GetComponent <Text>().text = timer.ToString("0.0"); foreach (var item in items) { if (false == item.Value.Next(Time.deltaTime)) { item.Value.End(); } } }