public void ReplaceTileAsset(UnityEngine.Tilemaps.Tile newValue)
    {
        var index     = GameComponentsLookup.TileAsset;
        var component = (TileAssetComponent)CreateComponent(index, typeof(TileAssetComponent));

        component.value = newValue;
        ReplaceComponent(index, component);
    }
Esempio n. 2
0
 /// <summary>
 /// Constructor
 /// It currently ignores the type of tile, will need further implementation
 /// </summary>
 /// <param name="associatedTileInTilemap">The associated tile</param>
 public TileType(UnityEngine.Tilemaps.Tile associatedTileInTilemap)
 {
     _isAccessible      = associatedTileInTilemap != null;
     _blocksLineOfSight = false;
 }
Esempio n. 3
0
        private IEnumerator WaitForPlacement(City city, World world, ConstructedTileProject project, GUIStateManager state)
        {
            state.SetState(GUIStateManager.GHOST_TILE);
            char sepChar = System.IO.Path.DirectorySeparatorChar;

            spriteRenderer.sprite = Resources.Load <Sprite>("Projects" + sepChar + "Constructed Tiles" + sepChar + project.ID);
            spriteRenderer.color  = new Color(0.5f, 0.5f, 0.5f);

            Vector3Int gridPos = world.WorldToCell(Camera.main.ScreenToWorldPoint(Input.mousePosition));

            HashSet <Vector3Int> range = city.GetCityRange(world);

            UnityEngine.Tilemaps.Tile green = Resources.Load <UnityEngine.Tilemaps.Tile>(System.IO.Path.Combine("Tiles", "Green"));
            foreach (Vector3Int pos in range)
            {
                if (IsValidTile(pos, city, world, project))
                {
                    world.SetMovementTile(pos, green);
                }
            }

            yield return(new WaitForSeconds(0.1f));

            bool click = Input.GetMouseButtonUp(0);

            while (!click || !IsValidTile(gridPos, city, world, project))
            {
                gridPos            = world.WorldToCell(Camera.main.ScreenToWorldPoint(Input.mousePosition));
                transform.position = world.CellToWorld(gridPos);

                string text = project.GetTooltipText(gridPos, world);
                if (text != null)
                {
                    if (!canvas.gameObject.activeSelf)
                    {
                        canvas.gameObject.SetActive(true);
                    }
                    tooltipText.text = text;
                }
                else
                {
                    if (canvas.gameObject.activeSelf)
                    {
                        canvas.gameObject.SetActive(false);
                    }
                }

                if (!IsValidTile(gridPos, city, world, project))
                {
                    spriteRenderer.color = new Color(0, 0, 0);
                }
                else
                {
                    spriteRenderer.color = new Color(0.5f, 0.5f, 0.5f);
                }

                click = Input.GetMouseButtonUp(0);
                yield return(null);
            }

            ConstructedTile tile = Resources.Load <ConstructedTile>("Projects" + sepChar + "Constructed Tiles" + sepChar + project.ID);

            if (world.GetConstructedTile(gridPos) != null)
            {
                project.OnPlacement(gridPos, (world.GetConstructedTile(gridPos)).Project);
            }
            else
            {
                project.OnPlacement(gridPos);
            }

            world.StartConstructionOfCityTile(tile, gridPos);

            foreach (Vector3Int pos in range)
            {
                world.SetMovementTile(pos, null);
            }

            Debug.Log("Tile Selected");
            state.SetState(GUIStateManager.CITY);
            yield break;
        }
Esempio n. 4
0
 public ImportedTile(UnityEngine.Tilemaps.Tile tileIn, string pathIn)
 {
     tile = tileIn;
     path = pathIn;
 }