Наследование: MonoBehaviour
Пример #1
0
 public PCarsSpotter(AudioPlayer audioPlayer, Boolean initialEnabledState)
 {
     this.audioPlayer = audioPlayer;
     this.enabled = initialEnabledState;
     this.initialEnabledState = initialEnabledState;
     this.longCarLength = carLength + gapNeededForClear;
 }
Пример #2
0
 void Awake()
 {
     _player = GameObject.Find("AudioPlayer").GetComponent<AudioPlayer>();
     _stopcrane_unpressed = GameObject.Find("Stopcrane_unpressed");
     _stopcrane_pressed = GameObject.Find("Stopcrane_pressed");
     _stopcrane_pressed.SetActive(false);
 }
    // Use this for initialization
    void Awake()
    {
        if(gameObject.name == "Player 1")
        {
            playerNum = 1;
        }
        else if (gameObject.name == "Player 2")
        {
            playerNum = 2;
        }

        if(PlayerPrefs.HasKey("Player " + playerNum + " special"))
        {
            type = PlayerPrefs.GetString("Player " + playerNum + " special");
        }

        Debug.Log (playerNum + " " + type);

        hpControl = GameObject.Find ("HealthBar " + playerNum).GetComponent<HealthController>();
        ManaBar = GameObject.Find ("ManaBar " + playerNum).GetComponent<ManaController>();

        hpControl.SetHP (3);
        //PlayerMovement pm = (PlayerMovement)gameObject.GetComponent("PlayerMovement");
        //pm.speed = setspd+2*spd;

        audio = gameObject.GetComponent<AudioPlayer>();
    }
Пример #4
0
 public R3ESpotterv2(AudioPlayer audioPlayer, Boolean initialEnabledState)
 {
     this.audioPlayer = audioPlayer;
     this.enabled = initialEnabledState;
     this.initialEnabledState = initialEnabledState;
     this.internalSpotter = new NoisyCartesianCoordinateSpotter(audioPlayer, initialEnabledState, carLength, carWidth, trackWidth, maxClosingSpeed);
 }
Пример #5
0
        public NotesEditor()
            : base()
        {
            InitializeComponent();

            udHoPo.Maximum = 20;
            udHoPo.Minimum = 0;
            udHoPo.Increment = (decimal)0.1;
            udHoPo.Value = new decimal(2.95);
            udHoPo.DecimalPlaces = 2;

            _isInitialised = false;

            _timer = new Stopwatch();
            _frames = 0;

            _maxLength = 0;
            _audioPlayer = null;
            _ghNotesItems = new List<GhNotesItem>();
            _notesItems = new List<NotesFileItem>();
            _wavFilenames = new List<string>();

            _startPlayPos = 0;
            _triggerPos = 500;
            _speed = 250;
            _convMsPix = (1000 / _speed); //1000 / 250 = quarter the speed of 1 pix per sec  (1 sec = 250 pixels)
            _dotSize = 12;
            _dotSizeHalf = _dotSize / 2;
            _dotSizeQuarter = _dotSize / 4;
            _dotSizeDouble = _dotSize * 2;

            _activeItemIdx = 0;
            _isPlaying = false;
            lblFps.Text = _noFpsString;
        }
Пример #6
0
        public static void synthtests(AudioPlayer pl)
        {
            // also tests performance, because if there is a long pause, this is taking a bit to calculate.
            //pl.Play(new CsWaveAudio.Triangle(300.0, 0.7).CreateWaveAudio(0.5));
            //pl.Play(new CsWaveAudio.Sawtooth(300.0, 0.7).CreateWaveAudio(0.5));
            //pl.Play(new CsWaveAudio.Square(300.0, 0.7).CreateWaveAudio(0.5));
            //pl.Play(new CsWaveAudio.Sine(300.0, 0.7).CreateWaveAudio(0.5));

            //pl.Play(new CsWaveAudio.SineWaveSum(new double[] { 300.0 }, new double[] { 1.0 }, 0.7).CreateWaveAudio(0.5));
            //pl.Play(new CsWaveAudio.SineWaveOrgan(300.0, 0.7).CreateWaveAudio(1.5));
            //pl.Play(new CsWaveAudio.SineWaveSmooth(300.0, 0.7).CreateWaveAudio(1.5));
            //pl.Play(new CsWaveAudio.ElectricOrgan(300.0, 0.7).CreateWaveAudio(0.5));
            //pl.Play(new CsWaveAudio.SquarePhaser(300.0, 0.7).CreateWaveAudio(3.5));

            //pl.Play(new CsWaveAudio.Splash(0.7).CreateWaveAudio(0.5));
            //pl.Play(new CsWaveAudio.RedNoise(0.1).CreateWaveAudio(0.5));
            //pl.Play(new CsWaveAudio.WhiteNoise(0.7).CreateWaveAudio(0.5));
            //pl.Play(new CsWaveAudio.RedNoiseGlitch(250, 0.5, 5, 0.3).CreateWaveAudio(19.5));

            //note-appears to get quieter, but energy spectrum actually the same- that's just our ears hearing frequencies at different volumen

            //WaveAudio j1 = (new CsWaveAudio.RedNoiseSmoothed(100, 0.5 ).CreateWaveAudio(2.5));
            //WaveAudio j2 = (new CsWaveAudio.RedNoiseSmoothed(150, 0.5 ).CreateWaveAudio(2.5));
            //WaveAudio j3 = (new CsWaveAudio.RedNoiseSmoothed(250, 0.5).CreateWaveAudio(2.5));
            //pl.Play(WaveAudio.Mix(WaveAudio.Mix(j1, j3),j2));

        }
 void Awake()
 {
     player = GameObject.Find("Player").GetComponent<PlayerController>();                
     winExplosion = Resources.Load("Prefabs/LevelEndExplosion") as GameObject;
     loseExplosion = Resources.Load("Prefabs/LevelLoseExplosion") as GameObject;        
     audioPlayer = GetComponent<AudioPlayer>();
 }
Пример #8
0
 public Spotter(AudioPlayer audioPlayer, Boolean initialEnabledState)
 {
     this.audioPlayer = audioPlayer;
     this.enabled = initialEnabledState;
     this.initialEnabledState = initialEnabledState;
     this.biggestAllowedNegativeTimeDelta = -1 * carLength / minSpeedForSpotterToOperate;
 }
Пример #9
0
 void Start()
 {
     string[] hitLayerNames = new string[1];
     hitLayerNames[0] = "TransparentFX";
     LAYER_MASK = LayerMask.GetMask(hitLayerNames);
     _audioPlayer = FindObjectOfType<AudioPlayer>();
 }
