void Start() { foreach (var ctrl in Baroque.GetControllers()) { StartCoroutine(_FollowJoystick(ctrl)); } StartCoroutine(_BlinkCanvasInfo()); }
protected ModelAction(Render render, Controller ctrl) { this.render = render; this.ctrl = ctrl; Controller[] controllers = Baroque.GetControllers(); other_ctrl = controllers[1 - ctrl.index]; }
public static void RestartFollowingAll() { foreach (var ctrl in Baroque.GetControllers()) { var pad = ctrl.GetComponentInChildren <PongPad>(); if (pad != null) { pad.RestartFollowing(); } } }
void Update() { var ctrl0 = Baroque.GetControllers()[0]; var ctrl1 = Baroque.GetControllers()[1]; transform.rotation = Quaternion.Euler(ctrl0.triggerVariablePressure * 90, 0, ctrl1.triggerVariablePressure * 90); var rend = GetComponent <Renderer>(); rend.material.color = new Color(ctrl0.triggerPressed ? 1f : 0f, ctrl1.triggerPressed ? 1f : 0f, 0); }
float[] RecordRenderModels() { List <float> tr = new List <float>(FlattenTransform(Baroque.GetHeadTransform())); foreach (var ctrl in Baroque.GetControllers()) { if (ctrl.isActiveAndEnabled) { tr.AddRange(FlattenTransform(ctrl.transform)); } } return(tr.ToArray()); }
public void UpdateControllerHints() { foreach (var ctrl in Baroque.GetControllers()) { if (clicked_trigger && clicked_touchpad) { ctrl.SetControllerHints(/*nothing*/); } else { ctrl.SetControllerHints(trigger: "open", touchpadPressed: "mark"); } } }
protected override void RemovePointersOnPausedExplicit() { var old_expls = expls; expls = null; foreach (var ctrl in Baroque.GetControllers()) { var expl = ctrl.GetAdditionalData(ref old_expls); if (expl.cylinder_tr != null) { Destroy((GameObject)expl.cylinder_tr.parent.gameObject); } } }
IEnumerator _FadeOutPadsAndHeadset(bool[] stop_instruction) { var mat = new Material(PongPadBuilder.instance.padsAndHeadsetTransparencyMaterial); void FixMat(Transform toplevel) { foreach (var rend in toplevel.GetComponentsInChildren <MeshRenderer>()) { rend.sharedMaterial = mat; } } var headset = Instantiate(PongPadBuilder.instance.headsetPrefab); var head_tr = Baroque.GetHeadTransform(); headset.SetPositionAndRotation(head_tr.position, head_tr.rotation); FixMat(headset); foreach (var ctrl in Baroque.GetControllers()) { var pad = ctrl.GetComponentInChildren <PongPad>(); if (pad != null) { pad = Instantiate(pad, headset, worldPositionStays: true); Destroy((PongPad)pad.GetComponent <PongPad>()); FixMat(pad.transform); } } while (!stop_instruction[0]) { yield return(null); var col = mat.color; col.a -= Time.deltaTime * 0.75f; if (col.a <= 0f) { break; } mat.color = col; } Destroy((GameObject)headset.gameObject); Destroy(mat); }
void SelectedLevel(LevelBox level_box, Vector3 hitpoint) { gameObject.SetActive(false); foreach (var ctrl in Baroque.GetControllers()) { ctrl.SetControllerHints(/*nothing*/); } foreach (var mines1 in FindObjectsOfType <Mines>()) { mines1.Unpopulate(); } var mines = level_box.correspondingMines; for (int z = 0; z < mines.nz; z++) { for (int y = 0; y < mines.ny; y++) { for (int x = 0; x < mines.nx; x++) { var sgt = Instantiate(sgtPrefab); sgt.mines = mines; sgt.targetInt = new Vector3Int(x, y, z); sgt.GetComponent <MeshRenderer>().sharedMaterial = level_box.correspondingMines.defaultMat; sgt.transform.localScale = level_box.particleSys.main.startSize.constant * Vector3.one; sgt.transform.localPosition = hitpoint + Random.insideUnitSphere * 0.5f; } } } foreach (var laser in lasers) { if (laser != null && laser.tr != null) { Destroy(laser.tr.gameObject); } } lasers = null; }
IEnumerator BombExplodeOrGameSucceeded(Vector3Int?bomb_pos = null) { interactions = false; click_neighbors = null; foreach (var ctrl in Baroque.GetControllers()) { if (ctrl.isActiveAndEnabled) { ctrl.HapticPulse(); } ctrl.SetControllerHints(/*nothing*/); } playArea.clock.StopTicking(); if (bomb_pos != null) { SetCell(bomb_pos.Value, 0); } remove_me = new List <GameObject>(); if (bomb_pos != null) { Vector3 p0 = transform.TransformPoint(bomb_pos.Value); var explosion = Instantiate(playArea.explosionPrefab); explosion.rotation = Quaternion.LookRotation(Baroque.GetHeadTransform().position - p0); explosion.position = p0 + explosion.forward * 0.05f; yield return(new WaitForSeconds(0.1f)); Destroy(explosion.gameObject); var bomb = Instantiate(playArea.explodedBombPrefab, transform); bomb.position = p0; bomb.localScale = Vector3.one; remove_me.Add(bomb.gameObject); yield return(new WaitForSeconds(0.3f)); playArea.smokeParticleSys.transform.position = p0; playArea.smokeParticleSys.Play(); yield return(new WaitForSeconds(0.6f)); } else { yield return(new WaitForSeconds(0.5f)); var main = playArea.successParticleSys.main; main.startColor = activeMat.color; /* ^^^ XXX waaaat "main" is a struct, but it's still how you change parameters. You * assign a value to the struct. There's a magic setter property that will actually * have an effect on the original particle system. Because if it was a normal struct, * such a field assignment would be lost after we forget about the 'main' local variable. */ playArea.successParticleSys.Play(); } playArea.selectLevel.SetActive(true); if (bomb_pos == null && playArea.clock.seconds > 0) { playArea.selectLevel.GetComponent <SelectLevel>().WriteNewScore(this, playArea.clock.seconds); } foreach (var ub in GetUnknownBoxes()) { if (bombs.Contains(ub.position)) { var bomb = Instantiate(playArea.bombPrefab, transform); bomb.localPosition = ub.position; bomb.localScale = Vector3.one; remove_me.Add(bomb.gameObject); if (bomb_pos == null) { bomb.localScale *= 0.45f; ub.WinkOut(); } } else if (bomb_pos != null && ub.probablyBomb) { ub.WinkOut(show_empty: true); } } }
private void Gt_onControllersUpdate(Controller[] controllers) { foreach (var level_box in GetComponentsInChildren <LevelBox>()) { level_box.SetHighlight(0); } foreach (var ctrl in Baroque.GetControllers()) /* includes inactive ones */ { var laser = ctrl.GetAdditionalData(ref lasers); if (!ctrl.isActiveAndEnabled) { if (laser.tr != null) { Destroy(laser.tr.gameObject); laser.tr = null; } } else { if (laser.tr == null) { laser.tr = Instantiate(laserPrefab); laser.q = ctrl.rotation; successParticleSys.trigger.SetCollider(ctrl.index, laser.tr.GetComponentInChildren <Collider>()); } laser.q = Quaternion.Lerp(ctrl.rotation, laser.q, Mathf.Exp(-Time.deltaTime * 50)); laser.tr.position = ctrl.position; laser.tr.rotation = laser.q; RaycastHit hitinfo; LevelBox level_box = null; float distance = 5f; if (Physics.SphereCast(laser.tr.position, 0.01f, laser.tr.forward, out hitinfo, 10f, 1 << LevelBox.LAYER, QueryTriggerInteraction.Ignore)) { level_box = hitinfo.collider.GetComponentInParent <LevelBox>(); distance = Vector3.Distance(ctrl.position, hitinfo.point); } var tr0 = laser.tr.GetChild(0); Vector3 p = tr0.localScale; p.y = distance * 0.5f; tr0.localScale = p; p = tr0.localPosition; p.z = distance * 0.5f + 0.07f; tr0.localPosition = p; Color c = level_box == null ? new Color(0.3f, 0.3f, 0.3f) : ctrl.triggerPressed ? new Color(1f, 1f, 1f) : level_box.laserColor; laser.tr.GetComponentInChildren <Renderer>().material.color = c; if (level_box != null) { level_box.SetHighlight((ctrl.triggerPressed | laser.trigger_pressed) ? 2 : 1); if (laser.trigger_pressed && !ctrl.triggerPressed) { SelectedLevel(level_box, hitinfo.point); ctrl.HapticPulse(); break; } float cur_time = Time.time; float prev_time = cur_time - Time.deltaTime; int n1 = (int)(prev_time * particlesPerSecond); int n2 = (int)(cur_time * particlesPerSecond); if (n2 > n1) { ParticleSystem.EmitParams emit_params = new ParticleSystem.EmitParams { position = hitinfo.point, applyShapeToPosition = true, startColor = level_box.laserColor, }; level_box.particleSys.Emit(emit_params, n2 - n1); } if (laser.level_box != level_box) { ctrl.HapticPulse(); } } laser.level_box = level_box; laser.trigger_pressed = ctrl.triggerPressed; ctrl.SetControllerHints(trigger: "choose level"); } } }
protected override void AddPointersOnPausedExplicit() { foreach (var coll in pausedCanvasGobj.GetComponentsInChildren <BoxCollider>()) { coll.GetComponent <UnityEngine.UI.Text>().color = new Color(0.9f, 0.9f, 0.9f); } foreach (var ctrl in Baroque.GetControllers()) { if (ctrl.isReady) { var expl = ctrl.GetAdditionalData(ref expls); if (expl.cylinder_tr == null) { var gobj = Instantiate(pausedPointerPrefab, ctrl.transform); expl.cylinder_tr = gobj.transform.GetChild(0); } const float Z_MAX = 0.75f; float z = Z_MAX; Collider click = null; if (Physics.Raycast(ctrl.transform.position, ctrl.transform.forward, out var hitInfo, 2 * Z_MAX, layerMask: 1 << IntroPointer.LAYER_SELECTION)) { click = hitInfo.collider; } if (click != null && (expl.clicking_button == null || expl.clicking_button == click)) { var text = hitInfo.collider.GetComponent <UnityEngine.UI.Text>(); if (expl.clicking_button == null) { text.color = new Color(1f, 0.7f, 0.7f); } else { text.color = new Color(1f, 0.45f, 0.45f); } z = hitInfo.distance * 0.5f; } var cylinder_tr = expl.cylinder_tr; var v = cylinder_tr.localScale; v.y = z; cylinder_tr.localScale = v; v = cylinder_tr.localPosition; v.z = z; cylinder_tr.localPosition = v; if (ctrl.triggerPressed) { if (expl.clicking_button == null) { expl.clicking_button = click; } //expl.menu_press = 0; } else if (expl.clicking_button != null && expl.clicking_button == click) { SetPausedExplicit(false); if (click.gameObject.name == "EXIT") { Scores.NewScore(episodeNumber, _total_points); UnityEngine.SceneManagement.SceneManager.LoadScene("Intro"); } break; } else { expl.clicking_button = null; /*if (ctrl.touchpadPressed || ctrl.menuPressed) * { * if (expl.menu_press == 1) * expl.menu_press = 2; * } * else if (expl.menu_press == 2) * { * SetPausedExplicit(false); * break; * } * else * expl.menu_press = 1;*/ } } } }