Esempio n. 1
0
    private Vector3 GetPositionFromTemperature(RoomSensor s1, RoomSensor s2, float temperature)
    {
        var sensor1Pos  = s1.pos;
        var sensor2Pos  = s2.pos;
        var sensor1temp = s1.temperature;
        var sensor2temp = s2.temperature;

        var sensorDistance      = Vector3.Distance(sensor1Pos, sensor2Pos);
        var distanceFromSensor1 = sensorDistance * (temperature - sensor1temp) / (sensor2temp - sensor1temp);

        var target = Vector3.MoveTowards(sensor1Pos, sensor2Pos, distanceFromSensor1);

        return(target);
    }
Esempio n. 2
0
 private IEnumerator pollRoomSensor(RoomSensor sensor)
 {
     while (true)
     {
         StartCoroutine(api.GetSensors(sensor.id, (temp) =>
         {
             sensor.temperature    = temp;
             sensor.tempLabel.text = (temp + tempSuffix);
             if (temp > 15)
             {
                 sensor.tempLight.color = warmColor;
             }
             else
             {
                 sensor.tempLight.color = coldColor;
             }
         }));
         yield return(new WaitForSeconds(3f));
     }
 }
 private void Awake()
 {
     parentTransform = transform.parent;
     roomSensor      = parentTransform.GetComponentInChildren <RoomSensor>();
 }