Пример #10
0
        private async void PlaySound(Uri soundUri)
        {
            Exception exception = null;

            try
            {
                if (_audioPlayer == null)
                    _audioPlayer = new AudioPlayer();

                _audioPlayer.PlaySound(soundUri);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            if (exception != null)
            {
                var dialog = new MessageDialog(exception.ToString(), "Exception Caught!");
                try
                {
                    await dialog.ShowAsync();
                }
                catch (UnauthorizedAccessException)
                {
                }
            }
        }
Пример #11
0
 public static void Main(string[] args)
 {
     AudioPlayer audioPlayer = new AudioPlayer();
     audioPlayer.play("mp3", "beyond the horizon.mp3");
     audioPlayer.play("mp4", "alone.mp4");
     audioPlayer.play("vlc", "far far away.vlc");
     audioPlayer.play("avi", "mind me.avi");
 }
Пример #12
0
 void Awake()
 {
     _isSpawnEnabled = true;
     _moveDuration = ConfigReader.GetConfig().GetField("tram").GetField("MoveDuration").n;
     _stopDuration = ConfigReader.GetConfig().GetField("tram").GetField("StopDuration").n;
     _player = GameObject.Find("AudioPlayer").GetComponent<AudioPlayer>();
     _doorOpened = new bool[DoorsCount];
 }
Пример #13
0
    private void Awake()
    {
        // If we're a prefab, we set our instance
        instance = this;

        // Make sure we don't get destroyed
        DontDestroyOnLoad(gameObject);
    }
 void Awake()
 {
     levelManager = GameObject.Find("LevelManager").GetComponent<LvlMngrController>();
     bulletAPI = GetComponent<PlayerBulletAPI>();
     audioPlayer = GetComponent<AudioPlayer>();
     rigidBody = GetComponent<Rigidbody2D>();
     sight = this.transform.FindChild("Sight").GetComponent<LineRenderer>();               
 }
Пример #15
0
 public MainPage()
 {
     microphone=Microphone.GetMicrophone();
     audioPlayer=new AudioPlayer();
     camera = Camera.GetCamera();
     InitializeComponent();
     this.Loaded += new RoutedEventHandler(MainPage_Loaded);
 }
Пример #16
0
 void OnMusicFinished(AudioPlayer player)
 {
     switch(player.id) {
         case "FailSong": PlayLastPlayer(); break;
         case "WinnerSong": PlayLastPlayer(); break;
         case "MainThemeSong": player.nextClip(); break;
     }
 }
Пример #17
0
 void OnMusicFinished(AudioPlayer player)
 {
     switch(player.id) {
         case "FailSong": player.Pause(); GetPlayerById("MainThemeSong").Play(); break;
         case "WinnerSong": player.Pause(); GetPlayerById("MainThemeSong").Play(); break;
         case "MainThemeSong": player.nextClip(); break;
     }
 }
Пример #18
0
 private void InitSound()
 {
     if (BorisSound == null)
         return;
     var audio = new AudioObject(this.gameObject, BorisSound, 1, 0, true, true);
     SoundPlayer = AudioManager.PlayAudio(audio);
     StartSound();
 }
		public PlaybackController()
		{
			audioPlayer = new AudioPlayer();
			audioPlayer.CurrentAudioStreamChanged += new EventHandler<EventArgs>(OnCurrentAudioStreamChanged);
			audioPlayer.BufferStateChanged += new EventHandler<MediaStateChangedEventArgs>(OnBufferStateChanged);
			audioPlayer.NetworkStateChanged += new EventHandler<MediaStateChangedEventArgs>(OnNetworkStateChanged);
			audioPlayer.PlaybackStateChanged += new EventHandler<MediaStateChangedEventArgs>(OnPlaybackStateChanged);
			audioPlayer.SeekStateChanged += new EventHandler<MediaStateChangedEventArgs>(OnSeekStateChanged);
		}
Пример #20
0
 public void PlaySettingsAudio(AudioClip ac)
 {
     if (activePlayer != null)
     {
         activePlayer.MarkRemovable();
     }
     AudioObject ao = new AudioObject(ScreenAudioManager.GetScreenAudioObject(), ac, mute ? 0f : 1f, 0f, false, false);
     activePlayer = AudioManager.PlayAudio(ao);
     latestClip = ac;
 }
Пример #21
0
	// Use this for initialization
	void Awake () {
		if (_instance == null)
		{
			_instance = this;
			DontDestroyOnLoad (this);
		}
		else
		{
			Debug.LogWarning("Multiple AudioPlayers present!");
			Destroy (this);
		}
	}
Пример #22
0
        public Timings(AudioPlayer audioPlayer)
        {
            this.audioPlayer = audioPlayer;
            closeAheadMinSectorWait = 10 - gapAheadReportFrequency;
            closeAheadMaxSectorWait = closeAheadMinSectorWait + 2;
            gapAheadMinSectorWait = 10 - gapAheadReportFrequency;
            gapAheadMaxSectorWait = gapAheadMinSectorWait + 2;

            closeBehindMinSectorWait = 10 - gapBehindReportFrequency;
            closeBehindMaxSectorWait = closeBehindMinSectorWait + 2;
            gapBehindMinSectorWait = 10 - gapBehindReportFrequency;
            gapBehindMaxSectorWait = gapBehindMinSectorWait + 2;
        }
Пример #23
0
 public PCarsSpotterv2(AudioPlayer audioPlayer, Boolean initialEnabledState)
 {
     this.audioPlayer = audioPlayer;
     this.enabled = initialEnabledState;
     this.initialEnabledState = initialEnabledState;
     if (CrewChief.gameDefinition.gameEnum == GameEnum.PCARS_NETWORK)
     {
         this.internalSpotter = new NoisyCartesianCoordinateSpotter(audioPlayer, initialEnabledState, carLength, udpCarWidth, udpTrackWidth, udpMaxClosingSpeed);
     }
     else
     {
         this.internalSpotter = new NoisyCartesianCoordinateSpotter(audioPlayer, initialEnabledState, carLength, carWidth, trackWidth, maxClosingSpeed);
     }
 }
Пример #24
0
        public static void effectstest(AudioPlayer pl)
        {
            WaveAudio w = new WaveAudio(mediadir + "d44k16bit2ch.wav");
            pl.Play(Effects.Derivative(w));
            pl.Play(Effects.Flange(w));
            pl.Play(Effects.Reverse(w));
            pl.Play(Effects.ScalePitchAndDuration(w, 0.75));
            pl.Play(Effects.ScalePitchAndDuration(w, 1.25));
            pl.Play(Effects.Tremolo(w, 1.0, 1.0));
            pl.Play(Effects.Vibrato(w, 0.2, 0.5));

            w.setSampleRate(22050);
            pl.Play(w); // should sound "normal"
        }
Пример #25
0
	void Start() {
		_fadeTexture = new Texture2D(1, 1);
		_fadeTexture.SetPixel(0, 0, new Color(0, 0, 0));
		_fadeTexture.Apply();

		_animator = gameObject.GetComponent<Animator>();
		if (GameObject.Find("AudioPlayerAdvanced") != null)
			_audioPlayerAdvanced = Helper.Find<AudioPlayerAdvanced>("AudioPlayerAdvanced");
		else
			_audioPlayer = Helper.Find<AudioPlayer>("AudioPlayer");

		_player = Player.CreatePlayer();
		
		_animator.Play("FadeIn");
	}
Пример #26
0
    // Use this for initialization
    void Awake()
    {
        //Reinforce the singleton: set this as the instance or kill this
        if (instance == null) {
            instance = this;
        } else if (instance != this) {
            Destroy (gameObject);
        }

        DontDestroyOnLoad (transform.gameObject);

        audioPlayer = GetComponent<AudioSource> ();
        audioPlayer.volume = 0f;

        Invoke ("PlayMusic", 1f);
    }
Пример #27
0
        public SN76489()
        {
            AudioPlayer<Int16> audioPlayer = new AudioPlayer<Int16>();
            MixedChannel channel = new MixedChannel(44100);
            _channel1 = new SineChannel();
            _channel2 = new SineChannel();
            _channel3 = new SineChannel();
            
            channel.AddChannel(_channel1);
            channel.AddChannel(_channel2);
            channel.AddChannel(_channel3);

            audioPlayer.Channel = channel;
            audioPlayer.Initialize(WrenCore.WindowHandle);
            audioPlayer.Play();
        }
Пример #28
0
        static void Main(string[] args)
        {
            AudioPlayer pl = new AudioPlayer();

            // Uncomment the tests you wish to run.


            //CsWaveAudioTests.synthtests(pl);
            //CsWaveAudioTests.effectstest(pl);
            //CsWaveAudioTests.effectsaudacitytest(pl);
            CsWaveAudioTests.iotests();
            //CsWaveAudioTests.propertytests();
            //CsWaveAudioTests.operations_test(pl);
            //CsWaveAudioTests.pitchdetect_test(pl);
            //CsWaveAudioTests.padsynthtests(pl);

            Console.WriteLine("Done");
            Console.ReadKey();
        }
Пример #29
0
        public Form1()
        {
            InitializeComponent();
            this.m_audioPlayer = new AudioPlayer();

            this.savedNum = SetKeyState.GetNumState();
            this.savedScroll = SetKeyState.GetScrollState();
            this.savedCaps = SetKeyState.GetCapsState();

            if (File.Exists(@"..\..\cis.wav"))
                this.m_currentSound = new WaveAudio(@"..\..\cis.wav");
            else if (File.Exists(@"cis.wav"))
                this.m_currentSound = new WaveAudio(@"cis.wav");

            if (m_currentSound != null)
            {
                this.m_currentSound.setNumChannels(1, true);
                this.lblFilename.Text = "Loaded: cis.wav";
            }
        }
Пример #30
0
 //speed defaults to 0, optional attribute
 public void Process(string message, int speed = 0)
 {
     var spPos = 0;
             //logic for creating syntethic speech.
             for (var i = 0; i < message.Length; i++)
                 {
                     if (! message[i].Equals('@') || ! message.Substring(i).StartsWith("@wav("))
                         {
                             continue;
                         }
                     //play a soundfile!
                     _speaker.Speak(message.Substring(spPos, i - spPos), speed);
                     spPos = i + "@wav(".Length; // 5 + looper o.O yeah, because reasons
                     //sooo where is the closing ) on the @wav( filename ) tag?
                     var cP = message.Substring(spPos, message.Substring(spPos).IndexOf(')'));
                     spPos += cP.Length + 1;
                     var ap = new AudioPlayer(cP);
                     ap.Play();
                 }
             _speaker.Speak(message.Substring(spPos), speed); //words!
 }
Пример #31
0
 public DamageReporting(AudioPlayer audioPlayer)
 {
     this.audioPlayer = audioPlayer;
 }
Пример #32
0
        public TabPage Create(VrfGuiContext vrfGuiContext, byte[] input)
        {
            var tab      = new TabPage();
            var resource = new ValveResourceFormat.Resource();

            if (input != null)
            {
                resource.Read(new MemoryStream(input));
            }
            else
            {
                resource.Read(vrfGuiContext.FileName);
            }

            var resTabs = new TabControl
            {
                Dock = DockStyle.Fill,
            };

            switch (resource.ResourceType)
            {
            case ResourceType.Texture:
                var tab2 = new TabPage("TEXTURE")
                {
                    AutoScroll = true,
                };

                try
                {
                    var tex = (Texture)resource.DataBlock;

                    var control = new Forms.Texture
                    {
                        BackColor = Color.Black,
                    };
                    control.SetImage(tex.GenerateBitmap().ToBitmap(), Path.GetFileNameWithoutExtension(vrfGuiContext.FileName),
                                     tex.ActualWidth, tex.ActualHeight);

                    tab2.Controls.Add(control);
                    Program.MainForm.Invoke(new ExportDel(AddToExport), resTabs,
                                            $"Export {Path.GetFileName(vrfGuiContext.FileName)} as an image", vrfGuiContext.FileName,
                                            new ExportData {
                        Resource = resource
                    });
                }
                catch (Exception e)
                {
                    var control = new TextBox
                    {
                        Dock      = DockStyle.Fill,
                        Font      = new Font(FontFamily.GenericMonospace, 8),
                        Multiline = true,
                        ReadOnly  = true,
                        Text      = e.ToString(),
                    };

                    tab2.Controls.Add(control);
                }

                resTabs.TabPages.Add(tab2);
                break;

            case ResourceType.Panorama:
                if (((Panorama)resource.DataBlock).Names.Count > 0)
                {
                    var nameTab     = new TabPage("PANORAMA NAMES");
                    var nameControl = new DataGridView
                    {
                        Dock                = DockStyle.Fill,
                        AutoSize            = true,
                        ReadOnly            = true,
                        AllowUserToAddRows  = false,
                        AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                        DataSource          =
                            new BindingSource(
                                new BindingList <Panorama.NameEntry>(((Panorama)resource.DataBlock).Names), null),
                    };
                    nameTab.Controls.Add(nameControl);
                    resTabs.TabPages.Add(nameTab);
                }

                break;

            case ResourceType.PanoramaLayout:
                Program.MainForm.Invoke(new ExportDel(AddToExport), resTabs, $"Export {Path.GetFileName(vrfGuiContext.FileName)} as XML",
                                        vrfGuiContext.FileName, new ExportData {
                    Resource = resource
                });
                break;

            case ResourceType.PanoramaScript:
                Program.MainForm.Invoke(new ExportDel(AddToExport), resTabs, $"Export {Path.GetFileName(vrfGuiContext.FileName)} as JS",
                                        vrfGuiContext.FileName, new ExportData {
                    Resource = resource
                });
                break;

            case ResourceType.PanoramaStyle:
                Program.MainForm.Invoke(new ExportDel(AddToExport), resTabs, $"Export {Path.GetFileName(vrfGuiContext.FileName)} as CSS",
                                        vrfGuiContext.FileName, new ExportData {
                    Resource = resource
                });
                break;

            case ResourceType.Particle:
                var viewerControl = new GLParticleViewer(vrfGuiContext);
                viewerControl.Load += (_, __) =>
                {
                    var particleSystem   = (ParticleSystem)resource.DataBlock;
                    var particleRenderer = new ParticleRenderer.ParticleRenderer(particleSystem, vrfGuiContext);

                    viewerControl.AddRenderer(particleRenderer);
                };

                var particleRendererTab = new TabPage("PARTICLE");
                particleRendererTab.Controls.Add(viewerControl.Control);
                resTabs.TabPages.Add(particleRendererTab);
                break;

            case ResourceType.Sound:
                var soundTab = new TabPage("SOUND");
                var ap       = new AudioPlayer(resource, soundTab);
                resTabs.TabPages.Add(soundTab);

                Program.MainForm.Invoke(new ExportDel(AddToExport), resTabs,
                                        $"Export {Path.GetFileName(vrfGuiContext.FileName)} as {((Sound) resource.DataBlock).SoundType}", vrfGuiContext.FileName,
                                        new ExportData {
                    Resource = resource
                });

                break;

            case ResourceType.World:
                var worldmeshTab = new TabPage("MAP");
                worldmeshTab.Controls.Add(
                    new GLWorldViewer(vrfGuiContext, (World)resource.DataBlock).ViewerControl);
                resTabs.TabPages.Add(worldmeshTab);
                break;

            case ResourceType.WorldNode:
                var nodemeshTab = new TabPage("WORLD NODE");
                nodemeshTab.Controls.Add(new GLWorldViewer(vrfGuiContext, (WorldNode)resource.DataBlock)
                                         .ViewerControl);
                resTabs.TabPages.Add(nodemeshTab);
                break;

            case ResourceType.Model:
                Program.MainForm.Invoke(new ExportDel(AddToExport), resTabs, $"Export {Path.GetFileName(vrfGuiContext.FileName)} as glTF",
                                        vrfGuiContext.FileName, new ExportData {
                    Resource = resource, VrfGuiContext = vrfGuiContext
                });
                Program.MainForm.Invoke(new ExportDel(AddToExport), resTabs, $"Export {Path.GetFileName(vrfGuiContext.FileName)} as GLB",
                                        vrfGuiContext.FileName, new ExportData {
                    Resource = resource, VrfGuiContext = vrfGuiContext, FileType = ExportFileType.GLB
                });

                var modelRendererTab = new TabPage("MODEL");
                modelRendererTab.Controls.Add(new GLModelViewer(vrfGuiContext, (Model)resource.DataBlock)
                                              .ViewerControl);
                resTabs.TabPages.Add(modelRendererTab);
                break;

            case ResourceType.Mesh:

                Program.MainForm.Invoke(new ExportDel(AddToExport), resTabs, $"Export {Path.GetFileName(vrfGuiContext.FileName)} as glTF",
                                        vrfGuiContext.FileName, new ExportData {
                    Resource = resource, VrfGuiContext = vrfGuiContext
                });
                Program.MainForm.Invoke(new ExportDel(AddToExport), resTabs, $"Export {Path.GetFileName(vrfGuiContext.FileName)} as GLB",
                                        vrfGuiContext.FileName, new ExportData {
                    Resource = resource, VrfGuiContext = vrfGuiContext, FileType = ExportFileType.GLB
                });

                var meshRendererTab = new TabPage("MESH");
                meshRendererTab.Controls.Add(new GLModelViewer(vrfGuiContext, new Mesh(resource)).ViewerControl);
                resTabs.TabPages.Add(meshRendererTab);
                break;

            case ResourceType.Material:
                var materialViewerControl = new GLMaterialViewer();
                materialViewerControl.Load += (_, __) =>
                {
                    var material         = vrfGuiContext.MaterialLoader.LoadMaterial(resource);
                    var materialRenderer = new MaterialRenderer(material);

                    materialViewerControl.AddRenderer(materialRenderer);
                };

                var materialRendererTab = new TabPage("MATERIAL");
                materialRendererTab.Controls.Add(materialViewerControl.Control);
                resTabs.TabPages.Add(materialRendererTab);
                break;
            }

            foreach (var block in resource.Blocks)
            {
                if (block.Type == BlockType.RERL)
                {
                    var externalRefsTab = new TabPage("External Refs");

                    var externalRefs = new DataGridView
                    {
                        Dock = DockStyle.Fill,
                        AutoGenerateColumns = true,
                        AutoSize            = true,
                        ReadOnly            = true,
                        AllowUserToAddRows  = false,
                        AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                        DataSource          =
                            new BindingSource(
                                new BindingList <ResourceExtRefList.ResourceReferenceInfo>(resource.ExternalReferences
                                                                                           .ResourceRefInfoList), null),
                    };

                    externalRefsTab.Controls.Add(externalRefs);

                    resTabs.TabPages.Add(externalRefsTab);

                    continue;
                }

                if (block.Type == BlockType.NTRO)
                {
                    if (((ResourceIntrospectionManifest)block).ReferencedStructs.Count > 0)
                    {
                        var externalRefsTab = new TabPage("Introspection Manifest: Structs");

                        var externalRefs = new DataGridView
                        {
                            Dock = DockStyle.Fill,
                            AutoGenerateColumns = true,
                            AutoSize            = true,
                            ReadOnly            = true,
                            AllowUserToAddRows  = false,
                            AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                            DataSource          =
                                new BindingSource(
                                    new BindingList <ResourceIntrospectionManifest.ResourceDiskStruct>(
                                        ((ResourceIntrospectionManifest)block).ReferencedStructs), null),
                        };

                        externalRefsTab.Controls.Add(externalRefs);
                        resTabs.TabPages.Add(externalRefsTab);
                    }

                    if (((ResourceIntrospectionManifest)block).ReferencedEnums.Count > 0)
                    {
                        var externalRefsTab = new TabPage("Introspection Manifest: Enums");
                        var externalRefs2   = new DataGridView
                        {
                            Dock = DockStyle.Fill,
                            AutoGenerateColumns = true,
                            AutoSize            = true,
                            ReadOnly            = true,
                            AllowUserToAddRows  = false,
                            AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                            DataSource          =
                                new BindingSource(
                                    new BindingList <ResourceIntrospectionManifest.ResourceDiskEnum>(
                                        ((ResourceIntrospectionManifest)block).ReferencedEnums), null),
                        };

                        externalRefsTab.Controls.Add(externalRefs2);
                        resTabs.TabPages.Add(externalRefsTab);
                    }

                    //continue;
                }

                var tab2 = new TabPage(block.Type.ToString());
                try
                {
                    var control = new TextBox();
                    control.Font = new Font(FontFamily.GenericMonospace, control.Font.Size);

                    if (block.Type == BlockType.DATA)
                    {
                        switch (resource.ResourceType)
                        {
                        case ResourceType.Sound:
                            control.Text = Utils.Utils.NormalizeLineEndings(((Sound)block).ToString());
                            break;

                        case ResourceType.Particle:
                        case ResourceType.Mesh:
                            if (block is BinaryKV3 blockKeyvalues)
                            {
                                //Wrap it around a KV3File object to get the header.
                                control.Text =
                                    Utils.Utils.NormalizeLineEndings(blockKeyvalues.GetKV3File().ToString());
                            }
                            else
                            {
                                control.Text = Utils.Utils.NormalizeLineEndings(block.ToString());
                            }

                            break;

                        default:
                            control.Text = Utils.Utils.NormalizeLineEndings(block.ToString());
                            break;
                        }
                    }
                    else
                    {
                        control.Text = Utils.Utils.NormalizeLineEndings(block.ToString());
                    }

                    control.Dock       = DockStyle.Fill;
                    control.Multiline  = true;
                    control.ReadOnly   = true;
                    control.ScrollBars = ScrollBars.Both;
                    tab2.Controls.Add(control);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);

                    var bv = new System.ComponentModel.Design.ByteViewer();
                    bv.Dock = DockStyle.Fill;
                    tab2.Controls.Add(bv);

                    Program.MainForm.Invoke((MethodInvoker)(() =>
                    {
                        resource.Reader.BaseStream.Position = block.Offset;
                        bv.SetBytes(resource.Reader.ReadBytes((int)block.Size));
                    }));
                }

                resTabs.TabPages.Add(tab2);
            }

            if (resource.ResourceType == ResourceType.PanoramaLayout ||
                resource.ResourceType == ResourceType.PanoramaScript ||
                resource.ResourceType == ResourceType.PanoramaStyle ||
                resource.ResourceType == ResourceType.SoundEventScript ||
                resource.ResourceType == ResourceType.SoundStackScript ||
                resource.ResourceType == ResourceType.EntityLump)
            {
                foreach (TabPage tab2 in resTabs.TabPages)
                {
                    if (tab2.Text == "DATA")
                    {
                        resTabs.SelectTab(tab2);
                        break;
                    }
                }
            }

            tab.Controls.Add(resTabs);

            return(tab);
        }
