public void FinishTutorial() { tutorial.SetActive(false); countdown = -1f; canvasManager.SetTutorialNameCanvasAlpha(0); CurrentGameMode.SetGameMode(CurrentGameMode.GameMode.Normal); }
public void Miss(string type) { if (!isGameOver) { CurrentGameMode.HandleMiss(type); } }
public void Process() { while (State == RoomState.Playing) { if (CurrentGameMode != null && CurrentGameMode.Initilized) { if (!CurrentGameMode.IsGoalReached()) { CurrentGameMode.Process(); if (CurrentGameMode != null && !CurrentGameMode.FreezeTick) { if (LastTick != DateTime.Now.Second) { LastTick = DateTime.Now.Second; UpTick += 1000; DownTick -= 1000; Send((new Packets.GameTick(this)).BuildEncrypted()); } } else { LastTick = -1; } } else { if (CurrentGameMode != null) { EndGame(CurrentGameMode.Winner()); } } } System.Threading.Thread.Sleep(10); } }
public void Cut(string type) { if (!isGameOver) { CurrentGameMode.HandleCut(type); } }
public void DelayStart() { delayStartButton.SetActive(false); delayCancelButton.SetActive(true); selectedGameMode = gameMode.delay; PhotonNetwork.JoinRandomRoom(); currentGameMode = FindObjectOfType <CurrentGameMode>(); }
public void OnLevelWasLoaded(int level) { uLink.Network.isMessageQueueRunning = true; if (networkView.isMine) { CurrentGameMode.ReceiveMapChanged(); } }
public override void Draw(GameTime gameTime) { if (IsVisible) { CurrentGameMode.Draw(_spriteBatch); } base.Draw(gameTime); }
public void LoadTutorialMainScene() { string sceneName = "Main"; Time.timeScale = 1; CurrentGameMode.SetGameMode(CurrentGameMode.GameMode.Tutorial); tutorialVerifier.PlayTutorial(); StartCoroutine(Fade(sceneName)); }
private void SelectedGameInfoChanged(object sender, EventArgs e) { CurrentGameMode gameMode = this.CurrentGameModes.CurrentItem as CurrentGameMode; if (gameMode != null) { this._eventAggregator.GetEvent <GameModeSelectedEvent>().Publish(gameMode.Name); } }
IEnumerator SpawnRoutine() { while (!CurrentGameMode.IsGameOver()) { yield return(new WaitForSeconds(CurrentGameMode.GetDelay())); CurrentGameMode.Update(); } }
private void Awake() { photonView = GetComponent <PhotonView>(); PlayerCharacter[] playersToAdd = FindObjectsOfType <PlayerCharacter>(); foreach (PlayerCharacter player in playersToAdd) { players.Add(player); } currentGameMode = FindObjectOfType <CurrentGameMode>(); }
void Update() { if (CurrentGameMode != null) { if (CurrentGameMode.IsGameOver() && !isGameOver) { onFailPanel.SetActive(true); isGameOver = CurrentGameMode.IsGameOver(); Invoke("ReturnToMenu", 3f); } } }
public void Awake() { if (instance == null) { instance = this; } else { Destroy(instance.gameObject); instance = this; } DontDestroyOnLoad(gameObject);//allows it to persist through levels }
public void HandleExplosives(string[] blocks, Entities.User u) { Player p = null; Players.TryGetValue(u.RoomSlot, out p); if (p != null) { CurrentGameMode.HandleExplosives(blocks, p); } else { u.Disconnect(); // No Player? } }
private void JoinGame() { StopTimer(); CurrentGameMode gameMode = this.CurrentGameModes.CurrentItem as CurrentGameMode; _service.SetCurrentGameMode(gameMode); if (_connexion.AddPlayerToGame(gameMode.Id, _service.GetCurrentPlayer().Id)) { _eventAggregator.GetEvent <ChangeViewMainRegionEvent>().Publish(ViewNames.MainViewGame); } else { _eventAggregator.GetEvent <ChangeViewMainRegionEvent>().Publish(ViewNames.AttenteMenu); } }
// If we are the master client, check if the round finish. // if (PhotonNetwork.isMasterClient) { private void Update() { if (CurrentPhase == GamePhase.RunningGame || CurrentPhase == GamePhase.Preparation) { // See if round finished. if (CurrentGameMode.IsRoundFinished()) { ProcessGamePhase(GamePhase.RoundEnded); } } if (CurrentPhase == GamePhase.ToNextRound) { CurrentGameMode.ToNextRound(); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); Container.Resolve <Background>().GenerateBackground(new[] { Content.Load <Texture2D>("sprites/backgrounds/redsand1") }); Container.Resolve <WallFactory>().CreateWalls(); Background = Container.Resolve <Background>(); GameWorld = Container.Resolve <GameWorld>(); Hud = Container.Resolve <Hud.Hud>(); CurrentGameMode = Container.Resolve <BasicGameMode>(); CurrentGameMode.SetUpForNewGame(); }
private void StartInitialAnimation() { countdown = initialAnimationDuration; audioManager.SetVolume("MusicMainScene", 0.6f); audioManager.PlayWithFade("MusicMainScene", 2f); canvasManager.SetCanvasAlpha(0); canvasManager.PlayInitialLoadingAnimation(); canvasManager.PlayAppearCanvasWithDelay(4f); canvasManager.SetCanvasAfterAnimationWithDelay(4f); if (CurrentGameMode.IsInNormalMode()) { nextAction = NextAction.Interval; } if (CurrentGameMode.IsInTutorialMode()) { nextAction = NextAction.Tutorial; } }
private void InitAllAvailableGameMode() { //Check if we are actually connected to a room if (PhotonNetwork.room == null) { return; } // Clear it so nothing goes wrong. m_GameModeList.Clear(); GameModeManager.GameModes roomSettingGameMode = GameModeManager.GameModes.FreeForAll; // Get current selected game mode form room custom properties. if (RoomProperties.ContantsKey(PhotonNetwork.room, RoomProperties.GameModeIndex)) { roomSettingGameMode = GameModeManager.GetGameModeDetail( (int)PhotonNetwork.room.customProperties[RoomProperties.GameModeIndex]).GameMode; } else { Debug.LogError("Room property key GameModeIndex does not exist."); return; } // Find all the game modes. foreach (var gameMode in GetComponentsInChildren <GameModeBase>()) { // If this game mode script matches currently selected game mode, enable the script. if (gameMode.GetGameMode() == roomSettingGameMode) { CurrentGameMode = gameMode; CurrentGameMode.Setup(true); } // Else disable it. else { gameMode.Setup(false); } // Add available game mode into the list. m_GameModeList.Add(gameMode); } }
/********************** Custom functions **************************/ public void SelectGameMode(string gameMode) { switch (gameMode) { case "GrowthMode": CurrentGameMode = gameObject.AddComponent <GrowthGameMode>(); CurrentGameMode.GameController = this; break; case "TutorialMode": CurrentGameMode = gameObject.AddComponent <TutorialGameMode>(); CurrentGameMode.GameController = this; break; case "ClassicMode": CurrentGameMode = gameObject.AddComponent <ClassicGameMode>(); CurrentGameMode.GameController = this; break; case "MiniMode": CurrentGameMode = gameObject.AddComponent <MiniGameMode>(); CurrentGameMode.GameController = this; break; case "PeriodicMode": CurrentGameMode = gameObject.AddComponent <PeriodicGameMode>(); CurrentGameMode.GameController = this; break; default: throw new System.ArgumentException("Mode is " + gameMode); } GlobalData.Instance.GameMode = gameMode; CurrentGameMode.ScoreChangedEvent += UpdateScoreText; InitializeGameBoard(); InitializePieceLayouts(); InitializeUI(); CurrentGameMode.Initialize(PieceLayouts); StartCoroutine(CurrentGameMode.StartGame(gameStartDelay)); }
public void LoadNormalMainScene() { string sceneName = "Main"; Time.timeScale = 1; CurrentGameMode.SetGameMode(CurrentGameMode.GameMode.Normal); if (tutorialVerifier.GetPlayedTutorial() == true) { StartCoroutine(Fade(sceneName)); } else if (playGame == false) { tutorialVerifier.AppearTutorialCanvas(); playGame = true; } else { StartCoroutine(Fade(sceneName)); } }
private void InitializeNewScene() { // Init scene camera. if (!SceneCamera) { SceneCamera = GetComponentInChildren <Camera>(); } EnableSceneCamera(true); // Initialize all available game modes. InitAllAvailableGameMode(); InitAllUI(); // After initiating the current selected game mode, // start a new round. CurrentGameMode.StartNewRound(PhotonNetwork.room); // Instantiate local player character game object. InitLocalPlayer(); }
internal IEnumerator ResolveBoardChange(float blockDestructionDelay) { yield return(StartCoroutine(CurrentGameMode.ClearBoard(blockDestructionDelay))); if (!processNextMove) { StartCoroutine(ResolveBoardChange(blockDestructionDelay)); processNextMove = true; yield break; } if (CurrentGameMode.IsGameOver()) { this.DestroyAll(currentPiece.gameObject); //gameOverText.Text = "Game Over\r\n"; if (FB.IsLoggedIn) { //Try to save high score var result = PersistentUtility.Instance.SaveHighScore(CurrentGameMode); } //Send playthrough information to server var scoreParse = new ParseObject("Score"); scoreParse["score"] = currentGameMode.Score; scoreParse["player"] = GlobalData.Instance.playerName; scoreParse["facebookUserID"] = GlobalData.Instance.playerFacebookID; scoreParse["gameVersion"] = GlobalData.Instance.version; scoreParse["gameMode"] = currentGameMode.ModeName; scoreParse["squaresCleared"] = currentGameMode.SquaresCleared; scoreParse["blocksCleared"] = currentGameMode.BlocksCleared; scoreParse["piecesPlaced"] = currentGameMode.PiecesPlaced; scoreParse["levelReached"] = currentGameMode.Level; scoreParse["maxChain"] = currentGameMode.MaxChain; scoreParse["maxCombo"] = currentGameMode.MaxCombo; scoreParse["totalChains"] = currentGameMode.TotalChains; scoreParse["totalCombos"] = currentGameMode.TotalCombos; scoreParse["timePlayed"] = currentGameMode.TimePlayed; scoreParse["hintsUsed"] = currentGameMode.HintsUsed; if (currentGameMode.ModeName == "PeriodicMode") { scoreParse["seedUsed"] = GlobalData.Instance.periodicModeSeed; scoreParse["rawSeedUsed"] = GlobalData.Instance.rawSeed; } scoreParse.SaveAsync(); GlobalData.Instance.GameStats = scoreParse; //gameOverText.PlayAnimation(); GameUIController.Instance.noMoreMovesMessage.GetComponents <dfTweenGroup>().Single(tg => tg.TweenName == "TweenCombined").Play(); GameUIController.Instance.gameOverMessage.GetComponents <dfTweenVector3>().Single(t => t.TweenName == "TweenIn").Play(); GameOver = true; waitUntilGameOverDismissal = 1.25f; } else { CurrentGameMode.UserHasPlayed = true; if (currentPiece.gameObject.activeSelf) { LayoutDTO nextPieceInfo = CurrentGameMode.GetNextPiece(); if (nextPieceInfo.Variant == Block.TOTAL_VARIANTS + 1) { GameUIController.Instance.NoMoreMovesTweenAlone.Play(); CurrentPiece.gameObject.SetActive(false); } if (nextPieceInfo != null) { CurrentPiece.InitPiece(nextPieceInfo.Layout, nextPieceInfo.Variant); } else { this.DestroyAll(CurrentPiece.gameObject); } } } }
private void Awake() { scoreBoard = GameObject.Find("ScoreBoard");//gets the scoreboard currentGameMode = FindObjectOfType <CurrentGameMode>(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { FilteredInputListener.Update(gameTime); if (GameState != GameStates.Paused) { if (FilteredInputListener.WasKeyPressed(Keys.Escape)) { GameState = GameStates.Paused; FilteredInputListener.ResetKey(Keys.Escape); } if (GameState == GameStates.Normal) { var modeState = CurrentGameMode.Update(gameTime); PhysicsWorld.Step(1.0f / 120.0f, 1, 1); if (Player.LivesRemaining <= 0) { Exit(); } if (modeState != GameModeStatus.Continue) { LastRespawnTime = gameTime.TotalGameTime; GameState = GameStates.WaitingForRespawn; } } else if (GameState == GameStates.WaitingForRespawn) { var timeWaited = gameTime.TotalGameTime - LastRespawnTime; if (timeWaited >= RespawnWaitTime) { GameState = GameStates.Normal; Player.Reset(); CurrentGameMode.Spawn(); } } base.Update(gameTime); } else { if (FilteredInputListener.WasKeyPressed(Keys.Escape)) { GameState = GameStates.Normal; FilteredInputListener.ResetKey(Keys.Escape); } else { var menuResult = CurrentMenu.Update(gameTime); if (menuResult != null) { if (menuResult.Action == MenuAction.Navigate) { CurrentMenu = Container.Resolve <MenuFactory>().Get(menuResult.NextMenuName); } else if (menuResult.Action == MenuAction.NewGame) { Player.SetUpForNewGame(); CurrentGameMode.SetUpForNewGame(); } else if (menuResult.Action == MenuAction.QuitGame) { GameWorld.SetUpForNewGame(); Exit(); } } } } }
public void SetCurrentGameMode(CurrentGameMode gameMode) { _gameMode = gameMode; }
public void SetCurrentGameMode(int id, string name) { _gameMode = new CurrentGameMode(id, name); }
private void InitGame() { CurrentGameMode.Init(ObjectSpawner); }
public string GetGameState() { return(CurrentGameMode.GetGameState()); }
private void ReturnToMenu() { isGameOver = false; CurrentGameMode.Init(ObjectSpawner); SceneManager.LoadScene(0); }