2019-10-05 18:41:07 +00:00
|
|
|
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;
|
2019-10-05 21:50:43 +00:00
|
|
|
public Emitter emitter;
|
2019-10-06 13:04:50 +00:00
|
|
|
public Animator animator;
|
|
|
|
public Hue hue;
|
|
|
|
public SpriteRenderer mainRenderer;
|
|
|
|
public SpriteRenderer auraRenderer;
|
|
|
|
public SpriteRenderer detailsRenderer;
|
2019-10-06 15:44:41 +00:00
|
|
|
public Disappear disappear;
|
2019-10-05 18:41:07 +00:00
|
|
|
|
|
|
|
public int Tier {
|
|
|
|
get {
|
|
|
|
return _tier;
|
|
|
|
}
|
|
|
|
set {
|
2019-10-06 13:04:50 +00:00
|
|
|
_tier = value;
|
2019-10-06 15:44:41 +00:00
|
|
|
Scale = Mathf.Pow(gameController.scaleMultiplier, _tier);
|
2019-10-06 17:04:47 +00:00
|
|
|
animator.runtimeAnimatorController = gameController.tierAnimation[_tier % gameController.tierAnimation.Length];
|
|
|
|
hue.PossibleColors = gameController.tierGradients[_tier % gameController.tierGradients.Length];
|
|
|
|
gameController.CheckNewMaxTier(_tier);
|
2019-10-06 15:44:41 +00:00
|
|
|
disappear.ResetTimer();
|
2019-10-05 18:41:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public float Scale {
|
|
|
|
get {
|
|
|
|
return transform.localScale.x;
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
transform.localScale = new Vector3(value, value, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public float Mass {
|
|
|
|
get {
|
2019-10-06 15:44:41 +00:00
|
|
|
return Mathf.Pow(gameController.particlesToMerge + 1, Tier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public GameObject ParticlePrefab {
|
|
|
|
get {
|
|
|
|
return gameController.particlePrefab;
|
2019-10-05 18:41:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void Awake() {
|
|
|
|
rigidbody = GetComponent<Rigidbody2D>();
|
|
|
|
gravitation = GetComponent<Gravitation>();
|
|
|
|
gameController = GameObject.Find("GameController").GetComponent<GameController>();
|
|
|
|
merger = GetComponentInChildren<Merger>();
|
|
|
|
particleCollider = GetComponent<Collider2D>();
|
|
|
|
mergeCollider = merger.GetComponent<Collider2D>();
|
2019-10-05 21:50:43 +00:00
|
|
|
emitter = GetComponent<Emitter>();
|
2019-10-06 13:04:50 +00:00
|
|
|
mainRenderer = GetComponent<SpriteRenderer>();
|
|
|
|
auraRenderer = transform.Find("Aura").GetComponent<SpriteRenderer>();
|
|
|
|
detailsRenderer = transform.Find("Details").GetComponent<SpriteRenderer>();
|
|
|
|
hue = GetComponent<Hue>();
|
|
|
|
animator = GetComponent<Animator>();
|
2019-10-06 15:44:41 +00:00
|
|
|
disappear = GetComponent<Disappear>();
|
2019-10-06 13:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void Start() {
|
2019-10-06 17:04:47 +00:00
|
|
|
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();
|
|
|
|
}
|
2019-10-05 18:41:07 +00:00
|
|
|
}
|
|
|
|
}
|