Example #1
0
 // Called when the player is caught.
 private void OnPlayerCaught(WallSegment wall)
 {
     Graffiti.PaintingEnabled = false;
     CancelGameplayTimers();
     GlobalAudioController.TransitionState("Sting");
     GlobalAudioController.Play("VO", bustedVO);
     GlobalAudioController.Play("Stings", bustedSting);
     TimerManager.Schedule(5).OnComplete(() => {
         Manager.SwitchState("Game Over");
     });
 }
Example #2
0
        // Spawn the next wall segment.
        private void GoToNextWall()
        {
            // Cancel gameplay tweens.
            CancelGameplayTimers();

            // If this is the first wall, we're going to skip the transition animation.
            bool firstWall = current == null;

            // Get next wall x pos.
            float prevX = firstWall ? 0 : current.transform.position.x;
            float x     = firstWall ? 0 : prevX + WALL_SEGMENT_SPACING;

            // Tween the camera to the next wall.
            WallSegment previous = current;

            // Spawn next wall.
            current = Instantiate(Resources.Load <WallSegment>("Prefabs/Wall Segment"), new Vector3(x, 0, 0), Quaternion.identity);
            current.transform.SetParent(transform, true);
            current.OnAllCompleted += OnWallComplete;
            current.OnPlayerCaught += OnPlayerCaught;

            // Transition to next wall.
            if (!firstWall)
            {
                TweenManager.Tween(1, 1).OnStep((t) => {
                    Camera.main.transform.position = new Vector3(
                        Mathf.Lerp(prevX, x, t),
                        Camera.main.transform.position.y,
                        Camera.main.transform.position.z
                        );
                }).OnComplete(() => {
                    if (previous != null)
                    {
                        current.SpawnGraffiti(NUM_GRAFFITI);
                        Destroy(previous.gameObject);
                    }
                });
            }
            else
            {
                current.SpawnGraffiti(NUM_GRAFFITI);
            }
        }
Example #3
0
 // Called when a wall is completed.
 private void OnWallComplete(WallSegment wall)
 {
     GoToNextWall();
 }