Esempio n. 1
0
 /// <summary>
 /// Provides derived classes an opportunity to handle changes to the CurrentCountDownState property.
 /// </summary>
 protected virtual void OnCurrentCountDownStateChanged(CountDownState oldCurrentCountDownState, CountDownState newCurrentCountDownState)
 {
     if (oldCurrentCountDownState != newCurrentCountDownState)
     {
         //_countDownVisualStates[newCurrentCountDownState.ToString()].Activate(this);
         VisualStateManager.GoToState(this, newCurrentCountDownState.ToString(), true);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Handles changes to the CurrentCountDownState property.
        /// </summary>
        private static void OnCurrentCountDownStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CountDownButton target = (CountDownButton)d;
            CountDownState  oldCurrentCountDownState = (CountDownState)e.OldValue;
            CountDownState  newCurrentCountDownState = target.CurrentCountDownState;

            target.OnCurrentCountDownStateChanged(oldCurrentCountDownState, newCurrentCountDownState);
        }
Esempio n. 3
0
        private void Countdown(RealmTime time)
        {
            if (_countDown == CountDownState.Notify60)
            {
                _countDown = CountDownState.Notify30;

                Manager.Chat.Announce("A public arena game is starting. Closing in 1 min. Type /arena to join.", true);
                foreach (var plr in Players.Values)
                {
                    if (plr.Owner?.IsNotCombatMapArea ?? false)
                    {
                        plr.Client.SendPacket(new GlobalNotification
                        {
                            Type = GlobalNotification.ADD_ARENA,
                            Text = "{\"name\":\"Public Arena\",\"open\":true}"
                        });
                    }
                    plr.SendInfo("Game starting in 60 seconds.");
                }
            }

            if (_countDown == CountDownState.Notify30 && _time > 30000)
            {
                _countDown = CountDownState.StartGame;

                foreach (var plr in Players.Values)
                {
                    plr.SendInfo("Game starting in 30 seconds.");
                }
            }

            if (_countDown == CountDownState.StartGame && _time > 60000)
            {
                _countDown       = CountDownState.Done;
                CurrentState     = ArenaState.Start;
                _time            = 0;
                _startingPlayers = Players.Count(p => p.Value.SpectateTarget == null);

                Manager.Monitor.ClosePortal(World.Arena);

                foreach (var plr in Players.Values.Where(_ => _.Owner?.IsNotCombatMapArea ?? false))
                {
                    plr.Client.SendPacket(new GlobalNotification
                    {
                        Type = GlobalNotification.ADD_ARENA,
                        Text = "{\"name\":\"Public Arena\",\"open\":false}"
                    });
                }
            }
        }
Esempio n. 4
0
    private void OnlineUpdate()
    {
        if (NetworkManager.singleton.numPlayers <= 1 && isServer)
        {
            return;
        }
        string text = "";

        //フェード状態が待機状態なら
        if (FadeController.fadeActionState == FadeActionState.Stay && isServer)
        {
            //カウントダウンを減らす
            countDownTime -= Time.deltaTime;
        }
        //カウントダウン状態で処理変更
        switch (countDownState)
        {
        //数値表示
        case CountDownState.NUMBER:
            //小数点以下切り上げで表示
            text = Mathf.Ceil(countDownTime).ToString("0");
            //時間が来たら
            if (countDownTime <= 0)
            {
                //1秒に設定
                countDownTime = 1.0f;
                //状態遷移
                countDownState = CountDownState.START;
            }
            break;

        //”Start”表示
        case CountDownState.START:
            //Start表示
            text = "Start!";
            //時間が来たら
            if (countDownTime <= 0)
            {
                //非表示
                countDownText.enabled = false;
                //状態遷移
                countDownState = CountDownState.END;
            }
            break;
        }

        //小数点以下切り上げで表示
        countDownText.text = text;
    }
Esempio n. 5
0
        private void Countdown(RealmTime time)
        {
            if (_countDown == CountDownState.Notify15)
            {
                _countDown = CountDownState.StartGame;
                foreach (var plr in Players.Values)
                {
                    plr.SendInfo("Game starting in 15 seconds.");
                }
            }

            if (_countDown == CountDownState.StartGame && _time > 15000)
            {
                _countDown  = CountDownState.Done;
                _arenaState = ArenaState.Start;
                _time       = 0;
            }
        }
Esempio n. 6
0
    private void OfflineUpdate()
    {
        //フェード状態が待機状態なら
        if (FadeController.fadeActionState == FadeActionState.Stay)
        {
            //カウントダウンを減らす
            countDownTime -= Time.deltaTime;
        }
        //カウントダウン状態で処理変更
        switch (countDownState)
        {
        //数値表示
        case CountDownState.NUMBER:
            //小数点以下切り上げで表示
            countDownText.text = Mathf.Ceil(countDownTime).ToString("0");
            //時間が来たら
            if (countDownTime <= 0)
            {
                //1秒に設定
                countDownTime = 1.0f;
                //状態遷移
                countDownState = CountDownState.START;
            }
            break;

        //”Start”表示
        case CountDownState.START:
            //Start表示
            countDownText.text = "Start!";
            //時間が来たら
            if (countDownTime <= 0)
            {
                //非表示
                countDownText.enabled = false;
                //状態遷移
                countDownState = CountDownState.END;
            }
            break;
        }
    }
Esempio n. 7
0
    private void CreateStateMachine()
    {
        _stateMachine = new StateMachine();

        var menu       = new MenuState();
        var load       = new LoadLevelState(this);
        var countDown  = new CountDownState(this);
        var play       = new PlayState(this);
        var pause      = new PauseState();
        var finishRace = new FinishRace();
        var exit       = new ExitState();

        _stateMachine.SetState(menu);

        _stateMachine.AddTransition(menu, load, () => LoadLevelState.LevelToLoad != null);
        _stateMachine.AddTransition(menu, exit, () => ExitButton.Pressed);

        _stateMachine.AddTransition(load, countDown, load.FinishLoading);

        _stateMachine.AddTransition(countDown, play, () => RaceStarted);
        _stateMachine.AddTransition(countDown, pause, () => PlayerInput.Instance.Pause);

        _stateMachine.AddTransition(play, finishRace, () => RaceFinished);
        _stateMachine.AddTransition(play, pause, () => PlayerInput.Instance.Pause);

        _stateMachine.AddTransition(finishRace, menu, () => MenuButton.Pressed);
        _stateMachine.AddTransition(finishRace, load, () => LoadLevelState.LevelToLoad != null);
        _stateMachine.AddTransition(finishRace, exit, () => ExitButton.Pressed);

        _stateMachine.AddTransition(pause, countDown, () => PauseButton.Pressed && !RaceStarted);
        _stateMachine.AddTransition(pause, countDown, () => PlayerInput.Instance.Pause && !RaceStarted);
        _stateMachine.AddTransition(pause, play, () => PauseButton.Pressed && RaceStarted);
        _stateMachine.AddTransition(pause, play, () => PlayerInput.Instance.Pause && RaceStarted);
        _stateMachine.AddTransition(pause, load, () => LoadLevelState.LevelToLoad != null);
        _stateMachine.AddTransition(pause, menu, () => MenuButton.Pressed);
        _stateMachine.AddTransition(pause, exit, () => ExitButton.Pressed);
    }
Esempio n. 8
0
 public void startCountdown()
 {
     currentCountDownState        = CountDownState.PAUSE;
     timeSinceLastCountDownChange = 0;
 }
Esempio n. 9
0
        public StatusMenu(int teamSlot)
        {
            int menuWidth = 168;
            List <MenuChoice> flatChoices = new List <MenuChoice>();

            mapIndices = new List <int>();
            foreach (int status in ZoneManager.Instance.CurrentMap.Status.Keys)
            {
                MapStatus statusInstance = ZoneManager.Instance.CurrentMap.Status[status];
                if (!statusInstance.Hidden)
                {
                    Data.MapStatusData statusData = Data.DataManager.Instance.GetMapStatus(status);
                    mapIndices.Add(status);
                    MenuText          statusName = statusName = new MenuText(statusData.GetColoredName(), new Loc(2, 1));
                    MapCountDownState countDown  = statusInstance.StatusStates.GetWithDefault <MapCountDownState>();
                    if (countDown != null && countDown.Counter > 0)
                    {
                        flatChoices.Add(new MenuElementChoice(() => { }, true, statusName, new MenuText("[" + countDown.Counter + "]", new Loc(menuWidth - 8 * 4, 1), DirH.Right)));
                    }
                    else
                    {
                        flatChoices.Add(new MenuElementChoice(() => { }, true, statusName));
                    }
                }
            }
            indices = new List <int>();
            foreach (int status in DungeonScene.Instance.ActiveTeam.Players[teamSlot].StatusEffects.Keys)
            {
                if (Data.DataManager.Instance.GetStatus(status).MenuName)
                {
                    indices.Add(status);
                    MenuText   statusName = null;
                    StackState stack      = DungeonScene.Instance.ActiveTeam.Players[teamSlot].StatusEffects[status].StatusStates.GetWithDefault <StackState>();
                    if (stack != null)
                    {
                        statusName = new MenuText(Data.DataManager.Instance.GetStatus(status).GetColoredName() + (stack.Stack < 0 ? " " : " +") + stack.Stack, new Loc(2, 1));
                    }
                    else
                    {
                        statusName = new MenuText(Data.DataManager.Instance.GetStatus(status).GetColoredName(), new Loc(2, 1));
                    }

                    CountDownState countDown = DungeonScene.Instance.ActiveTeam.Players[teamSlot].StatusEffects[status].StatusStates.GetWithDefault <CountDownState>();
                    if (countDown != null && countDown.Counter > 0)
                    {
                        flatChoices.Add(new MenuElementChoice(() => { }, true, statusName, new MenuText("[" + countDown.Counter + "]", new Loc(menuWidth - 8 * 4, 1), DirH.Right)));
                    }
                    else
                    {
                        flatChoices.Add(new MenuElementChoice(() => { }, true, statusName));
                    }
                }
            }
            List <MenuChoice[]> statuses = SortIntoPages(flatChoices, SLOTS_PER_PAGE);

            summaryMenu = new SummaryMenu(Rect.FromPoints(new Loc(16, GraphicsManager.ScreenHeight - 8 - 4 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2),
                                                          new Loc(GraphicsManager.ScreenWidth - 16, GraphicsManager.ScreenHeight - 8)));

            Description = new DialogueText("", summaryMenu.Bounds.Start + new Loc(GraphicsManager.MenuBG.TileWidth * 2, GraphicsManager.MenuBG.TileHeight),
                                           summaryMenu.Bounds.End.X - GraphicsManager.MenuBG.TileWidth * 4 - summaryMenu.Bounds.X, LINE_SPACE, false);
            summaryMenu.Elements.Add(Description);

            Initialize(new Loc(16, 16), menuWidth, Text.FormatKey("MENU_TEAM_STATUS_TITLE"), statuses.ToArray(), 0, 0, SLOTS_PER_PAGE);
        }
Esempio n. 10
0
    private void ConstructStateMachine()
    {
        sm = new StateMachine <GameBool, GameTrigger>(verbose: false);

        GenerateLevelState generateLevelState = new GenerateLevelState(blackBoard);
        ReadGameFlowState  readGameFlowState  = new ReadGameFlowState(blackBoard);
        InstructionState   instructionState   = new InstructionState(blackBoard);
        LevelBeatenState   levelBeatenState   = new LevelBeatenState(blackBoard);
        CountDownState     countDownState     = new CountDownState(blackBoard);
        GameOverState      gameOverState      = new GameOverState(blackBoard);
        EndGameState       endGameState       = new EndGameState(blackBoard);
        LoadingState       loadingState       = new LoadingState(blackBoard);
        ConfigState        configState        = new ConfigState(blackBoard);
        DeathState         deathState         = new DeathState(blackBoard);
        MenuState          menuState          = new MenuState(blackBoard);
        PlayState          playState          = new PlayState(blackBoard);
        EmptyState         emptyState         = new EmptyState();

        sm.AddEntryState(emptyState);
        sm.AddState(generateLevelState);
        sm.AddState(readGameFlowState);
        sm.AddState(instructionState);
        sm.AddState(levelBeatenState);
        sm.AddState(countDownState);
        sm.AddState(gameOverState);
        sm.AddState(endGameState);
        sm.AddState(loadingState);
        sm.AddState(configState);
        sm.AddState(deathState);
        sm.AddState(menuState);
        sm.AddState(playState);

        // start by going to the loading
        sm.AddTransition(
            emptyState,
            loadingState,
            sm.CreateTriggerCondition(GameTrigger.NextState));

        // loading state always goes to the menu state
        sm.AddTransition(
            loadingState,
            menuState,
            sm.CreateTriggerCondition(GameTrigger.NextState));

        // menu to config
        sm.AddTransition(
            menuState,
            configState,
            sm.CreateTriggerCondition(GameTrigger.GotoConfig));

        // config back to menu
        sm.AddTransition(
            configState,
            menuState,
            sm.CreateTriggerCondition(GameTrigger.GotoMainMenu));

        // menu straight to game if the player has already seen the instructions
        sm.AddTransition(
            menuState,
            readGameFlowState,
            sm.CreateTriggerCondition(GameTrigger.GotoGame),
            sm.CreateBoolCondition(GameBool.HasSeenInstructions, true));

        // menu to instructions
        sm.AddTransition(
            menuState,
            instructionState,
            sm.CreateTriggerCondition(GameTrigger.GotoGame),
            sm.CreateBoolCondition(GameBool.HasSeenInstructions, false));

        // instruction to start game state
        sm.AddTransition(
            instructionState,
            readGameFlowState,
            sm.CreateTriggerCondition(GameTrigger.NextState));

        // reading game to config to set up variables
        sm.AddTransition(
            readGameFlowState,
            configState,
            sm.CreateTriggerCondition(GameTrigger.SetUpConfig));

        // config back to read game flow
        sm.AddTransition(
            configState,
            readGameFlowState,
            sm.CreateTriggerCondition(GameTrigger.NextState));

        // reading game to generating a level
        sm.AddTransition(
            readGameFlowState,
            generateLevelState,
            sm.CreateTriggerCondition(GameTrigger.GotoGame));

        // on generation fail, go back to main menu
        sm.AddTransition(
            generateLevelState,
            menuState,
            sm.CreateTriggerCondition(GameTrigger.GotoMainMenu));

        // generating game to countdown
        sm.AddTransition(
            generateLevelState,
            countDownState,
            sm.CreateTriggerCondition(GameTrigger.NextState));

        // countdown to play state
        sm.AddTransition(
            countDownState,
            playState,
            sm.CreateTriggerCondition(GameTrigger.NextState));

        // play state to death
        sm.AddTransition(
            playState,
            deathState,
            sm.CreateTriggerCondition(GameTrigger.PlayerDied));

        // death back to generating level
        sm.AddTransition(
            deathState,
            generateLevelState,
            sm.CreateTriggerCondition(GameTrigger.NextState));

        // death state back to main menu
        sm.AddTransition(
            deathState,
            menuState,
            sm.CreateTriggerCondition(GameTrigger.GotoMainMenu));

        // play to level beaten
        sm.AddTransition(
            playState,
            levelBeatenState,
            sm.CreateTriggerCondition(GameTrigger.PlayerWon));

        // level beating to replay
        sm.AddTransition(
            levelBeatenState,
            generateLevelState,
            sm.CreateTriggerCondition(GameTrigger.ReplayLevel));

        // level beaten back to read game flow to figure out what is next
        sm.AddTransition(
            levelBeatenState,
            readGameFlowState,
            sm.CreateTriggerCondition(GameTrigger.NextState));

        // level beaten back to the main menu
        sm.AddTransition(
            levelBeatenState,
            menuState,
            sm.CreateTriggerCondition(GameTrigger.GotoMainMenu));

        // game is over since read game flow state can't find anything else
        sm.AddTransition(
            readGameFlowState,
            gameOverState,
            sm.CreateTriggerCondition(GameTrigger.GotoGameOver));

        // in the game over state, the only option is to go back to the main menu
        sm.AddTransition(
            gameOverState,
            menuState,
            sm.CreateTriggerCondition(GameTrigger.GotoMainMenu));
    }
Esempio n. 11
0
        private void Countdown(RealmTime time)
        {
            if (_countDown == CountDownState.Notify60)
            {
                _countDown = CountDownState.Notify30;

                foreach (var w in Manager.Worlds.Values)
                {
                    foreach (var p in w.Players.Values)
                    {
                        if (p.Owner == this)
                        {
                            p.SendInfo("Game starting in 60 seconds.");
                        }
                        else
                        {
                            p.SendInfo($"<{p.Manager.Config.serverInfo.name}> Oryx's Arena closing in 1 minute. Head to the Nexus to join!");
                            if (p.Owner is Nexus || p.Owner is Vault)
                            {
                                p.Client.SendPacket(new GlobalNotification {
                                    Type = GlobalNotification.ADD_ARENA,
                                    Text = "{\"name\":\"Oryx Arena\",\"open\":true}"
                                });
                            }
                        }
                    }
                }
            }

            if (_countDown == CountDownState.Notify30 && _time > 30000)
            {
                _countDown = CountDownState.StartGame;

                foreach (var w in Manager.Worlds.Values)
                {
                    foreach (var p in w.Players.Values)
                    {
                        p.SendInfo(p.Owner == this
                            ? "Game starting in 30 seconds."
                            : $"<{p.Manager.Config.serverInfo.name}> Oryx's Arena closing in 30 seconds. Head to the Nexus to join!");
                    }
                }
            }

            if (_countDown == CountDownState.StartGame && _time > 60000)
            {
                _countDown   = CountDownState.Done;
                CurrentState = ArenaState.Start;
                _time        = 0;
                _difficulty  = Math.Min(Players.Count(p => p.Value.Level == 20), 15);

                Manager.Monitor.ClosePortal(DeathArena);

                foreach (var p in Manager.Worlds.Values.SelectMany(w => w.Players.Values).Where(p => p.Owner is Nexus || p.Owner is Vault))
                {
                    p.Client.SendPacket(new GlobalNotification {
                        Type = GlobalNotification.ADD_ARENA,
                        Text = "{\"name\":\"Oryx Arena\",\"open\":false}"
                    });
                }
            }
        }
Esempio n. 12
0
        private void Countdown(RealmTime time)
        {
            if (_countDown == CountDownState.Notify60)
            {
                _countDown = CountDownState.Notify30;

                foreach (var w in Manager.Worlds.Values)
                {
                    foreach (var p in w.Players.Values)
                    {
                        if (p.Owner == this)
                        {
                            p.SendInfo("Game starting in 60 seconds.");
                        }
                        else
                        {
                            p.SendError("<ANNOUNCEMENT> Oryx's Arena closing in 1 min. Type /oa to join.");
                            if (p.Owner is Nexus || p.Owner is Vault)
                            {
                                p.Client.SendPacket(new GlobalNotification
                                {
                                    Type = GlobalNotification.ADD_ARENA,
                                    Text = "{\"name\":\"Oryx Arena\",\"open\":true}"
                                });
                            }
                        }
                    }
                }
            }

            if (_countDown == CountDownState.Notify30 && _time > 30000)
            {
                _countDown = CountDownState.StartGame;

                foreach (var w in Manager.Worlds.Values)
                {
                    foreach (var p in w.Players.Values)
                    {
                        if (p.Owner == this)
                        {
                            p.SendInfo("Game starting in 30 seconds.");
                        }
                        else
                        {
                            p.SendError("<ANNOUNCEMENT> Oryx's Arena closing in 30 seconds. Type /oa to join.");
                        }
                    }
                }
            }

            if (_countDown == CountDownState.StartGame && _time > 60000)
            {
                _countDown       = CountDownState.Done;
                _arenaState      = ArenaState.Start;
                _time            = 0;
                _startingPlayers = Players.Count;
                _difficulty      = Players.Count(p => p.Value.Level >= 15);

                Manager.Monitor.ClosePortal(World.DeathArena);

                foreach (var p in Manager.Worlds.Values.SelectMany(w => w.Players.Values).Where(p => p.Owner is Nexus || p.Owner is Vault))
                {
                    p.Client.SendPacket(new GlobalNotification
                    {
                        Type = GlobalNotification.ADD_ARENA,
                        Text = "{\"name\":\"Oryx Arena\",\"open\":false}"
                    });
                }
            }
        }