示例#1
0
文件: Program.cs 项目: mwawerHub/Pong
        private static void Main(string[] args)
        {
            try {
                var bgMusic = new BackgroundMusic();
                bgMusic.Play();

                Initialize.InitializeGame();
                while (true)
                {
                    Thread.Sleep(10);
                    var key = (Console.KeyAvailable) ? Console.ReadKey(true).Key : 0;
                    Update.UpdateAll(key);
                    if (State.ScreenNeedsRedraw)
                    {
                        Console.Clear();
                    }
                    Draw.DrawAll();
                    State.ScreenNeedsRedraw = false;
                    State.PlayerNeedsRedraw = false;
                    State.BallNeedsRedraw   = false;
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
                throw;
            }
        }
示例#2
0
    private void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
    {
        i = 0;
        if (stIndexes[scene.buildIndex] != stIndex)
        {
            stIndex = stIndexes[scene.buildIndex];
            BackgroundMusic.clip = soundtracks[stIndex];
            BackgroundMusic.Play();
        }

        insts = new Dictionary <int, GPGSyncInstance>();

        if (scene.buildIndex > 1)
        {
            //CreatePlayers();
            if (!singlplayer)
            {
                pcs.Clear();
                CreateLocalPlayer();
            }
            else
            {
                Transform spawn = GameObject.Find(Gateway).transform;
                Vector3   pos   = spawn != null ? spawn.position : new Vector3();
                Instantiate(playerPrefab, pos, Quaternion.identity);
            }
        }
    }
示例#3
0
        void addSound()
        {
            GameObject      backMusic       = new GameObject("background_music");
            BackgroundMusic backgroundMusic = new BackgroundMusic("Audio/BGM");

            backgroundMusic.Volume = 100;
            backgroundMusic.Play();
            backgroundMusic.IsRepeating = true;

            backMusic.AddComponent(backgroundMusic);
            backMusic.Parent = Root;
            backMusic.GetComponent <BackgroundMusic>().Play();
        }
    // Start is called before the first frame update
    void Start()
    {
        audioSources = GetComponents <AudioSource>();

        WhiteNoise.clip      = WhiteNoiseClip;
        BackgroundMusic.clip = BackgroundMusicClip;
        ShepardTone.clip     = ShepardToneClip;

        backgroundMusicMaxVolume = BackgroundMusic.volume;
        shepardToneMaxVolume     = ShepardTone.volume;

        ShepardTone.volume     = 0;
        BackgroundMusic.volume = 0;

        WhiteNoise.Play();
        BackgroundMusic.Play();
        ShepardTone.Play();
    }
示例#5
0
    //-------------------------------------------------------------------------
    //						CLASS METHOD DEFINITIONS
    //-------------------------------------------------------------------------
    void Awake()
    {
        manager = GetComponent <InteractableManager>();
        manager.Register(this);
        updateHandler_ = sceneIntro;

        // play the cell door sound
        CellDoorSoundSound.Play();

        // play background music but set volume to 0.
        // also set the fader for the bgm
        BackgroundMusic.Play();
        BackgroundMusic.Loop(true);
        BackgroundMusic.SetVolume(0.0f);

        bgmFader_ = new Fader(0.0f, 30.0f, 0.0f);

        //
        introBgFader_ = new Fader(1.0f, 0.0f, 5.0f);
    }
示例#6
0
    //Play requested sound
    public void PlaySound(string sound)
    {
        //Check given sound name matches and soundIDs
        for (int i = 0; i < soundFx.Length; i++)
        {
            if (sound == soundFx[i].soundID)
            {
                soundFx[i].Play();
                return;
            }
        }

        if (sound == music.soundID)
        {
            music.Play();
        }
        else
        {
            //Throw warning if sound wasn't found
            Debug.LogWarning("SoundManager: Requested sound was not found");
        }
    }
示例#7
0
        private static void LoadGameFile()
        {
            try
            {
                var parser = new FileIniDataParser();
                var data   = parser.ReadFile(StorageBase.GameIniFilePath);

                //state
                var state = data["State"];
                MapBase.OpenMap(state["Map"]);
                NpcManager.Load(state["Npc"]);
                ObjManager.Load(state["Obj"]);
                BackgroundMusic.Play(state["Bgm"]);
                Globals.PlayerIndex = int.Parse(state["Chr"]);

                //option
                var option = data["Option"];
                MapBase.MapTime = int.Parse(option["MapTime"]);
                WeatherManager.ShowSnow(int.Parse(option["SnowShow"]) != 0);
                if (!string.IsNullOrEmpty(option["RainFile"]))
                {
                    WeatherManager.BeginRain(option["RainFile"]);
                }
                if (string.IsNullOrEmpty(option["Water"]))
                {
                    Globals.IsWaterEffectEnabled = false;
                }
                else
                {
                    Globals.IsWaterEffectEnabled = int.Parse(option["Water"]) != 0;
                }
                if (string.IsNullOrEmpty(option["MpcStyle"]))
                {
                    MapBase.DrawColor = Color.White;
                }
                else
                {
                    MapBase.DrawColor = StorageBase.GetColorFromString(option["MpcStyle"]);
                }
                if (string.IsNullOrEmpty(option["AsfStyle"]))
                {
                    Sprite.DrawColor = Color.White;
                }
                else
                {
                    Sprite.DrawColor = StorageBase.GetColorFromString(option["AsfStyle"]);
                }
                if (string.IsNullOrEmpty(option["SaveDisabled"]))
                {
                    Globals.IsSaveDisabled = false;
                }
                else
                {
                    Globals.IsSaveDisabled = int.Parse(option["SaveDisabled"]) > 0;
                }
                if (string.IsNullOrEmpty(option["IsDropGoodWhenDefeatEnemyDisabled"]))
                {
                    Globals.IsDropGoodWhenDefeatEnemyDisabled = false;
                }
                else
                {
                    Globals.IsDropGoodWhenDefeatEnemyDisabled = int.Parse(option["IsDropGoodWhenDefeatEnemyDisabled"]) > 0;
                }
                //Timer
                var timer = data["Timer"];
                if (timer != null)
                {
                    var isOn = timer["IsOn"] != "0";
                    if (isOn)
                    {
                        ScriptExecuter.OpenTimeLimit(int.Parse(timer["TotalSecond"]));
                        var isHide = timer["IsTimerWindowShow"] != "1";
                        if (isHide)
                        {
                            ScriptExecuter.HideTimerWnd();
                        }
                        if (timer["IsScriptSet"] != "0")
                        {
                            ScriptExecuter.SetTimeScript(int.Parse(timer["TriggerTime"]),
                                                         timer["TimerScript"]);
                        }
                    }
                }

                //Variables
                ScriptExecuter.LoadVariables(data["Var"]);

                //ParallelScript
                ScriptManager.LoadParallelScript(data["ParallelScript"]);
            }
            catch (Exception exception)
            {
                Log.LogFileLoadError("Game.ini", StorageBase.GameIniFilePath, exception);
            }
        }
示例#8
0
        /// <summary>
        /// Check if the player click any key
        /// </summary>
        /// <param name="ElapsedTime"></param>
        public void ClickedKeys(double ElapsedTime)
        {
            //Prevent player from fast clicking
            FrameTimer += (float)ElapsedTime;
            if (FrameTimer >= 0.1f)
            {
                FrameTimer -= 0.1f;
                if (Grid.GameOn())
                {
                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Down))
                    {
                        UpDown.Play(false);
                        Grid.MoveDown();
                    }

                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Up))
                    {
                        UpDown.Play(false);
                        Grid.MoveUp();
                    }

                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Left))
                    {
                        LeftRight.Play(false);
                        Grid.MoveLeft();
                    }

                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Right))
                    {
                        LeftRight.Play(false);
                        Grid.MoveRight();
                    }
                }

                if (Engine.KeyClicked(System.Windows.Forms.Keys.Space))
                {
                    if (BackgroundMusic.IsBeingPlayed)
                    {
                        BackgroundMusic.StopPlaying();
                    }
                    else
                    {
                        BackgroundMusic.Play(true);
                    }
                }

                if (!Grid.GameOn())
                {
                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Enter))
                    {
                        Score = new Score(this.Engine, Grid.Score);
                        Engine.RegisterScene(Score);
                        Engine.GoToScene(Score);
                    }
                }
            }
            //Go back to the menu
            if (Engine.KeyClicked(System.Windows.Forms.Keys.Escape))
            {
                Menu menu = new Menu(Engine, this);
                Engine.GoToScene(menu);
            }
        }
