public BaseGame(int id, int roomId, Map map, eRoomType roomType, eGameType gameType, int timeType) : base(id, roomType, gameType, timeType) { m_roomId = roomId; m_players = new Dictionary<int, Player>(); m_turnQueue = new List<TurnedLiving>(); m_livings = new List<Living>(); m_random = new Random(); m_map = map; m_actions = new ArrayList(); PhysicalId = 0; BossWarField = ""; m_tempBox = new List<Box>(); m_tempPoints = new List<Point>(); if (roomType == eRoomType.Dungeon) { Cards = new int[21]; } else { Cards = new int[8]; } m_gameState = eGameState.Inited; }
public void AttemptChangeState(eGameState newState, bool force = false) { if (state == newState && !force) { return; } prevState = state; state = newState; switch (newState) { case eGameState.INIT: InitGame(); break; case eGameState.MENU: LoadMenu(); break; case eGameState.GAME: LoadGame(); break; } }
//public void SetGameDifficulty (eGameDifficulty diff) //{ // _gameDifficulty = diff; //} public void PuzzleCompete(int score) { PlayfieldManager.Instance.SetOverlayBaseScoreValue(score); //get time bonus float remainingTime = 1.0f; float rtime = _puzzleDurationTime - _elaspedPuzzleTime; remainingTime = rtime * 1.0f / _puzzleDurationTime; //float bonusFactor = (2.0f - remainingTime) * (float)_gameLevel; float bonus = remainingTime / 0.125f; //8 piece pie meter int ibonus = Mathf.RoundToInt(bonus); if (ibonus < 1) { ibonus = 1; } PlayfieldManager.Instance.SetOverlayBlitzMultValue(ibonus); Debug.LogError("ibonus = " + ibonus); float fScore = (float)(score * ibonus); fScore *= _difficultyMult; fScore *= _roundMult; int pScore = Mathf.RoundToInt(fScore); _roundScore = (int)pScore; _gameScore += (int)pScore; _gameState = eGameState.puzzleResults; }
void EndCurrentPuzzle() { if (CurPuzzle == Puzzles.Length - 1) { base.PlayFirstBranch(); Slot_Container sc = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object"); ArticyObject curStartOn = sc.Template.Slot_Feature.Slot_Feature_Slot; var a = curStartOn as IObjectWithFeatureSlot_Feature; if (a != null) { sc.Template.Slot_Feature.Slot_Feature_Slot = a.GetFeatureSlot_Feature().Slot_Feature_Slot; } else { Debug.LogError("no slot feature in EndCurrentPuzzle"); } SceneManager.LoadScene(1); // SceneManager.LoadScene(1); } else { Puzzles[CurPuzzle].gameObject.SetActive(false); CurPuzzle++; Puzzles[CurPuzzle].gameObject.SetActive(true); SetupLerpFade(1f, 0f, 1.5f); GameState = eGameState.FADE_IN; } }
IEnumerator FadePause() { GameState = eGameState.NONE; yield return(new WaitForSeconds(1f)); EndCurrentPuzzle(); }
public void SetState(eGameState state) { if (m_state == state) { return; } m_state = state; switch (m_state) { case eGameState.Normal: m_player.EndInvincible(); m_bgController.SetSpeedScale(1f); MonsterManager.Instance.SetSpawnInterval(1f); break; case eGameState.Invincible: m_player.SetInvincible(); m_bgController.SetSpeedScale(4f); MonsterManager.Instance.SetSpawnInterval(4f); break; case eGameState.Result: m_player.SetDie(); m_bgController.SetSpeedScale(1f); MonsterManager.Instance.StopCreateMonsters(); MeteoManager.Instance.StopCreateMeteo(); m_gameUI.SetActive(false); SoundManager.Instance.PlaySfx(SoundManager.eAudioSFXClip.Result); m_resultUI.SetUI(); break; } }
/// <summary> /// Initializes the State /// </summary> public override void Initialize() { gTargetState = eGameState.gsGame; eCurrentMap = eMapState.ssMain; mMainMap = new MainMap(); }
public void MoveToTitleScreen(EntityCommandBuffer cb) { HideInventory(cb); // Record every player move at title screen var pis = EntityManager.World.GetExistingSystem <PlayerInputSystem>(); pis.StartRecording(); // Start with a nice new seed CurrentSeed = MakeNewRandom(); RandomRogue.Init(CurrentSeed); // Clear the screen. Entities.WithAll <Player>().ForEach((Entity player, ref GoldCount gc, ref ExperiencePoints xp) => { _scoreManager.SetHiScores(gc.count + xp.now + (CurrentLevel - 1) * 10); }); ClearView(cb); if (GlobalGraphicsSettings.ascii) { GameView.Blit(cb, new int2(0, 0), "TINY ROGUE"); GameView.Blit(cb, new int2(30, 20), "PRESS SPACE TO BEGIN"); GameView.Blit(cb, new int2(30, 21), "PRESS H FOR HISCORES"); } else { var glog = EntityManager.World.GetExistingSystem <GraphicalLogSystem>(); glog.AddToLog("TINY ROGUE"); glog.AddToLog("PRESS SPACE TO BEGIN"); } _state = eGameState.Title; }
public void Start() { lock (Data._syncStop) { if (GameMode == eGameMode.FLAG) { SetCaptain(); } GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_START); _gameState = eGameState.PLAY; //IsTakeOut = false; if (RoomType == eRoomType.PAIRUP && MatchGame != null) { MatchGame.GameState = eGameState.PLAY; //MatchGame.IsTakeOut = false; } _processor.OnStarting(this, pkg); SendToAll(pkg); _processor.OnStarted(this); } }
/// <summary> /// pause game and press same button to resume game /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pause_click(object sender, EventArgs e) { //if current state is not paused //update button text and game state //and start/continue the game if (currentState == eGameState.Paused) { pauseBtn.Text = "pause"; currentState = eGameState.Running; timer1.Start(); } //if current state is paused //update button text, game state //and show text to indicate game is paused //and pause the game //hide everything currently in gdi window //and re-display it after game is resumed else { pauseBtn.Text = "continue"; currentState = eGameState.Paused; timer1.Stop(); missile.Loading = true; CDrawer.AddText("Game Paused", 60, Color.Cyan); missile.Loading = false; } }
public GameLogic(int i_BoardSize, bool i_Player1IsComputer, bool i_Player2IsComputer) { m_GameBoard = new Board(i_BoardSize); m_Player1 = new Player(ePlayersMark.Player1, i_Player1IsComputer); m_Player2 = new Player(ePlayersMark.Player2, i_Player2IsComputer); m_CurrentGameState = eGameState.Playing; }
public void StartGameState(eGameState newGameState ) { if( newGameState != CurrentGameState ) { //End current gamestate switch ( CurrentGameState ) { case eGameState.Waiting: case eGameState.Playing: break; } //Start new gamestate switch ( newGameState ) { case eGameState.Waiting: case eGameState.Playing: break; } //reset time m_WaitTime = 0; m_MatchTime = 0; if ( OnGameStateChanged != null ) { OnGameStateChanged.Invoke( newGameState ); } } }
private void HandleStateChange() { if (m_NextState == m_State) { return; } switch (m_NextState) { case eGameState.TitleScreen: // Going to the title screen so clear everything m_UIStack.Clear(); m_UIGameplay = null; m_Timer.RemoveAll(); m_UIStack.Push(new UI.UITitleScreen(m_Game.Content)); break; case eGameState.MainMenu: m_UIStack.Clear(); m_UIGameplay = null; m_Timer.RemoveAll(); m_UIStack.Push(new UI.UIMainMenu(m_Game.Content)); ClearGameObjects(); break; case eGameState.Gameplay: SetupGameplay(); break; } m_State = m_NextState; }
private eGameState gameHasWinner(eTeam i_CurrentTeamMove) { eGameState gameStateResult = eGameState.GameIsInProgress; eTeam enemy = OpponentUtils.GetOpponent(i_CurrentTeamMove); int enenyCount = 0; for (int x = 0; x < this.r_Board.GetLength(1); x++) { for (int y = 0; y < this.r_Board.GetLength(1); y++) { if (this.r_Board[x, y].Team == enemy) { enenyCount++; } } } if (enenyCount == 0) { if (enemy == eTeam.Player1) { gameStateResult = eGameState.Player2Won; } else { gameStateResult = eGameState.Player1Won; } } return(gameStateResult); }
public eGameState CalcGameState(eTeam i_CurrentTeamMove) { eGameState gameStateResult = gameHasWinner(i_CurrentTeamMove); if (eGameState.GameIsInProgress == gameStateResult) { bool player1HasMoves = checkPlayerHasAvailableMove(eTeam.Player1); bool player2HasMoves = checkPlayerHasAvailableMove(eTeam.Player2); if (!player1HasMoves && !player2HasMoves) { gameStateResult = eGameState.Tie; } else if (!player2HasMoves) { gameStateResult = eGameState.Player1Won; } else if (!player1HasMoves) { gameStateResult = eGameState.Player2Won; } } return(gameStateResult); }
/// <summary> /// Initializes Variables /// </summary> protected override void Initialize() { gCurrentState = eGameState.gsMainMenu; sGameState = new StateGame(); sGameOverState = new StateGameOver(); sMainMenuState = new StateMainMenu(); }
/// <summary> /// Updates the Game /// </summary> protected override void Update() { switch (gCurrentState) { case eGameState.gsGame: InitializeState(sGameState); gTargetState = sGameState.Update(Window); DisposeState(sGameState); break; case eGameState.gsGameOver: sGameState = new StateGame(); InitializeState(sGameOverState); gTargetState = sGameOverState.Update(Window); DisposeState(sGameOverState); break; case eGameState.gsMainMenu: InitializeState(sMainMenuState); gTargetState = sMainMenuState.Update(Window); DisposeState(sMainMenuState); break; case eGameState.gsQuit: Window.Close(); break; } }
public bool CanStartGame(GamePlayer player, GSPacketIn data) { lock (Data._syncStop) { if (player == _player && _gameState == eGameState.FREE) { if (_processor.OnCanStartGame(this, player)) { _processor.InitGame(this); BeginTimer(70 * 1000); Data.StartReset(this); //StopTimer(); _gameState = eGameState.LOAD; _isChangeStyle = false; SendRoomInfo(); IsTakeOut = false; Data.MapType = eMapType.Normal; Data.MapIndex = Managers.MapMgr.GetMapIndex(MapIndex, (byte)eMapType.Normal); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_LOAD); pkg.WriteInt(Data.MapIndex); pkg.WriteInt(Data.StartedGameClass); pkg.WriteBoolean(false); SendToAll(pkg); return(true); } } return(false); } }
public void MoveToReadQueuedLog() { if (!PlayerInputSystem.Replaying) { _state = eGameState.ReadQueuedLog; } }
public void BeginPairUpLoad() { IsHost = true; BeginTimer(70 * 1000); Data.StartReset(this); //StopTimer(); _gameState = eGameState.LOAD; SendRoomInfo(); if (RoomType == eRoomType.PAIRUP && MatchGame != null) { //MatchGame.BeginTimer(70 * 1000); MatchGame.StopTimer(); MatchGame.GameState = eGameState.LOAD; MatchGame.IsHost = false; } Data.MapIndex = Managers.MapMgr.GetMapIndex(MapIndex, (byte)eMapType.PairUp); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_LOAD); pkg.WriteInt(Data.MapIndex); pkg.WriteInt(Data.StartedGameClass); _isChangeStyle = Managers.FightRateMgr.CanChangeStyle(this, pkg); Data.IsChangeStyle = _isChangeStyle; Data.ChangeTeam = _player.CurrentTeamIndex; Data.MapType = eMapType.PairUp; SendToAll(pkg); }
IEnumerator CoPlayGame() { Time.timeScale = 1f; cinematicManager.btnSkip.enabled = false; cinematicManager.btnBeginPlay.enabled = false; cinematicManager.btnGoToTitle.enabled = false; Tweener tween = FadeHelper.FadeIn(imgBlackBoard, 1f); yield return(new WaitWhile(() => tween.IsPlaying())); cinematicManager.HidePrologue(); audioSource.DOFade(0f, 1f); yield return(new WaitForSeconds(1f)); audioSource.Stop(); audioSource.volume = 1f; Camera.main.GetComponent <AudioListener>().enabled = false; yield return(SceneManager.LoadSceneAsync("GameScene", LoadSceneMode.Additive)); yield return(SceneManager.UnloadSceneAsync("TitleScene")); yield return(SceneManager.UnloadSceneAsync("CinematicScene")); FadeHelper.FadeOut(imgBlackBoard, 1f); gameState = eGameState.playingGame; }
public void ChangeState(eGameState gs) { // destroy all potential levels before signalling a reload before gameState = gs; Destroy(GameObject.Find("_level1")); Destroy(GameObject.Find("_level2")); Destroy(GameObject.Find("_level3")); switch (gameState) { case (eGameState.eGS_MainMenu): { break; } case (eGameState.eGS_Level1): { Application.LoadLevelAdditive("LEVEL1"); break; } case (eGameState.eGS_Level2): { Application.LoadLevelAdditive("LEVEL2"); break; } case (eGameState.eGS_Level3): { Application.LoadLevelAdditive("LEVEL3"); break; } } }
public static void GameOver() { GameState = eGameState.Game_Over; Animator Game_Over_Anim = GameObject.FindGameObjectWithTag("GameOver")?.GetComponent <Animator>(); Game_Over_Anim?.SetTrigger("Game_Over"); }
public void GoToGameState(eGameState _gameState) { GameState = _gameState; // enter new state. switch (GameState) { case eGameState.MainMenu: break; case eGameState.PreGame: UIController.Instance.MenuContainer.SetActive(false); UIController.Instance.UIContainer.SetActive(true); UIController.Instance.CountdownText.BeginCountdown(3); PlayerController.Instance.SetupGame(); break; case eGameState.Play: break; case eGameState.PostGame: break; } }
public void GameEnd() { _currentState = eGameState.END; _HPbar.value = _player._nowHP; _BgInfo.SetActive(true); _txtInfo.text = "GameEnd"; }
void StartRound() { enemiesKilledText.gameObject.SetActive(false); asteroidsDestroyedText.gameObject.SetActive(false); shotsFiredText.gameObject.SetActive(false); accuracyText.gameObject.SetActive(false); gamesPlayedText.gameObject.SetActive(false); clickToStartText.gameObject.SetActive(false); brainCloudStatusText.gameObject.SetActive(false); scoreText.gameObject.SetActive(true); m_enemiesKilledThisRound = 0; m_asteroidsDestroyedThisRound = 0; m_shotsFiredThisRound = 0; // don't reset this every round... m_totalGamesPlayed = 0; m_accuracy = 0; m_score = 0; UpdateScoreText(); m_state = eGameState.GAME_STATE_PLAYING; m_playState = ePlayState.PLAY_STATE_STARTUP; m_startupTime = startWait; SpawnPlayer(); }
/// <summary> /// /// </summary> public XNArkanoidGame() { State.Game = this; mIsolatedStorage = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); XNArkanoidGame.mGameState = eGameState.Loading; mGraphics = new GraphicsDeviceManager(this); mSettings = Settings.Load(); mGraphics.PreferredBackBufferWidth = mSettings.ScreenWidth; mGraphics.PreferredBackBufferHeight = mSettings.ScreenHeight; // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); mVaus = new Vaus(this); // Create dialogs mMainDialog = new UIGame.GUIMainScreen(this); mMainDialog.ControlSelected += new global::XNArkanoid.UI.UIDialog.ControlSelectedDelegate(mMainDialog_ControlSelected); mContinueDialog = new UIGame.GUIContinueScreen(this); mContinueDialog.PlayerContinues += new EventHandler(mContinueDialog_PlayerContinues); mContinueDialog.CounterReachedZero += new EventHandler(mContinueDialog_CounterReachedZero); Level.AllBallsFallen += new Level.AllBallsFallenDelegate(Level_AllBallsFallen); Level.EndLevel += new Level.EndLevelDelegate(Level_EndLevel); XNArkanoidGame.mGameState = eGameState.DialogMain; }
public BaseGame(int id, int roomId, Map map, eRoomType roomType, eGameType gameType, int timeType) : base(id, roomType, gameType, timeType) { m_roomId = roomId; m_players = new Dictionary <int, Player>(); m_turnQueue = new List <TurnedLiving>(); m_livings = new List <Living>(); m_random = new Random(); m_map = map; m_actions = new ArrayList(); PhysicalId = 0; BossWarField = ""; m_tempBox = new List <Box>(); m_tempPoints = new List <Point>(); if (roomType == eRoomType.Treasure || roomType == eRoomType.Boss) { Cards = new int[21]; } else { Cards = new int[8]; } m_gameState = eGameState.Inited; }
public void ChangeState(eGameState newState) { State = newState; switch (newState) { case eGameState.MENU: BroadcastMessage("OnMainMenu", SendMessageOptions.DontRequireReceiver); break; case eGameState.GAME: BroadcastMessage("OnGameStart", SendMessageOptions.DontRequireReceiver); break; case eGameState.PAUSE: BroadcastMessage("OnPause", SendMessageOptions.DontRequireReceiver); break; case eGameState.GAME_END: BroadcastMessage("OnGameEnd", SendMessageOptions.DontRequireReceiver); break; case eGameState.TUTORIAL: BroadcastMessage("OnTutorial", SendMessageOptions.DontRequireReceiver); break; case eGameState.CREDITS: BroadcastMessage("OnCredits", SendMessageOptions.DontRequireReceiver); break; } BroadcastMessage("OnStateChange", SendMessageOptions.DontRequireReceiver); }
private void Awake() { #if DEBUG_AsteraX_LogMethods Debug.Log("AsteraX:Awake()"); #endif S = this; GAME_STATE_CHANGE_DELEGATE += delegate() { // This is an example of a C# anonymous delegate. It's used to set the state of // _gameState every time GAME_STATE changes. // Anonymous delegates like this do create "closures" like "this" below, which // stores the value of this when the anonymous delegate was created. Closures // can be slow, but in this case, it is so rarely used that it doesn't matter. this._gameState = AsteraX.GAME_STATE; S._gameState = AsteraX.GAME_STATE; }; // This strange use of _gameState as an intermediary in the following lines // is solely to stop the Warning from popping up in the Console telling you // that _gameState was assigned but not used. _gameState = eGameState.mainMenu; GAME_STATE = _gameState; }
private void OnRoomStateChanged(MapSchema <string> attributes) { if (_showCountdown && attributes.ContainsKey("countDown")) { _countDownString = attributes["countDown"]; scoreboardController.CountDown(_countDownString); } if (attributes.ContainsKey("currentGameState")) { eGameState nextState = TranslateGameState(attributes["currentGameState"]); if (IsSafeStateTransition(currentGameState, nextState)) { currentGameState = nextState; } else { LSLog.LogError($"CurrentGameState: Failed to transition from {currentGameState} to {nextState}"); } } if (attributes.ContainsKey("lastGameState")) { eGameState nextState = TranslateGameState(attributes["lastGameState"]); if (IsSafeStateTransition(lastGameState, nextState)) { lastGameState = nextState; } else { LSLog.LogError($"LastGameState: Failed to transition from {lastGameState} to {nextState}"); } } }
private void EndStage() { if (lifeCount <= 0) { state = eGameState.End; return; } lifeCount -= enemyCurrentCount; lifeText.text = "Life : " + lifeCount.ToString(); moneyCount += 10; moneyText.text = "Money : " + moneyCount.ToString(); foreach (GameObject enemy in enemyList) { Destroy(enemy.GetComponent <Enemy>().hpBar); Destroy(enemy.gameObject); } enemyList.Clear(); enemyCurrentCount = 0; cardBoard.SetCard(); state = eGameState.Wait; }
public void PuzzleCompete(int score) { //get time bonus float remainingTime = 1.0f; float rtime = _puzzleDurationTime - _elaspedPuzzleTime; remainingTime = rtime * 1.0f / _puzzleDurationTime; float bonusFactor = (2.0f - remainingTime) * (float)_gameLevel; float pScore = (float)score * bonusFactor; _gameScore += (int)pScore; _gameState = eGameState.puzzleResults; }
public BaseSceneGame(int id, IGameProcessor processor) { _id = id; _processor = processor; _userList = new GamePlayer[_processor.MaxPlayerCount]; _openState = new bool[_processor.MaxPlayerCount]; _locker = new ReaderWriterLock(); _count = 0; _gameState = eGameState.FREE; _roomType = eRoomType.FREE; Revert(); }
private void DoHighScoreSetup() { _CurrentState = eGameState.GAMESTATE_HIGH_SCORE; SetScreen("SCORES"); }
private void DoSetupStages() { SetScreen("STAGES"); _CurrentState = eGameState.GAMESTATE_STAGES; }
public void ChangeState(eGameState state) { mGameState = state; // disable all cameras rockCam.enabled = false; playerCam.enabled = false; bullseyeCam.enabled = false; miniCam.enabled = false; HUDBrushNow(false); if (state == eGameState.ePlayer) { playerCam.enabled = true; miniCam.enabled = true; } if (state == eGameState.eRock) { rockCam.enabled = true; miniCam.enabled = true; HUDBrushNow(true); cursor.transform.position = new Vector3(0.5f, 0.5f, 5f); } if (state == eGameState.eBullseye) { bullseyeCam.enabled = true; EndOfRound(); StartCoroutine(SwitchToEndOfRound(5)); // wait 5 seconds and switch to end of round scene } }
public void ForceStartGame() { m_gameState = eGameState.GAME_STATE_STARTING_GAME; }
private void DoGame(float fTimeDelta) { Ray ray; RaycastHit hit; if(!_PlayerDead) { if (Application.platform != RuntimePlatform.IPhonePlayer) { ray = _Camera.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(ray, out hit, 200)) { if(hit.transform.gameObject.name == "Ground") { _Player.SetPosition(hit.point.x,hit.point.z); } } } else { // Handle touches if(Input.touchCount > 0) { Touch pTouch = Input.touches[0]; switch(pTouch.phase) { case TouchPhase.Began: ray = _Camera.ScreenPointToRay(pTouch.position); //Debug.Log("Touch began x = " + pTouch.position.x + " z = " + pTouch.position.y); if(Physics.Raycast(ray, out hit, 200)) { if(hit.transform.gameObject.name == "Ground") { //Debug.Log("Hit ground"); _Player.SetOffset(hit.point.x,hit.point.z); _MouseDown = true; } } break; case TouchPhase.Moved: ray = _Camera.ScreenPointToRay(pTouch.position); //Debug.Log("Touch moved x = " + pTouch.position.x + " z = " + pTouch.position.y); if(Physics.Raycast(ray, out hit, 200)) { if(hit.transform.gameObject.name == "Ground") { _Player.SetPosition(hit.point.x,hit.point.z); //Debug.Log("Hit ground"); } } break; case TouchPhase.Ended: //Debug.Log("Touch ended"); _MouseDown = false; break; } } } _TimeCount += fTimeDelta; if(_TimeCount >= 1.0f) { _TimeCount -= 1.0f; ++_TimePlayed; } _Generator.Update(fTimeDelta); } else { _PlayerDeadCountdown -= fTimeDelta; if(_PlayerDeadCountdown <= 0.0f) { if(_Lives != 0) { --_Lives; _CurrentState = eGameState.GAMESTATE_SETUP_GAME; } else { _CurrentState = eGameState.GAMESTATE_SETUP_TITLE; } Particle.AddExplosion(_Player._X,_Player._Z-1.0f,300); ShakeCamera(0.3f,0.6f); PlaySample("PLAYERDEATH",1.0f); //if(_Score > _LocalHiScore) //{ _Scores.AddScore(Scores._Name,_Score,_TimePlayed); //} } } _Number.SetNumber(_Score); if(_Score > _LocalHiScore) { _LocalHiScore = _Score; } _SpeedUpFireCurrentTime -= fTimeDelta; if(_SpeedUpFireCurrentTime <= 0.0f) { _SpeedUpFireCurrentTime = 0.0f; } _TriFireCurrentTime -= fTimeDelta; if(_TriFireCurrentTime <= 0.0f) { _TriFireCurrentTime = 0.0f; } _MagnetCurrentTime -= fTimeDelta; if(_MagnetCurrentTime <= 0.0f) { _MagnetCurrentTime = 0.0f; } _ShieldCurrentTime -= fTimeDelta; if(_ShieldCurrentTime <= 0.0f) { _ShieldCurrentTime = 0.0f; } }
void EndGame() { StopCoroutine("RespawnPlayer"); m_gameState = eGameState.GAME_STATE_GAME_OVER; m_allyShipSunk.SetActive(false); m_enemyShipSunk.SetActive(false); m_redShipLogo.SetActive(false); m_greenShipLogo.SetActive(false); GameObject.Find("PlayerController").GetComponent<PlayerController>().DestroyPlayerPlane(); }
void SpawnPlayer() { if ((int)PhotonNetwork.player.customProperties["Team"] == 0) { m_gameState = eGameState.GAME_STATE_SPECTATING; } else { Vector3 spawnPoint = Vector3.zero; spawnPoint.z = 22; if ((int)PhotonNetwork.player.customProperties["Team"] == 1) { spawnPoint.x = Random.Range(m_team1SpawnBounds.bounds.center.x - m_team1SpawnBounds.bounds.size.x / 2, m_team1SpawnBounds.bounds.center.x + m_team1SpawnBounds.bounds.size.x / 2) - 10; spawnPoint.y = Random.Range(m_team1SpawnBounds.bounds.center.y - m_team1SpawnBounds.bounds.size.y / 2, m_team1SpawnBounds.bounds.center.y + m_team1SpawnBounds.bounds.size.y / 2); } else if ((int)PhotonNetwork.player.customProperties["Team"] == 2) { spawnPoint.x = Random.Range(m_team2SpawnBounds.bounds.center.x - m_team2SpawnBounds.bounds.size.x / 2, m_team2SpawnBounds.bounds.center.x + m_team2SpawnBounds.bounds.size.x / 2) + 10; spawnPoint.y = Random.Range(m_team2SpawnBounds.bounds.center.y - m_team2SpawnBounds.bounds.size.y / 2, m_team2SpawnBounds.bounds.center.y + m_team2SpawnBounds.bounds.size.y / 2); } GameObject playerPlane = PhotonNetwork.Instantiate("Plane", spawnPoint, Quaternion.LookRotation(Vector3.forward, (new Vector3(0, 0, 22) - spawnPoint)), 0); if ((int)PhotonNetwork.player.customProperties["Team"] == 1) { playerPlane.layer = 8; } else if ((int)PhotonNetwork.player.customProperties["Team"] == 2) { playerPlane.layer = 9; } GameObject.Find("PlayerController").GetComponent<PlayerController>().SetPlayerPlane(playerPlane.GetComponent<PlaneController>()); playerPlane.GetComponent<Rigidbody>().isKinematic = false; m_gameState = eGameState.GAME_STATE_PLAYING_GAME; } }
private void DoSetupGame() { _CurrentState = eGameState.GAMESTATE_GAME; _Player.Enable(); _Number.SetNumber(0); _SequencerSemaphore = 0; _SequencerLifetime = 0.0f; _SequencerDelay = 0.0f; _PlayerDead = false; _SpeedUpFireCurrentTime = 0.0f; _TriFireCurrentTime = 0.0f; _MagnetCurrentTime = 0.0f; _ShieldCurrentTime = 0.0f; SetScreen("PLAY"); for(int i = 0; i < 20; ++i) { Sprite pSprite = _LivesSprites[i]; pSprite._Alive = false; } for(int i = 0; i < _Lives; ++i) { Sprite pSprite = _LivesSprites[i]; pSprite._Alive = true; } Screen.showCursor = false; Debug.Log("Playing GAMEON"); PlaySample("GAMEON",1.0f); }
public void Revert() { //_mapIndex = 0; //_teamType = eTeamType.FREE; bool isNew = Managers.WorldMgr.WaitingScene.Info.NewerServer ; //if (Managers.WorldMgr.WaitingScene.Info.NewerServer == 0) //{ if (RoomType == eRoomType.PAIRUP) { for (int i = 0; i < _openState.Length; i++) { if (isNew) { if (i < _openState.Length / 4) { _openState[i] = true; } else { _openState[i] = false; } } else { if (i < _openState.Length / 2) { _openState[i] = true; } else { _openState[i] = false; } } } } else { for (int i = 0; i < _openState.Length; i++) { if (i >= 4 && isNew) { _openState[i] = false; } else { _openState[i] = true; } } } _gameState = eGameState.FREE; _gameClass = eGameClass.FREE; //Data = null; _matchGame = null; _consortiaID = -1; pairUpState = 0; listType = 0; _classChangeMode = 0; }
public void BeginPairUpLoad() { IsHost = true; BeginTimer(70 * 1000); Data.StartReset(this); //StopTimer(); _gameState = eGameState.LOAD; SendRoomInfo(); if (RoomType == eRoomType.PAIRUP && MatchGame != null) { //MatchGame.BeginTimer(70 * 1000); MatchGame.StopTimer(); MatchGame.GameState = eGameState.LOAD; MatchGame.IsHost = false; } Data.MapIndex = Managers.MapMgr.GetMapIndex(MapIndex,(byte)eMapType.PairUp); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_LOAD); pkg.WriteInt(Data.MapIndex); pkg.WriteInt(Data.StartedGameClass); _isChangeStyle = Managers.FightRateMgr.CanChangeStyle(this,pkg); Data.IsChangeStyle = _isChangeStyle; Data.ChangeTeam = _player.CurrentTeamIndex; Data.MapType = eMapType.PairUp; SendToAll(pkg); }
public bool CanStartGame(GamePlayer player,GSPacketIn data) { lock (Data._syncStop) { if (player == _player && _gameState == eGameState.FREE) { if (_processor.OnCanStartGame(this, player)) { _processor.InitGame(this); BeginTimer(70 * 1000); Data.StartReset(this); //StopTimer(); _gameState = eGameState.LOAD; _isChangeStyle = false; SendRoomInfo(); IsTakeOut = false; Data.MapType = eMapType.Normal; Data.MapIndex = Managers.MapMgr.GetMapIndex(MapIndex, (byte)eMapType.Normal); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_LOAD); pkg.WriteInt(Data.MapIndex); pkg.WriteInt(Data.StartedGameClass); pkg.WriteBoolean(false); SendToAll(pkg); return true; } } return false; } }
public void Stop() { lock (Data._syncStop) { if (GameState != eGameState.LOAD && GameState != eGameState.PLAY) return; GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_OVER); _processor.OnStopping(this, pkg); SendToAll(pkg); _gameState = eGameState.OVER; if (RoomType == eRoomType.PAIRUP && MatchGame != null) { MatchGame.GameState = eGameState.OVER; } _data.CurrentMap = null; //_data._fallItemID.Clear(); _data.FlagPlayer.Clear(); foreach (GamePlayer player in _data.GetAllPlayers()) { //player.UpdateStyle(); player.OnGameStop(); //player.Out.SendCheckCode(); } _processor.OnStopped(this); //if(!_data.killFlag) //{ // if (MatchGame != null) // { // ShowArk(MatchGame, null); // } // ShowArk(this, null); //} if (MatchGame != null && !MatchGame.IsTakeOut) { ShowArk(MatchGame, null); } if (!IsTakeOut) { ShowArk(this, null); } } }
public void Start() { lock (Data._syncStop) { if (GameMode == eGameMode.FLAG) SetCaptain(); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_START); _gameState = eGameState.PLAY; //IsTakeOut = false; if (RoomType == eRoomType.PAIRUP && MatchGame != null) { MatchGame.GameState = eGameState.PLAY; //MatchGame.IsTakeOut = false; } _processor.OnStarting(this, pkg); SendToAll(pkg); _processor.OnStarted(this); } }
private void DoSetupHowToPlay(float fTimeDelta) { Debug.Log("Setup how to play"); _CurrentState = eGameState.GAMESTATE_HOW_TO_PLAY; SetScreen("HOW_TO_PLAY"); _Number.Disable(); }
private void DoGetNewVersionSetup() { _CurrentState = eGameState.GAMESTATE_GET_NEW_VERSION; _NewVersionTime = 0.0f; SetScreen("NEW_VERSION"); }
void StartRound() { enemiesKilledText.gameObject.SetActive(false); asteroidsDestroyedText.gameObject.SetActive(false); shotsFiredText.gameObject.SetActive(false); accuracyText.gameObject.SetActive(false); gamesPlayedText.gameObject.SetActive(false); clickToStartText.gameObject.SetActive(false); // brainCloudStatusText.gameObject.SetActive(false); scoreText.gameObject.SetActive(true); m_enemiesKilledThisRound = 0; m_asteroidsDestroyedThisRound = 0; m_shotsFiredThisRound = 0; // don't reset this every round... m_totalGamesPlayed = 0; m_accuracy = 0; m_score = 0; UpdateScoreText (); m_state = eGameState.GAME_STATE_PLAYING; m_playState = ePlayState.PLAY_STATE_STARTUP; m_startupTime = startWait; // Debug.Log ("here in start round"); SpawnPlayer(); }
void Update() { switch (m_gameState) { case eGameState.GAME_STATE_WAITING_FOR_PLAYERS: m_showScores = false; if (m_room.playerCount == m_room.maxPlayers) { m_gameState = eGameState.GAME_STATE_STARTING_GAME; } if (GameObject.Find("BackgroundMusic").GetComponent<AudioSource>().isPlaying) { GameObject.Find("BackgroundMusic").GetComponent<AudioSource>().Stop(); } Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, new Vector3(0, 0, -90), Time.deltaTime); break; case eGameState.GAME_STATE_STARTING_GAME: m_showScores = false; if (PhotonNetwork.isMasterClient && !m_once) { m_once = true; StartCoroutine("SpawnGameStart"); StartCoroutine("WaitForReadyPlayers"); } break; case eGameState.GAME_STATE_SPAWN_PLAYERS: m_showScores = false; if (PhotonNetwork.isMasterClient && m_once) { m_once = false; GetComponent<PhotonView>().RPC("SpawnPlayer", PhotonTargets.AllBuffered); } break; case eGameState.GAME_STATE_PLAYING_GAME: if (Input.GetKeyDown(KeyCode.Escape)) { m_showQuitMenu = !m_showQuitMenu; } if (Input.GetKey(KeyCode.Tab)) { m_showScores = true; } else { m_showScores = false; } if (m_showQuitMenu) { m_quitMenu.SetActive(true); } else { m_quitMenu.SetActive(false); } if (!m_once) { GameObject.Find("BackgroundMusic").GetComponent<AudioSource>().Play(); m_once = true; } if (PhotonNetwork.isMasterClient) { m_gameTime -= Time.deltaTime; m_roomProperties = PhotonNetwork.room.customProperties; m_roomProperties["GameTime"] = m_gameTime; PhotonNetwork.room.SetCustomProperties(m_roomProperties); List<ShipController> team1Ships = new List<ShipController>(); List<ShipController> team2Ships = new List<ShipController>(); for (int i = 0; i < m_spawnedShips.Count; i++) { if (m_spawnedShips[i].m_team == 1) { team1Ships.Add(m_spawnedShips[i]); } else if (m_spawnedShips[i].m_team == 2) { team2Ships.Add(m_spawnedShips[i]); } } bool team1IsDestroyed = true; bool team2IsDestroyed = true; for (int i = 0; i < team1Ships.Count; i++) { if (team1Ships[i].IsAlive()) { team1IsDestroyed = false; break; } } for (int i = 0; i < team2Ships.Count; i++) { if (team2Ships[i].IsAlive()) { team2IsDestroyed = false; break; } } if (m_gameTime <= 0 || team1IsDestroyed || team2IsDestroyed) { GetComponent<PhotonView>().RPC("EndGame", PhotonTargets.AllBuffered); } } else { if (PhotonNetwork.room != null) m_gameTime = (float)PhotonNetwork.room.customProperties["GameTime"]; } break; case eGameState.GAME_STATE_GAME_OVER: m_showScores = false; if (m_once) { m_once = false; GameObject.Find("PlayerController").GetComponent<PlayerController>().EndGame(); if (PhotonNetwork.isMasterClient) { if (m_team1Score > m_team2Score) { AwardExperience(1); } else if (m_team2Score > m_team1Score) { AwardExperience(2); } else { AwardExperience(0); } } } if (PhotonNetwork.isMasterClient) { m_gameTime -= Time.deltaTime; m_roomProperties = PhotonNetwork.room.customProperties; m_roomProperties["GameTime"] = m_gameTime; PhotonNetwork.room.SetCustomProperties(m_roomProperties); } else { if (PhotonNetwork.room != null) m_gameTime = (float)PhotonNetwork.room.customProperties["GameTime"]; } break; case eGameState.GAME_STATE_SPECTATING: if (Input.GetKey(KeyCode.Tab)) { m_showScores = true; } else { m_showScores = false; } if (PhotonNetwork.room != null) m_gameTime = (float)PhotonNetwork.room.customProperties["GameTime"]; PhotonPlayer[] playerList = PhotonNetwork.playerList; List<PhotonPlayer> playerListList = new List<PhotonPlayer>(); for (int i = 0; i < playerList.Length; i++) { playerListList.Add(playerList[i]); } int count = 0; while (count < playerListList.Count) { if (playerListList[count].customProperties["Team"] == null || (int)playerListList[count].customProperties["Team"] == 0) { playerListList.RemoveAt(count); } else { count++; } } playerList = playerListList.ToArray().OrderByDescending(x => (int)x.customProperties["Score"]).ToArray(); int playerIndex = -1; if (m_spectatingTarget != null) { for (int i = 0; i < playerList.Length; i++) { if (playerList[i] == m_spectatingTarget) { playerIndex = i; break; } } } if (Input.GetMouseButtonDown(0)) { if (playerIndex == 0 || playerIndex == -1) { playerIndex = playerList.Length - 1; } else { playerIndex--; } } else if (Input.GetMouseButtonDown(1)) { if (playerIndex == playerList.Length - 1 || playerIndex == -1) { playerIndex = 0; } else { playerIndex++; } } if (playerIndex != -1) m_spectatingTarget = playerList[playerIndex]; break; } if (!PhotonNetwork.isMasterClient && PhotonNetwork.room != null) { m_team1Score = (float)PhotonNetwork.room.customProperties["Team1Score"]; m_team2Score = (float)PhotonNetwork.room.customProperties["Team2Score"]; } }
void Update() { switch (m_state) { case eGameState.GAME_STATE_START_SCREEN: if (Input.GetMouseButtonDown(0)) { StartRound(); } break; case eGameState.GAME_STATE_PLAYING: switch (m_playState) { case ePlayState.PLAY_STATE_STARTUP: case ePlayState.PLAY_STATE_IN_BETWEEN_WAVES: m_startupTime -= Time.deltaTime; if (m_startupTime <= 0) { StartWave(); } break; case ePlayState.PLAY_STATE_WAVE: m_spawnTime -= Time.deltaTime; if (m_spawnTime <= 0) { if (m_hazardSpawned >= hazardCount) { // We have done the wave. m_playState = ePlayState.PLAY_STATE_IN_BETWEEN_WAVES; m_startupTime = waveWait; } else { m_hazardSpawned++; m_spawnTime = spawnWait; SpawnHazard(); } } break; } break; case eGameState.GAME_STATE_GAME_OVER: m_gameOverTime -= Time.deltaTime; if (m_gameOverTime <= 0) { m_state = eGameState.GAME_STATE_SCORE_SCREEN; scoreText.gameObject.SetActive(false); gameOverText.gameObject.SetActive(false); clickToStartText.text = "Click to Restart"; clickToStartText.gameObject.SetActive(true); SaveStatisticsLocally(); } break; case eGameState.GAME_STATE_SCORE_SCREEN: if (Input.GetMouseButtonDown(0)) { StartRound(); } break; } }
void GetReady() { m_gameState = eGameState.GAME_STATE_STARTING_GAME; m_playerProperties["Deaths"] = 0; m_playerProperties["Kills"] = 0; m_playerProperties["IsReady"] = "true"; PhotonNetwork.player.SetCustomProperties(m_playerProperties); }
public void GameOver() { gameOverText.gameObject.SetActive(true); m_state = eGameState.GAME_STATE_GAME_OVER; m_gameOverTime = gameOverWait; }
IEnumerator WaitForReadyPlayers() { bool playersReady = false; while (!playersReady) { PhotonPlayer[] playerList = PhotonNetwork.playerList.OrderBy(x => x.ID).ToArray(); playersReady = true; for (int i = 0; i < m_room.maxPlayers; i++) { if (i < playerList.Length) { if (playerList[i].customProperties["IsReady"] == null) playersReady = false; break; } } yield return new WaitForSeconds(0.5f); } m_gameState = eGameState.GAME_STATE_SPAWN_PLAYERS; }
private void DoSetupCompany() { _CurrentState = eGameState.GAMESTATE_COMPANY; _CompanyDelay = 2.5f; SetScreen("COMPANY"); }
public void setGameState(eGameState i_NewState) { this.m_GameState = i_NewState; }
private void DoNameSetup() { _CurrentState = eGameState.GAMESTATE_NAME; Scores.SetupNameScreen(); SetScreen("NAME"); }
private void DoSetupCredits() { _CurrentState = eGameState.GAMESTATE_CREDITS; _LastState = eGameState.GAMESTATE_TITLE; SetScreen("CREDITS"); _Number.Disable(); }
private void DoSetupTitle() { _CurrentState = eGameState.GAMESTATE_TITLE; //_Number.SetNumber(_LocalHiScore); _Player.Disable(); Scores.ShutdownNameScreen(); _Score = 0; SetScreen("TITLE"); _Scores.GetScoresTable(); Screen.showCursor = true; ClearHUD(); }