Пример #33
0
 public SafeSpace(UrTile Tile)
 {
     this.Tile  = Tile;
     this.Anim  = Tile.GetComponentInChildren <PlayAnimation>();
     this.Sound = Tile.GetComponentInChildren <AudioPlayer>();
 }
Пример #34
0
 public override void Dispose()
 {
     AudioPlayer.Dispose();
 }
Пример #35
0
 /// <param name="player"> Audio player </param>
 public PlayerPauseEvent(AudioPlayer player) : base(player)
 {
 }
Пример #36
0
        private void PlayAudio_Tap(object sender, EventArgs e)
        {
            Button cur = sender as Button;

            if (cur != null)
            {
                AttachmentViewModel currentTrack = cur.DataContext as AttachmentViewModel;

                if (currentTrack != null)
                {
                    if (AudioPlayer.CurrentState == MediaElementState.Playing)
                    {
                        AudioPlayer.Stop();

                        if (_currentTrack.Mid == currentTrack.Mid)
                        {
                            Image content = cur.Content as Image;
                            if (null != content)
                            {
                                content.Source = ResourceHelper.GetBitmap(@"/SlXnaApp1;component/Images/Play.png");
                            }

                            _currentPlayButton = null;
                            _currentTrack      = null;
                        }
                        else // Handle the case when user don't stop current audio, but start another one...
                        {
                            Image content = cur.Content as Image;
                            if (null != content)
                            {
                                content.Source = ResourceHelper.GetBitmap(@"/SlXnaApp1;component/Images/Pause.png");
                            }

                            Image contentOld = _currentPlayButton.Content as Image;
                            if (null != content)
                            {
                                contentOld.Source = ResourceHelper.GetBitmap(@"/SlXnaApp1;component/Images/Play.png");
                            }

                            _currentTrack      = currentTrack;
                            AudioPlayer.Source = new Uri(_currentTrack.Uri, UriKind.Absolute);
                            //_currentTrack.Progress = 0;
                            AudioPlayer.Play();

                            _currentPlayButton = cur;
                        }
                    }
                    else
                    {
                        Image content = cur.Content as Image;
                        if (null != content)
                        {
                            content.Source = ResourceHelper.GetBitmap(@"/SlXnaApp1;component/Images/Pause.png");
                        }

                        _currentTrack      = currentTrack;
                        AudioPlayer.Source = new Uri(_currentTrack.Uri, UriKind.Absolute);
                        //_currentTrack.Progress = 0;
                        AudioPlayer.Play();

                        _currentPlayButton = cur;
                    }
                }
            }
        }