示例#9
0
 public override void Enter()
 {
     bgm.Play();
 }
 public MainWindow()
 {
     InitializeComponent();
     BackgroundMusic.Play();
     BackgroundMusic.Volume = 0;
 }
示例#11
0
    void RefreshCurrentSpeech()
    {
        isChangingSpeech = true;

        isCharacterChanged  = PreviousSpeech == null || (PreviousSpeech != null && !PreviousSpeech.character.Equals(CurrentSpeech.character));
        isBackgroundChanged = !string.IsNullOrEmpty(CurrentSpeech.background);

        if (currentCharacter && (isCharacterChanged || isBackgroundChanged))
        {
            currentCharacter.Hide();
        }

        if (isCharacterChanged)
        {
            if (!Assets.CHARACTER_NARRATOR.Equals(CurrentSpeech.character))
            {
                currentCharacter = GetCharacter(CurrentSpeech.character);
            }
            else
            {
                currentCharacter = null;
            }
        }

        //  Hide current dialog anyway. If speaking character not changed, dialog will be shown up with a small delay
        if (currentDialog)
        {
            currentDialog.Hide();
        }

        if (isBackgroundChanged)
        {
            if (PreviousSpeech == null)
            {
                StartCoroutine(ShowBackground(Assets.Load <Sprite>(Assets.BACKGROUND, CurrentSpeech.background)));
            }
            else
            {
                StartCoroutine(UpdateBackground(Assets.Load <Sprite>(Assets.BACKGROUND, CurrentSpeech.background)));
            }
        }
        else if (isCharacterChanged)
        {
            Invoke("OnBackgroundUpdated", CHANGE_CHARACTER_DELAY);
        }
        else
        {
            OnBackgroundUpdated();
        }

        if (!string.IsNullOrEmpty(CurrentSpeech.music))
        {
            if (Assets.MUSIC_OFF.Equals(CurrentSpeech.music))
            {
                BackgroundMusic.Stop();
            }
            else
            {
                BackgroundMusic.Play(Assets.Load <AudioClip>(Assets.MUSIC, CurrentSpeech.music));
            }
        }
    }