Example #1
0
 void IBall.SetPositionAndVelocity(PongPad pad, Vector3 position, Vector3 velocity)
 {
     StopAllCoroutines();
     free_falling = false;
     Hit(pad);
     Points.AddPoints(transform.position, GetColor(), GetPoints());
 }
Example #2
0
    IEnumerator ShootLaser(PongPad pad)
    {
        float next_shot       = 0;
        int   remaining_shots = 20;
        var   prefab          = PongPadBuilder.instance.shotBallPrefab;

        while (IsAttachedToPad(pad) && remaining_shots > 0)
        {
            float dt = Time.deltaTime;
            next_shot += dt * 5f;
            if (next_shot >= 1f)
            {
                next_shot       -= 1f;
                remaining_shots -= 1;
                Instantiate(prefab).ShootOutOf(pad);
            }
            yield return(null);

            while (PongPadBuilder.paused)
            {
                yield return(null);
            }
        }
        Destroy((GameObject)gameObject);
    }
Example #3
0
    protected override void Hit(PongPad pad)
    {
        void HitBall(Ball ball)
        {
            ball.BiggerBall();
        }

        AttachToPad(pad, HitBall);
    }
Example #4
0
    protected override void Hit(PongPad pad)
    {
        void HitBall(Ball ball)
        {
            ball.Unstoppable();
        }

        AttachToPad(pad, HitBall);
    }
Example #5
0
    protected override void Hit(PongPad pad)
    {
        void HitBall(Ball ball)
        {
            ball.Duplicate();
        }

        AttachToPad(pad, HitBall);
    }
Example #6
0
 protected override void Hit(PongPad pad)
 {
     AttachToPad(pad, null);
     FindObjectOfType <FollowJoystick>().StartWarpWallsBonus();
 }
Example #7
0
 protected override void Hit(PongPad pad)
 {
     AttachToPad(pad, null);
     StartCoroutine(ShootLaser(pad));
 }
Example #8
0
    IEnumerator _FollowJoystick(Controller ctrl)
    {
        while (!_JoystickReleased(ctrl))
        {
            yield return(null);
        }

        while (true)
        {
            yield return(null);

            if (!ctrl.isReady)
            {
                continue;
            }

            Vector2 pos = ctrl.touchpadPosition;
            if (pos.sqrMagnitude < 0.6f * 0.6f || Mathf.Abs(pos.x) < 0.3f)
            {
                continue;
            }

            if (PongPadBuilder.paused)
            {
                continue;
            }

            /* moving the joystick! */
            if (canvasInfo != null)
            {
                Destroy((GameObject)canvasInfo);
                canvasInfo = null;
            }
            if (stop_instruction != null)
            {
                stop_instruction[0] = true;
            }
            stop_instruction = new bool[1];
            StartCoroutine(_FadeOutPadsAndHeadset(stop_instruction));

            float dir = Mathf.Sign(pos.x);
            current_angle += dir * 120f;
            if (current_angle >= 360f)
            {
                current_angle -= 360f;
            }
            else if (current_angle < 0f)
            {
                current_angle += 360f;
            }

            transform.rotation = Quaternion.Euler(0, -current_angle, 0);
            PongPadBuilder.instance.UpdateTrackingSpacePosition();
            PongPad.RestartFollowingAll();

            Baroque.FadeToColor(new Color(0.5f, 0.5f, 0.5f), 0.05f);
            yield return(new WaitForSeconds(0.05f));

            Baroque.FadeToColor(Color.clear, 0.05f);

            /* wait until we release the joystick */
            while (!_JoystickReleased(ctrl))
            {
                yield return(null);
            }
        }
    }
 void SpawnPads()
 {
     player1Pad = Instantiate(padPrefab, firstPlayerStart);
     player2Pad = Instantiate(padPrefab, secondPlayerStart);
 }
Example #10
0
    protected override void FrameByFrameUpdate()
    {
        if (track_cell == null)
        {
            bool next_level_now = false;
            foreach (var cell in FindObjectsOfType <Cell>())
            {
                if (!cell.nextLevelIfOnlyMe)
                {
                    track_cell = cell.gameObject;
                    break;
                }
                next_level_now = true;
            }
            if (track_cell == null)
            {
                if (level_end_time == null)
                {
                    Bonus.RemoveAllBonuses();

                    if (IsFinalLevel)
                    {
                        Ball.RemoveAllBalls();
                        track_cell = gameObject;
                        StartCoroutine(EndGame());
                        return;
                    }
                    else
                    {
                        if (number_of_cells_in_this_level > 0)
                        {
                            music_volumes_fraction = 1f;
                            for (int i = 0; i < music_sources.Length; i++)
                            {
                                int j   = Random.Range(0, music_sources.Length);
                                var tmp = music_sources[i];
                                music_sources[i] = music_sources[j];
                                music_sources[j] = tmp;
                            }
                        }
                        number_of_cells_in_this_level = 0;
                        number_of_cells_killed        = 0;
                        UpdateMusicVolumes();
                        level_end_time = Time.time + (next_level_now ? 0f : 1.2f);
                    }
                }

                if (Time.time >= level_end_time.Value)
                {
                    level_end_time = null;
                    if (levelInstance != null)
                    {
                        Destroy((GameObject)levelInstance);
                    }

                    Bonus.RemoveAllBonuses();
                    levelInstance = Instantiate(levelPrefabs[current_level++]);

                    number_of_cells_in_this_level = levelInstance.GetComponentsInChildren <Cell>().Length;
                    number_of_cells_killed        = 0;
                }
            }
        }

        Physics.SyncTransforms();

        PongPad.UpdateAllBalls();
    }