Exemple #1
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());
        }
Exemple #2
0
    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);
    }
Exemple #3
0
    public static void AddPoints(Vector3 position, Color color, int count, float points_size = 0f)
    {
        Quaternion rot = Quaternion.LookRotation(position - Baroque.GetHeadTransform().position);

        rot.eulerAngles += Random.insideUnitSphere * 10f;

        var b = PongPadBuilder.instance;
        var p = Instantiate(b.canvasPointsPrefab, position, rot);

        p.text.text  = count.ToString();
        p.text.color = color;
        if (points_size > 1f)
        {
            p.transform.localScale *= points_size;
        }

        if (total_points_color == new Color())
        {
            total_points_color = b.totalPointsText.color;
        }

        UpdateTotalPoints(count);
        b.StartCoroutine(_Blink());

        IEnumerator _Blink()
        {
            float fraction = 0.75f;

            while (true)
            {
                b.totalPointsText.color = Color.Lerp(total_points_color, color, fraction);
                if (fraction <= 0f)
                {
                    break;
                }
                yield return(null);

                fraction -= Time.deltaTime;
            }
        }
    }
    // Update is called once per frame
    void OnTriggerDown(Controller controller)
    {
        if (!popup.enabled)
        {
            // determine direction
            Vector3 head_forward = controller.position - Baroque.GetHeadTransform().position;
            Vector3 fw           = controller.forward + head_forward.normalized;
            fw.y = 0;
            Vector3 handposition = controller.position + (0.05f * fw);

            // move numpad
            popup.transform.position = handposition;
            popup.transform.rotation = Quaternion.LookRotation(fw);
        }

        // flip enable
        popup.enabled = !popup.enabled;

        // flip visibility
        var popupRenderer = popup.GetComponent <Canvas>();

        popupRenderer.enabled = !popupRenderer.enabled;
    }
Exemple #5
0
    private void Update()
    {
        Vector3 direction = Baroque.GetHeadTransform().position - transform.position;

        transform.rotation = Quaternion.LookRotation(direction);
    }
Exemple #6
0
    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);
            }
        }
    }