/// <summary> /// 改变游戏状态 /// </summary> /// <param name="state"></param> public void ChangeGameState(GAME_STATE state) { if (state == GAME_STATE.START) { // UI界面状态切换 m_UiStart.SetActive(true); m_UiGame.SetActive(false); m_UiEnd.SetActive(false); // 背景音乐状态切换 m_AudioSourceStart.Stop(); // 武器状态切换 m_Weapon.ChangeMoveState(false); // 飞盘定时器状态切换 m_FeiPanManager.StopCreateFeiPan(); // 游戏状态切换 m_GameState = GAME_STATE.START; // 开始时间切换 m_StartTime = 0; // 分数值切换 SetScore(0); } else if (state == GAME_STATE.PLAYING) { // UI界面状态切换 m_UiStart.SetActive(false); m_UiGame.SetActive(true); m_UiEnd.SetActive(false); // 背景音乐状态切换 m_AudioSourceStart.Play(); // 武器状态切换 m_Weapon.ChangeMoveState(true); // 飞盘定时器状态切换 m_FeiPanManager.StartCreateFeiPan(); // 游戏状态切换 m_GameState = GAME_STATE.PLAYING; // 开始时间切换 m_StartTime = Time.time; // 启动游戏状态切换 Invoke("GameEnd", TOTAL_TIME); // 分数值切换 SetScore(0); } else if (state == GAME_STATE.END) { // UI界面状态切换 m_UiStart.SetActive(false); m_UiGame.SetActive(false); m_UiEnd.SetActive(true); // 背景音乐状态切换 m_AudioSourceStart.Stop(); // 武器状态切换 m_Weapon.ChangeMoveState(false); // 飞盘定时器状态切换 m_FeiPanManager.StopCreateFeiPan(); // 游戏状态切换 m_GameState = GAME_STATE.END; // 开始时间切换 m_StartTime = 0; } }
public void GameOver(bool isOver, bool isClear) { gameState = GAME_STATE.GAME_OVER; if (isOver) { if (selectedPanel != null) { selectedPanel.SetActive(false); } selectedPanel = gameClearPanel; selectedPanel.SetActive(true); this.isClear = isClear; GameObject.Find("Result").GetComponent <Text> ().text = "CLEAR : " + isClear + "\n" + "MODE : " + mod + "\n" + "MAXCombo : " + maxCombo + "\n" + "SCORE : " + currentScore; } else { if (selectedPanel != null) { selectedPanel.SetActive(false); } selectedPanel = gameOverPanel; selectedPanel.SetActive(true); if (isClear) { GameObject.Find("Game").GetComponent <Image>().sprite = gameClear; btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(() => GameOverClear(true)); } } }
// Use this for initialization void Start() { currentyGameState = GAME_STATE.Playing; playerScore = 0f; playerMultipler = 1; playerPoints = 100f; // Default Amount progressionTimer = Time.timeSinceLevelLoad; progressionIncrementer = 0.8f; progressionCountdown = 10f; bossTimer = Time.timeSinceLevelLoad; bossCountdown = 120f; currentSpawn = SPAWN_NPC.Jeep; scoreDisplay = GameObject.Find("Text_ScoreDisplay").GetComponent <Text>(); multiDisplay = GameObject.Find("Text_MultiplerDisplay").GetComponent <Text>(); healthDisplay = GameObject.Find("Text_HealthDisplay").GetComponent <Text>(); audio = GetComponents <AudioSource>(); playerControl = FindObjectOfType <PlayerController>(); playerPrefs = FindObjectOfType <PlayerPrefsControlScript>(); minHealth = playerPrefs.GetMinimumHealth(); playerHealth += minHealth; upgradedDamage = playerPrefs.GetFirePower(); playerDamage += upgradedDamage; minMultiplier = playerPrefs.GetMinimumMultipler(); playerMultipler += minMultiplier; UpdateHUD(); }
IEnumerator ReStart() { yield return(new WaitForSeconds(2f)); // 뒤로가기 랑 모드 보여 주기 _GameState = GAME_STATE.GAME_READY; //배경화면 다시 정상처리 _BackGround.GetComponent <Image>().sprite = _BackGroundImg[0]; //버튼 바꿔주기 _StartButton.GetComponent <Image>().sprite = _StartImg[0]; //글자 없애주기 _StartButton.transform.GetChild(0).GetComponent <Text>().text = ""; // 플레이어 버튼 다시 켜주기 for (_iPlyaerCnt = 0; _iPlyaerCnt < _iPlayer; _iPlyaerCnt++) { _Players.transform.GetChild(_iPlyaerCnt).gameObject.GetComponent <Image>().sprite = _TouchImg[0]; } _Back.SetActive(true); _ModeBtn.SetActive(true); }
public void OnClickPlayer() // 플레이어 터치버튼 눌렀을 경우 { if (EventSystem.current.currentSelectedGameObject.GetComponent <Image>() != _TouchImg[1] && _GameState == GAME_STATE.GAME_PLAY) // 플레이어 온 일때만 하여라. { //누르면 플레이어 버튼 off 됨 EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite = _TouchImg[1]; _iPlyaerCnt--; if (_iPlyaerCnt == 0) // 벌칙 걸렸을때. { _GameState = GAME_STATE.GAME_IDLE; //게임 종료 _StartButton.transform.GetChild(0).GetComponent <Text>().text = "벌칙 당첨!"; StartCoroutine("ReStart"); StartCoroutine("Lose"); _BackGround.GetComponent <Image>().sprite = _BackGroundImg[1]; } else // 일반적으로 눌렀을 경우 { if (_gameMode == MODE.MODE_HARD) { RandomProblem(); } } } }
// Use this for initialization void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } print("hello"); gameState = GAME_STATE.IN_GAME; if (!MenuManager.SELECTED_MODE) { StartCoroutine("GenerateWave"); } else { StartCoroutine("GenerateWaveGMS"); } mod = (MenuManager.SELECTED_MODE)?"GMS":"NORMAL"; scoreText = GameObject.Find("ComboScore").GetComponent <Text> (); waveText = waveAlertText.GetComponent <Text> (); ultGaugeFrame = GameObject.Find("UltGaugeFrame").GetComponent <Animator>(); ultGauge = GameObject.Find("UltGauge").GetComponent <Image>(); }
//PRIVATE FUNCTIONS // Use this for initialization void Start() { current_level_ = 1; max_score_ = 0; max_asteroids_ = 5; GameObject score_game_object = new GameObject("ScoreText"); current_score_text_ = score_game_object.AddComponent <GUIText>(); current_score_text_.gameObject.transform.position = new Vector3(0.1f, 0.95f, 0.0f); current_score_text_.text = "0"; GameObject info_text_object = new GameObject("InfoText"); info_text_ = info_text_object.AddComponent <GUIText>(); info_text_.gameObject.transform.position = new Vector3(0.5f, 0.9f, 0.0f); info_text_.GetComponent <GUIText>().alignment = TextAlignment.Center; info_text_.GetComponent <GUIText>().anchor = TextAnchor.MiddleCenter; GameObject max_score_object = new GameObject("MaxScore"); max_score_text_ = max_score_object.AddComponent <GUIText>(); max_score_text_.gameObject.transform.position = new Vector3(0.5f, 0.95f, 0.0f); max_score_text_.GetComponent <GUIText>().alignment = TextAlignment.Center; max_score_text_.GetComponent <GUIText>().anchor = TextAnchor.MiddleCenter; max_score_text_.text = "0"; current_state_ = GAME_STATE.MAIN_MENU; hud_player_lives_ = new List <GameObject>(); music_player_instance_ = (GameObject)Instantiate(music_player_prefab_); high_scores_initials_ = new List <string>(); high_scores_ = new List <int>(); }
// Use this for initialization void Start () { game_state = GAME_STATE.IDLE; startTimer = false; }
// Use this for initialization void Start() { timer = GameObject.FindGameObjectWithTag("Timer"); timer.SetActive(false); game = new GameController(); board = (IBoardController)GameObject.FindGameObjectWithTag("Board").GetComponentInChildren(typeof(IBoardController)); board.DisplayMessage("HELLO", new Color(1, 1, 0)); //board.UpdateDescription("Hello", new Color(1, 1, 0)); //board.AnimateDescription(true); studyingButton = GameObject.FindGameObjectWithTag("StudyingButton"); freestyleButton = GameObject.FindGameObjectWithTag("FreestyleButton"); exitButton = GameObject.FindGameObjectWithTag("ExitButton"); keyboardButtons = GameObject.FindGameObjectWithTag("Keyboard"); keyboard = (Keyboard)keyboardButtons.GetComponent(typeof(Keyboard)); studyingButton.SetActive(true); freestyleButton.SetActive(true); exitButton.SetActive(false); keyboardButtons.SetActive(false); scoreboard = (scoreboard)GameObject.FindGameObjectWithTag("Scoreboard").GetComponentInChildren(typeof(scoreboard)); currentState = GAME_STATE.START_STATE; finished = false; }
public void playerGoal( ) { if (state != GAME_STATE.GOAL) { state = GAME_STATE.GOAL; } }
void Start() { //For clearing the score and taps uncomment it!! PlayerPrefs.SetInt("score", 0); PlayerPrefs.SetInt("taps", 0); if (instance) { Destroy(gameObject); Debug.LogError("Already initialised"); } else { GameController.instance = this; } if (PlayerPrefs.GetInt("score", 0) < 0) { PlayerPrefs.SetInt("score", 0); } if (PlayerPrefs.GetInt("taps", 0) < 0) { PlayerPrefs.SetInt("taps", 5); } gameMainScore = PlayerPrefs.GetInt("score"); gameMainTaps = PlayerPrefs.GetInt("taps"); currentState = GAME_STATE.GAME_WELCOME; previousState = GAME_STATE.GAME_STATE_MAX; }
void OnPlayerDestroyed() { if (player_ship_intance_ != null) { Destroy(player_ship_intance_); if (hud_player_lives_.Count > 0) { Destroy(hud_player_lives_[num_lives_ - 1]); hud_player_lives_.RemoveAt(num_lives_ - 1); num_lives_ -= 1; if (num_lives_ > 0) { current_state_ = GAME_STATE.PLAYER_DESTROYED; } else { current_state_ = GAME_STATE.GAME_OVER; } } respawn_timer_ = 0.0f; } music_player_instance_.GetComponent <MusicPlayer>().Stop(); respawn_timer_ += Time.deltaTime; if (respawn_timer_ > seconds_to_respawn_ && IsSafeForRespawn()) { SpawnPlayer(); music_player_instance_.GetComponent <MusicPlayer>().Reset(); music_player_instance_.GetComponent <MusicPlayer>().Play(); current_state_ = GAME_STATE.PLAYING; } }
void Update() { if (!mBallSnapped && mGameState == GAME_STATE.PRESNAP) { if (Input.GetKeyDown(KeyCode.Space)) { GE_BALL_SNAP.Raise(null); mBallSnapped = true; mGameState = GAME_STATE.RUNNING; } } rPlayState.text = "STATE: " + mGameState; SetScoreText(); SetDownAndDisText(); SetTimeAndQuarterText(); // testing scores if (Input.GetKeyDown(KeyCode.U)) { GE_HOME_SCORE.Raise(null); } // make the timer count down. if (mGameState == GAME_STATE.RUNNING) { mQuarTime.mTime -= Time.deltaTime; } }
bool CheckForRoundEnd() { if (m_NumberOfPlayersAlive == 1) { //Look for the player still alive. for (int playerAliveIndex = 0; playerAliveIndex < (int)PLAYER.PLAYER_MAX; ++playerAliveIndex) { if (PlayerActiveInMatch[playerAliveIndex]) { if (PlayerIsAlive[playerAliveIndex]) { //Increase his score. ++PlayerScore[playerAliveIndex]; //Change the state to round over. m_State = GAME_STATE.ROUND_OVER; if (!CheckForMatchEnd()) { UIManager.GlobalUIManager.SetWinningPlayer((PLAYER)playerAliveIndex); StartCoroutine(RestartRound()); } return(true); } } } } return(false); }
void init() { CreateStartLevel(); moveToSpawnTime = 0; state = GAME_STATE.MOVE_TO_SPAWN; _noJump.ResetLevel(); }
private void LateUpdate() { if (state != GAME_STATE.PAUSED) { if (Input.GetKeyUp(KeyCode.Escape)) { Pause(true); UIManager.instance.SetActive("Pause", true); } } else { if (Input.GetKeyUp(KeyCode.Escape)) { Pause(false); UIManager.instance.SetActive("Pause", false); UIManager.instance.SetActive("Help", false); } } OnStageChanged(); lateState = state; lateStage = stage; }
public void playerDead( ) { if (state != GAME_STATE.DEAD) { state = GAME_STATE.DEAD; } }
public void enableDifficultyPanel() { currentGameState = GAME_STATE.DIFFICULTY; menuPanel.SetActive(false); difficultyPanel.SetActive(true); }
public void disablePausedPanel() { currentGameState = GAME_STATE.GAMEPLAY; pausedPanel.SetActive(false); Time.timeScale = 1; }
public void enablePausedPanel() { currentGameState = GAME_STATE.PAUSED; pausedPanel.SetActive(true); Time.timeScale = 0; }
public void Menu() { _state = GAME_STATE.MENU; _paused = true; ActionMouse(true); EventManagerCustom.InitGameMehod(); }
// Update is called once per frame void Update() { if (systemRecord.shardNum == 7) { states = GAME_STATE.INTERACT; } }
private void GameOver(GAME_STATE result) { // Deactivate Ost SoundController.Instance.StopOst(); //Deactivate Pause Canvas if (pauseCanvas) { pauseCanvas.gameObject.SetActive(false); } // Discriminate Result if (result == GAME_STATE.VICTORY) { print("PEGOU A GALINHA!"); SoundController.Instance.SetSfx(victoryClip); ChickenEndgame.playerPoints = scoreManager.GetScore(); StartCoroutine(EndDelay()); } else { print("FUGIU!"); SoundController.Instance.SetSfx(defeatClip); StartCoroutine(ResetDelay()); } }
private void startGame(int timeout) { stckStart.Visibility = (gameState == GAME_STATE.RUNNING) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; txtCount.Visibility = (gameState == GAME_STATE.RUNNING) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible; if (timeout > 1) //starttimer if is timed game { //start timer timer = new DispatcherTimer(); int counter = getTimeout(); timer.Tick += delegate(object s, EventArgs args) { counter--; txtTimer.Text = counter.ToString(); if (counter == 0) { timer.Stop(); stopGame(txtCount.Text); } }; timer.Interval = new TimeSpan(0, 0, 1); timer.Start(); } else { startTime = DateTime.Now; isTimed = false; } gameState = GAME_STATE.RUNNING; }
void GameEnd() { //処理 currentState = GAME_STATE.End; var(whiteCount, blockConnt) = stoneCount.CountStones(); gameWinner.WinnerJudgment(whiteCount, blockConnt); }
// Update is called once per frame void Update() { GAME_STATE gs = GamePlayManager.Instance.gameState; if (gs == GAME_STATE.GAME_STATE_READY) { MoveY(); } else if (gs == GAME_STATE.GAME_STATE_PLAY) { if (Input.GetButtonDown(GameSetting.Instance.inputJump)) { Jump(); } } else if (gs == GAME_STATE.GAME_STATE_OVER) { // 速度为0后进入结算得分状态 Vector3 vel = GetComponent <Rigidbody2D>().velocity; if (vel.x == 0 && vel.y == 0) { GamePlayManager.Instance.SetGameState(GAME_STATE.GAME_STATE_SCORE); } } }
public void SetGameState(GAME_STATE newState) { switch (newState) { case GAME_STATE.HOME: homePanel.SetActive(true); gameOverPanel.SetActive(false); //gamePanel.SetActive(false); break; case GAME_STATE.READY: homePanel.SetActive(false); gameOverPanel.SetActive(false); gamePanel.SetActive(true); break; case GAME_STATE.PLAYING: break; case GAME_STATE.GAME_OVER: homePanel.SetActive(false); gameOverPanel.SetActive(true); sudoku.fillValues(); //set all labels break; } }
public void StartGame() { Debug.Log("Game Started"); currentState = GAME_STATE.RUNNING; // TODO, Fill me in based on the game! bestTime = float.MaxValue; for (int iCar = 0; iCar < cars.Count; ++iCar) { int playerIndex = iCar + 1; cars[iCar].CarName = "Player " + (playerIndex).ToString(); if (iCar < carColors.Count) { cars[iCar].CarColor = carColors[iCar]; } // For Rewired input cars[iCar].PlayerID = iCar; cars[iCar].EnableCar(); } // Setup UI UIManager.SetupLapTimers(); UIManager.SetupPowerupUI(); roadManager.Activate(); }
void on_game_start(CPacket msg) { this.players = new List <CPlayer>(); byte count = msg.pop_byte(); for (byte i = 0; i < count; ++i) { byte player_index = msg.pop_byte(); GameObject obj = new GameObject(string.Format("player{0}", i)); CPlayer player = obj.AddComponent <CPlayer>(); player.initialize(player_index); player.clear(); byte virus_count = msg.pop_byte(); for (byte index = 0; index < virus_count; ++index) { short position = msg.pop_int16(); player.add(position); } this.players.Add(player); } this.current_player_index = msg.pop_byte(); reset(); this.game_state = GAME_STATE.STARTED; }
void Awake() { this.table_board = new List <short>(); this.available_attack_cells = new List <short>(); this.graycell = Resources.Load("images/graycell") as Texture; this.focus_cell = Resources.Load("images/border") as Texture; this.blank_image = Resources.Load("images/blank") as Texture; this.game_board = Resources.Load("images/gameboard") as Texture; this.background = Resources.Load("images/gameboard_bg") as Texture; this.img_players = new List <Texture>(); this.img_players.Add(Resources.Load("images/red") as Texture); this.img_players.Add(Resources.Load("images/blue") as Texture); this.win_img = Resources.Load("images/win") as Texture; this.lose_img = Resources.Load("images/lose") as Texture; this.draw_img = Resources.Load("images/draw") as Texture; this.gray_transparent = Resources.Load("images/gray_transparent") as Texture; this.board = new List <short>(); this.network_manager = GameObject.Find("NetworkManager").GetComponent <CNetworkManager>(); this.game_state = GAME_STATE.READY; this.main_title = GameObject.Find("MainTitle").GetComponent <CMainTitle>(); this.score_images = gameObject.AddComponent <CImageNumber>(); this.win_player_index = byte.MaxValue; this.draw = this.on_gui_playing; this.battle_info = gameObject.AddComponent <CBattleInfoPanel>(); }
public void ChangeGameState(GAME_STATE state) { //Eliminar de la lista de componentes el GameComponent actual //Insertar en la lista de componentes el GameComponent asociado al estado de la entrada //Modificar el estado actual currentGameState = state; }
public cEngine(GraphicsDeviceManager gd, ContentManager cm) { _instance = this; _graphics = gd; _contentManager = cm; _postProcessor = new cPostProcessor(gd.GraphicsDevice, cm); _gameState = GAME_STATE.NOTHING; _batch = new cCustomSpriteBatch(gd.GraphicsDevice); _HUD = new cHUD(); }
public CarStopper(Minigame game) { state = GAME_STATE.Intro; minigame = game; introTitle = minigame.getTitle(); introDescription = minigame.getDescription(); setupLabels(); mainCanvas.Children.Add(introTitleLabel); mainCanvas.Children.Add(introDescriptionLabel); mainCanvas.Children.Add(instructionLabel); mainCanvas.Children.Add(exitLabel); this.transitionTimer = new System.Windows.Threading.DispatcherTimer(); this.transitionTimer.Tick += moveToNextState; this.transitionTimer.Interval = TimeSpan.FromMilliseconds(2000); this.transitionTimer.Start(); this.fadeTimer = new System.Windows.Threading.DispatcherTimer(); this.fadeTimer.Tick += fadeToNextState; this.fadeTimer.Interval = TimeSpan.FromMilliseconds(40); this.fadeTimer.IsEnabled = false; this.carTimer = new System.Windows.Threading.DispatcherTimer(); this.carTimer.Tick += moveCar; this.carTimer.Interval = TimeSpan.FromMilliseconds(20); rightHandCursor = new System.Windows.Controls.Image(); rightHandCursor.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.HandCursor); rightHandCursor.Width = 100; leftHandCursor = new System.Windows.Controls.Image(); System.Drawing.Bitmap leftHandBitmap = ShoopDoup.Properties.Resources.HandCursor; leftHandBitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); leftHandCursor.Source = this.toBitmapImage(leftHandBitmap); leftHandCursor.Width = 100; rightHandCursor.Opacity = 0; leftHandCursor.Opacity = 0; carBitmaps = new List<Bitmap>(); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperBus); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperCar); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperTruck); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperMotorcycle); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperSUV); mainCanvas.Children.Add(rightHandCursor); mainCanvas.Children.Add(leftHandCursor); }
IEnumerator Start() { MenuManager.manager.onPlayerButtonClicked += PlayerButtonClicked; MenuManager.manager.onPlayButtonClicked += PlayButtonClicked; MenuManager.manager.onPauseButtonClicked += PauseButtonClicked; MenuManager.manager.onResumeButtonClicked += ResumeButtonClicked; MenuManager.manager.onNewGameButtonClicked += NewGameButtonClicked; MenuManager.manager.onMainMenuButtonClicked += MainMenuButtonClicked; _state = GAME_STATE.menu; IsReady = true; yield break; }
public void Load( int iMapID, eLoadType type) { Debug.Log ("SceneLoad .Load " + iMapID); curLoadType = type; m_eOldGameState = AsGameMain.s_gameState; AsGameMain.s_gameState = GAME_STATE.STATE_LOADING; if(PlayerPrefs.HasKey( AsNpcStore.SaveKindKey)) PlayerPrefs.DeleteKey( AsNpcStore.SaveKindKey); if( true == AssetbundleManager.Instance.useAssetbundle) AssetbundleManager.Instance.DownloadAssets_Group( _GetPatchGroup( iMapID)); m_nMapID = iMapID; m_eType = type; StartCoroutine( "MapLoadCheck"); }
public WhackAMoleController(Minigame game) { state = GAME_STATE.Intro; minigame = game; introTitle = minigame.getTitle(); introDescription = minigame.getDescription(); setupLabels(); mainCanvas.Children.Add(introTitleLabel); mainCanvas.Children.Add(introDescriptionLabel); mainCanvas.Children.Add(instructionLabel); this.transitionTimer = new System.Windows.Threading.DispatcherTimer(); this.transitionTimer.Tick += moveToNextState; this.transitionTimer.Interval = TimeSpan.FromMilliseconds(2000); this.transitionTimer.Start(); this.fadeTimer = new System.Windows.Threading.DispatcherTimer(); this.fadeTimer.Tick += fadeToNextState; this.fadeTimer.Interval = TimeSpan.FromMilliseconds(40); this.fadeTimer.IsEnabled = false; this.popupTimer = new System.Windows.Threading.DispatcherTimer(); this.popupTimer.Tick += changePopup; this.popupTimer.Interval = TimeSpan.FromMilliseconds(2500); rightHandCursor = new System.Windows.Controls.Image(); rightHandCursor.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.HandCursor); rightHandCursor.Width = 100; leftHandCursor = new System.Windows.Controls.Image(); System.Drawing.Bitmap leftHandBitmap = ShoopDoup.Properties.Resources.HandCursor; leftHandBitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); leftHandCursor.Source = this.toBitmapImage(leftHandBitmap); leftHandCursor.Width = 100; rightHandCursor.Opacity = 0; leftHandCursor.Opacity = 0; mainCanvas.Children.Add(rightHandCursor); mainCanvas.Children.Add(leftHandCursor); }
void OnLevelWasLoaded(int level) { switch (level) { case 0: currentState = GAME_STATE.MENU; DisplayStartMenu(); break; case 1: currentState = GAME_STATE.INGAME; StartCoroutine(DisplayDay()); currentDay++; break; case 2: currentState = GAME_STATE.SUCCESS; break; case 3: currentState = GAME_STATE.FAIL; StartCoroutine(ResetFail()); break; } }
void OnGUI() { if (GUI.Button (new Rect (100, 100, 100, 100), "avoid")) { if(gameState == GAME_STATE.AVOID){ btnAvoid = true; }else{ gameState = GAME_STATE.GAME_OVER; } } string strToShow; if (gameState == GAME_STATE.GAME_OVER) { strToShow = "GAME_OVER"; } else { strToShow = "timer_game: " + timer_game + "\n"; strToShow += "timer_avoid: " + timer_avoid + "\n"; strToShow += "timer_judgement: " + timer_judgement + "\n"; strToShow += "next_time: " + next_time + "\n"; strToShow += "avoid_interval: " + avoid_interval + "\n"; strToShow += "time_to_avoid: " + time_to_avoid + "\n"; } GUI.TextArea (new Rect (0, 0, 200, 100), strToShow); }
void PauseButtonClicked() { _state = GAME_STATE.pause; //CustomTimer.manager.StopTimer(); if (onGamePause != null) onGamePause(); }
//-------------------------------------------------------------------------------------------------------------------- //Name: //Description: //Parameters: //Returns: //-------------------------------------------------------------------------------------------------------------------- private void checkSceneOutroDone() { //Advance players states once everyone has played the outro //Player is advanced to SceneChangeRdy state by the NetPlayer script once fading out is done if (!arePlayerStatesSynced (NetPlayer.PLAYER_STATE.SceneChangeReady)) return; foreach(GameObject p in players) p.GetComponent<NetPlayer>().setPlayerState(NetPlayer.PLAYER_STATE.LoadingScene); GameState = GAME_STATE.SceneChange; //If we'er in the main scene, just start races, otherwise we need to update race counter and such if(SceneManager.GetActiveScene().name == "_Main") ServerChangeScene (circuitScenes[iRaceCounter]); else{ //Move to next scene iRaceCounter++; if (iRaceCounter >= circuitScenes.Length) returnToMain (); else{ GameState = GAME_STATE.SceneChange; ServerChangeScene (circuitScenes [iRaceCounter]); } } }
private void OnCapitalShipExplodedRPC() { DebugConsole.Log( "Capital ship has exploded, moving into post-game" ); this.gameState = GAME_STATE.POST_GAME; GamePlayer myPlayer = GamePlayerManager.instance.myPlayer; if ( myPlayer.fighter != null ) { myPlayer.fighter.fighterCamera.gameObject.SetActive( false ); } else if ( myPlayer.capitalShip != null ) { //TODO: Disable capital camera } }
//-------------------------------------------------------------------------------------------------------------------- //Name: //Description: //Parameters: //Returns: //-------------------------------------------------------------------------------------------------------------------- private void checkPlayersLoadedScene() { if (!arePlayerStatesSynced(NetPlayer.PLAYER_STATE.SceneLoaded)) return; //Everyone has loaded the new scene GameState = GAME_STATE.SceneIntro; foreach (GameObject p in players){ if (p == null) continue; NetPlayer _NetPlayer = p.GetComponent<NetPlayer> (); _NetPlayer.setRaceTime (0.0f); _NetPlayer.RpcSetTrack (trackNames [iRaceCounter]); _NetPlayer.RpcGiveCarCameraControl (); } }
//-------------------------------------------------------------------------------------------------------------------- //Name: //Description: //Parameters: //Returns: //-------------------------------------------------------------------------------------------------------------------- private void checkRaceFinished() { //Someone has finished the race, start the countdown timer if it hasn't started already. bool result = true; foreach (GameObject pl in players) if (pl.GetComponent<NetPlayer> ().getPlayerState () != NetPlayer.PLAYER_STATE.Racing) result = false; if(!result && fRaceOverTimer == 0.0f){ fRaceOverTimer = 20.0f; //20s foreach(GameObject p in players){ if(p==null) continue; p.GetComponent<NetPlayer>().RpcStartRaceOverTimer(); } } if (!arePlayerStatesSynced (NetPlayer.PLAYER_STATE.RaceFinished)) return; GameState = GAME_STATE.SceneOutro; foreach(GameObject p in players){ NetPlayer _NetPlayer = p.GetComponent<NetPlayer>(); _NetPlayer.incPoints(POINTS[_NetPlayer.iPlace-1] + (_NetPlayer.hasFlag() ? 4 : 0)); _NetPlayer.incFlags (_NetPlayer.hasFlag()?1:0); if(_NetPlayer.isHuman()) _NetPlayer.RpcShowScoreboard(); else _NetPlayer.setPlayerState(NetPlayer.PLAYER_STATE.SceneChangeReady); } //End foreach(GameObject p in players) }
//-------------------------------------------------------------------------------------------------------------------- //Name: //Description: //Parameters: //Returns: //-------------------------------------------------------------------------------------------------------------------- private void checkSceneIntroDone() { //Advance players states once everyone has played the into if (!arePlayerStatesSynced (NetPlayer.PLAYER_STATE.RaceReady)) return; GameState = GAME_STATE.RaceReady; checkPlayersRaceReady (); }
private void moveToNextState(object sender, EventArgs e) { Console.WriteLine("Moving to next state"); fadeTimer.Start(); transitionTimer.Stop(); state = state + 1; if (state == GAME_STATE.Playing) { addNewCarTimer.Start(); //drawGrid(); } if (state == GAME_STATE.Exit) { qrCode.Opacity = 0; mainCanvas.Children.Add(ShoopDoupSpeakingImage); mainCanvas.Children.Add(qrCode); Canvas.SetLeft(qrCode, 800); Canvas.SetTop(qrCode, 400); Canvas.SetLeft(ShoopDoupSpeakingImage, 0); Canvas.SetTop(ShoopDoupSpeakingImage, 0); Canvas.SetZIndex(ShoopDoupSpeakingImage, 0); Canvas.SetZIndex(exitLabel, 1); this.exitTimer.Start(); } }
protected void Update() { if ( Network.peerType != NetworkPeerType.Disconnected && Network.isServer && this.gameState == GAME_STATE.PRE_GAME && Network.time - this.timeStarted >= this.startPauseDuration ) { this.gameState = GAME_STATE.PRE_GAME; this.GetComponent<NetworkView>().RPC( "OnGameStartedRPC", RPCMode.All ); } #if UNITY_EDITOR if ( Network.peerType == NetworkPeerType.Disconnected && this.gameState == GAME_STATE.PRE_GAME ) { this.gameState = GAME_STATE.PLAYING; this.LocalGameStart(); } #endif }
private void OnStateChange(GAME_STATE newState) { switch (state) { case GAME_STATE.SPLITSCREEN: this.StopAllAudio(); this.fantasyFrolick.Play(); break; case GAME_STATE.TRANSITIONING: this.StopAllAudio(); this.songTime = this.outtatime.clip.length; this.outtatime.Play(); this.timeStamp = Time.realtimeSinceStartup; Time.timeScale = 0; break; case GAME_STATE.SINGLESCREEN: GameObject.Find("Cameras").GetComponent<CameraController>().ExitTransitionState(); this.StopAllAudio(); this.fantasyFrenzy.Play(); break; case GAME_STATE.KNIGHTWIN: GameManager.Instance.timeStamp = Time.realtimeSinceStartup; //.34f GameManager.Instance.songTime = 0.19f; break; case GAME_STATE.FREEZEFRAME: this.timeStamp = Time.realtimeSinceStartup; this.songTime = this.allHopeLost.clip.length; this.StopAllAudio(); this.allHopeLost.Play(); Time.timeScale = 0; break; case GAME_STATE.WINSCREEN: this.StopAllAudio(); Application.LoadLevel("WinScene"); break; } }
public static void SetGameState(GAME_STATE state) { if (GameManager.state != state) { GameManager.state = state; GameManager.Instance.OnStateChange(state); } }
private void OnCapitalShipDeathRPC( int _playerID ) { DebugConsole.Log( "Capital ship has reached critical damage, moving into Capital Destruction" ); GamePlayer commander = GamePlayerManager.instance.GetPlayerWithID( _playerID ); commander.capitalShip.isDying = true; this.gameState = GAME_STATE.CAPITAL_DESTRUCTION; }
void ResumeButtonClicked() { _state = GAME_STATE.play; //CustomTimer.manager.StartTimer(); if (onGameResume != null) onGameResume(); }
void MainMenuButtonClicked() { _state = GAME_STATE.menu; //CustomTimer.manager.StopTimer(); if (onGameMenu != null) onGameMenu(); }
private void controllerFinished(object o, EventArgs e) { exitTimer.Stop(); introCarTimer.Stop(); introCarAnimatorTimer.Stop(); transitionTimer.Stop(); fadeTimer.Stop(); userExitedTimer.Stop(); addNewCarTimer.Stop(); if (state != GAME_STATE.Exit) { state = GAME_STATE.Playing; moveToNextState(null, null); } else { ReturnToStandbyController(); } }
void PlayButtonClicked() { _state = GAME_STATE.play; //CustomTimer.manager.ResetAndStart(); if (onGamePlay != null) onGamePlay(); /* if (onGameScoreHasChanged != null) onGameScoreHasChanged(); * */ }
public void ChangeState(GAME_STATE state) { currentState = state; }
//-------------------------------------------------------------------------------------------------------------------- //Name: //Description: //Parameters: //Returns: //-------------------------------------------------------------------------------------------------------------------- private void checkPlayersRaceReady() { //if(players[0].GetComponent<NetPlayer>().getPlayerState() == NetPlayer.PLAYER_STATE.Racing) //Check if everyone has started racing to change game state if (arePlayerStatesSynced (NetPlayer.PLAYER_STATE.Racing)) GameState = GAME_STATE.Racing; fRaceOverTimer = 0.0f; if (!arePlayerStatesSynced (NetPlayer.PLAYER_STATE.RaceReady)) return; foreach (GameObject p in players){ if (p == null) continue; NetPlayer _NetPlayer = p.GetComponent<NetPlayer> (); _NetPlayer.RpcGiveCarCameraControl (); _NetPlayer.RpcStartRaceCountdown (); } }
//-------------------------------------------------------------------------------------------------------------------- //Name: Start //Description: Default start function, nothing special here //Parameters: NA //Returns: NA //-------------------------------------------------------------------------------------------------------------------- void Start() { iRaceCounter = 0; fTimer = Time.time; GameMode = GAME_MODE.None; GameState = GAME_STATE.None; players = new GameObject[PLAYER_COUNT]; }
//-------------------------------------------------------------------------------------------------------------------- //Name: //Description: //Parameters: //Returns: //-------------------------------------------------------------------------------------------------------------------- private void checkLevelSelectReady() { if (!arePlayerStatesSynced (NetPlayer.PLAYER_STATE.LevelSelectReady)) return; // foreach(GameObject p in players) // p.GetComponent<NetPlayer>().setPlayerState(NetPlayer.PLAYER_STATE.SceneChangeReady); GameState = GAME_STATE.SceneOutro; foreach (GameObject p in players){ NetPlayer _lNP = p.GetComponent<NetPlayer> (); _lNP.setPlayerState (_lNP.isHuman() ? NetPlayer.PLAYER_STATE.SceneOutro : NetPlayer.PLAYER_STATE.SceneChangeReady); } // GameState = GAME_STATE.SceneChange; // ServerChangeScene (circuitScenes[iRaceCounter]); }
//-------------------------------------------------------------------------------------------------------------------- //Name: //Description: //Parameters: //Returns: //-------------------------------------------------------------------------------------------------------------------- private void checkVehicleSelectReady() { if (!arePlayerStatesSynced (NetPlayer.PLAYER_STATE.VehicleSelectReady)) return; GameState = GAME_STATE.LevelSelection; //foreach (GameObject p in players){ for(int i = 0; i < PLAYER_COUNT; i++){ //Add NPC's for any empty spots if(players[i]==null){ GameObject NpcPlayer = (GameObject)Instantiate(playerPrefab, Vector3.zero, Quaternion.identity); NetPlayer _NetPlayer = NpcPlayer.GetComponent<NetPlayer> (); NetworkServer.Spawn(NpcPlayer); _NetPlayer.Setup (i, false); players[i] = NpcPlayer; players[i].GetComponent<NetPlayer> ().setPlayerState(NetPlayer.PLAYER_STATE.LevelSelectReady); } else if (i==0){ players[i].GetComponent<NetPlayer>().setPlayerState(NetPlayer.PLAYER_STATE.LevelSelect); players[i].GetComponent<NetPlayer>().RpcStartLevelSelection(); } else players[i].GetComponent<NetPlayer>().setPlayerState(NetPlayer.PLAYER_STATE.LevelSelectReady); } //End for(int i = 0; i < PLAYER_COUNT; i++) }
public CarStopperController(Minigame game) { state = GAME_STATE.Instructions; minigame = game; introTitle = minigame.getTitle(); introDescription = minigame.getDescription(); this.sp = new System.Media.SoundPlayer(ShoopDoup.Properties.Resources.carexplosion); carDictionary = new Dictionary<String, Car>(); Console.WriteLine(minigame.getData().Count); int randomElementIndex = randomGen.Next(minigame.getData().Count); baseItem = (String)minigame.getData().ElementAt(randomElementIndex).getElementValue(); minigame.getData().RemoveAt(randomElementIndex); setupLabels(); //mainCanvas.Children.Add(introTitleLabel); //mainCanvas.Children.Add(introDescriptionLabel); mainCanvas.Children.Add(instructionLabel); mainCanvas.Children.Add(exitLabel); mainCanvas.Children.Add(scoreLabel); mainCanvas.Children.Add(baseLabel); this.transitionTimer = new System.Windows.Threading.DispatcherTimer(); this.transitionTimer.Tick += moveToNextState; this.transitionTimer.Interval = TimeSpan.FromMilliseconds(3000); this.fadeTimer = new System.Windows.Threading.DispatcherTimer(); this.fadeTimer.Tick += fadeToNextState; this.fadeTimer.Interval = TimeSpan.FromMilliseconds(40); this.fadeTimer.IsEnabled = false; this.carTimer = new System.Windows.Threading.DispatcherTimer(); this.carTimer.Tick += moveCars; this.carTimer.Interval = TimeSpan.FromMilliseconds(20); this.exitTimer = new System.Windows.Threading.DispatcherTimer(); this.exitTimer.Tick += controllerFinished; this.exitTimer.Interval = TimeSpan.FromMilliseconds(10000); this.userExitedTimer = new System.Windows.Threading.DispatcherTimer(); this.userExitedTimer.Tick += controllerFinished; this.userExitedTimer.Interval = TimeSpan.FromMilliseconds(2000); this.introCarTimer = new System.Windows.Threading.DispatcherTimer(); this.introCarTimer.Tick += addNewInstructionCar; this.introCarTimer.Interval = TimeSpan.FromMilliseconds(2600); this.introCarAnimatorTimer = new System.Windows.Threading.DispatcherTimer(); this.introCarAnimatorTimer.Tick += moveCars; this.introCarAnimatorTimer.Interval = TimeSpan.FromMilliseconds(20); this.addNewCarTimer = new System.Windows.Threading.DispatcherTimer(); this.addNewCarTimer.Tick += addNewCar; this.addNewCarTimer.Interval = TimeSpan.FromMilliseconds(4000); rightHandCursor = new System.Windows.Controls.Image(); rightHandCursor.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.BlueHandCursor); rightHandCursor.Width = 100; leftHandCursor = new System.Windows.Controls.Image(); System.Drawing.Bitmap leftHandBitmap = ShoopDoup.Properties.Resources.BlueHandCursor; leftHandBitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); leftHandCursor.Source = this.toBitmapImage(leftHandBitmap); leftHandCursor.Width = 100; trafficBackgroundImage = new System.Windows.Controls.Image(); trafficBackgroundImage.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.TrafficLaneBackGround); trafficBackgroundImage.Width = 1280; trafficBackgroundImage.Height = 800; trafficBackgroundImage.Opacity = .8; qrCode = new System.Windows.Controls.Image(); qrCode.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.qr); qrCode.Height = 248; qrCode.Width = 248; baseLabelBox = new System.Windows.Controls.Image(); baseLabelBox.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.blueText); scoreBox = new System.Windows.Controls.Image(); scoreBox.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.TwoDigitBlue); scoreBox.Height = 100; scoreBox.Width = 200; ShoopDoupSpeakingImage = new System.Windows.Controls.Image(); ShoopDoupSpeakingImage.Source = this.toBitmapImage(ShoopDoup.Properties.Resources.ThinkingUpgame); ShoopDoupSpeakingImage.Width = 1280; ShoopDoupSpeakingImage.Height = 800; ShoopDoupSpeakingImage.Opacity = 0; rightHandCursor.Opacity = 0; leftHandCursor.Opacity = 0; carBitmaps = new List<Bitmap>(); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperBus); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperCar); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperTruck); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperMotorcycle); carBitmaps.Add(ShoopDoup.Properties.Resources.CarStopperSUV); mainCanvas.Children.Add(rightHandCursor); mainCanvas.Children.Add(leftHandCursor); mainCanvas.Children.Add(trafficBackgroundImage); mainCanvas.Children.Add(scoreBox); Canvas.SetZIndex(rightHandCursor, 4); Canvas.SetZIndex(leftHandCursor, 4); Canvas.SetLeft(trafficBackgroundImage, 0); Canvas.SetTop(trafficBackgroundImage, 0); Canvas.SetZIndex(trafficBackgroundImage, -5); Canvas.SetZIndex(scoreBox, -1); Canvas.SetLeft(scoreBox, 40); Canvas.SetTop(scoreBox, 8); runIntro(); }
private void OnGameStartedRPC() { GamePlayer player = GamePlayerManager.instance.GetPlayerWithID( Common.MyNetworkID() ); if ( player.playerType == PLAYER_TYPE.COMMANDER1 || player.playerType == PLAYER_TYPE.COMMANDER2 ) { PlayerInstantiator.instance.CreatePlayerObject( player, false ); } this.gameState = GAME_STATE.PLAYING; }