public ProjectileController(Vector2 direction, float speed, GameplayState gs, int dmg) { _velocity = direction; _velocity.Normalize(); _velocity *= speed; _gs = gs; }
/// <summary> /// Coroutine to replace the standard GameplayState start round coroutine. /// </summary> private IEnumerator StartGameplay() { GameplayState gameplayState = SceneManager.Instance.GameplayState; gameplayState.StopAllCoroutines(); yield return(new WaitForSeconds(2.0f)); gameplayState.Room.ActivateCeilingLights(); GameplayState.OnLightsOnEvent?.Invoke(); if ((KTInputManager.Instance.GetCurrentSelectable() == null || KTInputManager.Instance.GetCurrentSelectable().Parent == KTInputManager.Instance.RootSelectable) && !KTInputManager.Instance.IsMotionControlMode()) { KTInputManager.Instance.SelectRootDefault(); } if (KTInputManager.Instance.IsMotionControlMode()) { KTInputManager.Instance.SelectableManager.EnableMotionControls(); } yield return(new WaitForSeconds(1.0f)); GetNextBomb(); PropertyInfo roundStartedProperty = typeof(GameplayState).GetProperty("RoundStarted", BindingFlags.Instance | BindingFlags.Public); roundStartedProperty.SetValue(gameplayState, true, null); FieldInfo paceMakerField = typeof(GameplayState).GetField("paceMaker", BindingFlags.Instance | BindingFlags.NonPublic); ((PaceMaker)paceMakerField.GetValue(gameplayState)).StartRound(gameplayState.Mission); }
public void SetGameplayState(int newState, double stateStartTime) { GameplayStateType NewState = (GameplayStateType)newState; switch (NewState) { case GameplayStateType.waiting: m_CurrentState = new GameplayState_waiting(this, stateStartTime); break; case GameplayStateType.countdown: m_CurrentState = new GameplayState_countdown(this, stateStartTime); break; case GameplayStateType.battle: m_CurrentState = new GameplayState_battle(this, stateStartTime); break; case GameplayStateType.ending: m_CurrentState = new GameplayState_ending(this, stateStartTime); break; default: break; } m_CurrentState.Init(); }
public void GetPauseHit() { if (mGameplayState != GameplayState.PAUSED) { mGameplayState = GameplayState.PAUSED; } }
/// <summary> /// /// </summary> /// <param name="oldState"></param> private static void OnStateChanged(GameplayState oldState) { switch (_state) { case GameplayState.GameRunning: Time.timeScale = 1.0f; break; case GameplayState.Cutscene: Time.timeScale = 0.0f; break; case GameplayState.GamePaused: TweenExtensions.SetCutscenesActive(false); AnimatorExtensions.SetCutscenesPlaying(false); AudioExtensions.SetGameplayLoopingPlaying(false); Time.timeScale = 0.0f; break; } if (oldState == GameplayState.GamePaused && oldState != _state) { TweenExtensions.SetCutscenesActive(true); AnimatorExtensions.SetCutscenesPlaying(true); AudioExtensions.SetGameplayLoopingPlaying(true); } }
public void Start() { if (GameplayState.CurrentState == GameplayState.StateType.GAME_OVER) { titleLabel.text = "GAME OVER"; musicAudioSource.clip = gameOverMusic; } else { titleLabel.text = "VICTORY"; musicAudioSource.clip = victoryMusic; } musicAudioSource.Play(); rescuedHostagesLabel.text = GameplayState.RescuedHostages.ToString(); killedEnemiesLabel.text = GameplayState.KilledEnemies.ToString(); float precisionAsPercent = GameplayState.GetShootPrecision() * 100.0f; shootPrecisionLabel.text = precisionAsPercent.ToString("F"); totalShootsLabel.text = GameplayState.TotalShoots.ToString(); mainMenuButton.onClick.AddListener(MainMenu); replayButton.onClick.AddListener(Replay); Cursor.visible = true; Cursor.lockState = CursorLockMode.None; }
private static Entity EnemyEntity(GameplayState gs, Enemy enemy) => enemy.Type.Match( star: () => { var e = new Entity(); e.Transform.Position = enemy.Position + new Vector2(64, 64); e.AddComponent(new SpriteRenderer("StarEnemy") { Layer = "Enemies" }); e.AddComponent(new EnemyController(gs, enemy)); e.AddComponent(new ProjectileSpawner(gs, new SequencedCircularProjectileSpawnerStrategy(12, gs.Random.Next(3000), 200, 10000), (pos, dir) => { var proj = new Entity(); proj.Transform.Position = pos; proj.AddComponent(new SpriteRenderer("StarEnemy_Shot") { Layer = "Projectiles" }); proj.AddComponent(new ProjectileController(dir, 0.3f, gs, 10)); return(proj); } )); return(e); } );
static void Prefix(GameplayState new_state) { if (new_state != GameplayState.PLAYING) { RearView.Pause(); } else if (new_state == GameplayState.PLAYING) { bool want = !NetworkManager.IsHeadless() && RearView.MPNetworkMatchEnabled && NetworkMatch.m_client_server_location != null && NetworkMatch.m_client_server_location.StartsWith("OLMOD ") && !GameManager.m_local_player.m_spectator; if (want != RearView.Enabled) { RearView.Enabled = want; if (RearView.Enabled) { RearView.Init(); } else { RearView.Pause(); } } } }
public void ChangeState(GameplayState newState) { titleScreen.Hide(); tutorialScreen.Hide(); gameplayScreen.Hide(); gameEndScreen.Hide(); switch (newState) { case GameplayState.Title: titleScreen.Show(); break; case GameplayState.Tutorial: tutorialScreen.Show(); break; case GameplayState.Gameplay: gameplayScreen.Show(); GameStart(); break; case GameplayState.GameEnd: gameEndScreen.Show(); GameEnd(); break; default: break; } gameplayState = newState; }
private static Entity InanimateEntity(GameplayState gs, Inanimate inanimate) => inanimate.Type.Match( vase: () => { var e = new Entity(); e.AddComponent(new SpriteRenderer("Vase") { Layer = "Inanimates" }); e.AddComponent(new InanimateController(gs, inanimate)); e.Transform.Position = inanimate.Position + new Vector2(64, 64); return(e); }, sacrificialFirePit: () => { var e = new Entity(); e.AddComponent(new SpriteRenderer("SacrificialFirePit") { Layer = "Inanimates" }); e.AddComponent(new SacrificePitController(gs)); e.Transform.Position = inanimate.Position + new Vector2(128, 128); return(e); } );
public void Fail() { if (Mode == GameplayMode.StaticLevel) { //Statistik string command = "{"; command += "action:PlAY_LEVEL"; command += ",place:" + dataStaticLevel.Place; command += ",level:" + dataStaticLevel.Level; command += ",timePlaying:" + TimePlaying.ToString();; command += ",status:4_FAILED"; command += "}"; ServerStatistic.DoRequest(command); failedPopupController.ShowForPlayingStaticLevel(FailCallback); } else if (Mode == GameplayMode.Edited) { failedPopupController.ShowForPlayingEditedLevel(FailCallback); } else if (Mode == GameplayMode.ValidateLevel) { failedPopupController.ShowForValidateLevel(FailCallback); } State = GameplayState.Failed; }
private void RefreshBubble(List <Gelembung> daftarGelembung) { foreach (Gelembung gelembung in daftarGelembung) { for (int i = 0; i < Bubbles.Length; i++) { if (gelembung.PackageName == Bubbles[i].PackageName) { if (gelembung.Type == BubbleType.White) { GameObject objek = (GameObject)Instantiate(Bubbles[i].WhitePreview); objek.transform.SetParent(ParentObject.BubblePreview.transform); objek.transform.localScale = new Vector3(1, 1, 1); objek.GetComponent <RectTransform>().localPosition = new Vector3(objek.GetComponent <RectTransform>().localPosition.x, objek.GetComponent <RectTransform>().localPosition.y, 0); } else if (gelembung.Type == BubbleType.Red) { GameObject objek = (GameObject)Instantiate(Bubbles[i].RedPreview); objek.transform.SetParent(ParentObject.BubblePreview.transform); objek.transform.localScale = new Vector3(1, 1, 1); objek.GetComponent <RectTransform>().localPosition = new Vector3(objek.GetComponent <RectTransform>().localPosition.x, objek.GetComponent <RectTransform>().localPosition.y, 0); } else if (gelembung.Type == BubbleType.Orange) { GameObject objek = (GameObject)Instantiate(Bubbles[i].OrangePreview); objek.transform.SetParent(ParentObject.BubblePreview.transform); objek.transform.localScale = new Vector3(1, 1, 1); objek.GetComponent <RectTransform>().localPosition = new Vector3(objek.GetComponent <RectTransform>().localPosition.x, objek.GetComponent <RectTransform>().localPosition.y, 0); } } } } State = GameplayState.Playing; }
/// <summary> /// functions to defining how changing the gameplay state /// </summary> /// public void changeToAState(GameplayState toState) { switch (toState) { case GameplayState.Tutorial: toTutorial(); break; case GameplayState.AssemblyDisassembly: toAssemblyDisassembly(); break; case GameplayState.AssemblyDisassemblyTutorial: toAssemblyDisassemblyTutorial(); break; case GameplayState.Shooting: toSooting(); break; case GameplayState.Testing: toTesting(); break; case GameplayState.Pause: pauseGame(); break; default: break; } }
public void ShowDialog(bool value, GameplayState gameplayState = GameplayState.Starting) { GameDialog.SetActive(value); if (value) { switch (gameplayState) { case GameplayState.Finished: Title.text = "Congrats!"; Info.text = "You've completed the level!"; RetryButton.SetActive(false); ContinueButton.SetActive(true); break; case GameplayState.Failed: default: Title.text = "Too bad!"; Info.text = "You lost..."; RetryButton.SetActive(true); ContinueButton.SetActive(true); break; } } }
public override void Update(GameTime gameTime) { base.Update(gameTime); while (brain.CurrentState == MoveToTarget) { brain.PopState(); } Animation.Location = new Vector2(Position.X, Position.Y + (Animation.Scale * 256) / 2); Animation.Update(gameTime); spits.ForEach(p => p.Update(gameTime)); GameplayState gameplay = Game.Instance.GameStateManager.States .FirstOrDefault(s => s is GameplayState) as GameplayState; if (gameplay.Players.Length == 0 && brain.CurrentState != GoHome) { while (brain.HasStates) { brain.PopState(); } brain.PushState(GoHome); } if (!Health.Alive) { Destory(); } }
void Start() { pauseState = new PauseState(); gameplayState = new GameplayState(); gameplayState.EnterState(); currentState = gameplayState; }
public void ShowDialog(bool value, GameplayState gameplayState = GameplayState.Planning) { GameDialog.SetActive(value); if (value) { switch (gameplayState) { case GameplayState.Finished: Title.text = "Congrats!"; Info.text = "You've completed the level!"; RetryButton.SetActive(false); ContinueButton.SetActive(true); break; case GameplayState.FallenOver: Title.text = "Too bad!"; Info.text = "Snake fell over..."; RetryButton.SetActive(true); ContinueButton.SetActive(false); break; case GameplayState.OutOfEnergy: default: Title.text = "Almost there!"; Info.text = "Ran out of Energy..."; RetryButton.SetActive(true); ContinueButton.SetActive(false); break; } } }
/// <summary> /// Handles the logic for clearing the lines and updating the score and level. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> private void HandleLinesClearingState(GameTime gameTime) { List <int[]> clearedLines = field.ClearLines(); int linesClearedCount = clearedLines.Count; if (linesClearedCount > 0) { if (linesClearedCount == 4) { linesClearedDelta -= 8; AudioHelper.PlaySound("Tetris!"); } else { linesClearedDelta -= linesClearedCount; AudioHelper.PlaySound("LineClear"); } } if (linesClearedDelta <= 0) { LevelUp(); } score += linesClearedCount * (level + 1) * 100; usedHold = false; currentGameplayState = GameplayState.InitializeTetromino; }
private void load(GameplayState gameplayState) { if (gameplayState != null) { ((IBindable <JudgementResult>)LastResult).BindTo(gameplayState.LastJudgementResult); } }
/// <summary> /// Unity event. /// </summary> private void Start() { GameplayState gameplayState = SceneManager.Instance.GameplayState; RoomSelectable = gameplayState.Room.GetComponent <Selectable>(); InvoiceData.ClearData(); Mission mission = null; if (GameplayState.MissionToLoad == ModMission.CUSTOM_MISSION_ID) { mission = GameplayState.CustomMission; } else { mission = MissionManager.Instance.GetMission(GameplayState.MissionToLoad); } InvoiceData.MissionName = mission?.DisplayName; if (string.IsNullOrEmpty(InvoiceData.MissionName)) { InvoiceData.MissionName = "Free Play"; } FactoryGameModePicker.GameMode gameModeEnum; GameMode = FactoryGameModePicker.CreateGameMode(GameplayState.MissionToLoad, gameObject, out gameModeEnum); InvoiceData.GameMode = gameModeEnum; QuickDelay(() => GameMode.Setup(this)); OnLightChange(false); }
public HUD(GameplayState parentState) { this.parentState = parentState; dialogueBox = new DialogueBox(this, "", ""); dialogueBox.PaddingLeft = 128; dialogueBox.PaddingTop = 5f; }
private void HandleNewState(GameplayState handleState) { switch (playState) { case GameplayState.START: // Hide pause text if (pauseText) { pauseText.gameObject.SetActive(false); } break; case GameplayState.PLAYING: if (pauseText) { pauseText.gameObject.SetActive(false); } break; case GameplayState.PAUSE: // Show pause text if(pauseText) { pauseText.gameObject.SetActive(true); } break; case GameplayState.END: // Game is over, so if win GO isn't active, then the player lost. // If that's the case, activate the lose GO if (!winText.activeInHierarchy) { loseText.gameObject.SetActive(true); } // Should probably add in a reset button at some point break; } }
// Use this for initialization void Start() { mMapNames.Add("Maps/map_one"); mMapNames.Add("Maps/map_two"); mMapNames.Add("Maps/map_three"); mSelectionMenu = new SelectionMenu(); mGameplayState = new GameplayState(); SetupWorld(); SetupPlayerSpawns(); mSpawningPlayers = false; mGameplay = true; WHATEVER = GameObject.FindGameObjectWithTag("MenuScene"); MenuHandler mh = WHATEVER.GetComponent <MenuHandler>(); mGameplayState.Start(mh.mTankNames, mSpawnPositions); Destroy(WHATEVER); GameObject musicGO = (GameObject)Instantiate(Resources.Load("gameplay_music")); mAudioSources = musicGO.GetComponents <AudioSource>(); song = Random.Range(0, 3); mAudioSources[song].Play(); }
/// <summary> /// Reset the game state to its default values /// </summary> public static void ResetGameState() { BeatsPerMinute = 220; Score = 0; Lives = 3; CurrentGameplayState = GameplayState.MainMenu; }
public void Attack(GameObject target) { //target.GetComponent<Player>().position.GetComponent<Node>().Occupant = null; //target.GetComponent<Player>().position.GetComponent<Node>().ContainsEntity = false; int atkRoll = rand.Next(1, 21); //gMan.GetComponent<GameManager>().DebugText.GetComponent<Text>().text = "Attack Roll: " + atkRoll; //Destroy(target); if (/*rand.Next(1, 21)*/ atkRoll >= target.GetComponent <Player>().defense) { target.GetComponent <Player>().TakeDamage(rand.Next(1, aClass.dmgDie + 1)); } //targetListUI.GetComponent<PopulateList>().ClearList(); FindTargets(gMan.GetComponent <Graph>()); currentAttacks--; gMan.GetComponent <GameManager>().ActiveMainMenu(); gMan.GetComponent <GameManager>().targetMenu.SetActive(false); playState = GameplayState.none; }
public StartGameCommandHandler(GameStateMachine gameStateMachine, GameplayState gameplayState, MainMenuState mainMenuState) { _gameStateMachine = gameStateMachine; _gameplayState = gameplayState; _mainMenuState = mainMenuState; }
public void Populate(GameplayState gs) { var seChance = _intensity < 4 ? 20 : _intensity < 8 ? 30 : _intensity < 12 ? 50 : 100; var spawnGroups = Flatten(Tilemap) .GroupBy(t => (t.Tag as TileTag).SpawnGroup) .Where(t => t.Key != 0); foreach (var spawnGroup in spawnGroups) { var si = gs.Random.Next(100) < 20; var se = gs.Random.Next(100) < seChance; if (!spawnGroup.Any()) { continue; } var tileQueue = new Queue <Tile>(spawnGroup.OrderBy(sg => gs.Random.Next(100))); if (si) { var tile = tileQueue.Dequeue(); _inanimates.Add(new Inanimate(tile.Bounds.Location.ToVector2(), InanimateType.Vase, gs)); } if (se && tileQueue.Count() > 0) { var tile = tileQueue.Dequeue(); _enemies.Add(new Enemy(tile.Bounds.Location.ToVector2(), EnemyType.StarEnemy, gs)); } } }
public TestSceneGameplayCursor() { var ruleset = new OsuRuleset(); gameplayState = new GameplayState(CreateBeatmap(ruleset.RulesetInfo), ruleset, Array.Empty <Mod>()); AddStep("change background colour", () => { background?.Expire(); Add(background = new Box { RelativeSizeAxes = Axes.Both, Depth = float.MaxValue, Colour = new Colour4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1) }); }); AddSliderStep("circle size", 0f, 10f, 0f, val => { config.SetValue(OsuSetting.AutoCursorSize, true); gameplayState.Beatmap.Difficulty.CircleSize = val; Scheduler.AddOnce(loadContent); }); AddStep("test cursor container", () => loadContent(false)); }
/// <summary> /// Unity event. /// </summary> private void Start() { GameplayState gameplayState = SceneManager.Instance.GameplayState; RoomSelectable = gameplayState.Room.GetComponent <Selectable>(); InvoiceData.ClearData(); Mission mission = gameplayState.Mission; InvoiceData.MissionName = mission != null?Localization.GetLocalizedString(mission.DisplayNameTerm != "Freeplay"?mission.DisplayNameTerm : "Missions/freeplay_DisplayName") : null; FactoryGameModePicker.GameMode gameModeEnum; GameMode = FactoryGameModePicker.CreateGameMode(GameplayState.MissionToLoad, gameObject, out gameModeEnum); InvoiceData.GameMode = gameModeEnum; QuickDelay(() => GameMode.Setup(this)); OnLightChange(false); KMModSettings modSettings = GetComponent <KMModSettings>(); ModSettings activeModSettings = JsonConvert.DeserializeObject <ModSettings>(modSettings.Settings); GetComponent <SpoopyScares>().enabled = activeModSettings.halloweenEvent; }
// Загрузка уровня public override void OnStart(Action callback) { PoolManager.SpawnObject(Resources.Load(starsSkyPath) as GameObject); loadingLevelPanel = UiManager.EnablePanel <LoadedLevelPanel>(); loadingLevelPanel.StatusText.text = StringKeys.Loading; gameplayState = DI.Resolve <GameplayState>(); gameplayState.LevelMusic = LevelsManager.Instance.Levels[loadingLevelIndex].music; gameplayState.Player = new Player(); gameplayState.Player.Init(selectedShip, gameplayState.Lose); gameplayState.EnemyManager = new EnemyManager(); gameplayState.EnemyManager.Init(LevelsManager.Instance.Levels[loadingLevelIndex].LevelData.levelObjects.ToArray()); gameplayState.BackgoundPrefab = LevelsManager.Instance.Levels[loadingLevelIndex].Background; backgroundPanel = UiManager.EnablePanel <BackgroundPanel>(); backgroundPanel.SetImage(Resources.Load <Sprite>(backgroundPanelPath)); loadingLevelPanel.StatusText.text = StringKeys.PressToStart; MonoBehaviourTools.Instance.StartCor(StartGame()); callback?.Invoke(); }
public GameManager(GameplayState gameplayState, PauseState pauseState, LobbyState lobbyState, EndgameState endgameState) { _gameplayState = gameplayState; _pauseState = pauseState; _lobbyState = lobbyState; _endgameState = endgameState; }
// Use this for initialization void Start () { // Initialise base state CurrentStateType = GameplayStateType.waiting; m_NextStateType = GameplayStateType.waiting; m_CurrentState = new GameplayState_waiting(this , PhotonNetwork.time); m_CurrentState.Init(); }
public void SetGameState(GameplayState newState) { playState = newState; HandleNewState(newState); }
void Start() { gameplayState = null; }
void Update() { gameplayState = SceneManager.Instance.GameplayState; ProcessInput(); if (gameplayState == null) return; }