// Update is called once per frame void FixedUpdate() { Peripheral Periph = GetComponent <Peripheral> (); BasePartBehaviour bph = GetComponent <BasePartBehaviour> (); Periph.Ports [0] = Mathf.RoundToInt(bph.Thermal.Temperature); }
void FixedUpdate() { Rigidbody2D rb = gameObject.GetComponentInParent <Rigidbody2D> (); if (rb != null) { BasePartBehaviour tc = gameObject.GetComponent <BasePartBehaviour> (); Peripheral Peripheral = gameObject.GetComponent <Peripheral> (); gimbal = Peripheral.Ports [0]; SetSparker = (Peripheral.Ports [1] != 0); Peripheral.Ports [3] = Mathf.RoundToInt(tc.Thermal.Temperature); float f = Peripheral.Ports [2] / 64f; foreach (RecourseConnection rc in thruster.requiredRecourses) { f = Mathf.Min(f, rc.TakeRecourse(Peripheral.Ports [2]) / 64f); } if (sparkerOn) { float t = sparker.sparkerConsumption; foreach (RecourseConnection rc in sparker.requiredRecourses) { t = Mathf.Min(t, rc.TakeRecourse(sparker.sparkerConsumption)); } tc.Thermal.ThermalEnergy += t; } ParticleSystem.MainModule main = FuelEffects.main; if (tc.Thermal.Temperature > thruster.ignitionTemperatureThreshold) { rb.AddForceAtPosition(GimbalTransform.up * f * thruster.forcePerUnit, transform.position); tc.Thermal.ThermalEnergy += thruster.inginitionThermalEnergy * f; if (IgnitionEffects != null) { if (IgnitionEffects.isStopped) { IgnitionEffects.Play(); } ParticleSystem.EmissionModule em = IgnitionEffects.emission; main.startSpeedMultiplier = f * particleViolence; em.rateOverTimeMultiplier = f * particleViolence; } if (FuelEffects != null) { if (FuelEffects.isPlaying) { FuelEffects.Stop(); } } } else { rb.AddForceAtPosition(GimbalTransform.up * f, GimbalTransform.position); if (IgnitionEffects != null) { if (IgnitionEffects.isPlaying) { IgnitionEffects.Stop(); } } if (FuelEffects != null) { if (FuelEffects.isStopped) { FuelEffects.Play(); } ParticleSystem.EmissionModule em = FuelEffects.emission; main.startSpeedMultiplier = f * particleViolence; em.rateOverTimeMultiplier = f * particleViolence; } } } }
// Update is called once per frame void FixedUpdate() { BasePartBehaviour bpb = gameObject.GetComponent <BasePartBehaviour> (); RecourseConnection rc = gameObject.GetComponent <RecourseConnection> (); foreach (string k in peripherals.Keys) { if (peripherals [k] [0] < connectedPeripherals.Length) { if (connectedPeripherals [peripherals [k] [0]] != null) { setValue(k, connectedPeripherals [peripherals [k] [0]].Ports [peripherals [k] [1]]); } } } int tick = 0; while (tick < clockSpeed && program_pointer < rawProgram.Length && delay < 1 && rc.RecourseAvailability(powerConsumption) >= powerConsumption) { bpb.Thermal.ThermalEnergy += ThermalEnergyGeneration; rc.TakeRecourse(powerConsumption); string[] instruction = rawProgram [program_pointer].Split(new char[1] { ' ' }); switch (instruction [0].ToLower()) { case "print": for (int i = 1; i < instruction.Length; i++) { Output += char.ConvertFromUtf32(getLitteral(instruction [i])); } break; case "println": for (int i = 1; i < instruction.Length; i++) { Output += char.ConvertFromUtf32(getLitteral(instruction [i])); } Output += "\n"; break; case "printi": Output += getLitteral(instruction [1]).ToString(); break; case "set": setValue(instruction [1], getLitteral(instruction [2])); break; case "add": setValue(instruction [1], getValue(instruction [1]) + getLitteral(instruction [2])); break; case "sub": setValue(instruction [1], getValue(instruction [1]) - getLitteral(instruction [2])); break; case "jump": program_pointer = getLitteral(instruction [1]) - 1; break; case "tag": setValue(instruction [1], program_pointer); break; case "if": switch (instruction [2]) { case "equals": if (getLitteral(instruction [1]) != getLitteral(instruction [3])) { program_pointer++; } break; case "notequals": if (getLitteral(instruction [1]) == getLitteral(instruction [3])) { program_pointer++; } break; case "greaterthan": if (getLitteral(instruction [1]) < getLitteral(instruction [3])) { program_pointer++; } break; case "lessthan": if (getLitteral(instruction [1]) > getLitteral(instruction [3])) { program_pointer++; } break; } break; case "periph": peripherals.Add(instruction [1], new int[] { getLitteral(instruction [2]), getLitteral(instruction [3]) }); break; case "delay": delay = getLitteral(instruction [1]); break; case "clear": Output = ""; break; } program_pointer++; tick++; } if (delay > 0) { delay -= 1; } foreach (string k in peripherals.Keys) { if (peripherals [k] [0] < connectedPeripherals.Length) { if (connectedPeripherals [peripherals [k] [0]] != null) { connectedPeripherals [peripherals [k] [0]].Ports [peripherals [k] [1]] = getValue(k); } } } }
// Update is called once per frame void Update() { if (CurrentPart != null) { CurrentPart.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0, 0, 8); Collider2D relativeCollider = Physics2D.OverlapCircle(Camera.main.ScreenToWorldPoint(Input.mousePosition), 2, 1); if (relativeCollider != null) { Transform relativeTransform = relativeCollider.transform; CurrentPart.transform.position = relativeTransform.TransformPoint(Round(relativeTransform.InverseTransformPoint(CurrentPart.transform.position), 0.5f)); CurrentPart.transform.eulerAngles = relativeTransform.eulerAngles + Round(CurrentPart.transform.eulerAngles - relativeTransform.eulerAngles, 90f); } if (Input.GetKeyDown(KeyCode.R)) { CurrentPart.transform.Rotate(new Vector3(0, 0, 1), -90f); } if (Input.GetMouseButtonUp(0)) { if ((transform.position - Input.mousePosition).magnitude < 300) { Destroy(CurrentPart); } else { BasePartBehaviour bph = CurrentPart.GetComponent <BasePartBehaviour> (); foreach (BasePartBehaviour.connectionPoint v in bph.ConnectionPoints) { foreach (Collider2D c in Physics2D.OverlapPointAll(CurrentPart.transform.TransformPoint(v.LocalPosition))) { if (c.tag == "Part" && !Physics2D.IsTouching(c, bph.GetComponent <Collider2D>())) { CurrentPart.transform.SetParent(c.attachedRigidbody.transform); } } } if (CurrentPart.transform.parent == null) { GameObject newShip = Instantiate(BaseShip); newShip.transform.position = CurrentPart.transform.position; CurrentPart.transform.SetParent(newShip.transform); } CameraController cc = Camera.main.GetComponent <CameraController> (); cc.Target = CurrentPart.transform.parent.gameObject; cc.Offset = (cc.transform.position - CurrentPart.transform.parent.position); foreach (Collider2D collider in CurrentPart.GetComponents <Collider2D> ()) { collider.enabled = true; } CurrentPart = null; } } } else { if (Input.GetMouseButtonDown(0)) { Collider2D co = Physics2D.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)); foreach (Collider2D c in Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition))) { if (co == null) { co = c; } else { if ((c.transform.position - Camera.main.ScreenToWorldPoint(Input.mousePosition)).magnitude < (co.transform.position - Camera.main.ScreenToWorldPoint(Input.mousePosition)).magnitude) { co = c; } } } if (co != null) { if (co.tag == "Part" && co.isActiveAndEnabled) { CurrentPart = co.gameObject; Transform oldTransform = CurrentPart.transform.parent; CurrentPart.transform.SetParent(null); foreach (Collider2D collider in CurrentPart.GetComponents <Collider2D> ()) { collider.enabled = false; } co.enabled = false; if (oldTransform.childCount < 1) { Destroy(oldTransform.gameObject); } } } else { foreach (Button b in PartPanelWindow.GetComponentsInChildren <Button>()) { if ((Input.mousePosition - b.transform.position).magnitude < 25) { CurrentPart = Instantiate(Parts [b.transform.GetSiblingIndex()]); CurrentPart.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition); foreach (Collider2D c in CurrentPart.GetComponentsInChildren <Collider2D>()) { c.enabled = false; } } } } } } }