# Temperature logic in Atlas D (Plankton) *Key*: [[DESIGNS/ToyWorldsAtlas/AtlasD_Doc|AtlasD_Doc]] *Relevant*: [[DESIGNS/ToyWorldsAtlas/TWA_Code_Colour_D|TWA_Code_Colour_D]] ### UI temp slider ### PD_TemperatureContr ```cs using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PD_TemperatureContr : MonoBehaviour { public GameObject plankton; public Image warmthImage; public Image coolnessImage; // Temperature indexes public int warmArea; public int coolArea; public int neutralArea; public List<int> areaList; private List<int> colourCodesList; private void Start() { colourCodesList = plankton.GetComponent<JsonObj_Atlas>().colourCodes; } public void OnButtonCheckTemperature() { ResetAreas(); CalculateTemperature(); UpdateTermometerUI(); } private void ResetAreas() { warmArea = 0; coolArea = 0; neutralArea = 0; } private void UpdateTermometerUI() { int totalArea = warmArea + coolArea + neutralArea; if (totalArea == 0) return; warmthImage.fillAmount = (float)warmArea / totalArea; coolnessImage.fillAmount = (float)coolArea / totalArea; } private void CalculateTemperature() { for(int i = 0; i < colourCodesList.Count; i++) { int colour = colourCodesList[i]; int area = areaList[i]; if (colour >= 0 && colour <= 3) { warmArea += area; } else if (colour >= 3 && colour <= 6) { coolArea += area; } else if (colour >= 7 && colour <= 8) { neutralArea += area; } } } } ``` #### Old cursed option ```cs // TEMPERATURE LOGIC // We first add body + caviar + organs, and then calculate organ parts if they have a different colour-temp void CheckButtonCare1() { // False means it's never been clicked before; // This way we don't substract from the opposite temperature index of another button when it was not activated if (!boredom1) { // 17 (body & Caviar) + 11 (organ) warmthIndex += 28; Debug.Log("W+28"); } else { warmthIndex += 28; coolnessIndex -= 28; Debug.Log("W+28, C-28"); } care1 = true; // indicates that care1 was clicked at least once } void CheckButtonBoredom1() { if (!care1) { coolnessIndex += 28; Debug.Log("C+28"); } else { warmthIndex -= 28; coolnessIndex += 28; Debug.Log("W-28, C+28"); } boredom1 = true; } // DWELLING-2 void CheckButtonDwelling2() { if (uncanny2 == false) { // 17 (body & Caviar) + 16 (organ) = 33 warmthIndex += 33; Debug.Log("W+33"); } else { warmthIndex += 33; coolnessIndex -= 33; Debug.Log("W+33, C-33"); } dwelling2 = true; // Checks 1_IV organ part if (buttonFlagsList[0] == true) { warmthIndex -= 6; // turns neutral Debug.Log("W-6"); } // Checks 1_IV organ part if (buttonFlagsList[1] == true) { coolnessIndex -= 6; // turns neutral Debug.Log("C-6"); } } // UNCANNY-2 void CheckButtonUncanny2() { if (dwelling2 == false) { coolnessIndex += 33; } else { coolnessIndex += 33; warmthIndex -= 33; } uncanny2 = true; // Checks 1_IV organ part if (buttonFlagsList[0] == true) { if (dwelling2) { warmthIndex += 6; // turns warm } } // Checks 1_IV organ part if (buttonFlagsList[1] == true) { if (dwelling2) { coolnessIndex += 6; // turns warm } } } // HARMONY-3 void CheckButtonHarmony3() { if (harmony3 == false && care3 == false) { // 24 (body & Caviar) + 17 (organ) = 41 warmthIndex += 41; } else { warmthIndex += 0; } harmony3 = true; // Checks 1_V if (buttonFlagsList[1] == true) { if (care3) { warmthIndex -= 1; // turns neutral } else if (!care3) { coolnessIndex -= 1; } } } // CARE-3 void CheckButtonCare3() { if (harmony3 == false && care3 == false) { warmthIndex += 41; } else { warmthIndex += 0; } care3 = true; // Checks 1_V if (buttonFlagsList[1] == true) { if (harmony3) { warmthIndex += 1; } else if (!harmony3) // if the first button pressed in 3rd row since Start() { coolnessIndex -= 1; warmthIndex += 1; } } } // FINITUDE-4 void CheckButtonFinitude4() { // 37 (body & Caviar) + 7 (organ) = 44 coolnessIndex += 44; finitude4 = true; // Checks 2_I if (buttonFlagsList[2] == true) // if dwelling2 is active { warmthIndex -= 9; coolnessIndex += 9; Debug.Log("W-9, C+9"); } // Checks 2_I if (buttonFlagsList[3] == true) // if uncanny2 is active { if (everydayness4) { coolnessIndex += 9; Debug.Log("C+9"); } } // Check 3_I if (buttonFlagsList[4] == true) { warmthIndex -= 10; } // Check 3_I if (buttonFlagsList[5] == true) { warmthIndex -= 10; coolnessIndex += 10; } // Check 4_IV if (buttonFlagsList[2] == true) { warmthIndex -= 4; coolnessIndex += 4; } // Check 4-IV if (buttonFlagsList[3] == true) { if (everydayness4) { coolnessIndex += 4; } } // Checks 4_V if (buttonFlagsList[4] == true) { coolnessIndex -= 1; // substracts the neutral part } // Checks 4_V if (buttonFlagsList[5] == true) { if (everydayness4) { warmthIndex -= 1; coolnessIndex += 1; } } } // EVERYDAYNESS-4 void CheckButtonEveydayness4() { if (finitude4 == false) { coolnessIndex -= 0; } else { coolnessIndex -= 44; } everydayness4 = true; // Checks 2_I if (buttonFlagsList[2] == true) // if dwelling2 is active { if (finitude4) // that is, if uncanny4 is active now { warmthIndex += 9; coolnessIndex -= 9; Debug.Log("W+9, C-9"); } } // Checks 2_I if (buttonFlagsList[3] == true) // if uncanny2 is active { coolnessIndex -= 9; Debug.Log("C-9"); } // Check 3_I if (buttonFlagsList[4] == true) { if (finitude4) { warmthIndex += 10; } } // Check 3_I if (buttonFlagsList[5] == true) { if (finitude4) { warmthIndex += 10; coolnessIndex -= 10; } } // Checks 4_IV if (buttonFlagsList[2] == true) { if (finitude4) { warmthIndex += 4; coolnessIndex -= 4; } } // Check 4-IV if (buttonFlagsList[3] == true) { coolnessIndex -= 4; } // Checks 4_V if (buttonFlagsList[4] == true) { if (!finitude4) { warmthIndex -= 1; coolnessIndex += 1; } else if (finitude4) { coolnessIndex += 1; // turns cold from neutral } } // Checks 4_V if (buttonFlagsList[5] == true) { if (!finitude4) { warmthIndex += 1; } if (finitude4) { coolnessIndex -= 1; warmthIndex += 1; } } } // BOREDOM-5 void CheckButtonBoredom5() { // 19 (body & Caviar) + 15 (organ) coolnessIndex += 34; boredom5 = true; // Checks 2_II if (buttonFlagsList[2] == true) { warmthIndex -= 6; } // Checks 2_II if (buttonFlagsList[3] == true) { if (questioning5) { coolnessIndex += 6; } } // Checks 3_II if (buttonFlagsList[4] == true) { if (!questioning5) { warmthIndex -= 6; } if (questioning5) { coolnessIndex -= 6; } } // Checks 3_II if (buttonFlagsList[5] == true) { if (questioning5) { warmthIndex += 6; } } // Checks 5_VI if (buttonFlagsList[0] == true) // care1 { if (!questioning5) { coolnessIndex -= 6; warmthIndex += 6; } if (questioning5) { warmthIndex += 6; } } // Checks 5_VI if (buttonFlagsList[1] == true) { if (!questioning5) { coolnessIndex -= 6; } else if (questioning5) { warmthIndex -= 6; } } // Check 5_VIII if (buttonFlagsList[6] == true) { coolnessIndex -= 2; warmthIndex += 2; } // Check 5_VIII if (buttonFlagsList[7] == true) { if (!questioning5) { coolnessIndex -= 2; warmthIndex += 2; } if (questioning5) { warmthIndex += 2; } } } // QUESTIONING-5 void CheckButtonQuestioning5() { if (boredom5 == false) { coolnessIndex -= 0; } else { coolnessIndex -= 34; } questioning5 = true; // Checks 2_II if (buttonFlagsList[2] == true) { if (boredom5) { warmthIndex += 6; } } // Check 2_II if (buttonFlagsList[3] == true) { coolnessIndex -= 6; } // Checks 3_II if (buttonFlagsList[4] == true) { if (!boredom5) { warmthIndex -= 6; coolnessIndex += 6; } if (boredom5) { coolnessIndex += 6; } } // Checks 3_II if (buttonFlagsList[5] == true) { warmthIndex -= 6; } // Checks 5_VI if (buttonFlagsList[0] == true) // care1 { warmthIndex -= 6; } // Checks 5_VI if (buttonFlagsList[1] == true) // boredom1 { warmthIndex += 6; } // Check 5_VIII if (buttonFlagsList[6] == true) { if (!boredom5) { coolnessIndex += 2; } if (boredom5) { warmthIndex -= 2; coolnessIndex += 2; } } // Check 5_VIII if (buttonFlagsList[7] == true) { if (!boredom5) { warmthIndex += 2; } } } // UNCANNY-6 void CheckButtonUncanny6() { if (togetherness6 == false) { coolnessIndex += 14; } else { warmthIndex -= 14; coolnessIndex += 14; } uncanny6 = true; // Check 5_VII if (buttonFlagsList[8] == true) { if (togetherness6) { coolnessIndex += 5; } } // Check 5_VII if (buttonFlagsList[9] == true) { if (togetherness6) { coolnessIndex -= 5; } } } // TOGETHERNESS-6 void CheckButtonTogetherness6() { if (uncanny6 == false) { warmthIndex += 14; } else { warmthIndex += 14; coolnessIndex -= 14; } togetherness6 = true; // Check 5_VII if (buttonFlagsList[8] == true) { coolnessIndex -= 5; } // Check 5_VII if (buttonFlagsList[9] == true) { coolnessIndex += 5; } } // PRESENCE-7 void CheckButtonPresence7() { if (finitude7 == false) { coolnessIndex -= 0; } else { coolnessIndex -= 21; } presence7 = true; // Checks 1_III organ part if (buttonFlagsList[0] == true) { if (finitude7) // is relevant only if 7.1 changes from 7.2; otherwise turns warm to warm { warmthIndex += 4; // turns warm coolnessIndex -= 4; // cancels 7.2's affects } } // Checks 1_III organ part if (buttonFlagsList[1] == true) // if boredom1 is active { if (finitude7) { warmthIndex -= 4; // turns neutral } else if (!finitude7) { coolnessIndex -= 4; } } // Checks 2_III if (buttonFlagsList[2] == true) { if (!finitude7) { warmthIndex -= 1; } if (finitude7) { coolnessIndex -= 1; } } // Checks 2_III if (buttonFlagsList[3] == true) { coolnessIndex -= 1; warmthIndex += 1; } // Checks 3_III if (buttonFlagsList[4] == true) { warmthIndex -= 1; } // Checks 3_III if (buttonFlagsList[5] == true) { if (finitude7) { warmthIndex += 1; coolnessIndex -= 1; } } // Check 4_III if (buttonFlagsList[7] == true) { coolnessIndex -= 2; warmthIndex += 2; } // Check 4_III if (buttonFlagsList[8] == true) { if (!finitude7) { warmthIndex += 2; } if (finitude7) { coolnessIndex -= 2; warmthIndex += 2; } } } // FINITUDE-7 void CheckButtonFinitude7() { coolnessIndex += 21; finitude7 = true; // Checks 1_III organ part if (buttonFlagsList[0] == true) // if care1 is active { warmthIndex -= 4; // turns cool coolnessIndex += 4; } // Checks 1_III organ part if (buttonFlagsList[1] == true) // if boredom1 is active { if (presence7) { warmthIndex += 4; // turns neutral } else if (!presence7) // if it's the first button clicked in the 7th row since Start() { coolnessIndex -= 4; warmthIndex += 4; } } // Checks 2_III if (buttonFlagsList[2] == true) { if (!presence7) { warmthIndex -= 1; coolnessIndex += 1; } if (presence7) { coolnessIndex += 1; } } // Checks 2_III if (buttonFlagsList[3] == true) { if (presence7) { warmthIndex -= 1; } } // Checks 3_III if (buttonFlagsList[4] == true) { warmthIndex -= 1; } // Checks 3_III if (buttonFlagsList[5] == true) { warmthIndex -= 1; coolnessIndex += 1; } // Check 4_III if (buttonFlagsList[7] == true) { if (presence7) { coolnessIndex += 2; warmthIndex -= 2; } } // Check 4_III if (buttonFlagsList[8] == true) { if (!presence7) { coolnessIndex += 2; } if (presence7) { coolnessIndex += 2; warmthIndex -= 2; } } } ```