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

125 lines
3.3 KiB
C#
Raw Normal View History

2019-10-05 08:55:53 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2019-10-06 13:04:50 +00:00
using UnityEngine.Animations;
2019-10-05 08:55:53 +00:00
public class GameController : MonoBehaviour
{
2019-10-06 15:44:41 +00:00
[Header("Constants")]
2019-10-05 18:41:07 +00:00
public float gravitationConstant = 2;
public int particlesToMerge = 5;
public int scaleMultiplier = 3;
2019-10-06 22:21:35 +00:00
public int particleDurationConstant = 5;
2019-10-06 13:04:50 +00:00
2019-10-06 22:21:35 +00:00
[Header("Black Hole")]
2019-10-06 15:44:41 +00:00
public GameObject blackHolePrefab;
[Header("Particles")]
public GameObject particlePrefab;
2019-10-06 13:04:50 +00:00
public Gradient[] tierGradients;
public RuntimeAnimatorController[] tierAnimation;
2019-10-06 15:44:41 +00:00
2019-10-07 11:44:26 +00:00
[Header("Upgrade Parameters")]
2019-10-06 15:44:41 +00:00
public float[] upgradePushForce;
public float[] upgradePushRadius;
2019-10-06 22:21:35 +00:00
public int[] upgradeParticleCount;
public int[] upgradeParticleTiers;
2019-10-06 15:44:41 +00:00
2019-10-07 11:44:26 +00:00
[Header("Bought Updates")]
2019-10-06 22:21:35 +00:00
public int _levelAntig = 0;
public int _levelMatter = 0;
public int _levelFission = 0;
public int LevelAntig {
get {
return _levelAntig;
}
set {
_levelAntig = value;
pusher.pushForce = upgradePushForce[_levelAntig];
pusher.pushRadius = upgradePushRadius[_levelAntig];
}
}
public int LevelMatter {
get {
return _levelMatter;
}
set {
_levelMatter = value;
spawner.spawnedTier = upgradeParticleTiers[_levelMatter];
}
}
public int LevelFission {
get {
return _levelFission;
}
set {
_levelFission = value;
spawner.spawnCount = upgradeParticleCount[_levelFission];
}
}
2019-10-06 15:44:41 +00:00
2019-10-07 11:44:26 +00:00
[Header("Simulation Status")]
public List<Gravitation> simulatedObjects;
public int maxTierPresent;
2019-10-06 15:44:41 +00:00
[Header("References")]
2019-10-07 14:23:15 +00:00
[HideInInspector]
public UpgradePanel upgradePanel;
2019-10-07 11:44:26 +00:00
[HideInInspector]
2019-10-06 15:44:41 +00:00
public SpawnOnMouseClick spawner;
2019-10-07 11:44:26 +00:00
[HideInInspector]
2019-10-06 15:44:41 +00:00
public PushOnMouseClick pusher;
2019-10-07 11:44:26 +00:00
[HideInInspector]
2019-10-06 15:44:41 +00:00
public CameraPan panner;
2019-10-07 11:44:26 +00:00
[HideInInspector]
2019-10-06 15:44:41 +00:00
public MusicManager musicManager;
2019-10-07 11:44:26 +00:00
[HideInInspector]
2019-10-06 22:21:35 +00:00
public Canvas canvas;
2019-10-06 15:44:41 +00:00
2019-10-07 11:44:26 +00:00
[HideInInspector]
public BlackHole blackHole;
2019-10-06 15:44:41 +00:00
protected void Awake() {
spawner = Camera.main.GetComponent<SpawnOnMouseClick>();
pusher = Camera.main.GetComponent<PushOnMouseClick>();
panner = Camera.main.GetComponent<CameraPan>();
musicManager = GetComponent<MusicManager>();
2019-10-06 17:04:47 +00:00
simulatedObjects = new List<Gravitation>();
2019-10-06 22:21:35 +00:00
canvas = GameObject.FindGameObjectWithTag("Canvas").GetComponent<Canvas>();
2019-10-07 14:23:15 +00:00
upgradePanel = GameObject.FindGameObjectWithTag("UpgradePanel").GetComponent<UpgradePanel>();
2019-10-06 17:04:47 +00:00
}
protected void Start() {
maxTierPresent = -1;
2019-10-06 22:21:35 +00:00
LevelAntig = 0;
LevelFission = 0;
LevelMatter = 0;
2019-10-06 17:04:47 +00:00
}
public void CheckNewMaxTier(int tier) {
if(tier > maxTierPresent) {
maxTierPresent = tier;
musicManager.UpdateLayers(maxTierPresent);
}
}
public void RecalculateMaxTier() {
maxTierPresent = -1;
foreach(GameObject particleObject in GameObject.FindGameObjectsWithTag("Particle")) {
Particle particle = particleObject.GetComponent<Particle>();
if(particle.Tier > maxTierPresent) {
maxTierPresent = particle.Tier;
}
};
musicManager.UpdateLayers(maxTierPresent);
2019-10-06 15:44:41 +00:00
}
2019-10-05 08:55:53 +00:00
}