Пример #37
0
 /// <summary>
 /// Освобождает используемые ресурсы
 /// </summary>
 public void Dispose()
 {
     AudioPlayer.Stop();
     Items = null;
 }
Пример #38
0
 public MandatoryPitStops(AudioPlayer audioPlayer)
 {
     this.audioPlayer = audioPlayer;
 }
Пример #39
0
 private void Start()
 {
     controller  = GetComponent <NejikoController>();
     audioPlayer = GetComponent <AudioPlayer>();
 }
Пример #40
0
 public Fuel(AudioPlayer audioPlayer)
 {
     this.audioPlayer = audioPlayer;
 }
        private TabPage ProcessFile(string fileName, byte[] input, TreeViewWithSearchResults.TreeViewPackageTag currentPackage)
        {
            var tab           = new TabPage();
            var vrfGuiContext = new VrfGuiContext(fileName, currentPackage);

            uint   magic = 0;
            ushort magicResourceVersion = 0;

            if (input != null)
            {
                if (input.Length >= 6)
                {
                    magic = BitConverter.ToUInt32(input, 0);
                    magicResourceVersion = BitConverter.ToUInt16(input, 4);
                }
            }
            else
            {
                var magicData = new byte[6];

                using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    fs.Read(magicData, 0, 6);
                }

                magic = BitConverter.ToUInt32(magicData, 0);
                magicResourceVersion = BitConverter.ToUInt16(magicData, 4);
            }

            if (magic != Package.MAGIC && input == null && Regex.IsMatch(fileName, @"_[0-9]{3}\.vpk$"))
            {
                // TODO: Update tab name
                fileName = $"{fileName.Substring(0, fileName.Length - 8)}_dir.vpk";
                magic    = Package.MAGIC;
            }

            if (magic == Package.MAGIC || fileName.EndsWith(".vpk", StringComparison.Ordinal))
            {
                var package = new Package();

                if (input != null)
                {
                    package.SetFileName(fileName);
                    package.Read(new MemoryStream(input));
                }
                else
                {
                    package.Read(fileName);
                }

                // create a TreeView with search capabilities, register its events, and add it to the tab
                var treeViewWithSearch = new TreeViewWithSearchResults(ImageList);
                treeViewWithSearch.InitializeTreeViewFromPackage(new TreeViewWithSearchResults.TreeViewPackageTag
                {
                    Package       = package,
                    ParentPackage = currentPackage?.Package,
                });
                treeViewWithSearch.TreeNodeMouseDoubleClick += VPK_OpenFile;
                treeViewWithSearch.TreeNodeMouseClick       += VPK_OnClick;
                treeViewWithSearch.ListViewItemDoubleClick  += VPK_OpenFile;
                treeViewWithSearch.ListViewItemRightClick   += VPK_OnClick;
                treeViewWithSearch.Disposed += VPK_Disposed;
                tab.Controls.Add(treeViewWithSearch);

                // since we're in a separate thread, invoke to update the UI
                Invoke((MethodInvoker)(() => findToolStripButton.Enabled = true));
            }
            else if (magic == CompiledShader.MAGIC || fileName.EndsWith(".vcs", StringComparison.Ordinal))
            {
                var shader = new CompiledShader();

                var buffer = new StringWriter();
                var oldOut = Console.Out;
                Console.SetOut(buffer);

                if (input != null)
                {
                    shader.Read(fileName, new MemoryStream(input));
                }
                else
                {
                    shader.Read(fileName);
                }

                Console.SetOut(oldOut);

                var control = new TextBox();
                control.Font       = new Font(FontFamily.GenericMonospace, control.Font.Size);
                control.Text       = NormalizeLineEndings(buffer.ToString());
                control.Dock       = DockStyle.Fill;
                control.Multiline  = true;
                control.ReadOnly   = true;
                control.ScrollBars = ScrollBars.Both;
                tab.Controls.Add(control);
            }
            else if (magic == ClosedCaptions.MAGIC || (input == null && fileName.EndsWith(".dat", StringComparison.Ordinal)))
            {
                var captions = new ClosedCaptions();
                if (input != null)
                {
                    captions.Read(fileName, new MemoryStream(input));
                }
                else
                {
                    captions.Read(fileName);
                }

                var control = new DataGridView
                {
                    Dock                = DockStyle.Fill,
                    AutoSize            = true,
                    ReadOnly            = true,
                    AllowUserToAddRows  = false,
                    AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                    DataSource          = new BindingSource(new BindingList <ClosedCaption>(captions.Captions), null),
                    ScrollBars          = ScrollBars.Both,
                };
                tab.Controls.Add(control);
            }
            else if (magic == BinaryKV3.MAGIC || magic == BinaryKV3.MAGIC2)
            {
                var    kv3 = new BinaryKV3();
                Stream kv3stream;

                if (input != null)
                {
                    kv3stream = new MemoryStream(input);
                }
                else
                {
                    kv3stream = File.OpenRead(fileName);
                }

                using (var binaryReader = new BinaryReader(kv3stream))
                {
                    kv3.Size = (uint)kv3stream.Length;
                    kv3.Read(binaryReader, null);
                }

                kv3stream.Close();

                var control = new TextBox();
                control.Font       = new Font(FontFamily.GenericMonospace, control.Font.Size);
                control.Text       = kv3.ToString();
                control.Dock       = DockStyle.Fill;
                control.Multiline  = true;
                control.ReadOnly   = true;
                control.ScrollBars = ScrollBars.Both;
                tab.Controls.Add(control);
            }
            else if (magicResourceVersion == Resource.KnownHeaderVersion || (input == null && fileName.EndsWith("_c", StringComparison.Ordinal)))
            {
                var resource = new Resource();
                if (input != null)
                {
                    resource.Read(new MemoryStream(input));
                }
                else
                {
                    resource.Read(fileName);
                }

                var resTabs = new TabControl
                {
                    Dock = DockStyle.Fill,
                };

                switch (resource.ResourceType)
                {
                case ResourceType.Texture:
                    var tab2 = new TabPage("TEXTURE")
                    {
                        AutoScroll = true,
                    };

                    try
                    {
                        var tex = (Texture)resource.DataBlock;

                        var control = new Forms.Texture
                        {
                            BackColor = Color.Black,
                        };
                        control.SetImage(tex.GenerateBitmap().ToBitmap(), Path.GetFileNameWithoutExtension(fileName), tex.Width, tex.Height);

                        tab2.Controls.Add(control);
                        Invoke(new ExportDel(AddToExport), $"Export {Path.GetFileName(fileName)} as an image", fileName, new ExportData {
                            Resource = resource
                        });
                    }
                    catch (Exception e)
                    {
                        var control = new TextBox
                        {
                            Dock      = DockStyle.Fill,
                            Font      = new Font(FontFamily.GenericMonospace, 8),
                            Multiline = true,
                            ReadOnly  = true,
                            Text      = e.ToString(),
                        };

                        tab2.Controls.Add(control);
                    }

                    resTabs.TabPages.Add(tab2);
                    break;

                case ResourceType.Panorama:
                    if (((Panorama)resource.DataBlock).Names.Count > 0)
                    {
                        var nameTab     = new TabPage("PANORAMA NAMES");
                        var nameControl = new DataGridView
                        {
                            Dock                = DockStyle.Fill,
                            AutoSize            = true,
                            ReadOnly            = true,
                            AllowUserToAddRows  = false,
                            AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                            DataSource          = new BindingSource(new BindingList <Panorama.NameEntry>(((Panorama)resource.DataBlock).Names), null),
                        };
                        nameTab.Controls.Add(nameControl);
                        resTabs.TabPages.Add(nameTab);
                    }

                    break;

                case ResourceType.PanoramaLayout:
                    Invoke(new ExportDel(AddToExport), $"Export {Path.GetFileName(fileName)} as XML", fileName, new ExportData {
                        Resource = resource
                    });
                    break;

                case ResourceType.PanoramaScript:
                    Invoke(new ExportDel(AddToExport), $"Export {Path.GetFileName(fileName)} as JS", fileName, new ExportData {
                        Resource = resource
                    });
                    break;

                case ResourceType.PanoramaStyle:
                    Invoke(new ExportDel(AddToExport), $"Export {Path.GetFileName(fileName)} as CSS", fileName, new ExportData {
                        Resource = resource
                    });
                    break;

                case ResourceType.Particle:
                    var viewerControl = new GLParticleViewer(vrfGuiContext);
                    viewerControl.Load += (_, __) =>
                    {
                        var particleSystem   = (ParticleSystem)resource.DataBlock;
                        var particleRenderer = new ParticleRenderer(particleSystem, vrfGuiContext);

                        viewerControl.AddRenderer(particleRenderer);
                    };

                    var particleRendererTab = new TabPage("PARTICLE");
                    particleRendererTab.Controls.Add(viewerControl.Control);
                    resTabs.TabPages.Add(particleRendererTab);
                    break;

                case ResourceType.Sound:
                    var soundTab = new TabPage("SOUND");
                    var ap       = new AudioPlayer(resource, soundTab);
                    resTabs.TabPages.Add(soundTab);

                    Invoke(new ExportDel(AddToExport), $"Export {Path.GetFileName(fileName)} as {((Sound)resource.DataBlock).SoundType}", fileName, new ExportData {
                        Resource = resource
                    });

                    break;

                case ResourceType.EntityLump:
                    var entitiesTab = new TabPage("ENTITY LUMP");
                    var text        = new TextBox
                    {
                        Dock       = DockStyle.Fill,
                        ScrollBars = ScrollBars.Vertical,
                        Multiline  = true,
                        ReadOnly   = true,
                        Font       = new Font(FontFamily.GenericMonospace, entitiesTab.Font.Size),
                        Text       = NormalizeLineEndings(((EntityLump)resource.DataBlock).ToString()),
                    };
                    entitiesTab.Controls.Add(text);
                    resTabs.TabPages.Add(entitiesTab);

                    break;

                case ResourceType.World:
                    var worldmeshTab = new TabPage("MAP");
                    worldmeshTab.Controls.Add(new GLWorldViewer(vrfGuiContext, (World)resource.DataBlock).ViewerControl);
                    resTabs.TabPages.Add(worldmeshTab);
                    break;

                case ResourceType.WorldNode:
                    var nodemeshTab = new TabPage("WORLD NODE");
                    nodemeshTab.Controls.Add(new GLWorldViewer(vrfGuiContext, (WorldNode)resource.DataBlock).ViewerControl);
                    resTabs.TabPages.Add(nodemeshTab);
                    break;

                case ResourceType.Model:
                    var modelRendererTab = new TabPage("MODEL");
                    modelRendererTab.Controls.Add(new GLModelViewer(vrfGuiContext, (Model)resource.DataBlock).ViewerControl);
                    resTabs.TabPages.Add(modelRendererTab);
                    break;

                case ResourceType.Mesh:
                    if (!resource.ContainsBlockType(BlockType.VBIB))
                    {
                        Console.WriteLine("Old style model, no VBIB!");
                        break;
                    }

                    Invoke(new ExportDel(AddToExport), $"Export {Path.GetFileName(fileName)} as OBJ", fileName, new ExportData {
                        Resource = resource, VrfGuiContext = vrfGuiContext
                    });

                    var meshRendererTab = new TabPage("MESH");
                    meshRendererTab.Controls.Add(new GLModelViewer(vrfGuiContext, new Mesh(resource)).ViewerControl);
                    resTabs.TabPages.Add(meshRendererTab);
                    break;

                case ResourceType.Material:
                    var materialViewerControl = new GLMaterialViewer();
                    materialViewerControl.Load += (_, __) =>
                    {
                        var material         = vrfGuiContext.MaterialLoader.LoadMaterial(resource);
                        var materialRenderer = new MaterialRenderer(material, vrfGuiContext);

                        materialViewerControl.AddRenderer(materialRenderer);
                    };

                    var materialRendererTab = new TabPage("MATERIAL");
                    materialRendererTab.Controls.Add(materialViewerControl.Control);
                    resTabs.TabPages.Add(materialRendererTab);
                    break;
                }

                foreach (var block in resource.Blocks)
                {
                    if (block.Type == BlockType.RERL)
                    {
                        var externalRefsTab = new TabPage("External Refs");

                        var externalRefs = new DataGridView
                        {
                            Dock = DockStyle.Fill,
                            AutoGenerateColumns = true,
                            AutoSize            = true,
                            ReadOnly            = true,
                            AllowUserToAddRows  = false,
                            AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                            DataSource          = new BindingSource(new BindingList <ResourceExtRefList.ResourceReferenceInfo>(resource.ExternalReferences.ResourceRefInfoList), null),
                        };

                        externalRefsTab.Controls.Add(externalRefs);

                        resTabs.TabPages.Add(externalRefsTab);

                        continue;
                    }

                    if (block.Type == BlockType.NTRO)
                    {
                        if (((ResourceIntrospectionManifest)block).ReferencedStructs.Count > 0)
                        {
                            var externalRefsTab = new TabPage("Introspection Manifest: Structs");

                            var externalRefs = new DataGridView
                            {
                                Dock = DockStyle.Fill,
                                AutoGenerateColumns = true,
                                AutoSize            = true,
                                ReadOnly            = true,
                                AllowUserToAddRows  = false,
                                AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                                DataSource          = new BindingSource(new BindingList <ResourceIntrospectionManifest.ResourceDiskStruct>(((ResourceIntrospectionManifest)block).ReferencedStructs), null),
                            };

                            externalRefsTab.Controls.Add(externalRefs);
                            resTabs.TabPages.Add(externalRefsTab);
                        }

                        if (((ResourceIntrospectionManifest)block).ReferencedEnums.Count > 0)
                        {
                            var externalRefsTab = new TabPage("Introspection Manifest: Enums");
                            var externalRefs2   = new DataGridView
                            {
                                Dock = DockStyle.Fill,
                                AutoGenerateColumns = true,
                                AutoSize            = true,
                                ReadOnly            = true,
                                AllowUserToAddRows  = false,
                                AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                                DataSource          = new BindingSource(new BindingList <ResourceIntrospectionManifest.ResourceDiskEnum>(((ResourceIntrospectionManifest)block).ReferencedEnums), null),
                            };

                            externalRefsTab.Controls.Add(externalRefs2);
                            resTabs.TabPages.Add(externalRefsTab);
                        }

                        //continue;
                    }

                    var tab2 = new TabPage(block.Type.ToString());
                    try
                    {
                        var control = new TextBox();
                        control.Font = new Font(FontFamily.GenericMonospace, control.Font.Size);

                        if (block.Type == BlockType.DATA)
                        {
                            switch (resource.ResourceType)
                            {
                            case ResourceType.Sound:
                                control.Text = NormalizeLineEndings(((Sound)block).ToString());
                                break;

                            case ResourceType.Particle:
                            case ResourceType.Mesh:
                                if (block is BinaryKV3 blockKeyvalues)
                                {
                                    //Wrap it around a KV3File object to get the header.
                                    control.Text = NormalizeLineEndings(blockKeyvalues.GetKV3File().ToString());
                                }
                                else if (block is NTRO blockNTRO)
                                {
                                    control.Text = NormalizeLineEndings(blockNTRO.ToString());
                                }

                                break;

                            default:
                                control.Text = NormalizeLineEndings(block.ToString());
                                break;
                            }
                        }
                        else
                        {
                            control.Text = NormalizeLineEndings(block.ToString());
                        }

                        control.Dock       = DockStyle.Fill;
                        control.Multiline  = true;
                        control.ReadOnly   = true;
                        control.ScrollBars = ScrollBars.Both;
                        tab2.Controls.Add(control);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);

                        var bv = new ByteViewer();
                        bv.Dock = DockStyle.Fill;
                        tab2.Controls.Add(bv);

                        Invoke((MethodInvoker)(() =>
                        {
                            resource.Reader.BaseStream.Position = block.Offset;
                            bv.SetBytes(resource.Reader.ReadBytes((int)block.Size));
                        }));
                    }

                    resTabs.TabPages.Add(tab2);
                }

                tab.Controls.Add(resTabs);
            }
            else
            {
                var resTabs = new TabControl
                {
                    Dock = DockStyle.Fill,
                };
                tab.Controls.Add(resTabs);

                var bvTab = new TabPage("Hex");
                var bv    = new ByteViewer
                {
                    Dock = DockStyle.Fill,
                };
                bvTab.Controls.Add(bv);
                resTabs.TabPages.Add(bvTab);

                if (input == null)
                {
                    input = File.ReadAllBytes(fileName);
                }

                if (!input.Contains <byte>(0x00))
                {
                    var textTab = new TabPage("Text");
                    var text    = new TextBox
                    {
                        Dock       = DockStyle.Fill,
                        ScrollBars = ScrollBars.Vertical,
                        Multiline  = true,
                        ReadOnly   = true,
                        Text       = System.Text.Encoding.UTF8.GetString(input),
                    };
                    textTab.Controls.Add(text);
                    resTabs.TabPages.Add(textTab);
                    resTabs.SelectedTab = textTab;
                }

                Invoke((MethodInvoker)(() =>
                {
                    bv.SetBytes(input);
                }));
            }

            return(tab);
        }
