// GET: region/Details/5 public ActionResult Details(int?id) { if (id == null) { return(RedirectToAction("Index")); } region region = db.region.Find(id); List <municipio_region> lstmunicipiosRegion = new List <municipio_region>(); lstmunicipiosRegion = db.municipio_region.Where(z => z.codigo_region == id).ToList(); List <municipio> lstMunicipios = new List <municipio>(); List <municipio> lstMunicipios_2 = new List <municipio>(); lstMunicipios = db.municipio.Where(x => x.estado == true).ToList(); //solo activos foreach (municipio item in lstMunicipios) { if (lstmunicipiosRegion.FindAll(x => x.codigo_municipio == item.codigo).Count == 1) { lstMunicipios_2.Add(item); } } ViewBag.lstMunicipios = lstMunicipios_2; if (region == null) { return(HttpNotFound()); } return(View(region)); }
/// <summary> /// Put this initializer somewhere after all players have been initialized. Do this only after you have put all customtypes in the dictionary. /// </summary> internal static void InitUnitLogic() { region reg = CreateRegion(); group g = CreateGroup(); rect rec = GetWorldBounds(); RegionAddRect(reg, rec); TriggerRegisterEnterRegion(CreateTrigger(), reg, Filter(AttachClass)); // Add existing units GroupEnumUnitsInRect(g, rec, Filter(AttachClass)); // Deattach when unit leaves the map TriggerRegisterLeaveRegion(CreateTrigger(), reg, Filter(() => { ((NoxUnit)GetLeavingUnit()).Remove(); return(false); })); // catch unit removal, destroy everything attached // Utility functions TimerStart(CreateTimer(), RegenerationTimeout, true, () => { foreach (NoxUnit ue in Indexer.Values) { ue.Regenerate(); } }); // Recycle stuff DestroyGroup(g); g = null; rec = null; reg = null; }
public List <region> select() { string sql = "select * from region_code"; List <region> columns = new List <region>(); try { mycon.Open(); MySqlCommand mycmd = new MySqlCommand(sql, mycon); MySqlDataReader reader = mycmd.ExecuteReader(); List <List <string> > itemList = new List <List <string> >(); int count = 0; while (reader.Read()) { count++; try { string code = reader.GetString("code"); string name = reader.GetString("name"); region reg = new region(code, name); columns.Add(reg); } catch (System.Exception) { columns.Add(null); } } return(columns); } finally { mycon.Close(); } }
// Destroy a road public void destroy_road() { dest = null; // Destroy the outgoing road (visually) road_renderer.enabled = false; }
public IHttpActionResult post([FromBody] region regions) { try { if (string.IsNullOrEmpty(regions.name)) { ModelState.AddModelError("name", "Name is Required"); } if (ModelState.IsValid) { using (Count10_DevEntities entities = new Count10_DevEntities()) { regions.active = regions.active.HasValue ? regions.active : true; regions.archived = regions.archived.HasValue ? regions.archived : false; regions.updated_by = regions.updated_by.HasValue ? regions.updated_by : 1; regions.created_by = regions.created_by.HasValue ? regions.created_by : 1; regions.created_at = DateTime.Now; regions.updated_at = DateTime.Now; entities.regions.Add(regions); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, regions); } return(Ok(regions)); } return(BadRequest(ModelState)); } catch (Exception) { return(BadRequest(ModelState)); } }
public ActionResult EditRegion(EditRegion ae) { if (ModelState.IsValid) { using (mmpEntities mP = new mmpEntities()) { #region Region Already exists var isRegionExists = IsRegionExist(ae.region_name); if (isRegionExists) { ModelState.AddModelError("RegionExists", "Region already exists"); return(View(ae)); } #endregion region region = new region() { region_id = ae.region_id, region_name = ae.region_name }; mP.Entry(region).State = EntityState.Modified; mP.SaveChanges(); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } return(View()); }
// Returns the nearest region in the "dir" direction. Returns null if none exists private static region raycast_to_region(Vector2 src, Vector2 dir, GameObject exclude) { List <RaycastHit2D> results = new List <RaycastHit2D>(); Physics2D.Raycast(src, dir, contactFilter, results); GameObject closest = null; float min_dist = float.MaxValue; foreach (RaycastHit2D hit in results) { if (hit.collider != null && hit.collider.gameObject != exclude && hit.distance < min_dist) { closest = hit.collider.gameObject; min_dist = hit.distance; } } if (closest != null) { region hit_region = closest.GetComponent <region>(); if (hit_region != null) { return(hit_region); } } // Otherwise, we hit nothing, or a "blocker" region return(null); }
public HttpResponseMessage put(int id, [FromBody] region regions) { try { using (Count10_DevEntities entities = new Count10_DevEntities()) { var entity = entities.regions.FirstOrDefault(e => e.id == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Region with Id = " + id.ToString() + " not found to edit")); } else { entity.name = regions.name; entity.alt_name = regions.alt_name; entity.parent_id = regions.parent_id; entity.organization_id = regions.organization_id; entity.notes = regions.notes; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public async Task <IActionResult> Edit(int id, [Bind("regionId,nombreRegion,tarifaEnvioId")] region region) { if (id != region.regionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(region); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!regionExists(region.regionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["tarifaEnvioId"] = new SelectList(_context.tarifaEnvios, "tarifaEnvioId", "tarifaEnvioId", region.tarifaEnvioId); return(View(region)); }
public async Task <ActionResult <region> > Postregion(region region) { _context.regions.Add(region); await _context.SaveChangesAsync(); return(CreatedAtAction("Getregion", new { id = region.id }, region)); }
public async Task <IActionResult> Putregion(int id, region region) { if (id != region.id) { return(BadRequest()); } _context.Entry(region).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!regionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult AddRegions(List <AddRegion> regions) { if (ModelState.IsValid) { using (mmpEntities mP = new mmpEntities()) { mP.Configuration.ProxyCreationEnabled = false; foreach (var i in regions) { #region Region Already exists var isRegionExists = IsRegionExist(i.region_name); if (isRegionExists) { ModelState.AddModelError("RegionExists", "Region already exists"); return(View(regions)); } #endregion region region = new region() { region_name = i.region_name }; mP.regions.Add(region); } mP.SaveChanges(); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } } else { return(View(regions)); } }
// GET: region/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index")); } region region = db.region.Find(id); List <municipio_region> lstmunicipiosRegion = new List <municipio_region>(); lstmunicipiosRegion = db.municipio_region.Where(z => z.codigo_region == id).ToList(); //Lista de municipios asocaciados a la region List <municipio> lstMunicipios = new List <municipio>(); List <municipio> lstMunicipios_2 = new List <municipio>(); lstMunicipios = db.municipio.Where(x => x.estado == true).ToList(); //solo activos foreach (municipio item in lstMunicipios) { if (lstmunicipiosRegion.FindAll(x => x.codigo_municipio == item.codigo).Count == 0) { lstMunicipios_2.Add(item); // Añadimos solo los municipios que no estran asociados a la region } } if (region == null) { return(HttpNotFound()); } ViewBag.lstmunicipiosRegion = lstmunicipiosRegion; ViewBag.lstMunicipios = lstMunicipios_2; ViewBag.lstMunicipios_Completo = lstMunicipios; return(View(region)); }
public ChampionRotation GetChampionRotation(region region, bool onlyFreeToPlay = true, bool useCaching = false) { ChampionRotation val = Cache.Get <ChampionRotation>(region.ToString(), onlyFreeToPlay.ToString()); //cache getting if (val != null) { return(val); } RiotApiCaller <ChampionRotation> caller = new RiotApiCaller <ChampionRotation>(suffix.championRotation); caller.AddParam(param.region, region); caller.AddParam(param.freeToPlay, onlyFreeToPlay); if (useCaching) { Cache.AddOrUpdate(caller.CreateRequest(new System.TimeSpan(0, 22, 0))); } else { caller.CreateRequest(); } return(caller.Result.FirstOrDefault()); }
async private Task Initialize(Repository repo, form summaryForm, int year) { var region = await repo.GetRegion(Authentication.Credentials.RegionId); _formula = await repo.GetFormulasBySummaryForm(summaryForm.form_id); this.IsAvailable = (_formula != null); if (this.IsAvailable) { _region = region; _summaryForm = summaryForm; _regularForm = _formula.regular_form; _year = year; var municipalityList = await repo.GetMunicipalities(); var municipalitiesHaveFormData = await repo.GetMunicipalitiesHaveFormData(_regularForm.form_id, _year); var municipalitiesHaveFormDataIdList = municipalitiesHaveFormData .Select(t => t.municipality_id) .ToList(); foreach (var munit in municipalityList) { var hasForm = municipalitiesHaveFormDataIdList.Contains(munit.municipality_id); munit.SetAttachedProperty("bHasForm", hasForm); } this.municipalityBindingSource.DataSource = municipalityList; } }
public Mastery GetMastery(int masteryId, region region, language lang, masteryListData?masteryData = null, bool useCaching = false) { Mastery val = Cache.Get <Mastery>(masteryId.ToString(), region.ToString(), lang.ToString(), masteryData.ToString()); //cache getting if (val != null) { return(val); } RiotApiCaller <Mastery> caller = new RiotApiCaller <Mastery>(suffix.masteryById); caller.AddParam(param.region, region); caller.AddParam(param.locale, lang); caller.AddParam(param.id, masteryId); if (masteryData != null) { caller.AddParam(param.masteryData, masteryData); } else { caller.AddParam(param.masteryData, ""); //important for basic information } if (useCaching) //your choice { Cache.AddOrUpdate(caller.CreateRequest(new System.TimeSpan(1, 0, 0, 0))); // cache adding } else { caller.CreateRequest();//everytime data coming from riotgames server } return(caller.Result.FirstOrDefault()); }
public SummonerSpellList GetSummonerSpells(region region, language lang, spellData?spellData = null, bool useCaching = false) { SummonerSpellList val = Cache.Get <SummonerSpellList>(region.ToString(), lang.ToString(), spellData.ToString()); //cache getting if (val != null) { return(val); } RiotApiCaller <SummonerSpellList> caller = new RiotApiCaller <SummonerSpellList>(suffix.summonerSpells); caller.AddParam(param.region, region); caller.AddParam(param.locale, lang); if (spellData != null) { caller.AddParam(param.spellData, spellData); } else { caller.AddParam(param.spellData, ""); //important for basic information } if (useCaching) //your choice { Cache.AddOrUpdate(caller.CreateRequest(new System.TimeSpan(1, 0, 0, 0))); // cache adding } else { caller.CreateRequest();//everytime data coming from riotgames server } return(caller.Result.FirstOrDefault()); }
public ItemData GetItem(long itemId, region region, language lang, itemListData?itemData = null, bool useCaching = false) { ItemData val = Cache.Get <ItemData>(itemId.ToString(), region.ToString(), lang.ToString(), itemData.ToString()); //cache getting if (val != null) { return(val); } RiotApiCaller <ItemData> caller = new RiotApiCaller <ItemData>(suffix.item); caller.AddParam(param.region, region); caller.AddParam(param.locale, lang); caller.AddParam(param.id, itemId); if (itemData != null) { caller.AddParam(param.itemData, itemData.Value); } else { caller.AddParam(param.itemData, ""); //important for basic information } if (useCaching) //your choice { Cache.AddOrUpdate(caller.CreateRequest(new System.TimeSpan(1, 0, 0, 0))); // cache adding } else { caller.CreateRequest();//everytime data coming from riotgames server } return(caller.Result.FirstOrDefault()); }
public RuneList GetRunes(region region, language lang, runeListData runeData = runeListData.basic, bool useCaching = false) { RuneList val = Cache.Get <RuneList>(region.ToString(), lang.ToString(), runeData.ToString()); //cache getting if (val != null) { return(val); } RiotApiCaller <RuneList> caller = new RiotApiCaller <RuneList>(suffix.runes); caller.AddParam(param.region, region); caller.AddParam(param.locale, lang); caller.AddParam(param.runeListData, runeData); if (useCaching) //your choice { Cache.AddOrUpdate(caller.CreateRequest(new System.TimeSpan(1, 0, 0, 0))); // cache adding } else { caller.CreateRequest();//everytime data coming from riotgames server } return(caller.Result.FirstOrDefault()); }
public IHttpActionResult AddRegion() { region r = new region() { Name = "Aguascalientes", Description = "[Insertar descripción]", AreaLimitsText = "[Insertar Area Límite]", Enabled = true }; db.regions.Add(r); db.SaveChanges(); return Ok(r); }
public Team GetTeam(long teamId, region region, bool useCaching = false) { Team val = Cache.Get <Team>(teamId.ToString(), region.ToString()); //cache getting if (val != null) { return(val); } List <Team> result = GetTeams(new List <long>() { teamId }, region); if (result.Count > 0) { if (useCaching) { Cache.AddOrUpdate(new cacheObject <Team>(new cacheParam <Team>(teamId, region), result.FirstOrDefault(), new TimeSpan(0, 22, 0))); } return(result.FirstOrDefault()); } else { return(null); } }
public async Task <IActionResult> Disable(int id) { region b = _context.regions.FirstOrDefault(u => u.id == id && u.status == true); if (b != null) { b.status = false; } else { b = null; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!regionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult Putregion(int id, region region) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != region.ID) { return(BadRequest()); } db.Entry(region).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!regionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public player GetPlayerProfile(string name, region reg) { string url = ENDPOINT_API + regStr(reg) + $"/{name}/complete"; JObject obj = JObject.Parse(client.GetAsync(url).Result.Content.ReadAsStringAsync().Result); JArray rls = JArray.Parse(obj["ratings"].ToString()); role[] roles = new role[rls.Count]; byte i = 0; foreach (var r in rls) { roles[i] = new role { name = r["role"].ToString(), level = int.Parse(r["level"].ToString()) }; } return(new player { profile = new profile { endorsement = int.Parse(obj["endorsement"].ToString()), name = obj["name"].ToString(), level = int.Parse(obj["level"].ToString()), prestige = int.Parse(obj["prestige"].ToString()), rating = int.Parse(obj["rating"].ToString()), ratings = roles }, }); }
public ChampionStatus GetChampionRotationById(region region, long championId, bool useCaching = false) { ChampionStatus val = Cache.Get <ChampionStatus>(championId.ToString(), region.ToString()); //cache getting if (val != null) { return(val); } RiotApiCaller <ChampionStatus> caller = new RiotApiCaller <ChampionStatus>(suffix.championRotationId); caller.AddParam(param.region, region); caller.AddParam(param.id, championId); if (useCaching) { Cache.AddOrUpdate(caller.CreateRequest(new System.TimeSpan(0, 22, 0))); } else { caller.CreateRequest(); } return(caller.Result.FirstOrDefault()); }
public player GetPlayer(string name, region reg) { string url = ENDPOINT_API + regStr(reg) + $"/{name}/complete"; JObject obj = JObject.Parse(client.GetAsync(url).Result.Content.ReadAsStringAsync().Result); JToken quickCr = obj["quickPlayStats"]["careerStats"]["allHeroes"]["average"]; JToken compCr = obj["competitiveStats"]["careerStats"]["allHeroes"]["average"]; JArray rls = JArray.Parse(obj["ratings"].ToString()); role[] roles = new role[rls.Count]; byte i = 0; foreach (var r in rls) { roles[i] = new role { name = r["role"].ToString(), level = r["level"].Value <int>() }; } return(new player { profile = new profile { endorsement = obj["endorsement"].Value <int>(), name = obj["name"].ToString(), level = obj["level"].Value <int>(), prestige = obj["prestige"].Value <int>(), rating = obj["rating"].Value <int>(), ratings = roles }, quickCareer = new careerStats { allDamageDone = quickCr["allDamageDoneAvgPer10Min"].Value <float>(), barrierDamageDone = quickCr["barrierDamageDoneAvgPer10Min"].Value <float>(), deaths = quickCr["deathsAvgPer10Min"].Value <float>(), eliminations = quickCr["eliminationsAvgPer10Min"].Value <float>(), finalBlows = quickCr["finalBlowsAvgPer10Min"].Value <float>(), healingDone = quickCr["healingDoneAvgPer10Min"].Value <float>(), heroDamageDone = quickCr["heroDamageDoneAvgPer10Min"].Value <float>(), objectiveKills = quickCr["objectiveKillsAvgPer10Min"].Value <float>(), objectiveTime = quickCr["objectiveTimeAvgPer10Min"].ToString(), soloKills = quickCr["soloKillsAvgPer10Min"].Value <float>(), timeSpentOnFire = quickCr["timeSpentOnFireAvgPer10Min"].ToString() }, compCareer = new careerStats { allDamageDone = compCr["allDamageDoneAvgPer10Min"].Value <float>(), barrierDamageDone = compCr["barrierDamageDoneAvgPer10Min"].Value <float>(), deaths = compCr["deathsAvgPer10Min"].Value <float>(), eliminations = compCr["eliminationsAvgPer10Min"].Value <float>(), finalBlows = compCr["finalBlowsAvgPer10Min"].Value <float>(), healingDone = compCr["healingDoneAvgPer10Min"].Value <float>(), heroDamageDone = compCr["heroDamageDoneAvgPer10Min"].Value <float>(), objectiveKills = compCr["objectiveKillsAvgPer10Min"].Value <float>(), objectiveTime = compCr["objectiveTimeAvgPer10Min"].ToString(), soloKills = compCr["soloKillsAvgPer10Min"].Value <float>(), timeSpentOnFire = compCr["timeSpentOnFireAvgPer10Min"].ToString() } }); }
public MatchDetail GetMatchDetail(long matchId, region region, bool includeTimeline = false, bool useCaching = false) { MatchDetail val = Cache.Get <MatchDetail>(matchId.ToString(), region.ToString(), includeTimeline.ToString()); //cache getting if (val != null) { return(val); } RiotApiCaller <MatchDetail> caller = new RiotApiCaller <MatchDetail>(suffix.matchdetail); caller.AddParam(param.matchId, matchId); caller.AddParam(param.region, region); caller.AddParam(param.includeTimeline, includeTimeline); if (useCaching) { Cache.AddOrUpdate(caller.CreateRequest(new TimeSpan(0, 22, 0))); } else { caller.CreateRequest(); } return(caller.Result.FirstOrDefault()); }
public Summoner GetSummoner(long summonerId, region region, bool useCaching = false) { Summoner val = Cache.Get <Summoner>(summonerId.ToString(), region.ToString()); //cache getting if (val != null) { return(val); } List <Summoner> result = GetSummoners(new List <long>() { summonerId }, region); if (result.Count > 0) { if (useCaching) { Cache.AddOrUpdate(new cacheObject <Summoner>(new cacheParam <Summoner>(summonerId, region), result.FirstOrDefault(), new TimeSpan(0, 22, 0))); } return(result.FirstOrDefault()); } else { return(null); } }
public Champions GetChampions(region region, language lang, champData?chamData = null, bool useCaching = false) { Champions val = Cache.Get <Champions>(region.ToString(), lang.ToString(), chamData.ToString()); //cache getting if (val != null) { return(val); } RiotApiCaller <Champions> caller = new RiotApiCaller <Champions>(suffix.champions); caller.AddParam(param.region, region); caller.AddParam(param.locale, lang); if (chamData != null) { caller.AddParam(param.champData, chamData.Value); } else { caller.AddParam(param.champData, ""); //important for basic information } if (useCaching) //your choice { Cache.AddOrUpdate(caller.CreateRequest(new System.TimeSpan(1, 0, 0, 0))); // cache adding } else { caller.CreateRequest();//everytime data coming from riotgames server } return(caller.Result.FirstOrDefault()); }
public List <ChampionMastery> GetChampionMasteryTop(long playerId, region region, int count = 3) { return(new Summoner() { Id = playerId, Region = region } .GetChampionTop(count)); }
public ChampionMastery GetChampionMastery(long playerId, long championId, region region) { return(new Summoner() { Id = playerId, Region = region } .GetChampionMastery(championId)); }
public int GetChampionMasteryScore(long playerId, region region) { return(new Summoner() { Id = playerId, Region = region } .GetChampionScore()); }
unsafe public bool valid(region a) { throw new NotImplementedException(); }
public region(region reg) { ID = reg.ID; CellRefs = new ArrayList(reg.CellRefs); }
unsafe public static bool overlaps(region a, region b) { return !disuniont(a, b); }
unsafe public static bool disuniont(region a, region b) { throw new NotImplementedException(); }
unsafe public static region intersection(region a, region b) { throw new NotImplementedException(); }
unsafe public static region difference(region a, region b) { throw new NotImplementedException(); }
protected override DHJassValue Run() { region r = new region(); return new DHJassHandle(null, r.handle); }
unsafe public static bool isin(void* ptr, region region) { throw new NotImplementedException(); }
IEnumerator GenerateRoom() { region tempRegion; bool fits; int roomWidth, roomHeight; int roomX, roomY; for (int indx = 0; indx < roomGenIterations; indx++) { tempRegion = new region (regions.Count); fits = true; // Random room size roomWidth = Random.Range (minRoomSize, maxRoomSize)-1; roomHeight = Random.Range (minRoomSize, maxRoomSize)-1; // Random room place roomX = Random.Range (1, width + 1 - roomWidth); roomY = Random.Range (1, height + 1 - roomHeight); // See if room fits for (int pWidth = roomX; pWidth <= roomX + roomWidth; pWidth++) { for (int pHeight = roomY; pHeight <= roomY + roomHeight; pHeight++) { if (dungeon [pWidth, pHeight].Type != CellType.empty) fits = false; } } if (fits == true) { for (int pWidth = roomX; pWidth <= roomX + roomWidth; pWidth++) { for (int pHeight = roomY; pHeight <= roomY + roomHeight; pHeight++) { dungeon [pWidth, pHeight].Type = CellType.room; dungeon [pWidth, pHeight].MyRegion = tempRegion.ID; tempRegion.AddCellRefToRegion ((Vector2)dungeon [pWidth, pHeight].Pos); // Remove inner walls dungeon [pWidth, pHeight].walls [0] = false; dungeon [pWidth, pHeight].walls [1] = false; dungeon [pWidth, pHeight].walls [2] = false; dungeon [pWidth, pHeight].walls [3] = false; // Set room edges to Walls if (pHeight == roomY + roomHeight) dungeon [pWidth, pHeight].walls [0] = true; if (pWidth == roomX + roomWidth) dungeon [pWidth, pHeight].walls [1] = true; if (pHeight == roomY) dungeon [pWidth, pHeight].walls [2] = true; if (pWidth == roomX) dungeon [pWidth, pHeight].walls [3] = true; yield return StartCoroutine (UpdateDungeon(pWidth,pHeight)); } } regions.Add (tempRegion); } } }
public QueryReportRegionData(region region, query query, object data) : base (query, data) { this.Region = region; }
IEnumerator GenerateMaze() { region tempRegion = new region(regions.Count); int selectedDir = 0; ArrayList possibleMoves = new ArrayList(); ArrayList pathList = new ArrayList(); Vector2 currentCell; // Check every cell for unused space to ensure whole map is filled. for (int pWidth = 0; pWidth <= width; pWidth++){ for (int pHeight = 0; pHeight <= height; pHeight++){ if (dungeon[pWidth,pHeight].Type == CellType.empty ) { currentCell = new Vector2(pWidth,pHeight); pathList.Add(currentCell); while (pathList.Count != 0){ // Assign new values to cell { dungeon[(int)currentCell.x,(int)currentCell.y].Type = CellType.hallway; dungeon[(int)currentCell.x,(int)currentCell.y].MyRegion = tempRegion.ID; tempRegion.AddCellRefToRegion(currentCell); possibleMoves.Clear(); if (currentCell.y+1 <= height && dungeon[(int)currentCell.x,(int)currentCell.y+1].Type == CellType.empty) { if (straightHalls && selectedDir == 0){ possibleMoves.Add(0); possibleMoves.Add(0); } possibleMoves.Add(0); } if (currentCell.x+1 <= width && dungeon[(int)currentCell.x+1,(int)currentCell.y].Type == CellType.empty) { if (straightHalls && selectedDir == 1){ possibleMoves.Add(1); possibleMoves.Add(1); } possibleMoves.Add(1); } if (currentCell.y-1 >= 0 && dungeon[(int)currentCell.x,(int)currentCell.y-1].Type == CellType.empty) { if (straightHalls && selectedDir == 2){ possibleMoves.Add(2); possibleMoves.Add(2); } possibleMoves.Add(2); } if (currentCell.x-1 >= 0 && dungeon[(int)currentCell.x-1,(int)currentCell.y].Type == CellType.empty) { if (straightHalls && selectedDir == 3){ possibleMoves.Add(3); possibleMoves.Add(3);} possibleMoves.Add(3); } if (possibleMoves.Count == 0) { pathList.RemoveAt(pathList.Count-1); yield return StartCoroutine (UpdateDungeon((int)currentCell.x,(int)currentCell.y)); if (pathList.Count != 0) currentCell = (Vector2)pathList[pathList.Count-1]; } else{ selectedDir = (int)possibleMoves[Random.Range(0,possibleMoves.Count)]; switch (selectedDir){ case 0: // Up dungeon[(int)currentCell.x,(int)currentCell.y].walls[0] = false; dungeon[(int)currentCell.x,(int)currentCell.y+1].walls[2] = false; yield return StartCoroutine (UpdateDungeon((int)currentCell.x,(int)currentCell.y)); yield return StartCoroutine (UpdateDungeon((int)currentCell.x,(int)currentCell.y+1)); currentCell = new Vector2(currentCell.x,currentCell.y+1); break; case 1: // Right dungeon[(int)currentCell.x,(int)currentCell.y].walls[1] = false; dungeon[(int)currentCell.x+1,(int)currentCell.y].walls[3] = false; yield return StartCoroutine (UpdateDungeon((int)currentCell.x,(int)currentCell.y)); yield return StartCoroutine (UpdateDungeon((int)currentCell.x+1,(int)currentCell.y)); currentCell = new Vector2(currentCell.x+1,currentCell.y); break; case 2: // Down dungeon[(int)currentCell.x,(int)currentCell.y].walls[2] = false; dungeon[(int)currentCell.x,(int)currentCell.y-1].walls[0] = false; yield return StartCoroutine (UpdateDungeon((int)currentCell.x,(int)currentCell.y)); yield return StartCoroutine (UpdateDungeon((int)currentCell.x,(int)currentCell.y-1)); currentCell = new Vector2(currentCell.x,currentCell.y-1); break; case 3: // Left dungeon[(int)currentCell.x,(int)currentCell.y].walls[3] = false; dungeon[(int)currentCell.x-1,(int)currentCell.y].walls[1] = false; yield return StartCoroutine (UpdateDungeon((int)currentCell.x,(int)currentCell.y)); yield return StartCoroutine (UpdateDungeon((int)currentCell.x-1,(int)currentCell.y)); currentCell = new Vector2(currentCell.x-1,currentCell.y); break; } pathList.Add(currentCell); } } } } } regions.Add(tempRegion); } }
public static Tile CreateRegionTile(region r, bool isArchive = false) { var rTile = CreateTile(TileItemSize.Wide, 2); rTile.Tag = TagHelper.GetTag(TagHelper.TagType.Tile, r, isArchive ? "r-archive" : "r"); rTile.Elements[0].Appearance.Assign(AppearanceMid); rTile.Elements[0].Text = r.name; rTile.Elements[1].Appearance.Assign(AppearanceText); rTile.Elements[1].TextAlignment = TileItemContentAlignment.BottomLeft; return rTile; }