// This will highlight tiles the player can move to // For now the movement is set at 1 per tile move void OnMouseEnter() { tilenumber = GetComponent <TileNumber>(); startColor = GetComponent <Renderer>().material.color; costText.color = Color.green; CostOfTile(); if (pauseMenu.isPaused == false) { if (Player.instance.currentTile.Contains("Tortoise")) { GetComponent <Renderer>().material.color = Color.red; } else { GetComponent <Renderer>().material.color = Color.green; } // Change to red if tile is ahead of player if (Player.instance.index <= tilenumber.tileValue) { GetComponent <Renderer>().material.color = Color.red; } if (Player.instance.areaIndex != tilenumber.tileArea) { GetComponent <Renderer>().material.color = Color.red; } } }
private void Awake() { LettuceSound = GetComponent <AudioSource>(); costText.text = ""; pauseMenu.GetComponent <PauseMenu>(); tilenumber = GetComponent <TileNumber>(); }
// This will highlight tiles the player can move to and will lead to calculating how much it will cost the player void OnMouseEnter() { if (pauseMenu.isPaused == false) { tilenumber = GetComponent <TileNumber>(); startColor = GetComponent <Renderer>().material.color; costText.color = Color.red; CostOfTile(); // If player can afford tile, it will go green, if not then red if (Player.instance.playerCurrency >= costTile && Player.instance.playerCurrency <= 10 && Player.instance.lettuces <= 0) { GetComponent <Renderer>().material.color = new Color32(100, 255, 100, 255); } else { GetComponent <Renderer>().material.color = Color.red; } // Will also change colour of tile to red as well if its behind the player to indicate you cannot move to it if (Player.instance.index >= tilenumber.tileValue) { GetComponent <Renderer>().material.color = Color.red; } } }
/// <summary> /// STD-Construktor /// </summary> /// <param name="_value"></param> /// <param name="_x"></param> /// <param name="_y"></param> public Tile(TileNumber _tiletype, int _x, int _y) { tiletype = _tiletype; x = _x; y = _y; Color[] data; Rectangle rect = GetTileSpritePosition(tiletype); tile_texture = new Texture2D(Globals.GraphicsDevice, rect.Width, rect.Height); data = new Color[rect.Width * rect.Height]; Globals.tileMap.GetData(0, rect, data, 0, data.Length); tile_texture.SetData(data); borders = new List <bool>(); borders.Add(false); borders.Add(false); borders.Add(false); borders.Add(false); borders.Add(false); borders.Add(false); progressbar = new Progressbar(); }
/// <summary> /// Set Tiletype bei Enum-TileType; Update Texture of tile /// </summary> /// <param name="_tileType"></param> /// <param name="GraphicsDevice"></param> /// <param name="tileMap"></param> public void SetTileType(TileNumber _tileType) { tiletype = _tileType; Color[] data; Rectangle rect = GetTileSpritePosition(tiletype); tile_texture = new Texture2D(Globals.GraphicsDevice, rect.Width, rect.Height); data = new Color[rect.Width * rect.Height]; Globals.tileMap.GetData(0, rect, data, 0, data.Length); tile_texture.SetData(data); }
/// <summary> /// Set Tiletype bei Enum-TileBaseType; Update Texture of tile; used bei Map-Generation /// </summary> /// <param name="_tilebasetype"></param> /// <param name="GraphicsDevice"></param> /// <param name="tileMap"></param> public void SetTileType(TileBaseType _tilebasetype) { bool isEnvrionment; tileBaseType = _tilebasetype; switch (tileBaseType) { case TileBaseType.Mountain: isEnvrionment = true; tiletype = TileNumber.mountain; break; case TileBaseType.Wood: isEnvrionment = true; tiletype = TileNumber.wood; break; case TileBaseType.Water: isEnvrionment = true; tiletype = TileNumber.flatwater; break; case TileBaseType.Enemy: SetAsEnemyTile(); isEnvrionment = false; break; default: isEnvrionment = false; break; } if (isEnvrionment) { Color[] data; Rectangle rect = GetTileSpritePosition(tiletype); tile_texture = new Texture2D(Globals.GraphicsDevice, rect.Width, rect.Height); data = new Color[rect.Width * rect.Height]; Globals.tileMap.GetData(0, rect, data, 0, data.Length); tile_texture.SetData(data); } }
private void Awake() { costText.text = ""; pauseMenu.GetComponent <PauseMenu>(); tilenumber = GetComponent <TileNumber>(); }
/// <summary> /// Returns a Rectangle descriping position and dimension of sprite on a spritemap /// </summary> /// <param name="tileNumber"></param> /// <returns></returns> private Rectangle GetTileSpritePosition(TileNumber tileNumber) { return(new Rectangle(Constants.tile_width * ((int)tileNumber % Constants.tiles_per_row), Constants.tile_height * ((int)tileNumber / Constants.tiles_per_row), Constants.tile_width, Constants.tile_height)); }