Пример #42
0
    // Use this for initialization
    void Awake()
    {
        //Set ourselves.
        Pandora = this;

        TimePaused = true;
//		Debug.LogError("Toybox Start");

        //Create an audioplayer if we dont ahve one.
        if (AudioPlayer.GetPlayer() == null)
        {
            SoundAudioPlayer = Instantiate(SoundAudioPlayer) as AudioPlayer;
        }

        //Lets just always create the toybox at normal scale.
        //Time.timeScale = timescalenormal;

        //Create the gem pot manager
        Rewards = Instantiate(Rewards) as GemPotManager;

        if (Controls)
        {
            //Little local storage to test if joystick has been found.
            bool found = false;

            //See if there is one in the scene first.
            foreach (Object o in FindObjectsOfType(typeof(Joystick)))
            {
                if (o.name == "TOYBOX_JOYSTICK")
                {
                    Controls = (Joystick)o;
                    found    = true;
                }
            }

            //If nothign was found then this is the first time.
            if (!found)
            {
                //Create and name.
                Controls      = Instantiate(Controls) as Joystick;
                Controls.name = "TOYBOX_JOYSTICK";

                //Keep us alive just because man.
                DontDestroyOnLoad(Controls.gameObject);
            }
        }


        ///////// Bot Creation ///////

        //Create the command center.
        CommandCenter_01 = Instantiate(CommandCenter_01) as CommandCenter;

        if (!CreateCommandCenter)
        {
            CommandCenter_01.gameObject.SetActive(false);
        }

        //Create the bot
        Bot_01 = Instantiate(Bot_01) as BasicBot;


        //Create the shield
        BotShield_01 = Instantiate(BotShield_01) as SimpleShield;

        //Attach the shield to the bot.

        Bot_01.SetDefenseUnit(BotShield_01);

        //Trigger the spawns and store them in the cannon list.



        ///////// Bot Creation ///////



        /////////Scene Setup//////////

//		Camera_01 = GameObjectTracker.instance.GameCamera;
//
//
//		if(Camera_01)
//		{
//			//Set teh camera to look at the bot.
//			Camera_01.SetBotToFollow(Bot_01);
//
//			//Set teh game camera as the current game camera.
//			Camera.SetupCurrent(Camera_01.MyCamera);
//		}
//
        //Create the ball stack and yeah...
        SceneBallStack = Instantiate(SceneBallStack) as BallStack;

        /////////Scene Setup//////////


        //Create the NGUI last

        if ((FUIHud && createFUI) && ActivityManager.Instance == null)
        {
            FUIHud = Instantiate(FUIHud) as UIRoot;

            //What happens if we dont destroy?
            DontDestroyOnLoad(FUIHud.gameObject);
        }
        else
        {
            //If the activitiy manager is alrady crated and is not active, then we simply activate.
            if (ActivityManager.Instance.SetActive == false)
            {
                ActivityManager.Instance.SetActive = true;

                //here we should activate the gameplay world as well.
                GameObjectTracker.GetGOT().World.gameObject.SetActive(true);
            }
        }


        if (fui3DManager && createFui3D)
        {
            fui3DManager = Instantiate(fui3DManager) as FUI3DManager;
        }

        if (MyPowerUpSpawner == null)
        {
            Debug.LogError("No powerup spawner in testgame");
        }
//		Debug.LogError("Toybox End");
    }
