/// <summary> /// 添加记忆 /// </summary> /// <param name="go"></param> /// <param name="type"></param> public void AddMemory(GameObject go, Sensor.SensorType type) { MemoryItem memory = null; foreach (var item in m_AllMemory) { if (item.m_Go == go) { memory = item; break; } } if (memory == null) { memory = new MemoryItem(go, Time.time, m_CanMemoryTime, type); m_AllMemory.Add(memory); //记住这个对象 } else { memory.m_LastMemoryTime = Time.time; memory.m_MemoryTimeLeft = m_CanMemoryTime; memory.m_SensorType = type; }//如果已经记住过 则更新信息 }
public Sensor.SensorType m_SensorType; //被感知到的方式 public MemoryItem(GameObject go, float time, float timeleft, Sensor.SensorType type) { m_Go = go; m_LastMemoryTime = time; m_MemoryTimeLeft = timeleft; m_SensorType = type; }
public void Trigger(Sensor.SensorType t) { register = !register; if (register) { hub.SendToHub(this, t); } }
public void SendToHub(SensorMain s, Sensor.SensorType t) { //print(t.ToString() + " " + s.location.ToString()); if (s.location == SensorMain.SensorLocation.Entrance) { if (t == Sensor.SensorType.Enter) { inHouse++; } else { inHouse--; } } else if (s.location == SensorMain.SensorLocation.LivingRoom) { if (t == Sensor.SensorType.Enter) { inLivingRoom++; inKitchen--; } else { inLivingRoom--; inKitchen++; } } else if (s.location == SensorMain.SensorLocation.Kitchen) { if (t == Sensor.SensorType.Enter) { inKitchen++; } else { inKitchen--; } } if (inKitchen > 0) { kitchen.enabled = true; } else { kitchen.enabled = false; } if (inLivingRoom > 0) { livingRoom.enabled = true; } else { livingRoom.enabled = false; } if (inHouse == 0 || inLivingRoom + inKitchen == inHouse) { entrance.enabled = false; } else { entrance.enabled = true; } }