using System.Collections; using System.Collections.Generic; using UnityEngine; public class Particle : MonoBehaviour { protected int _tier = 0; public new Rigidbody2D rigidbody; public Gravitation gravitation; public GameController gameController; public Merger merger; public Collider2D particleCollider; public Collider2D mergeCollider; public Emitter emitter; public Animator animator; public Hue hue; public SpriteRenderer mainRenderer; public SpriteRenderer auraRenderer; public SpriteRenderer detailsRenderer; public Disappear disappear; public int Tier { get { return _tier; } set { _tier = value; Scale = Mathf.Pow(gameController.scaleMultiplier, _tier); animator.runtimeAnimatorController = gameController.tierAnimation[_tier % gameController.tierAnimation.Length]; hue.PossibleColors = gameController.tierGradients[_tier % gameController.tierGradients.Length]; gameController.CheckNewMaxTier(_tier); disappear.ResetTimer(); } } public float Scale { get { return transform.localScale.x; } set { transform.localScale = new Vector3(value, value, 1); } } public float Mass { get { return Mathf.Pow(gameController.particlesToMerge + 1, Tier); } } public float Duration { get { return gameController.particleDurationPerTier * (Tier + 1); } } public GameObject ParticlePrefab { get { return gameController.particlePrefab; } } protected void Awake() { rigidbody = GetComponent(); gravitation = GetComponent(); gameController = GameObject.Find("GameController").GetComponent(); merger = GetComponentInChildren(); particleCollider = GetComponent(); mergeCollider = merger.GetComponent(); emitter = GetComponent(); mainRenderer = GetComponent(); auraRenderer = transform.Find("Aura").GetComponent(); detailsRenderer = transform.Find("Details").GetComponent(); hue = GetComponent(); animator = GetComponent(); disappear = GetComponent(); } protected void Start() { animator.runtimeAnimatorController = gameController.tierAnimation[_tier % gameController.tierAnimation.Length]; hue.PossibleColors = gameController.tierGradients[_tier % gameController.tierGradients.Length]; } protected void OnDestroy() { if(Tier >= gameController.maxTierPresent) { gameController.RecalculateMaxTier(); } } }