Пример #43
0
 public RaceTime(AudioPlayer audioPlayer)
 {
     this.audioPlayer = audioPlayer;
 }
Пример #44
0
 private void Awake()
 {
     ME = this;
 }
Пример #45
0
        private static void Main(string[] args)
        {
            var filename = args.Length > 0 ? args[0] : null;
            var startPos = args.Length >= 2 ? TimeSpan.FromSeconds(int.Parse(args[1])) : TimeSpan.Zero;

            Console.WriteLine("Found devices:");
            var devices = AlDevice.GetDevices().ToArray();

            for (var i = 0; i < devices.Length; i++)
            {
                Console.WriteLine($"[{i}] {devices[i]}");
            }

            Console.Write($"Select one (default {AlDevice.DefaultDeviceName}): ");
            var selection = Console.ReadLine();

            Console.WriteLine();

            AudioBufferTracker.Default.Start();

            using (var device = int.TryParse(selection, out var index)
                ? AlDevice.Create(devices[index])
                : AlDevice.GetDefault())
            {
                Console.WriteLine("Opened the device!");

                using (var player = new AudioPlayer(device))
                {
                    var oggDecoder = filename == null ? null : new OggDecoder(filename);
                    var synth      = new SynthStream(1000);

                    player.Load(oggDecoder);
                    player.Play();
                    player.Source.TimePosition = startPos;

                    Console.Write("Press Enter to stop.");
                    string input;
                    while (!string.IsNullOrWhiteSpace(input = Console.ReadLine()))
                    {
                        if (int.TryParse(input, out var freq))
                        {
                            if (freq >= 20 && freq <= 20000)
                            {
                                synth.Frequency = freq;
                                player.Load(synth);
                            }
                        }
                        else if (input == "song")
                        {
                            if (oggDecoder != null)
                            {
                                player.Load(oggDecoder);
                            }
                        }
                        else if (input == "pause")
                        {
                            player.Pause();
                        }
                        else if (input == "play")
                        {
                            player.Play();
                        }
                        else if (input.StartsWith("pitch"))
                        {
                            var s = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                            if (s.Length >= 2 && float.TryParse(s[1], out var val))
                            {
                                player.AlSource.Pitch = val;
                            }
                        }
                        else if (input.StartsWith("gain"))
                        {
                            var s = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                            if (s.Length >= 2 && float.TryParse(s[1], out var val))
                            {
                                player.AlSource.Gain = val;
                            }
                        }
                        else if (input.StartsWith("pos"))
                        {
                            if (oggDecoder == null)
                            {
                                continue;
                            }
                            var s = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                            if (s.Length >= 2 && int.TryParse(s[1], out var val))
                            {
                                oggDecoder.TimePosition = TimeSpan.FromSeconds(val);
                            }
                        }
                        else if (input == "sine")
                        {
                            synth.Oscillator = OscillatorFunctions.Sine;
                        }
                        else if (input == "triangle")
                        {
                            synth.Oscillator = OscillatorFunctions.Triangle;
                        }
                        else if (input == "square")
                        {
                            synth.Oscillator = OscillatorFunctions.Square;
                        }
                        else if (input == "saw")
                        {
                            synth.Oscillator = OscillatorFunctions.SawTooth;
                        }
                    }

                    oggDecoder?.Dispose();
                }
            }
        }
