Equals() public method

Makes RoomInfo comparable (by name).
public Equals ( object p ) : bool
p object
return bool
Ejemplo n.º 1
0
    public static void VisualizeGeneration(GenerationInfo generation)
    {
        GameObject visualizedGeneration = new GameObject("Generation");

        visualizedGeneration.transform.position = new Vector3(0, 0, -201);
        for (int x = 0; x < generation.size.x; x++)
        {
            for (int y = 0; y < generation.size.y; y++)
            {
                if (generation.rooms[x, y] != null && generation.rooms[x, y].Position == new Vector2Int(x, y))
                {
                    RoomInfo   room       = generation.rooms[x, y];
                    GameObject roomObject = new GameObject("room");
                    roomObject.transform.parent = visualizedGeneration.transform;
                    roomObject.AddComponent <MeshFilter>().mesh             = GameManager.singleton.OnePlane;
                    roomObject.AddComponent <MeshRenderer>().material       = new Material(GameManager.singleton.GenerationMaterial);
                    roomObject.GetComponent <MeshRenderer>().material.color =
                        (room.Equals(generation.startRoom) || room.Equals(generation.endRoom) ? Color.green : Color.red) - new Color(0, 0, 0, 0.8f);
                    roomObject.transform.localPosition = new Vector3(x * 495, y * 277);
                    roomObject.transform.localScale    = new Vector3(room.Size.x * 495, room.Size.y * 277, 1);

                    foreach (GateInfo gate in room.Gates)
                    {
                        GameObject gateObject = new GameObject("gate");
                        gateObject.AddComponent <MeshFilter>().mesh             = GameManager.singleton.OnePlaneCenter;
                        gateObject.AddComponent <MeshRenderer>().material       = new Material(GameManager.singleton.GenerationMaterial);
                        gateObject.GetComponent <MeshRenderer>().material.color = Color.blue - new Color(0, 0, 0, 0.8f);
                        gateObject.transform.localScale = new Vector3(100, 100, 1);

                        Vector3 pos = gate.LocalPosition.x == 0 || gate.LocalPosition.x == 2 ? new Vector3() :
                                      gate.LocalPosition.x == 1 ? new Vector3(0, 277 * room.Size.y) :
                                      new Vector3(495 * room.Size.x, 0);
                        pos = new Vector3(
                            gate.LocalPosition.x == 0 || gate.LocalPosition.x == 1 ? 247.5f + 495f * gate.LocalPosition.y : pos.x,
                            gate.LocalPosition.x == 2 || gate.LocalPosition.x == 3 ? 138.5f + 277f * gate.LocalPosition.y : pos.y
                            );
                        gateObject.transform.localPosition = roomObject.transform.localPosition + pos + new Vector3(0, 0, -201f);
                        gateObject.transform.parent        = roomObject.transform;
                    }
                }
            }
        }
    }