You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

187 lines
3.7 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CircuitManager : MonoBehaviour {
public static CircuitManager Instance {
get; set;
}
[Header("Circuit Values")]
public CircuitLevels basic;
public CircuitLevels capacitor;
public CircuitLevels generator;
public CircuitLevels speeder;
void Awake() {
//Manage Singleton
if (Instance != null && Instance != this)
Destroy(gameObject);
else
Instance = this;
DontDestroyOnLoad(gameObject);
}
public CircuitLevels GetLevelsByType(CircuitType circuitType) {
switch (circuitType) {
case CircuitType.Basic:
return basic;
case CircuitType.Capacitor:
return capacitor;
case CircuitType.Generator:
return generator;
case CircuitType.Speeder:
return speeder;
}
return null;
}
}
[Serializable]
public class CircuitLevels {
public CircuitValues level1;
public CircuitValues level2;
public CircuitValues level3;
public CircuitValues GetValuesByLevel(int level) {
switch (level) {
case 1:
return level1;
case 2:
return level2;
case 3:
return level3;
}
return null;
}
public float[] GetValueLevelsByValueType(ValueType valueType) {
switch (valueType) {
case ValueType.Capacity:
return new float[] { level1.capacity, level2.capacity, level3.capacity};
case ValueType.ChargeRate:
return new float[] { level1.chargeRate, level2.chargeRate, level3.chargeRate };
case ValueType.SendRate:
return new float[] { level1.sendRate, level2.sendRate, level3.sendRate };
case ValueType.SendSpeed:
return new float[] { level1.sendSpeed, level2.sendSpeed, level3.sendSpeed };
case ValueType.Range:
return new float[] { level1.range, level2.range, level3.range };
case ValueType.Connections:
return new float[] { level1.connections, level2.connections, level3.connections };
case ValueType.UpgradeCost:
return new float[] { level1.upgradeCost, level2.upgradeCost, level3.upgradeCost };
}
return null;
}
public CircuitLevels() {
}
}
public class CircuitValueLevels {
public float level1;
public float level2;
public float level3;
public float GetValueByLevel(int level) {
switch (level) {
case 1:
return level1;
case 2:
return level2;
case 3:
return level3;
}
return 0;
}
public CircuitValueLevels(float level1, float level2, float level3) {
this.level1 = level1;
this.level2 = level2;
this.level3 = level3;
}
}
[Serializable]
public class CircuitValues {
public float capacity;
public int connections;
public float chargeRate;
public float sendSpeed;
public float sendRate;
public float range;
public float upgradeCost;
}
[Serializable]
public class CircuitPrefabGroup {
public CircuitType type;
public GameObject level1;
public GameObject level2;
public GameObject level3;
public GameObject GetValuesByLevel(int level) {
switch (level) {
case 1:
return level1;
case 2:
return level2;
case 3:
return level3;
}
return null;
}
}
[Serializable]
public class CircuitColors {
public Color basis;
public Color deco;
public Color display;
}
public enum CircuitType {
Basic,
Capacitor,
Generator,
Speeder
}
public enum ValueType {
Capacity,
ChargeRate,
SendRate,
SendSpeed,
Range,
Connections,
UpgradeCost
}
[Serializable]
public class CircuitCost {
public CircuitType type;
public int cost;
}
[Serializable]
public class CircuitAmount {
public CircuitType type;
public int amount;
public CircuitAmount(CircuitType type, int amount) {
this.type = type;
this.amount = amount;
}
}
public class CircuitMatch {
public CircuitType type;
public Circuit circuit;
public CircuitMatch(CircuitType type, Circuit circuit) {
this.type = type;
this.circuit = circuit;
}
}