示例#1
0
 /// <summary>
 /// Set the pinball brain to use for the game
 /// </summary>
 /// <param name="brain"></param>
 public void SetUnityBridge(UnityBridge unityBridge)
 {
     this.brain       = unityBridge.Brain;
     this.videoPlayer = unityBridge.VideoPlayer;
 }
示例#2
0
    // Use this for initialization
    void Awake()
    {
        //Connect player score UI
        Brain.OnPlayerScoreChanged(0).Subscribe(e => playerScore[e.playerID].SetScore(e.currentScore)).AddTo(this);
        Brain.OnPlayerScoreChanged(1).Subscribe(e => playerScore[e.playerID].SetScore(e.currentScore)).AddTo(this);
        Brain.OnPlayerScoreChanged(2).Subscribe(e => playerScore[e.playerID].SetScore(e.currentScore)).AddTo(this);
        Brain.OnPlayerScoreChanged(3).Subscribe(e => playerScore[e.playerID].SetScore(e.currentScore)).AddTo(this);
        //Activate correct playerscore UI
        Brain.OnCurrentPlayerChanged().Subscribe(e => {
            foreach (UIPlayerScore s in playerScore)
            {
                s.Show(false);
            }
            playerScore[e].Show(true);
        }).AddTo(this);

        //Setup videoplayer
        VideoPlayer = new UnityVideoPlayer();
        videoPlayerObject.SetActive(false);
        VideoPlayer.OnVideoStarted().Subscribe(e => {
            videoPlayerObject.SetActive(true);
            videoPlayerOutput.texture = e.texture;
            videoPlayerOutput.SetNativeSize();
        }).AddTo(this);
        VideoPlayer.OnVideoFinished().Subscribe(e => {
            videoPlayerObject.SetActive(false);
        }).AddTo(this);

        //Brain.NextPlayer();


        //Setup videomode games
        this.asteroidGame = GameObject.Instantiate(Resources.Load <GameObject>("WC2/Prefabs/Videomode/AsteroidGame"), videoModeGameContainer).GetComponent <IVideomodeGame>();
        this.asteroidGame.SetUnityBridge(this);
        this.asteroidGame.OnGameFinished().Subscribe(e => VideoPlayer.Play(Videos.WC2.Flyby)).AddTo(this);
        //this.asteroidGame.StartGame();
        //Start videomode once brain fires event
        this.Brain.OnBrainEvent <GameBrain.Event_StartVideoMode>().Subscribe(e => {
            this.asteroidGame.StartGame();
        }).AddTo(this);


        //Setup debug unity target visuals
        Brain.lowerLeftDropTargetbank.OnUniqueTargetHit(GameBrain.Switches.DROPTARGETBANK_LOWERLEFT_1).Subscribe(e => debugStuff.targets[0].color = new Color(1, 1, 1, 1)).AddTo(this);
        Brain.lowerLeftDropTargetbank.OnUniqueTargetHit(GameBrain.Switches.DROPTARGETBANK_LOWERLEFT_2).Subscribe(e => debugStuff.targets[1].color = new Color(1, 1, 1, 1)).AddTo(this);
        Brain.lowerLeftDropTargetbank.OnUniqueTargetHit(GameBrain.Switches.DROPTARGETBANK_LOWERLEFT_3).Subscribe(e => debugStuff.targets[2].color = new Color(1, 1, 1, 1)).AddTo(this);
        Brain.lowerLeftDropTargetbank.OnUniqueTargetHit(GameBrain.Switches.DROPTARGETBANK_LOWERLEFT_4).Subscribe(e => debugStuff.targets[3].color = new Color(1, 1, 1, 1)).AddTo(this);
        Brain.lowerLeftDropTargetbank.OnUniqueTargetHit(GameBrain.Switches.TARGETBANK_LOWERLEFT_1).Subscribe(e => debugStuff.targets[4].color     = new Color(1, 1, 1, 1)).AddTo(this);
        Brain.lowerLeftDropTargetbank.OnUniqueTargetHit(GameBrain.Switches.TARGETBANK_LOWERLEFT_2).Subscribe(e => debugStuff.targets[5].color     = new Color(1, 1, 1, 1)).AddTo(this);
        Brain.lowerLeftDropTargetbank.OnUniqueTargetHit(GameBrain.Switches.TARGETBANK_LOWERLEFT_3).Subscribe(e => debugStuff.targets[6].color     = new Color(1, 1, 1, 1)).AddTo(this);
        Brain.lowerLeftDropTargetbank.OnReset().Subscribe(e => {
            for (int i = 0; i < debugStuff.targets.Count; i++)
            {
                Image img = debugStuff.targets[i];
                img.color = new Color(1, 1, 1, 0.2f);
            }
        }).AddTo(this);

        //Start the game
        Brain.StartNewGame();
    }