public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ElectricDevice myScript = (ElectricDevice)target;


        if (GUILayout.Button("Turn on", GUILayout.Width(100)))
        {
            myScript.On();
        }

        if (GUILayout.Button("Turn off", GUILayout.Width(100)))
        {
            myScript.Off();
        }

        if (GUILayout.Button("Update", GUILayout.Width(100)))
        {
            myScript.update_energy();
        }

        if (GUILayout.Button("Reset meter", GUILayout.Width(100)))
        {
            myScript.reset_energy();
        }
    }
 //
 public void RefreshSlots()
 {
     ApplianceSlot[] slots = GetComponentsInChildren <ApplianceSlot>();
     foreach (ApplianceSlot slot in slots)
     {
         ElectricDevice removedDevice = slot.transform.GetComponent <ElectricDevice>();
     }
 }
Ejemplo n.º 3
0
    private void Deselect()
    {
        selectedDevice.Deselect();
        selectedDevice = null;
        canvasController.DeselectDevice();

        cameraController.StopFollow();
    }
 void Start()
 {
     if (devicesController == null)
     {
         devicesController = GetComponentInParent <ElectricDevicesController>();
     }
     if (device == null)
     {
         device = GetComponentInParent <ElectricDevice>();
     }
 }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        powertext.text = "";

        for (int i = 0; i < devicesController.devices.Length; i++)
        {
            ElectricDevice device = devicesController.devices[i];

            if (devicesController.selectedDevice == device)
            {
                powertext.text += "<b>" + device.name + " Power:" + " " + device.Power.ToString() + " kW" + "</b> " + "\n";
            }
            else
            {
                powertext.text += device.name + " Power: " + " " + device.Power.ToString() + " kW" + "\n";
            }
        }
    }
Ejemplo n.º 6
0
    public void Select(ElectricDevice device)
    {
        if (selectedDevice != device) // A new device will be selected
        {
            if (selectedDevice)
            {
                Deselect();
            }

            if (cameraController.MoveTo(device.transform))
            {
                device.Select();

                canvasController.Populate(device);
                selectedDevice = device;
            }
        }
        else
        { // The selected device is already selected, so deselect it
            Deselect();
        }
    }
 public void Populate(ElectricDevice electricDevice)
 {
     PopulateDataNode(electricDevice);
 }