Example #1
0
    void Start()
    {
        activeSounds = new ArrayList();

        //Singleton initialization
        //s_Instance = this;

        //Service Locator
        SoundLocator.Provide(this);

        //List of all sounds
        _towerCrumble  = (AudioClip)Resources.Load("Sounds/TowerCrumble");
        _towerShoot    = (AudioClip)Resources.Load("Sounds/TowerShoot");
        _bombExplode   = (AudioClip)Resources.Load("Sounds/BombExplode");
        _sandTrack     = (AudioClip)Resources.Load("Sounds/SandTrack");
        _mainExplosion = (AudioClip)Resources.Load("Sounds/MainExplosion");
        _freeze        = (AudioClip)Resources.Load("Sounds/Freeze");



        freeze        = gameObject.AddComponent <AudioSource>();
        freeze.clip   = _freeze;
        freeze.volume = 0.25f;


        mainExplosion        = gameObject.AddComponent <AudioSource>();
        mainExplosion.clip   = _mainExplosion;
        mainExplosion.volume = 0.8f;


        bombExplode        = gameObject.AddComponent <AudioSource>();
        bombExplode.clip   = _bombExplode;
        bombExplode.volume = 0.2f;

        towerShoot      = gameObject.AddComponent <AudioSource>();
        towerShoot.clip = _towerShoot;

        towerShoot.volume = 0.5f;

        soundTrack        = gameObject.AddComponent <AudioSource>();
        soundTrack.clip   = _sandTrack;
        soundTrack.volume = 1f;
        soundTrack.loop   = true;

        PlayMusic();
    }
Example #2
0
        public BunnyHopGame()
        {
            config   = new Config();
            database = new InMemoryDatabase();
            ConfigLocator.Provide(config);
            ContentLocator.Provide(Content);
            InMemoryDatabaseLocator.Provide(database);

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = ConfigLocator.Config.VirtualWidth * ConfigLocator.Config.Scale;
            graphics.PreferredBackBufferHeight = ConfigLocator.Config.VirtualHeight * ConfigLocator.Config.Scale;
            graphics.PreferMultiSampling       = false;
            graphics.ApplyChanges();
            GraphicsLocator.Provide(graphics);

            var viewportAdapter = new BoxingViewportAdapter(Window,
                                                            GraphicsDevice,
                                                            ConfigLocator.Config.VirtualWidth,
                                                            ConfigLocator.Config.VirtualHeight);

            camera = new Camera2D(viewportAdapter);
            CameraLocator.Provide(camera);

            soundEffects = new List <SoundEffect>();
            SoundLocator.Provide(soundEffects);

            Content.RootDirectory = "Content";
            stateStack            = new Stack <State>();
            stateStack.Push(new SplashState());

            //https://docs.microsoft.com/pt-br/dotnet/api/system.globalization.cultureinfo.currentculture?view=netcore-3.1
            //CultureInfo culture = new CultureInfo("ko-KR", false); // us-EN ko-KR ja-JP
            //Thread.CurrentThread.CurrentCulture = culture;
            //Thread.CurrentThread.CurrentUICulture = culture;
            //Resources.Culture = CultureInfo.CurrentCulture;
            //Debug.Print(CultureInfo.CurrentCulture.Name);
            //Debug.Print(CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
            //Debug.Print(Resources.Culture.Name);
        }