示例#1
0
 private void OnCollisionExit(Collision collision)
 {
     can.SetActive(false);
     if (can2 != null)
     {
         can2.SetActive(false);
         R1.SetActive(false);
     }
 }
示例#2
0
    private void OnCollisionStay(Collision collision)
    {
        if (collision.transform.tag == "Player")
        {
            int indie = collision.transform.GetComponent <UserMovement>().charIndexNumber;

            if (can2 != null)
            {
                R1.SetActive(true);
                if (Input.GetKeyDown(R1_[index[indie]]))
                {
                    Debug.Log("R1");
                    if (sw == 0)
                    {
                        sw++;
                    }
                    else
                    {
                        sw = 0;
                    }
                }
            }

            switch (sw)
            {
            case 0:

                can.SetActive(true);

                if (can2 != null)
                {
                    can2.SetActive(false);
                }

                if (Input.GetKeyDown(kb[index[indie]]))
                {
                    magnet.GetComponent <magMovement>().goTo(stationNames[0]);
                }
                if (Input.GetKeyDown(ka[index[indie]]))
                {
                    magnet.GetComponent <magMovement>().goTo(stationNames[1]);
                }

                if (Input.GetKeyDown(kc[index[indie]]))
                {
                    magnet.GetComponent <magMovement>().goTo(stationNames[2]);
                }

                if (Input.GetKeyDown(kd[index[indie]]))
                {
                    magnet.GetComponent <magMovement>().goTo(endNodeName);
                }
                break;

            case 1:

                can.SetActive(false);
                can2.SetActive(true);

                if (Input.GetKeyDown(kb[index[indie]]))
                {
                    magnet.GetComponent <magMovement>().goTo(stationNames[3]);
                }
                if (Input.GetKeyDown(ka[index[indie]]))
                {
                    magnet.GetComponent <magMovement>().goTo(stationNames[4]);
                }

                if (Input.GetKeyDown(kc[index[indie]]))
                {
                    magnet.GetComponent <magMovement>().goTo(stationNames[5]);
                }

                if (Input.GetKeyDown(kd[index[indie]]))
                {
                    magnet.GetComponent <magMovement>().goTo(endNodeName);
                }

                break;
            }
        }
    }