コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        // 選択したマスが移動可能なマスであれば移動を開始する
        if ((Input.GetKeyDown(KeyCode.Return) || Input.GetButtonDown("O") || Input.GetKeyDown(KeyCode.Space)) && !moving_)
        {
            if (FindObjectOfType <BattleFlowTest>().state_ != State_.move_mode ||
                FindObjectOfType <BattleFlowTest>()._nowChooseChar != gameObject)
            {
                return;                                                                 // 10/31 追加
            }
            FindObjectOfType <RayBox>().move_ = false;

            Ray        ray = new Ray(rayBox.transform.position, -rayBox.transform.up);// 10/27 追加
            RaycastHit hit = new RaycastHit();
            if (Physics.Raycast(ray, out hit, 1000.0f))
            {
                if (hit.transform.tag == "Floor")
                {
                    Square_Info a = hit.transform.GetComponent <Square_Info>();
                    if (a.IsDecision())
                    {
                        Search(hit.transform.gameObject);
                        GameObject[] obj = GameObject.FindGameObjectsWithTag("Floor");
                        foreach (GameObject g in obj)
                        {
                            g.GetComponent <Square_Info>().DecisionEnd();
                        }
                    }
                }
                else if (hit.transform.tag == "Player")
                {
                    GameObject[] obj = GameObject.FindGameObjectsWithTag("Floor");
                    foreach (GameObject g in obj)
                    {
                        g.GetComponent <Square_Info>().DecisionEnd();
                    }
                    FindObjectOfType <BattleFlowTest>().moveEnd();
                }
            }
        }

        // 移動
        if (moving_)
        {
            Move();
        }
    }