//Muda o estado do jogo tomando tomando as decisoes necessarias void ChangeGameState(E_GameState state) { switch (state) { case E_GameState.Playing: snake.StartMoving(); ui.RemoveMsg(); ui.UpdateScores(score.CurrentScore, score.Highscore); break; case E_GameState.GameStart: ResetGame(); ui.DisplayMsg("Press a movement key to start the game.\n(use the arrow keys to move)"); ui.UpdateScores(score.CurrentScore, score.Highscore); break; case E_GameState.Death: snake.StopMoving(); ui.DisplayMsg("You Died!\n\nPress a movement key to try again.", Color.red); ui.UpdateScores(score.CurrentScore, score.Highscore); break; case E_GameState.Win: snake.StopMoving(); ui.DisplayMsg("You Won!\n\nPress a movement key to try again.", Color.green); ui.UpdateScores(score.CurrentScore, score.Highscore); break; } }
// Start is called before the first frame update void Start() { audioManagement = GameObject.Find("AudioSystem").GetComponent <AudioManagement>(); isScrolling = true; gameState = E_GameState.Play; }
//Verifica se a cobra bateu em algum lugar ou comeu uma fruta void SnakeMoved(Hashtable eventParam) { if (eventParam == null) { return; } if (eventParam.ContainsKey("Pos")) { board.UpdateSnakeBodyMatrix(); switch (board.CheckIfHitObject((Vector2Int)eventParam["Pos"])) { case Board.E_HitObject.Food: EventManager.BroadcastEvent("SnakeGrow", null); score.CurrentScore++; ui.UpdateScores(score.CurrentScore, score.Highscore); snake.speed = difficulty.GetDifficultyValue(score.CurrentScore); FooodEaten(); break; case Board.E_HitObject.SnakeBody: gameState = E_GameState.Death; break; case Board.E_HitObject.Wall: gameState = E_GameState.Death; break; } } }
/// <summary> /// Processes the game in its current state /// </summary> public void Iterate() { switch (m_State) { case E_GameState.BEGINNING: m_State = Beginning(); break; case E_GameState.WAITING_TO_START: m_State = WaitingToStart(); break; case E_GameState.PLAYING: m_State = Playing(); break; case E_GameState.LEVEL_FINISHED: m_State = LevelFinished(); break; case E_GameState.END: End(); break; } }
public void StartTutorial() { _GameType = E_GameType.Tutorial; _GameState = E_GameState.Tutorial; CurrentLevel = "tutorial"; StartCoroutine(LoadScene(CurrentLevel, false)); }
/// <summary> /// 切换到结束场景 /// </summary> public void onEnding() { gameState = E_GameState.GS_ENDING; for (int i = 0; i < BeforeEnterBattleObjs.Count; i++) { FrameSyncManager.RemovePlayer(BeforeEnterBattleObjs[i].id); } SceneManager.LoadScene(SceneComNames.Ending, LoadSceneMode.Single); Debug.Log("Ending_Scene start."); }
/// <summary> /// 返回大厅 /// </summary> public void onReturnHalls() { Debug.Log("onReturnHalls_GameRoom ."); gameState = E_GameState.GS_WAIT_FOR_BEGINE; resetMatchingData(); BeforeEnterBattleObjs.Clear(); Debug.Log("resetAllServerDataresetAllServerDataresetAllServerData"); SceneManager.LoadScene(SceneComNames.GameRoom, LoadSceneMode.Single); Debug.Log("GameRoom_Scene start."); }
public void togglePause() { if (Time.timeScale == 0f) { gameState = E_GameState.Play; } else { gameState = E_GameState.Pause; } }
public List <KBEngine.Entity> BeforeEnterBattleObjs = new List <KBEngine.Entity>(); //保存未跳转界面前进入的entity private void Awake() { DontDestroyOnLoad(transform.gameObject); SceneManager.LoadScene(SceneComNames.Login); Instance = this; installEvents(); gameState = E_GameState.GS_WAIT_FOR_BEGINE; ReadBulletPropertyByExcel(); ReadWeaponPropertyByExecl(); }
public void StartTutorial() { ClearInstances(); PlayerPrefs.SetInt("firstTime", 1); _GameType = E_GameType.Tutorial; _GameState = E_GameState.Tutorial; CurrentLevel = "tutorial"; Application.LoadLevel(CurrentLevel); }
//重置数据 public void resetAllServerData() { gameState = E_GameState.GS_WAIT_FOR_BEGINE; AvatarId = -1; //用户账号下的角色列表信息 SelectRoteId = 0; AvatarBaseInfos.Clear(); //重置匹配信息 resetMatchingData(); }
public void removeLive() { if (liveHolder.transform.childCount > 0) { GameObject lastChild = liveHolder.transform.GetChild(liveHolder.transform.childCount - 1).gameObject; Destroy(lastChild); } if (liveHolder.transform.childCount == 1) { gameState = E_GameState.Defeat; } }
private void OnGameEnd(E_GameState result) { if (result == E_GameState.Lose) { this.gameObject.SetActive(true); txt.text = "YOU\nLOSE"; } else if (result == E_GameState.Win) { this.gameObject.SetActive(true); txt.text = "YOU\nWIN"; } }
//Reposiciona a nova comida e verifica se vencemos o jogo public void FooodEaten() { Vector2Int newFoodPos = board.GetEmptyPosition(); if (newFoodPos != Vector2Int.zero) { food.PlaceFood(newFoodPos); } else { gameState = E_GameState.Win; } }
//Recebe a mensagem se uma tecla foi pressionada void MovementKeyPressed(Hashtable eventParam) { if (eventParam == null) { return; } if (eventParam.ContainsKey("Code")) { switch (gameState) { case E_GameState.GameStart: gameState = E_GameState.Playing; break; case E_GameState.Win: gameState = E_GameState.GameStart; break; case E_GameState.Death: gameState = E_GameState.GameStart; break; } } }
// Start is called before the first frame update void Start() { gameState = E_GameState.GameStart; }
/// <summary> /// 切换到战斗场景 /// </summary> public void onReadyForBattle() { gameState = E_GameState.GS_RUNING; SceneManager.LoadScene(SceneComNames.Battle, LoadSceneMode.Single); Debug.Log("Battle_Scene start."); }
public GameStateEvent(E_GameState state) : base("GameState") { gameState = state; }
public void StartTutorial() { _GameType = E_GameType.Tutorial; _GameState = E_GameState.Tutorial; CurrentLevel = "tutorial"; StartCoroutine(LoadScene(CurrentLevel, false)); }
private void OnGameEnded(E_GameState obj) { EnableInput = false; }
/// <summary> /// 设置游戏状态 /// </summary> /// <param name="state"></param> public void RunState(E_GameState state) { switch (state) { case E_GameState.Start: ioo.playerManager.Reset(); break; case E_GameState.SelectMap: EventDispatcher.TriggerEvent(EventDefine.Event_Character_To_Map); ioo.TriggerListener(EventLuaDefine.Character_Select_End); break; case E_GameState.Play: if (mState == E_GameState.Water) { if (mCPAIsPlaying) { ioo.cameraManager.PlayCPA(); } OnStageSysIsPause(false); ioo.characterSystem.Active(); ioo.TriggerListener(EventLuaDefine.Event_Fill_Water, false); break; } if (mState == E_GameState.Hold) { ioo.TriggerListener(EventLuaDefine.Event_Hold_Player, false); break; } ioo.cameraManager.InitSceneCamera(); break; case E_GameState.Water: mWaterTime = 30; mWaterValue = 0; OnStageSysIsPause(true); ioo.characterSystem.Pause(); mPressCount = new int[Define.MAX_PLAYER_NUMBER]; ioo.TriggerListener(EventLuaDefine.Event_Fill_Water, true); if (ioo.cameraManager.IsCPAPlaying()) { mCPAIsPlaying = true; ioo.cameraManager.PauseCPA(); } break; case E_GameState.Summary: //ioo.cameraManager.InitSceneCamera(); //ioo.cameraManager.PauseRoll = true; //ioo.cameraManager.PauseMove = true; break; case E_GameState.Hold: mHoldTime = 8; mHoldValue = 0; mPressCount = new int[Define.MAX_PLAYER_NUMBER]; ioo.TriggerListener(EventLuaDefine.Event_Hold_Player, true); break; } mState = state; }