void Update() { if (m_eState == StartGameState.State_StartPicAnim) { if (m_UISprte.fillAmount <= 0) { //播放我的游戏名称动画 m_eState = StartGameState.State_StartGameNameAnim; } else { //按照指定步长播放动画 m_UISprte.fillAmount -= (m_fPlaySpeed * Time.deltaTime); } } else if (m_eState == StartGameState.State_StartGameNameAnim) { //播放动画 m_uioffset.TrigMove(UITweener.Method.BounceIn); //延迟销毁 Invoke("DelayDestroyWidgetOffSet", m_uioffset.duration); //更改当前界面状态 m_eState = StartGameState.State_None; } else if (m_eState == StartGameState.State_FruitAnim) { m_eState = StartGameState.State_None; //播放水果动画 TweenPosition.Begin(m_vFruit, m_fFruitMoveDuration, m_vOrigPos).method = UITweener.Method.BounceIn; } }
private void DefineStateMachine() { stateMachine = new StateMachine(); //Define states startGame = new StartGameState(startScreen, startFartButton); var fart = new FartState(fartParticleSystem, farterAnimator, poopChance); var lidOn = new LidOnState(jar, lid); var lidClosed = new LidClosedState(); var poop = new PoopState(poopScreen); //Define transitions At(fart, startGame, FartStarted()); At(lidOn, fart, LidIsOn()); At(lidClosed, lidOn, LidClosed()); At(poop, fart, Pooped()); void At(IState to, IState from, Func <bool> condition) => stateMachine.AddTransition(@from, to, condition); //Define predicates as Func<bool> Func <bool> FartStarted() => () => startFartButton.fartPressed && Time.timeScale != 0; Func <bool> LidIsOn() => () => jar.GetComponentInChildren <LidTrigger>().lidOn; Func <bool> LidClosed() => () => lid.GetComponent <LidTwist>().jarClosed; Func <bool> Pooped() => () => pooped; }
void Awake() { startGameState = new StartGameState(this); startTurnState = new StartTurnState(this); playerTurnState = new PlayerTurnState(this); dealerTurnState = new DealerTurnState(this); endHandState = new EndHandState(this); endGameState = new EndGameState(this); }
public void Test1() { using (var test = new EPuzzleTestManager()) { test.AddFile(@"mondai\MondaiDocument.xml", TestResources.Mondai03); test.AddFile(@"help\HelpDocument.xml", TestResources.HelpDocumentXml); test.Initialize(); var window = test.Window; var userInfo = window.EPuzzleData.CurrentUserInfo; var mondaiDocument = window.EPuzzleData.CurrentMondaiDocument; Assert.Throws<ArgumentNullException>(() => { new StartGameState(window, null); }); /* Assert.Throws<ArgumentException>(() => { new StartGameState(window, new [] { "xxx", }); });*/ { var startGameState = new StartGameState(window, new string[0]); var tutorButton = startGameState.GetAllItems().Where(x => "tutorButton" == x.Name).FirstOrDefault(); Assert.Null(tutorButton); } window.State = new StartGameState(window, new [] { "mondaiDocument2", }); { var tutorButton = window.State.GetAllItems().Where(x => "tutorButton" == x.Name).FirstOrDefault(); Assert.NotNull(tutorButton); } var tsudukiKaraButton = window.State.GetAllItems().OfType<EigoTestButtonItem>().FirstOrDefault(x => "tsudukiKara" == x.Name); Assert.Null(tsudukiKaraButton); var daimon = (Daimon)mondaiDocument.GetItem("daimon2"); userInfo.SetLastDaimonInfo(daimon); window.State = new StartGameState(window); tsudukiKaraButton = window.State.GetAllItems().OfType<EigoTestButtonItem>().FirstOrDefault(x => "tsudukiKara" == x.Name); Assert.NotNull(tsudukiKaraButton); window.State.CurrentItem = tsudukiKaraButton; window.State.OnAction0(); test.AddTime(10d); window.Tick(); test.AddTime(10d); window.Tick(); Assert.IsInstanceOf<DaimonState>(window.State); Assert.AreSame(daimon, ((DaimonState)window.State).Daimon); } }
/// <summary> /// 处理开始游戏响应 /// </summary> /// <param name="isOk"></param> public void HandleStartGameResponse(bool isOk) { if (isOk) { //可以开始游戏-后续交给Update-更改标志位 _startGameState = StartGameState.Execute; } else { //不能开始游戏-后续交给Update-更改标志位 _startGameState = StartGameState.NoExecute; } }
void Update() { //游戏开场动画图片 if (m_eGameState == StartGameState.State_StartPicAnim /*游戏开场图片动画*/) { if (m_uiShownPic.fillAmount <= 0) { m_eGameState = StartGameState.State_StartGameNameAnim;/*游戏名称动画*/ } else { m_uiShownPic.fillAmount -= (m_fStartPicAnimSpeed * Time.deltaTime); } } //游戏名称动画. else if (m_eGameState == StartGameState.State_StartGameNameAnim /*游戏名称动画*/) { DelayPlayGameNameAnim(); m_eGameState = StartGameState.State_None; } }
//延迟销毁uiwidgetoffset。 void DelayDestroyWidgetOffSet() { Destroy(m_uioffset); m_eState = StartGameState.State_FruitAnim; }
public GameStateMachine() { CurrentState = new StartGameState(); }
void Update() { #region 创建房间对roomPanel的具体设置 if (_actionState == ActionState.Success) { //设置P1,P2的面板信息 User user = GameFacade.Instance.PlayerManager.currentLoginedUser; Score userScore = GameFacade.Instance.PlayerManager.currentUserScore; //Debug.Log("玩家" + user.Username + "战绩" + userScore.WinCount + "/" + userScore.TotalCount); SetP1Info(user.Username, userScore.TotalCount, userScore.WinCount); ResetP2Info(); //其作为房主-判断开始按钮的交互性-如果不可交互-则设置为可交互 if (startGameBtn.interactable == false) { startGameBtn.interactable = true; } Debug.Log("已完成对Text的设置"); _actionState = ActionState.StandBy; } else if (_actionState == ActionState.Failed) { //打开MsgPanel提示创建房间失败 MessagePanel msgPanel = GameFacade.Instance.UiManager.PushPanel(PanelType.Message) as MessagePanel; msgPanel.ShowTipsMsg("创建房间失败"); _actionState = ActionState.StandBy; } #endregion #region 玩家进入/退出房间对房主的RoomPanel进行更新 if (_updateRoomState == UpdateRoomState.HaveP2) { SetP2Info(_p2Username, _p2TotalCount, _p2WinCount); _updateRoomState = UpdateRoomState.StandBy; } else if (_updateRoomState == UpdateRoomState.NoP2) { ResetP2Info(); //对p2Name变量置空,解决p2加入后,又退出,p1在没有p2的情况下直接开始游戏的bug _p2Username = null; _updateRoomState = UpdateRoomState.StandBy; } #endregion #region 房间面板的关闭 if (_quitRoomState == QuitRoomState.Execute) { GameFacade.Instance.UiManager.PopPanel(); // _quitRoomState = QuitRoomState.StandBy; } #endregion #region 开始游戏控制 if (_startGameState == StartGameState.Execute) { //开始游戏TODO Debug.Log("开始游戏"); //打开GamePanel面板 GameFacade.Instance.UiManager.PushPanel(PanelType.Game); //创建所有角色 GameFacade.Instance.PlayerManager.SpawnAllRoles(); //切换相机状态 GameFacade.Instance.CameraManager.SwitchToFollowState(GameFacade.Instance.PlayerManager.CurrentControllRoleGo.transform); _startGameState = StartGameState.StandBy; } else if (_startGameState == StartGameState.NoExecute) { //不能开始游戏 Debug.Log("开始游戏失败"); MessagePanel msgPanel = GameFacade.Instance.UiManager.PushPanel(PanelType.Message) as MessagePanel; msgPanel.ShowTipsMsg("无法开始游戏"); _startGameState = StartGameState.StandBy; } #endregion }