public MyTile GetTile(Vector3Int inputGridPos) { MyTile currentTile = new MyTile(); allTiles.TryGetValue(inputGridPos, out currentTile); return(currentTile); }
public void StormMovesShips() { foreach (Unit u in GetPlayerUnits(currentPlayerSide)) { int[] xy = GetXYbyTileName(u.gameObject.transform.parent.name); int x = xy[0]; int y = xy[1]; int[] windDir = currentWeather.curWind; MyTile tileToDrift = null; for (int radius = u.stormDrift; radius > 0; radius--) { tileToDrift = GetTileByXY(x + radius * windDir[0], y + (-1) * radius * windDir[0]).GetComponent <MyTile>(); if (tileToDrift != null) { break; } } if (tileToDrift == null) { tileToDrift = GetTileByXY(x, y).GetComponent <MyTile>(); } u.transform.parent = tileToDrift.gameObject.transform; u.transform.localPosition = new Vector2(0, 0); tileToDrift.AddShipToTile(u.gameObject); u.movementCompleted = true; ResetMoveHighlight(); ResetUnderFireHighlight(); if (!u.fireCompleted) { HighlightArea(tileToDrift.gameObject, "fire"); } } }
public void Generate1(Player p) { p.SortTiles(); List <MyTile> tiles = p.my_tiles; List <MyTile> show_tiles = p.show_tiles; for (int i = 0; i < tiles.Count; i++) { MyTile temp = tiles[i]; temp.transform.position = new Vector3(-tile_x * ((tiles.Count - 1) / 2.0f - (float)(i)), base_height, -(chessboard_z / 2 - tile_z * 2)); temp.transform.rotation = Quaternion.Euler(0.0f, 180.0f, 0.0f); if (temp.is_showing) { temp.is_showing = false; temp.ResetPotential(); temp.show(); } } for (int i = 0; i < show_tiles.Count; i++) { MyTile temp = show_tiles[i]; temp.transform.position = new Vector3(-tile_x * ((show_tiles.Count - 1) / 2.0f - (float)(i)), show_base_height, -(chessboard_z / 2 - tile_z * 2 - tile_y)); temp.transform.rotation = Quaternion.Euler(-90.0f, 0.0f, -180.0f); } }
public MyTile CreateTile() { GameObject g = Resources.Load("Prefabs/Tile") as GameObject; MyTile tile = Instantiate(g).GetComponent <MyTile>(); return(tile); }
public virtual List <MyTile> Play() { if (play_time < consider_time) { play_time += Time.deltaTime; return(null); } List <MyTile> result = new List <MyTile>(); if (CheckOver()) { MyTile temp = CreateTile(); temp.tile_id = -1; result.Add(temp); return(result); } System.Random rnd = new System.Random(); if (my_tiles.Count != 0) { result = new List <MyTile>(); MyTile tile = my_tiles[rnd.Next(my_tiles.Count)]; my_tiles.Remove(tile); my_tiles_id.Remove(tile.tile_id); result.Add(tile); return(result); } return(null); }
public void GetTile(int id) { MyTile tile = CreateTile(); GetTileId(id); tile.Initialize(id); my_tiles.Add(tile); }
public void GetShowTile(int id) { GameObject g = Resources.Load("Prefabs/Tile") as GameObject; MyTile tile = Instantiate(g).GetComponent <MyTile>(); //GetTileId(id); tile.Initialize(id); show_tiles.Add(tile); }
public override List <MyTile> Ask_answer(MyTile tile) { List <MyTile> out_tiles = new List <MyTile>(); List <int> showing_ids = GetShowInts(); int match_num = tile.tile_id; for (int i = 0; i < my_tiles.Count; i++) { if (match_num == my_tiles[i].tile_id) { out_tiles.Add(my_tiles[i]); } } if (out_tiles.Count >= 2) { SetPotentialIfNotYet(out_tiles); } for (int i = 0; i < my_tiles.Count; i++) { for (int j = 0; j < my_tiles.Count; j++) { List <int> tempss = new List <int>(new int[] { tile.tile_id, my_tiles[i].tile_id, my_tiles[j].tile_id }); if (CheckThreeSequence(tempss)) { my_tiles[i].SetPotential(); my_tiles[j].SetPotential(); } } } showing_ids = GetShowInts(); List <int> temps = new List <int>(); for (int i = 0; i < showing_ids.Count; i++) { temps.Add(showing_ids[i]); } temps.Add(tile.tile_id); if (CheckThreeOrFourSame(temps) || CheckThreeSequence(temps)) { if (Input.GetMouseButtonDown(1)) { ClearPotential(); return(Delete(GetShowTiles())); } } if (Input.GetMouseButtonDown(1)) { ClearPotential(); return(new List <MyTile>()); } return(null); }
private bool canSpawn() { bool flag = false; if (MyTile != null && !MyTile.IsOccupied(TileLayer)) { flag = true; } return(flag); }
public virtual List <MyTile> Ask_answer(MyTile tile) { if (waitTime > Time.deltaTime) { waitTime -= Time.deltaTime; return(null); } List <MyTile> out_tiles = new List <MyTile>(); int match_num = tile.tile_id; for (int i = 0; i < my_tiles.Count; i++) { if (match_num == my_tiles[i].tile_id) { out_tiles.Add(my_tiles[i]); } } if (out_tiles.Count == 3) { return(Delete(out_tiles)); } if (out_tiles.Count == 2) { return(Delete(out_tiles)); } out_tiles = new List <MyTile>(); if (match_num % 10 == 0) { return(new List <MyTile>()); } for (int i = 0; i < my_tiles.Count; i++) { for (int j = 0; j < my_tiles.Count; j++) { List <int> temps = new List <int>(new int[] { tile.tile_id, my_tiles[i].tile_id, my_tiles[j].tile_id }); if (CheckThreeSequence(temps)) { out_tiles.Add(my_tiles[i]); out_tiles.Add(my_tiles[j]); return(Delete(out_tiles)); } } } out_tiles = new List <MyTile>(); waitTime = 3; return(new List <MyTile>()); }
void AddShip(MyTile t, string name, string ship_class, Player player) { GameObject shipObj = Resources.Load("Prefabs/ship") as GameObject; GameObject s = Instantiate(shipObj, new Vector3(0, 0, 0), Quaternion.identity); s.name = "ship"; t.AddShipToTile(s); s.GetComponent <Unit>().SetupShip(ship_class, player.side, name); ships.Add(s); }
void CleanTile(MyTile temp_tile, bool reuse = true) { //add it back to tile manager if (reuse) { tile_manager.tiles.Add(temp_tile.tile_id); } //destroy the current tile temp_tile.Suiside(); }
private MyTile CreateTileDataFromName(TileBase inputTile) { MyTile thisTile = new MyTile(); //i know but ok sh i cba to make custom class and everything string tileName = inputTile.name; switch (tileName) { case "moonrocktile": thisTile.isInteractable = false; thisTile.isDestructible = true; thisTile.isTurnedOn = true; thisTile.mass = 25000f; thisTile.hardness = 1f; break; case "halfblockmoonrocktile": thisTile.isInteractable = false; thisTile.isDestructible = true; thisTile.isTurnedOn = true; thisTile.mass = 12500f; thisTile.hardness = 1f; break; case "grasstile": thisTile.isInteractable = false; thisTile.isDestructible = true; thisTile.isTurnedOn = true; thisTile.mass = 20000f; thisTile.hardness = 0.5f; break; case "windowtile": thisTile.isInteractable = false; thisTile.isDestructible = true; thisTile.isTurnedOn = true; thisTile.mass = 5000f; thisTile.hardness = 0.5f; break; //special blocks case "gravitygeneratortile": thisTile.isInteractable = true; thisTile.isDestructible = true; thisTile.isTurnedOn = true; thisTile.mass = 5500000f; thisTile.hardness = 3f; break; } return(thisTile); }
/// <summary> /// the origin of the rectangles need to be set on left upper corner, as it is ad default /// </summary> public static float CheckColision(RectangleShape rect1, MyTile rect2) { // Vector2f CenterReact1 = rect1.Position + new Vector2f(rect1.Size.X / 2, rect1.Size.Y / 2); // Vector2f CenterReact2 = rect2.Position + new Vector2f(rect2.Size.X / 2, rect2.Size.Y / 2); if (rect1.GetGlobalBounds().Intersects(rect2.GetGlobalBounds()) == true) // this need to be simpliied { return(rect2.SpeedPunish); } else { return(0); } }
MyTile GetTileAtPosition(Vector2 pos) { int tileX = Mathf.RoundToInt(pos.x - 0.5f); int tileY = Mathf.RoundToInt(pos.y - 0.5f); MyTile tile = TileManager.Inst.myTiles[tileY, tileX]; if (tile != null) { return(tile); } return(null); }
void InitTiles() { for (int i = 0; i < TileHeight; i++) { for (int j = 0; j < TileWidth; j++) { TileBase nowTile; nowTile = myTileMap.GetTile(new Vector3Int(j, i, 0)); myTiles[i, j] = new MyTile(); string tempString = nowTile.name; if (nowTile.name == "tex_tileset_original_34") { myTiles[i, j].tileState = MyTile.TileState.Road; //hardcording if ((i == 7 && j == 1) || (i == 7 && j == 26) || (i == 26 && j == 1) || (i == 26 && j == 26)) { GameObject temp; temp = Instantiate(bigPellet, new Vector3(j + 0.5f, i + 0.5f, 0), this.transform.rotation, pellets.transform); GameManager.Inst.totalPellet++; GameManager.Inst.allPellet.Insert(GameManager.Inst.allPellet.Count, temp); } else { if (j >= 9 && i >= 13 && j <= 18 && i <= 19) { } else { GameObject temp; temp = Instantiate(normalPellet, new Vector3(j + 0.5f, i + 0.5f, 0), this.transform.rotation, pellets.transform); GameManager.Inst.totalPellet++; GameManager.Inst.allPellet.Insert(GameManager.Inst.allPellet.Count, temp); } } if ((i == 16 && j == 0) || (i == 16 && j == 27)) { myTiles[i, j].isPortal = true; } } else { myTiles[i, j].tileState = MyTile.TileState.Wall; //이걸 만드는 이유가 레이로 쏴서 waypoint가 맞거나 벽에 맞을 때까지 가서 멈춘다. 그것 위한 콜라이더 였음 Instantiate(wall, new Vector3(j + 0.5f, i + 0.5f, 0), this.transform.rotation, walls.transform); } } } }
void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray.origin, ray.direction, out m_HitInfo)) { MyTile tile = m_HitInfo.transform.GetComponent <MyTile>(); if (tile != null) { this.transform.position = tile.transform.position; if (tile.IsOccuped()) { //Red Material if (_currentState == 0) { _currentState = 1; _currentMesh.material = _blockedMaterial; } } else { //Blue material if (_currentState == 1) { _currentState = 0; _currentMesh.material = _availableMaterial; } if (Input.GetMouseButtonDown(0)) { UIController.Instance.SetPauseButtons(false); tile.CreateTower(TowerManager.Instance.GetTower(_type)); Destroy(this.gameObject); return; } } } if (Input.GetMouseButtonDown(1)) { Destroy(this.gameObject); } } }
private void Awake() { tiles = new MyTile[dim, dim]; for (int x = 0; x < dim; x++) { for (int y = 0; y < dim; y++) { tiles[x, y] = new MyTile(x * TileSize + (int)transform.position.x * TileSize, y * TileSize + (int)transform.position.y * TileSize); GameObject tileGo = new GameObject("Tile_" + tiles[x, y].x + "_" + tiles[x, y].y); tileGo.transform.position = new Vector2(tiles[x, y].x, tiles[x, y].y); tileGo.transform.SetParent(this.transform, true); SpriteRenderer spriteRenderer = tileGo.AddComponent <SpriteRenderer>(); spriteRenderer.sprite = full; } } }
// Start is called before the first frame update void Start() { //Debug.Log("Maze started"); Tiles = new List <TileManager.Tile>(); Tiles = GameObject.Find("Game Manager").GetComponent <TileManager>().tiles; int x = 29; //transform.GetChild(0).childCount; int y = 32; //transform.childCount; tiles = new MyTile[x, y]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { tiles[i, j] = new MyTile(i, j); } } }
public void Execute(params object[] list) { // var toastMessage = new MyToast(); // toastMessage.Text1 = ((string)list[1]); // toastMessage.Text2 = ((string)list[2]); // toastMessage.NotificationUri = (string)list [0]; // toastMessage.CreatePayload (); // var result = PushNotifier.SendPushNotificationMessage(toastMessage); var tileMessage = new MyTile(); tileMessage.Text1 = ((string)list[1]); tileMessage.Text2 = ((string)list[2]); tileMessage.NotificationUri = (string)list [0]; tileMessage.CreatePayload(); var result2 = PushNotifier.SendPushNotificationMessage(tileMessage); //throw new NotImplementedException (); }
//Creates all the tiles. //Also setups the colortiles //This is very slow becuase gameobjects are quite slow and the program will crash if you create to many tiles at once. //Want to try to use something other then the tiles in the future and see if that speeds things up. void CreateGrid() { offset = RescaleOffset(); Vector2 spawnPosition = GetMiddlePos(); tiles = new MyTile[width, height]; for (int i = 0; i < height; i++) { for (int k = 0; k < width; k++) { Vector3 spawnPos = new Vector3(spawnPosition.x + (k * offset), spawnPosition.y + (i * offset), 0); GameObject temp = Instantiate(tile, spawnPos, Quaternion.identity, tileHolder); ColorTile colorTile = temp.GetComponent <ColorTile>(); MyTile currentTile = new MyTile(temp, spawnPos, new Vector2(k, i), colorTile); tiles[k, i] = currentTile; temp.GetComponent <ColorTile>().OnStart(currentTile); } } }
public void UpdateNativeArrays() { //first clear all allCalculatedGravity.Dispose(); playerPositionArray.Dispose(); playerMassArray.Dispose(); gravityConstantArray.Dispose(); allTileMassArray.Dispose(); allTilePosWorldArray.Dispose(); allTileIsTurnedOnArray.Dispose(); //create lists allCalculatedGravity = new NativeArray <Vector3>(1, Allocator.Persistent); playerPositionArray = new NativeArray <Vector3>(1, Allocator.Persistent); playerMassArray = new NativeArray <float>(1, Allocator.Persistent); gravityConstantArray = new NativeArray <float>(1, Allocator.Persistent); //get count of tiles to gravity on int tileCount = 0; foreach (var pos in ground.cellBounds.allPositionsWithin) { if (ground.HasTile(pos)) { tileCount++; } } allTileMassArray = new NativeList <float>(tileCount + 1, Allocator.Persistent); allTilePosWorldArray = new NativeList <Vector3>(tileCount + 1, Allocator.Persistent); allTileIsTurnedOnArray = new NativeList <bool>(tileCount + 1, Allocator.Persistent); //fill lists //-------- fill in all tile info into nativelists ------ foreach (var pos in ground.cellBounds.allPositionsWithin) { if (ground.HasTile(pos)) { MyTile currentTile = new MyTile(); allTiles.TryGetValue(pos, out currentTile); allTileMassArray.Add(currentTile.mass); allTilePosWorldArray.Add(ground.CellToWorld(pos)); allTileIsTurnedOnArray.Add(currentTile.isTurnedOn); } } }
public void Initialize() { chessboard = GameObject.Find("Chessboard"); tile = Resources.Load <MyTile>("Pretabs/Tile"); //float tile_x = tiles[0].transform.lossyScale.x; //float tile_z = tiles[0].transform.lossyScale.z; //float tile_y = tiles[0].transform.lossyScale.y; tiles_1 = new List <MyTile>(); tiles_2 = new List <MyTile>(); tiles_3 = new List <MyTile>(); tiles_4 = new List <MyTile>(); tile_x = 1.0f; tile_z = 0.5f; tile_y = 1.6f; chessboard_z = chessboard.transform.lossyScale.z; chessboard_x = chessboard.transform.lossyScale.x; chessboard_y = chessboard.transform.lossyScale.y; base_height = chessboard.transform.position.y + tile_y / 2 + chessboard_y / 2; show_base_height = chessboard.transform.position.y + tile_z / 2 + chessboard_y / 2; }
public static int GetZoomLevel() { double currentRes = GlobalLayers._MainMap.Resolution; // ArcGISLocalTiledLayer basetile = (ArcGISLocalTiledLayer)GlobalLayers._MainMap.Layers[0]; MyTile basetile = (MyTile)GlobalLayers._MainMap.Layers[0]; var lods = basetile.TileInfo.Lods.ToList(); int level = 20, i; for (i = 0; i < lods.Count(); i++) { if (Math.Abs(currentRes - lods[i].Resolution) < 0.000001) { level = i; break; } } // int level = lods.IndexOf(lods.Where(l => l.Resolution == currentRes).FirstOrDefault()); return(level); }
public bool CheckThreeToFour(int id) { int count = 0; for (int i = 0; i < show_tiles.Count; i++) { if (show_tiles[i].tile_id == id) { count++; if (count >= 3) { MyTile temp = CreateTile(); temp.Initialize(id); show_tiles.Insert(i, temp); return(true); } } } return(false); }
public void BlockNeighbours(MyTile tile) { Vector2[] oddrDirectionsEven = { new Vector2(+1, 0), new Vector2(0, -1), new Vector2(-1, -1), new Vector2(-1, 0), new Vector2(-1, +1), new Vector2(0, +1) }; Vector2[] oddrDirectionsOdd = { new Vector2(+1, 0), new Vector2(+1, -1), new Vector2(0, -1), new Vector2(-1, 0), new Vector2(0, +1), new Vector2(+1, +1) }; if (tile.y % 2 == 1) { foreach (Vector2 v2 in oddrDirectionsOdd) { int auxx = tile.x + (int)v2.x; int auxy = tile.y + (int)v2.y; if (auxx >= 0 && auxx < gridWidth && auxy >= 0 && auxy < gridHeight && tileGrid[auxx, auxy] != null) { tileGrid[auxx, auxy].SetOccuped(true); } } } else { foreach (Vector2 v2 in oddrDirectionsEven) { int auxx = tile.x + (int)v2.x; int auxy = tile.y + (int)v2.y; if (auxx >= 0 && auxx < gridWidth && auxy >= 0 && auxy < gridHeight && tileGrid[auxx, auxy] != null) { tileGrid[auxx, auxy].SetOccuped(true); } } } }
//public object Clone() //{ // TagItem tag = BaseClone(); // if (Translations != null) // tag.Translations = Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Select(t => (lm.Comol.Core.DomainModel.Languages.)t.Clone()).ToList(); // if (CommunityAssignments!=null) // tag.CommunityAssignments = CommunityAssignments.Where(c => c.Deleted == BaseStatusDeleted.None).Select(c => (CommunityTag)c.Clone()).ToList(); // if (tag.MyTile != null) // tag.MyTile = (lm.Comol.Core.Dashboard.Domain.Tile)MyTile.Clone(); // return tag; //} public virtual TagItem Copy(litePerson person, String ipAddress, String proxyIpAddress, String titlePrefix = "") { TagItem clone = BaseClone(); clone.CreateMetaInfo(person, ipAddress, proxyIpAddress); if (Translations != null) { clone.Translations = Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Select(t => t.Copy(clone, person, ipAddress, proxyIpAddress, titlePrefix, clone.CreatedOn)).ToList(); } if (CommunityAssignments != null) { clone.CommunityAssignments = CommunityAssignments.Where(c => c.Deleted == BaseStatusDeleted.None).Select(c => c.Copy(clone, person, ipAddress, proxyIpAddress, clone.CreatedOn)).ToList(); } if (Organizations != null) { clone.Organizations = Organizations.Where(c => c.Deleted == BaseStatusDeleted.None).Select(c => c.Copy(clone, person, ipAddress, proxyIpAddress, clone.CreatedOn)).ToList(); } if (MyTile != null) { clone.MyTile = MyTile.Copy(clone, person, ipAddress, proxyIpAddress, titlePrefix, clone.CreatedOn); } return(clone); }
public void Verify(MyTile tile) { if ((Color)tile.Background.GetValue(SolidColorBrush.ColorProperty) != Colors.Green) { foreach (MyLabel e in UnlockCells) { if (values[e.Row, e.Column] == 0) { return; } } Rectangle icon = new Rectangle() { Fill = new SolidColorBrush(Colors.White), Height = 45, Width = 45 }; foreach (MyLabel e in UnlockCells) { if (values[e.Row, e.Column] != result[e.Row, e.Column] && values[e.Row, e.Column] != 0) { icon.OpacityMask = new VisualBrush(Application.Current.Resources["appbar_close"] as Visual); tile.Content = icon; tile.Background = new SolidColorBrush(Colors.Red); return; } } icon.OpacityMask = new VisualBrush(Application.Current.Resources["appbar_check"] as Visual); tile.Content = icon; tile.Background = new SolidColorBrush(Colors.Green); finishBanner.Show(tile, errorCount); } }
public void PlayTile(MyTile tile) { my_tiles.Remove(tile); }
public void OnStart(MyTile myTile) { this.myTile = myTile; }