예제 #1
0
    private void OnControllerColliderHit(ControllerColliderHit hit)
    {
        GameObject body = hit.gameObject;

        if (lastHit == body)
        {
            return;
        }
        lastHit = body;
        if (body.tag == "Floor" || body.tag == "End")
        {
            Floor floor = body.GetComponent <Floor>();

            if (floor.active == false)
            {
                foreach (GameObject element in floor.adjacents)
                {
                    if (element != null)
                    {
                        Floor adjacent = element.GetComponent <Floor>();
                        if (adjacent.active == true)
                        {
                            floorGraph.AddVertex(body.name);
                            floorGraph.AddBidirectionalEdge(new Edge <string>(body.name, element.name));
                            floor.active = true;
                            Material mat = body.GetComponent <Renderer>().material;
                            if (body.tag == "Floor")
                            {
                                mat.color = new Color(255, 255, 0);
                            }
                            else
                            {
                                mat.color = new Color(0, 255, 0);
                            }

                            break;
                        }
                    }
                }
            }
        }
        else if (body.tag == "Switch")
        {
            body.SendMessage("StartSwitch");
        }
    }