private void AddPropSprites() { foreach (PropData propData in myRD.allPropDatas) { // -- Batteries -- if (propData.GetType() == typeof(BatteryData)) { BatteryData pd = propData as BatteryData; AddSpriteRenderer("Battery", rh.s_battery, go_props, pd.pos, BatteryIconSize, 10, Color.white); } // -- Grounds -- else if (propData.GetType() == typeof(GroundData)) { GroundData pd = propData as GroundData; groundDatas.Add(pd); // also add it to my ref list! srs_grounds.Add(AddSpriteRenderer("Ground", rh.s_ground, go_props, pd.pos, pd.size, 1, Color.white)); //WHY POSITION? why not center? } // -- DispGrounds -- else if (propData.GetType() == typeof(DispGroundData)) { DispGroundData pd = propData as DispGroundData; Color color = DispGround.GetBodyColor(pd); color = new Color(color.r, color.g, color.b, color.a * 0.6f); // alpha it out a bit, to taste. AddSpriteRenderer("DispGround", rh.s_ground, go_props, pd.pos, pd.size, 1, color); } // -- Gems -- else if (propData.GetType() == typeof(GemData)) { GemData pd = propData as GemData; Sprite sprite = rh.GetGemSprite(pd.type); AddSpriteRenderer("Gem", sprite, go_props, pd.pos, GemIconSize, 10, Color.white); } // -- Snacks -- else if (propData.GetType() == typeof(SnackData)) { SnackData pd = propData as SnackData; Color color = PlayerBody.GetBodyColorNeutral(PlayerTypeHelper.TypeFromString(pd.playerType)); AddSpriteRenderer("Snack", rh.s_snack, go_props, pd.pos, SnackIconSize, 10, color); } // -- Spikes -- else if (propData.GetType() == typeof(SpikesData)) { SpikesData spikesData = propData as SpikesData; Color color = Colors.Spikes(myRD.WorldIndex);// new Color(0.7f,0.1f,0f, 0.6f); SpriteRenderer newSprite = AddSpriteRenderer("Spikes", rh.s_spikes, go_props, spikesData.pos, Vector2.one, 0, color); newSprite.drawMode = SpriteDrawMode.Tiled; newSprite.size = spikesData.size; newSprite.transform.localEulerAngles = new Vector3(0, 0, spikesData.rotation); } } }
private void AddPropImages() { int snackIndex = 0; // for determining which Snacks we gots! foreach (PropData propData in myRD.allPropDatas) { // -- Spikes -- if (propData.GetType() == typeof(SpikesData)) { SpikesData spikesData = propData as SpikesData; Color color = Colors.Spikes(myRD.WorldIndex);// new Color(0.7f,0.1f,0f, 0.6f); Image newObj = AddImage("Spikes", rh.s_spikes, rt_props, spikesData.pos, spikesData.size, color); newObj.transform.localEulerAngles = new Vector3(0, 0, spikesData.rotation); newObj.type = Image.Type.Tiled; newObj.transform.localScale = Vector3.one / 100f; // kinda hacky-ish. newObj.rectTransform.sizeDelta *= 100f; newObj.transform.SetAsFirstSibling(); // put spikes BEHIND everything else. } // -- Grounds -- else if (propData.GetType() == typeof(GroundData)) { GroundData pd = propData as GroundData; Color color = new Color255(100, 130, 90).ToColor();//Ground.GetBodyColor(pd, myRD.WorldIndex); AddImage("Ground", rh.s_ground, rt_props, pd.pos, pd.size, color); } // -- DispGrounds -- else if (propData.GetType() == typeof(DispGroundData)) { DispGroundData pd = propData as DispGroundData; Color color = DispGround.GetBodyColor(pd); color = new Color(color.r, color.g, color.b, color.a * 0.6f); // alpha it out a bit, to taste. AddImage("DispGround", rh.s_ground, rt_props, pd.pos, pd.size, color); } // -- Batteries -- else if (propData.GetType() == typeof(BatteryData)) { BatteryData pd = propData as BatteryData; AddImage("Battery", rh.s_battery, rt_props, pd.pos, BatteryIconSize, Color.white); } // -- Gems -- else if (propData.GetType() == typeof(GemData)) { GemData pd = propData as GemData; Sprite sprite = rh.GetGemSprite(pd.type); AddImage("Gem", sprite, rt_props, pd.pos, GemIconSize, Color.white); } // -- Snacks -- else if (propData.GetType() == typeof(SnackData)) { SnackData pd = propData as SnackData; Color color; bool didEatSnack = SaveStorage.GetBool(SaveKeys.DidEatSnack(myRD, snackIndex)); if (didEatSnack) { color = new Color(0, 0, 0, 0.2f); } else { color = PlayerBody.GetBodyColorNeutral(PlayerTypeHelper.TypeFromString(pd.playerType)); } AddImage("Snack", rh.s_snack, rt_props, pd.pos, SnackIconSize, color); snackIndex++; } } }