public RendererBG(float scaleFactor) { _textFormat = new StringFormat(); _textFormat.Alignment = StringAlignment.Center; _textFormat.LineAlignment = StringAlignment.Center; _map = new MapBG(scaleFactor, true, new Size(6, 6)); }
internal void OnDeserializedMethod(StreamingContext context) { //DiagManager.Instance.LogInfo(String.Format("GroundMap.OnDeserializedMethod(): Map {0} deserialized!", AssetName)); //recompute the grid grid = new AABB.Grid(Width, Height, GraphicsManager.TileSize); //TODO: v0.5: remove this if (Background == null) { Background = new MapBG(); } if (BlankBG == null) { BlankBG = new AutoTile(); } if (ActiveChar != null) { ActiveChar.OnDeserializeMap(this); signCharToMap(ActiveChar); } ReloadEntLayer(0); }
public Map() { AssetName = ""; Name = new LocalText(); Comment = ""; Music = ""; ScriptEvents = new Dictionary <LuaEngine.EDungeonMapCallbacks, ScriptEvent>(); TileSight = SightRange.Clear; CharSight = SightRange.Clear; TeamSpawns = new SpawnList <TeamSpawner>(); ItemSpawns = new CategorySpawnChooser <InvItem>(); Background = new MapBG(); BlankBG = new AutoTile(); MapEffect = new ActiveEffect(); CheckEvents = new List <SingleCharEvent>(); Status = new Dictionary <int, MapStatus>(); TextureMap = new Dictionary <int, AutoTile>(); CurrentTurnMap = new TurnState(); }
public static void FreshGarden(m_garden garden) { Debug.Log(garden.getName()); GameObject.Find("Canvas/map").GetComponent <Dropdown>().value = 0; GameObject.Find("HeatCanvas").transform.Find("painting/Scroll View/map/background/HeatMapT").gameObject.SetActive(false); GameObject.Find("HeatCanvas").transform.Find("painting/Scroll View/map/background/HeatMapH").gameObject.SetActive(false); MapBG.clearAll(); garden.cleanSensor(); garden.cleanController(); GetSensors(garden); GetControllers(garden); GetGardenInfo(garden); return; }
public GroundMap() { AssetName = ""; rand = new ReRandom(0); ScriptEvents = new Dictionary <LuaEngine.EMapCallbacks, ScriptEvent>(); Entities = new List <EntityLayer>(); Status = new Dictionary <int, MapStatus>(); Background = new MapBG(); BlankBG = new AutoTile(); Name = new LocalText(); Comment = ""; Music = ""; Layers = new List <MapLayer>(); Decorations = new List <AnimLayer>(); }
public static void GetControllers(m_garden garden) { List <controller> controllers = new List <controller>(); HTTPRequest request_getController = new HTTPRequest(new Uri(data.IP + "/getControllerByGardenId?gardenId=" + garden.getId()), HTTPMethods.Get, (req_controller, res_controller) => { Debug.Log(res_controller.DataAsText); JArray array = JArray.Parse(res_controller.DataAsText); foreach (var e in array) { controller temp = new controller(); temp.setId((long)e["id"]); temp.setName((string)e["name"]); temp.setX((int)e["x"] * data.width / garden.getLength()); temp.setY((int)e["y"] * data.length / garden.getWidth()); temp.setState((bool)e["valid"]); controllers.Add(temp); MapBG.drawOne(temp.getId(), temp.getName(), temp.getX(), temp.getY(), MapBG.SensorControllerType.Irrigation, temp.getState(), 0, 0, 0); } garden.addController(controllers); }).Send(); return; }
public static void GetSensors(m_garden garden) { List <sensor> sensors = new List <sensor>(); HTTPRequest request_getSensor1 = new HTTPRequest(new Uri(data.IP + "/getTemperatureSensorByGardenId?gardenId=" + garden.getId()), HTTPMethods.Get, (req_sensor1, res_sensor1) => { Debug.Log(res_sensor1.DataAsText); JArray array = JArray.Parse(res_sensor1.DataAsText); foreach (var e in array) { sensor temp = new sensor(); temp.setId((long)e["id"]); temp.setName((string)e["name"]); temp.setX((int)e["x"] * data.width / garden.getLength()); temp.setY((int)e["y"] * data.length / garden.getWidth()); temp.setType(true); sensors.Add(temp); } garden.addSensor(sensors); }).Send(); HTTPRequest request_getSensor2 = new HTTPRequest(new Uri(data.IP + "/getWetnessSensorByGardenId?gardenId=" + garden.getId()), HTTPMethods.Get, (req_sensor2, res_sensor2) => { Debug.Log(res_sensor2.DataAsText); JArray array = JArray.Parse(res_sensor2.DataAsText); foreach (var e in array) { sensor temp = new sensor(); temp.setId((long)e["id"]); temp.setName((string)e["name"]); temp.setX((int)e["x"] * data.width / garden.getLength()); temp.setY((int)e["y"] * data.length / garden.getWidth()); temp.setType(false); sensors.Add(temp); } garden.addSensor(sensors); }).Send(); HTTPRequest request_getSensorData1 = new HTTPRequest(new Uri(data.IP + "/getLatestTemperatureByGardenId?gardenId=" + garden.getId()), HTTPMethods.Get, (req_data1, res_data1) => { Debug.Log(res_data1.DataAsText); JArray array = JArray.Parse(res_data1.DataAsText); foreach (var e in array) { foreach (sensor n in garden.getSensors()) { if (n.getId() == (long)e["id"] && n.getType()) { n.setData((float)e["temperature"]); } } } foreach (sensor e in garden.getSensors()) { if (e.getType() && e.getData() != 0) { MapBG.drawOne(e.getId(), e.getName(), e.getX(), e.getY(), MapBG.SensorControllerType.Temperature, true, e.getData(), garden.getIdealTemperature() * (float)1.2, garden.getIdealTemperature() * (float)0.8); } else if (e.getType() && e.getData() == 0) { MapBG.drawOne(e.getId(), e.getName(), e.getX(), e.getY(), MapBG.SensorControllerType.Temperature, false, garden.getIdealTemperature(), garden.getIdealTemperature() * (float)1.2, garden.getIdealTemperature() * (float)0.8); } } }).Send(); HTTPRequest request_getSensorData2 = new HTTPRequest(new Uri(data.IP + "/getLatestWetnessByGardenId?gardenId=" + garden.getId()), HTTPMethods.Get, (req_data2, res_data2) => { Debug.Log(res_data2.DataAsText); JArray array = JArray.Parse(res_data2.DataAsText); foreach (var e in array) { foreach (sensor n in garden.getSensors()) { if (n.getId() == (long)e["id"] && !n.getType()) { n.setData((float)e["wetness"]); } } } foreach (sensor e in garden.getSensors()) { if (!e.getType() && e.getData() != 0) { MapBG.drawOne(e.getId(), e.getName(), e.getX(), e.getY(), MapBG.SensorControllerType.Humidity, true, e.getData(), garden.getIdealHumidity() * (float)1.2, garden.getIdealHumidity() * (float)0.8); } else if (!e.getType() && e.getData() == 0) { MapBG.drawOne(e.getId(), e.getName(), e.getX(), e.getY(), MapBG.SensorControllerType.Humidity, false, garden.getIdealHumidity(), garden.getIdealHumidity() * (float)1.2, garden.getIdealHumidity() * (float)0.8); } } }).Send(); return; }