Пример #46
0
 private void OnDestroy()
 {
     ME = null;
 }
Пример #47
0
    private void Start()
    {
        AudioPlayer audio = GameObject.Find("AudioList").GetComponent <AudioPlayer>();

        audio.Play(5);
    }
Пример #48
0
 void Start()
 {
     halfRenderers     = GetComponentsInChildren <MeshRenderer>();
     halfColliders     = GetComponentsInChildren <MeshCollider>();
     banana_ChompSound = GetComponent <AudioPlayer>();
 }
Пример #49
0
    private IEnumerator ShowSelection()
    {
        AudioClip musicChoiceClip;

        HideObject(Captions);

        ChooseSpaceship();
        ChooseMusic(out musicChoiceClip);

        AudioPlayer player = new AudioPlayer(musicChoiceClip, MusicSource);

        musicChoiceClip.LoadAudioData();

        // Push the "front" selection boxes off to the side
        yield return(PushBoxesOut());

        // Show the "SelectionPane" where the selections will be shown
        yield return(Transition.FadeIn(SelectionPane, 1f, enableSr: true));

        // Bring attention to the seebox
        GlowCloud.transform.parent = SeeBoxFront.transform;
        yield return(Transition.TransitionBrightness(gameObject, SeeBoxFront,
                                                     BrightnessTransitionTime, Bright, Dark));

        // Animate the process of choosing a spaceship
        yield return(CycleOptions(SpaceshipsSelected, SelectedSpaceship));

        SelectedSpaceship.transform.parent = SpaceshipPane.transform;

        // Bring attention to the spaceship pane
        StartCoroutine(Darken(SeeBoxFront));
        yield return(Brighten(SpaceshipPane));

        // Put the spaceship on its frame
        yield return(MoveSelectionObject(SelectedSpaceship, SpaceshipPane, SeeBoxFront));

        yield return(new WaitForSeconds(musicChoiceClip.length));

        // Bring attention to the hearbox
        StartCoroutine(Darken(SpaceshipPane));
        yield return(Brighten(HearBoxFront));

        // Animate the process of choosing a measure
        GlowCloud.transform.parent = HearBoxFront.transform;
        yield return(CycleOptions(MeasuresSelected, SelectedMeasure));

        SelectedMeasure.transform.parent = MusicBox.transform;

        // Bring attention to the musicbox
        StartCoroutine(Darken(HearBoxFront));
        yield return(Brighten(MusicBox));

        // Put the measure on its frame
        yield return(MoveSelectionObject(SelectedMeasure, MusicBox, HearBoxFront));

        yield return(PlayClip(SelectedMeasure, player, musicChoiceClip.length));

        yield return(Transition.TransitionBrightness(gameObject, MusicBox,
                                                     BrightnessTransitionTime, Dark, Bright));

        yield return(null);
    }
 public OvertakingAidsMonitor(AudioPlayer audioPlayer)
 {
     this.audioPlayer = audioPlayer;
 }
Пример #51
0
 private IEnumerator PlayClip(GameObject music, AudioPlayer player, float length)
 {
     StartCoroutine(Glow(music, length));
     yield return(player.PlayBlocking());
 }
Пример #52
0
        internal void OnLoad()
        {
            Mouse    = window.Mouse;
            Keyboard = window.Keyboard;

                        #if ANDROID
            Graphics = new OpenGLESApi();
                        #elif !USE_DX
            Graphics = new OpenGLApi();
                        #else
            Graphics = new Direct3D9Api(this);
                        #endif
            Graphics.MakeApiInfo();
            ErrorHandler.AdditionalInfo = Graphics.ApiInfo;

                        #if ANDROID
            Drawer2D = new CanvasDrawer2D(Graphics);
                        #else
            Drawer2D = new GdiPlusDrawer2D(Graphics);
                        #endif

            Entities = new EntityList(this);
            AcceptedUrls.Load();
            DeniedUrls.Load();
            ETags.Load();
            LastModified.Load();

            if (Options.GetBool(OptionsKey.SurvivalMode, false))
            {
                Mode = new SurvivalGameMode();
            }
            else
            {
                Mode = new CreativeGameMode();
            }
            Components.Add(Mode);

            Input           = new InputHandler(this);
            defaultIb       = Graphics.MakeDefaultIb();
            ParticleManager = new ParticleManager(); Components.Add(ParticleManager);
            TabList         = new TabList(); Components.Add(TabList);
            LoadOptions();
            LoadGuiOptions();
            Chat = new Chat(); Components.Add(Chat);

            WorldEvents.OnNewMap       += OnNewMapCore;
            WorldEvents.OnNewMapLoaded += OnNewMapLoadedCore;
            Events.TextureChanged      += TextureChangedCore;

            BlockInfo.Init();
            ModelCache = new ModelCache(this);
            ModelCache.InitCache();
            AsyncDownloader = new AsyncDownloader(Drawer2D); Components.Add(AsyncDownloader);
            Lighting        = new BasicLighting(); Components.Add(Lighting);

            Drawer2D.UseBitmappedChat = ClassicMode || !Options.GetBool(OptionsKey.UseChatFont, false);
            Drawer2D.BlackTextShadows = Options.GetBool(OptionsKey.BlackText, false);
            Graphics.Mipmaps          = Options.GetBool(OptionsKey.Mipmaps, false);

            TerrainAtlas1D = new TerrainAtlas1D(this);
            TerrainAtlas   = new TerrainAtlas2D(this);
            Animations     = new Animations(); Components.Add(Animations);
            Inventory      = new Inventory(); Components.Add(Inventory);

            BlockInfo.SetDefaultPerms();
            World       = new World(this);
            LocalPlayer = new LocalPlayer(this); Components.Add(LocalPlayer);
            Entities.List[EntityList.SelfID] = LocalPlayer;
            Width = window.Width; Height = window.Height;

            MapRenderer = new MapRenderer(this);
            string renType = Options.Get(OptionsKey.RenderType) ?? "normal";
            if (!SetRenderType(renType))
            {
                SetRenderType("normal");
            }

            if (IPAddress == null)
            {
                Server = new Singleplayer.SinglePlayerServer(this);
            }
            else
            {
                Server = new Network.NetworkProcessor(this);
            }
            Graphics.LostContextFunction = Server.Tick;

            Cameras.Add(new FirstPersonCamera(this));
            Cameras.Add(new ThirdPersonCamera(this, false));
            Cameras.Add(new ThirdPersonCamera(this, true));
            Camera = Cameras[0];
            UpdateProjection();

            Gui               = new GuiInterface(this); Components.Add(Gui);
            CommandList       = new CommandList(); Components.Add(CommandList);
            SelectionManager  = new SelectionManager(); Components.Add(SelectionManager);
            WeatherRenderer   = new WeatherRenderer(); Components.Add(WeatherRenderer);
            HeldBlockRenderer = new HeldBlockRenderer(); Components.Add(HeldBlockRenderer);

            Graphics.DepthTest = true;
            Graphics.DepthTestFunc(CompareFunc.LessEqual);
            //Graphics.DepthWrite = true;
            Graphics.AlphaBlendFunc(BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha);
            Graphics.AlphaTestFunc(CompareFunc.Greater, 0.5f);
            Culling           = new FrustumCulling();
            Picking           = new PickedPosRenderer(); Components.Add(Picking);
            AudioPlayer       = new AudioPlayer(); Components.Add(AudioPlayer);
            AxisLinesRenderer = new AxisLinesRenderer(); Components.Add(AxisLinesRenderer);
            SkyboxRenderer    = new SkyboxRenderer(); Components.Add(SkyboxRenderer);

            plugins = new PluginLoader(this);
            List <string> nonLoaded = plugins.LoadAll();

            for (int i = 0; i < Components.Count; i++)
            {
                Components[i].Init(this);
            }
            ExtractInitialTexturePack();
            for (int i = 0; i < Components.Count; i++)
            {
                Components[i].Ready(this);
            }
            InitScheduledTasks();

            if (nonLoaded != null)
            {
                for (int i = 0; i < nonLoaded.Count; i++)
                {
                    plugins.MakeWarning(this, nonLoaded[i]);
                }
            }

            window.LoadIcon();
            string connectString = "Connecting to " + IPAddress + ":" + Port + "..";
            if (Graphics.WarnIfNecessary(Chat))
            {
                MapBordersRenderer.UseLegacyMode(true);
                EnvRenderer.UseLegacyMode(true);
            }
            Gui.SetNewScreen(new LoadingMapScreen(this, connectString, ""));
            Server.Connect(IPAddress, Port);
        }
