1
Fork 0
mirror of https://github.com/Steffo99/gravity-fusion.git synced 2024-11-22 16:24:20 +00:00
gravity-fusion/Assets/Components/Particle.cs

72 lines
2.2 KiB
C#
Raw Normal View History

2019-10-05 18:41:07 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody2D))]
[RequireComponent(typeof(Collider2D))]
[RequireComponent(typeof(Gravitation))]
2019-10-05 21:50:43 +00:00
[RequireComponent(typeof(Emitter))]
2019-10-05 18:41:07 +00:00
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-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-05 18:41:07 +00:00
Scale *= gameController.scaleMultiplier;
2019-10-06 13:04:50 +00:00
animator.runtimeAnimatorController = gameController.tierAnimation[_tier];
hue.PossibleColors = gameController.tierGradients[_tier];
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 {
return Mathf.Pow(gameController.particlesToMerge, Tier);
}
}
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>();
}
protected void Start() {
animator.runtimeAnimatorController = gameController.tierAnimation[_tier];
hue.PossibleColors = gameController.tierGradients[_tier];
2019-10-05 18:41:07 +00:00
}
}