public void InteractableInitialize() { //In case I forget... gameObject.layer = LayerMask.NameToLayer("Interactable"); if (GetComponent <PowerCube>() != null) { pc = GetComponent <PowerCube>(); it = InteractableType.PowerCube; } else if (GetComponent <PowerStation>() != null) { ps = GetComponent <PowerStation>(); it = InteractableType.PowerStation; } else if (GetComponent <DoorButton>() != null) { db = GetComponent <DoorButton>(); it = InteractableType.DoorButton; } else if (GetComponent <TimedDoorButton>() != null) { timd = GetComponent <TimedDoorButton>(); it = InteractableType.TimedDoorButton; } else { it = InteractableType.None; } //If universal functionality is needed, that will go here }
public void BalanceAddNew(PowerCube cube, int siblingIndex) { int currentCubeCount = cubes.Count(x => x != null); if (currentCubeCount <= 0f) { FlexData.EnergyContainer = new EnergyContainer(cube.EnergyContainer.CurrentAmount) { TotalCapacity = ElectricityConstants.WattHoursPerBatteryBlock + synergyBonusWatts }; } else { FlexData.EnergyContainer = new EnergyContainer(FlexData.EnergyContainer.CurrentAmount + cube.EnergyContainer.CurrentAmount) { //current cubes + new cube + synergy bonus TotalCapacity = ElectricityConstants.WattHoursPerBatteryBlock * (currentCubeCount + 1f) + synergyBonusWatts }; } cubes[siblingIndex] = cube; RefreshPowerBackings(); cube.RefreshVisualization(); cube.Hide(); }
void OnTriggerExit(Collider other) { PowerCube pC = other.GetComponent <PowerCube>(); if (pC != null) { adjCubes.Remove(pC); if (pC.tag == "MainCube") { containsMain = false; foreach (PowerCube p in adjCubes) { p.CheckSources(); } } CheckSources(); } }
public override void OnInspectorGUI() { PowerCube t = (PowerCube)target; t.IsAlwaysActive = EditorGUILayout.ToggleLeft("Is Always Active", t.IsAlwaysActive); serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty("responseTriggers"), true); serializedObject.ApplyModifiedProperties(); EditorGUILayout.Space(); t.activateSoundEffect = EditorGUILayout.ObjectField("Activate Sound Effect", t.activateSoundEffect, t.activateSoundEffect.GetType(), false) as AudioClip; t.activateSEDelay = EditorGUILayout.FloatField("Activate SE Delay", t.activateSEDelay); t.deactivateSoundEffect = EditorGUILayout.ObjectField("Deactivate Sound Effect", t.deactivateSoundEffect, t.deactivateSoundEffect.GetType(), false) as AudioClip; t.deactivateSEDelay = EditorGUILayout.FloatField("Deactivate SE Delay", t.deactivateSEDelay); EditorUtility.SetDirty(t); }
public void BalanceRemove(PowerCube cube) { int currentCubeCount = cubes.Count(x => x != null); if (FlexData.EnergyContainer.CurrentAmount >= ElectricityConstants.WattHoursPerBatteryBlock * 4f) { cube.EnergyContainer.Push(ElectricityConstants.WattHoursPerBatteryBlock); FlexData.EnergyContainer.Pull(ElectricityConstants.WattHoursPerBatteryBlock); } else { //zero out the leaving cube cube.EnergyContainer.Pull(ElectricityConstants.WattHoursPerBatteryBlock); //get the amount of watts per cube float perBalance = FlexData.EnergyContainer.CurrentAmount / (float)currentCubeCount; //and set that to the cube that is leaving cube.EnergyContainer.Push(perBalance); FlexData.EnergyContainer.Pull(perBalance); } if (currentCubeCount <= 1) { //no more cubes, zero out the battery FlexData.EnergyContainer.Pull(ElectricityConstants.WattHoursPerBatteryBlock * 2f); } for (int i = 0; i < cubes.Length; i++) { if (cubes[i] != null) { cubes[i] = null; } } RefreshPowerBackings(); cube.Show(); cube.RefreshVisualization(); }
void OnTriggerEnter(Collider other) { PowerCube pC = other.GetComponent <PowerCube>(); if (pC != null && pC != this) { adjCubes.Add(pC); if (pC.tag == "MainCube" || this.tag == "MainCube") { containsMain = true; foreach (PowerCube p in adjCubes) { p.CheckSources(); } } if (pC.IsActive && !this.IsActive && containsMain) { Activate(); } } }