public void init(int type, int health, IndicatorTile t) { owner = t; transform.parent = owner.transform; transform.localPosition = new Vector3(0, 0, 0); mat = GetComponent <Renderer>().material; mat.shader = Shader.Find("Sprites/Default"); if (type == 0) { if (health == 1) { mat.mainTexture = Resources.Load <Texture2D>("Textures/indicatorGhoulRed"); } else if (health == 2) { mat.mainTexture = Resources.Load <Texture2D>("Textures/indicatorGhoulYellow"); } else if (health > 2) { mat.mainTexture = Resources.Load <Texture2D>("Textures/indicatorGhoulGreen"); } } else if (type == 1) { if (health == 1) { mat.mainTexture = Resources.Load <Texture2D>("Textures/indicatorSpiderRed"); } else if (health == 2) { mat.mainTexture = Resources.Load <Texture2D>("Textures/indicatorSpiderYellow"); } else if (health > 2) { mat.mainTexture = Resources.Load <Texture2D>("Textures/indicatorSpiderGreen"); } } else if (type > 1) { if (health == 1) { mat.mainTexture = Resources.Load <Texture2D>("Textures/indicatorSlimeRed"); } else if (health == 2) { mat.mainTexture = Resources.Load <Texture2D>("Textures/indicatorSlimeYellow"); } else if (health > 2) { mat.mainTexture = Resources.Load <Texture2D>("Textures/indicatorSlimeGreen"); } } mat.color = new Color(1, 1, 1); }
//fills in the rectangle on the indicator that corresponds to the enemy private void addIndicatorTile(int type, int health, int x, int y) { if ((x < 0) && (x > -5)) { GameObject indicatorObject = new GameObject(); // create empty game object IndicatorTile tile4 = indicatorObject.AddComponent <IndicatorTile>(); // add tile script to object tile4.transform.parent = indicatorFolder.transform; // make the tile folder its parent tile4.transform.position = new Vector3(x / 2f - 1.75f, y, -.75f); tile4.init(type, health, this); // initialize the tile indicatorTiles.Add(tile4); tile4.name = "Indicator Tile " + indicatorTiles.Count; // name tile for easy finding } }