public static SafePoint IsSafePoint(Vector2 pos) { var result = new SafePoint { Spells = Spells.Where(i => !i.IsSafePoint(pos)).ToList() }; result.IsSafe = result.Spells.Count == 0; return(result); }
public static SafePoint IsSafePoint(Vector2 pos) { var result = new SafePoint { Spells = new List <SpellInstance>() }; foreach (var spell in DetectedSpells.Values.Where(i => i.Enable && i.IsDanger(pos))) { result.Spells.Add(spell); } result.IsSafe = result.Spells.Count == 0; return(result); }
void MapSet() { for (int i = 0; i < ThisCell.MapWidth; i++) { for (int k = 0; k < ThisCell.MapHeight; k++) { // Debug.Log($"Loading cell:{i},{k} and it's :{Map[i, k]}"); if (Map[i, k] == (int)MapCell.CellType.Wall) { // Debug.Log($"it's wall"); GameObject cell = Instantiate(CellPerhub); cell.transform.SetParent(gameObject.transform); MapCells.Add(cell); int temp = GetCountRightNeighbours(k, i, MapCell.CellType.Wall, true); if (temp > 1) { // Debug.Log("GG:1"); cell.GetComponent <MapCell>().SetAll(k, i, UnityEngine.Color.gray, MapCell.CellType.Wall, temp, 1); continue; } Map[i, k] = (int)MapCell.CellType.Wall; temp = GetCountUpNeighbours(k, i, MapCell.CellType.Wall, true); if (temp > 1) { // Debug.Log("GG:2"); cell.GetComponent <MapCell>().SetAll(k, i, UnityEngine.Color.gray, MapCell.CellType.Wall, 1, temp); continue; } cell.GetComponent <MapCell>().SetAll(k, i, UnityEngine.Color.gray, MapCell.CellType.Wall, 1, 1); } if (Map[i, k] == (int)MapCell.CellType.Empty) { // Debug.Log($"it's empty"); GameObject cell = Instantiate(EmptyPerhub); cell.transform.SetParent(gameObject.transform); MapCells.Add(cell); int temp = GetCountRightNeighbours(k, i, MapCell.CellType.Empty, true); if (temp > 1) { // Debug.Log("GG:1"); cell.GetComponent <MapCell>().SetAll(k, i, UnityEngine.Color.black, MapCell.CellType.Empty, temp, 1); continue; } Map[i, k] = (int)MapCell.CellType.Empty; temp = GetCountUpNeighbours(k, i, MapCell.CellType.Empty, true); if (temp > 1) { // Debug.Log("GG:2"); cell.GetComponent <MapCell>().SetAll(k, i, UnityEngine.Color.black, MapCell.CellType.Empty, 1, temp); continue; } cell.GetComponent <MapCell>().SetAll(k, i, UnityEngine.Color.gray, MapCell.CellType.Empty, 1, 1); } if (Map[i, k] == (int)MapCell.CellType.Key) { WorldKey cell = Instantiate(Resources.Load <WorldKey>("WorldKey")); cell.transform.SetParent(gameObject.transform); ThisCell.AddKey(cell); cell.GetComponent <MapCell>().SetAll(k, i, UnityEngine.Color.white, MapCell.CellType.Key, 0.5f, 0.5f); // cell.transform.position = new Vector3(k, i, -1); cell.gameObject.SetActive(false); MapCells.Add(cell.gameObject); //ThisCell.KeyPoints.Add(new Vector2(k, i)); } if (Map[i, k] == (int)MapCell.CellType.SpawnP) { GameObject cell = Instantiate(SpawnPerhub); cell.transform.SetParent(gameObject.transform); cell.GetComponent <MapCell>().SetAll(k, i, UnityEngine.Color.red, MapCell.CellType.SpawnP, 1, 1); cell.GetComponent <SpawnerCell>().Setter(GameObject.Find("Player").GetComponent <Player>(), loader); MapCells.Add(cell); } if (Map[i, k] == (int)MapCell.CellType.SaveP) { SafePoint cell = Instantiate(Resources.Load <SafePoint>("SafePoint")); cell.transform.SetParent(gameObject.transform); cell.loader = loader; cell.GetComponent <MapCell>().SetAll(k, i, UnityEngine.Color.white, MapCell.CellType.Key, 0.5f, 0.5f); // cell.transform.position = new Vector3(k, i, -1); MapCells.Add(cell.gameObject); } } } //loader.OutArray(generator.ResultMap, 25); }