Пример #53
0
 private void Start()
 {
     player = GetComponent <AudioPlayer>();
 }
Пример #54
0
 public void FinishGame(bool isClear)
 {
     m_isPlaying.Value = false;
     AudioPlayer.PlaySE((isClear) ? m_gameClearKey : m_gameOverKey);
 }
Пример #55
0
 void Awake()
 {
     Instance = this;
 }
Пример #56
0
 public GeneralAudioSettings(AudioPlayer audioPlayer)
 {
     this.audioPlayer = audioPlayer;
 }
Пример #57
0
        public Xmas2013scene(IEnumerable <string> args)
        {
            hours = new OperatingHours("Hours");

            timeline1     = new Controller.Timeline <string>(1);
            stateMachine  = new Controller.EnumStateMachine <States>("Main");
            hatLightState = new Controller.IntStateMachine("Hats");
            lightJesus    = new StrobeColorDimmer("Jesus");
            lightStar     = new Dimmer("Star");
            lightHat1     = new Dimmer("Hat 1");
            lightHat2     = new Dimmer("Hat 2");
            lightHat3     = new Dimmer("Hat 3");
            lightHat4     = new Dimmer("Hat 4");
            lightSnow1    = new Dimmer("Snow 1");
            lightSnow2    = new Dimmer("Snow 2");
            lightStairs1  = new Dimmer("Stair 1");
            lightStairs2  = new Dimmer("Stairs 2");
            lightGarland1 = new Dimmer("Garland 1");
            lightGarland2 = new Dimmer("Garland 2");
            lightGarland3 = new Dimmer("Garland 3");
            lightGarland4 = new Dimmer("Garland 4");
            lightString1  = new Dimmer("String 1");
            lightString2  = new Dimmer("String 1");
            lightXmasTree = new Dimmer("Xmas Tree");

            lightDeerLarge   = new Dimmer("Deer Large");
            lightDeerSmall   = new Dimmer("Deer Small");
            lightTreeUp      = new StrobeColorDimmer("Tree up");
            switchSanta      = new Switch("Santa");
            switchDeerHuge   = new Switch("Deer Huge");
            lightTopperSmall = new Dimmer("Topper Small");
            lightTopperLarge = new Dimmer("Topper Large");
            lightNet1        = new Dimmer("Net 1");
            lightNet2        = new Dimmer("Net 2");
            lightVader       = new StrobeColorDimmer("Vader");
            light3wise       = new StrobeColorDimmer("3wise");

            pulsatingEffect1 = new Effect.Pulsating(S(4), 0.4, 1.0, false);
            pulsatingStar    = new Effect.Pulsating(S(2), 0.2, 0.4, false);
            flickerEffect    = new Effect.Flicker(0.5, 0.6, false);
            faderIn          = new Effect.Fader(S(2), 0.0, 1.0, false);

            candyCane      = new Controller.Sequence("Candy Cane");
            twinkleSeq     = new Controller.Sequence("Twinkle");
            backgroundLoop = new Controller.Sequence("Background");
            music1Seq      = new Controller.Sequence("Christmas Canon");
            starwarsCane   = new Controller.Sequence("Starwars Cane");
            fatherSeq      = new Controller.Sequence("Father");
            offHours1Seq   = new Controller.Sequence("Off hours 1");
            offHours2Seq   = new Controller.Sequence("Off hours 2");
            waveformSeq    = new Controller.Sequence("Waveform");

            allPixels      = new VirtualPixel1D(100);
            starwarsPixels = new VirtualPixel1D(50);
            saberPixels    = new VirtualPixel1D(60);

            buttonTest             = new DigitalInput("Test");
            buttonStartInflatables = new DigitalInput("Inflatables");
            buttonOverrideHours    = new DigitalInput("Override hours", true);

            buttonBlue       = new DigitalInput("Blue");
            buttonRed        = new DigitalInput("Red");
            switchButtonBlue = new Switch("Blue");
            switchButtonRed  = new Switch("Red");
            elJesus          = new Switch("Jesus Halo");
            audioPlayer      = new AudioPlayer("Audio");

            popOut1Piano     = new Effect.PopOut(S(0.4));
            popOut1Drums     = new Effect.PopOut(S(0.4));
            popOut1DrumsFast = new Effect.PopOut(S(0.3));
            popOut1Chord     = new Effect.PopOut(S(0.4));
            popOut1Solo      = new Effect.PopOut(S(0.3));
            popOut1Solo2     = new Effect.PopOut(S(0.2));
            popOut1Choir     = new Effect.PopOut(S(1.0));
            popOut1Voice     = new Effect.PopOut(S(1.0));
            popOut1Vocal2    = new Effect.PopOut(S(2.0));
            popOut1VocalLong = new Effect.PopOut(S(5.0));
            popOut1End       = new Effect.PopOut(S(5.0));

            this.oscServer = new Expander.OscServer(10000);

            raspberry.DigitalInputs[4].Connect(buttonRed);
            raspberry.DigitalInputs[5].Connect(buttonBlue);
            raspberry.DigitalOutputs[0].Connect(switchButtonBlue);
            raspberry.DigitalOutputs[1].Connect(switchButtonRed);
            raspberry.DigitalOutputs[2].Connect(elJesus);

            raspberry.Connect(audioPlayer);
        }
Пример #58
0
 public override void OnInspectorGUI()
 {
     player = target as AudioPlayer;
     base.OnInspectorGUI();
 }
Пример #59
0
        /// <summary>
        /// Load Settings
        /// </summary>
        private void LoadSettings()
        {
            using (Profile.Settings xmlreader = new Profile.MPSettings())
            {
                Log.Info("BASS: Loading Settings");
                string strAudioPlayer = xmlreader.GetValueAsString("audioplayer", "playerId", "0");
                _audioPlayer   = (AudioPlayer)Enum.Parse(typeof(AudioPlayer), strAudioPlayer);
                _soundDevice   = xmlreader.GetValueAsString("audioplayer", "sounddevice", "Default Sound Device");
                _soundDeviceID = xmlreader.GetValueAsString("audioplayer", "sounddeviceid", "");
                _streamVolume  = xmlreader.GetValueAsInt("audioplayer", "streamOutputLevel", 85);
                _bufferingMs   = xmlreader.GetValueAsInt("audioplayer", "buffering", 5000);

                if (_bufferingMs <= 0)
                {
                    _bufferingMs = 1000;
                }
                else if (_bufferingMs > 8000)
                {
                    _bufferingMs = 8000;
                }

                _crossFadeIntervalMs = xmlreader.GetValueAsInt("audioplayer", "crossfade", 4000);

                if (_crossFadeIntervalMs < 0)
                {
                    _crossFadeIntervalMs = 0;
                }
                else if (_crossFadeIntervalMs > 16000)
                {
                    _crossFadeIntervalMs = 16000;
                }

                _softStop              = xmlreader.GetValueAsBool("audioplayer", "fadeOnStartStop", true);
                _useSkipSteps          = xmlreader.GetValueAsBool("audioplayer", "useSkipSteps", false);
                _enableReplaygain      = xmlreader.GetValueAsBool("audioplayer", "enableReplayGain", false);
                _enableAlbumReplaygain = xmlreader.GetValueAsBool("audioplayer", "enableAlbumReplayGain", false);

                _asioBalance         = (float)xmlreader.GetValueAsInt("audioplayer", "asiobalance", 0) / 100.00f;
                _wasApiExclusiveMode = xmlreader.GetValueAsBool("audioplayer", "wasapiExclusive", false);
                _wasApiSpeakers      = xmlreader.GetValueAsInt("audioplayer", "wasApiSpeakers", 1);

                bool doGaplessPlayback = xmlreader.GetValueAsBool("audioplayer", "gaplessPlayback", false);

                if (doGaplessPlayback)
                {
                    _crossFadeIntervalMs = 200;
                    _playBackType        = PlayBackType.GAPLESS;
                }
                else
                {
                    if (_crossFadeIntervalMs == 0)
                    {
                        _playBackType = PlayBackType.NORMAL;
                        //_crossFadeIntervalMs = 100;
                    }
                    else
                    {
                        _playBackType = PlayBackType.CROSSFADE;
                    }
                }

                _upMixMono       = xmlreader.GetValueAsInt("audioplayer", "upMixMono", 0);
                _upMixStereo     = xmlreader.GetValueAsInt("audioplayer", "upMixStereo", 0);
                _upMixQuadro     = xmlreader.GetValueAsInt("audioplayer", "upMixQuadro", 0);
                _upMixFiveDotOne = xmlreader.GetValueAsInt("audioplayer", "upMixFiveDotOne", 0);
            }
        }
Пример #60
0
 public Penalties(AudioPlayer audioPlayer)
 {
     this.audioPlayer = audioPlayer;
 }