/* * Updating the color of the skin * */ private void UpdatePlayerSkinColor(GameObject mat, PlayerStatistics.Upgrade currUpgrade, GameObject player) { PlayerStatistics.CustomColor mcolor = colorsData[currUpgrade.ParticlesColor.ToString()]; player.GetComponent <SpriteRenderer>().color = mcolor.ThirdColor; PlayerActions pa = player.GetComponent <PlayerActions>(); if (pa != null) { pa.SetColorForPathLines(mcolor.ThirdColor); } foreach (Transform child in mat.transform) { ParticleSystem ps = child.GetComponent <ParticleSystem>(); if (child.transform.name == "Player Trail" || child.transform.name == "Player Particles") { //Debug.Log("Updating "+ child.transform.name + "to: " + currUpgrade.ParticlesColor.ToString()); var col = ps.colorOverLifetime; col.enabled = true; Gradient grad = new Gradient(); grad.SetKeys(new GradientColorKey[] { new GradientColorKey(mcolor.FirstColor, 0.0f), new GradientColorKey(mcolor.SecondColor, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) }); col.color = grad; } else if (child.transform.name == "Player Glow") { ParticleSystem.MinMaxGradient grad = new ParticleSystem.MinMaxGradient(mcolor.ThirdColor, mcolor.FourthColor); var main = ps.main; main.startColor = grad; } } }
private void AddSkinsToLevel() { int numUpgrades = playerStats.upgradesList.Count; for (int i = 0; i < numUpgrades; i++) { PlayerStatistics.Upgrade currUpgrade = playerStats.upgradesList[i]; if (currUpgrade.IsActive) { if (currUpgrade.ApplicableOn == ObjectsDescription.Player) { skinsAndMaterials[currUpgrade.UpgradeCategory.ToString()].transform.parent = player.transform; skinsAndMaterials[currUpgrade.UpgradeCategory.ToString()].transform.position = player.transform.position; skinsAndMaterials[currUpgrade.UpgradeCategory.ToString()].SetActive(true); playerStats.UpdateColorOfSkin(currUpgrade, player); PlayerStatistics.CustomColor mcolor = playerStats.colorsData[currUpgrade.ParticlesColor.ToString()]; skinColor = mcolor.ThirdColor; } } } }
public void SelectColor(string colorStr) { PlayerStatistics.Upgrade currentUpgrade = playerStats.upgradesList[selectedUpgradeIndexForPreview]; if (SkinColors.Yellow.ToString() == colorStr) { currentUpgrade.ParticlesColor = SkinColors.Yellow; } else if (SkinColors.Blue.ToString() == colorStr) { currentUpgrade.ParticlesColor = SkinColors.Blue; } else if (SkinColors.Red.ToString() == colorStr) { currentUpgrade.ParticlesColor = SkinColors.Red; } else if (SkinColors.Purple.ToString() == colorStr) { currentUpgrade.ParticlesColor = SkinColors.Purple; } PlayerStatistics.CustomColor mcolor = playerStats.colorsData[currentUpgrade.ParticlesColor.ToString()]; colorSelector.GetComponent <Image>().color = mcolor.ThirdColor; playerStats.upgradesList[selectedUpgradeIndexForPreview] = currentUpgrade; UpdateUiData(currentUpgrade); if (currentUpgrade.ApplicableOn == ObjectsDescription.Player) { playerStats.UpdateColorOfSkin(currentUpgrade, playerSkin); } else if (currentUpgrade.ApplicableOn == ObjectsDescription.PlayerLauncher) { Debug.Log("Under Construction..."); } }