public void RestartGame() { Time.timeScale = 1; //Call the Level loader and load the first level levelChangeEvent.Raise(startLevelName); }
public override IEnumerator Perform(params GameObject[] target) { // TODO: Should be for loop speechEvent.Raise("3.."); stamina.SetValue(25); yield return(Wait()); speechEvent.Raise("2.."); stamina.SetValue(50); yield return(Wait()); speechEvent.Raise("1.."); stamina.SetValue(75); attack.Move(curve.Val, WaitTime); yield return(Wait()); speechEvent.Raise(""); target[0].GetComponent <PlayerHealth>().Damage(Power); stamina.SetValue(100); yield return(Wait()); }
IEnumerator RunTimer( int timeout, StringEvent bannerEvent, System.Func <bool> conditionPredicate ) { bool showTimeSplit = (timeout > 60); var startTime = Time.fixedTime; var lastTick = timeout; timerTick = lastTick; if (debug) { Debug.Log("Tick: " + lastTick); } if (bannerEvent != null) { bannerEvent.Raise(FmtTimerMsg(showTimeSplit, lastTick)); } var currentDelta = Time.fixedTime - startTime; while (conditionPredicate() && (currentDelta < (float)timeout)) { var currentTick = timeout - Mathf.FloorToInt(currentDelta); if (currentTick != lastTick) { lastTick = currentTick; timerTick = lastTick; if (debug) { Debug.Log("Tick: " + lastTick); } if (bannerEvent != null) { bannerEvent.Raise(FmtTimerMsg(showTimeSplit, lastTick)); } } // wait until next frame; yield return(null); currentDelta = Time.fixedTime - startTime; } // don't show last tick if condition was hit if (conditionPredicate()) { lastTick = 0; timerTick = lastTick; if (bannerEvent != null) { bannerEvent.Raise(FmtTimerMsg(showTimeSplit, lastTick)); } if (debug) { Debug.Log("Tick: " + lastTick); } } }
//Manages setting the item hover text on the hotbar private void ToggleHotbarItemText() { if (SlotItem != null) { showItemNameEvent.Raise(SlotItem.ItemName); } else { showItemNameEvent.Raise(""); } }
private void NetworkHandlerOnOnStringMessageReceived(string message) { if (stringMessageReceiver != null) { stringMessageReceiver.Raise(message); } }
IEnumerator StateCountdown() { if (debug) { Debug.Log("StateCountdown"); } yield return(null); // enable overview camera mode if (cameraController != null) { cameraController.WatchOverview(); } // wait for countdown timer yield return(StartCoroutine(RunTimer(countdownTicks, bannerFade, () => (!Input.GetKeyUp(KeyCode.Escape))))); if (bannerFade != null) { bannerFade.Raise("Start!"); } // TRANSITION: Play StartCoroutine(StatePlay()); }
public override void OnInspectorGUI() { StringEvent script = (StringEvent)target; //Event Description GUILayout.BeginVertical(); EditorGUILayout.LabelField("Event Description", EditorStyles.centeredGreyMiniLabel); EditorStyles.textField.wordWrap = true; script.EventDescription = EditorGUILayout.TextArea(script.EventDescription, GUILayout.MinHeight(100)); GUILayout.EndVertical(); //Test Event Button GUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Test Event", EditorStyles.centeredGreyMiniLabel); value = EditorGUILayout.TextField("Value ", value); if (GUILayout.Button("Raise")) { if (Application.isPlaying) { script.Raise(value); } } GUILayout.EndVertical(); }
void GemComplete(int gems) { GemEvent.Raise(gems.ToString()); GemEventWalked.Raise(ThisCellObject.Steps.ToString()); ThisCellObject.Gems = ThisCellObject.Gems + gems; HasWalkedEvent.Raise(); }
private void OnTriggerEnter2D(Collider2D targetCollider) { Interactable target = targetCollider.gameObject.GetComponent <Interactable>(); // Make sure target is interactable and isn't already in list if (target != null && !targetsInRange.Contains(target)) { targetsInRange.Add(target); // Set target as currentTarget if we don't already have one if (currentTarget == null) { SetTarget(target); updateContextClueBubble.Raise(currentTarget.interactionType); } } }
public void QuitToMenu(string menuLevelName) { //Set the timescale to 1 Time.timeScale = 1; //Fade to the menu scene levelChangeEvent.Raise(menuLevelName); }
private void RaiseKeyEvent(KeyCode key) { if (key != KeyCode.None && keys.Contains(key.ToString())) { keyPressEvent.Raise(key.ToString()); Debug.Log("Raised event with key " + key.ToString()); } }
private void OnTriggerEnter(Collider other) { //Check if it was the player who interacted with the if (other.CompareTag("Player")) { //Call an event to load the next level nextLevelEvent.Raise(nextLevelName); } }
public void OnPlayerCreate() { if (playerNameInput != null) { // validation: check for empty name if (playerNameInput.text == "") { return; } // Hide panel Hide(); // raise event for player selected var name = playerNameInput.text; if (playerSelected != null) { playerSelected.Raise(name); } } }
void Update() { #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.F1)) { onFinalSpeechResult.Raise("Broadcasting NO.1..."); Debug.Log("Sent speech msg."); } if (Input.GetKeyDown(KeyCode.F2)) { onFinalSpeechResult.Raise("Broadcasting NO.2..."); Debug.Log("Sent speech msg."); } if (Input.GetKeyDown(KeyCode.F3)) { onFinalSpeechResult.Raise("Broadcasting NO.3.."); Debug.Log("Sent speech msg."); } #endif }
void UpdateScore(int value) { if (debug) { Debug.Log("update score: " + value + " new score: " + (score + value)); } score += value; if (scoreBanner != null) { scoreBanner.Raise(score.ToString()); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); _invokeValue = EditorGUILayout.TextField("Invoke value", _invokeValue); var buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.fontSize = 32; if (GUILayout.Button("Raise", buttonStyle, _buttonHeight)) { _target.Raise(_invokeValue); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUI.enabled = Application.isPlaying; StringEvent e = target as StringEvent; if (GUILayout.Button("Raise")) { e.Raise(e.testRaiseData); } }
public void Activate(ItemSlot itemSlot, int slotIndex) { this.slotIndex = slotIndex; n = itemSlot.item.Name; confirmText.text = $"n!"; gameObject.SetActive(true); //to do //seperate the logic if we're in combat or not. attacking.Raise(n); turnoff.Raise(); }
private IEnumerator Act() { while (!Health.GetHP().IsEmpty()) { int i = Random.Range(0, actions.Count - 1); Action action = actions[i]; yield return(action.Perform(targetObject)); } //TODO: Die animation promptEvent.Raise("Judgement died violently."); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUI.enabled = Application.isPlaying; stringToEdit = GUILayout.TextArea(stringToEdit, 200); StringEvent e = target as StringEvent; if (GUILayout.Button("Raise")) { Debug.Log("stringToEdit: " + stringToEdit); e.Raise(stringToEdit); } }
IEnumerator StateAnnouncer() { if (debug) { Debug.Log("StateAnnouncer"); } // start announcer music if (announcerTrack != null) { announcerTrack.Play(AudioManager.GetInstance().GetEmitter(gameObject, announcerTrack)); } // enable announcer camera mode if (cameraController != null) { cameraController.WatchAnnouncer(); } if (bannerFade != null) { bannerMessage.Raise("ANNOUNCER INTRO - ESC TO EXIT"); } // FIXME: remove announcer timer yield return(StartCoroutine(RunTimer(5, null, () => (!Input.GetKeyUp(KeyCode.Escape))))); // TODO: add announcer voiceover mechanics/state if (announcerTrack != null) { announcerTrack.Stop(AudioManager.GetInstance().GetEmitter(gameObject, announcerTrack)); } // TRANSITION: Countdown StartCoroutine(StateCountdown()); }
public void NextMatch() { if (CurrentGameReference.Value.NextMatch() != null) { Match match = CurrentGameReference.Value.NextMatch(); CurrentGameReference.Value.CurrentMatch = match; CurrentMatchReference.Value = match; OnReloadScene.Raise(Properties.Scenes.Game); } else { OnUnloadScene.Raise(Properties.Scenes.Game); OnLoadScene.Raise(Properties.Scenes.Menu); } }
private void Timer() { if (HasGameStarted.Value) { CurrentTime.Value -= Time.deltaTime; if (CurrentTime.Value <= 0) { HasGameStarted.Value = false; Debug.Log("End Game"); InitializeScoreList(); CurrentTime.Value = StartingTime; DisplayScore.Raise(PlayersEntities.Count); OnLoadScene.Raise(MenuScene); OnUnloadScene.Raise(GameScene); } } }
private void OnLoginFailure(PlayFabError error) { isLoggedIn = false; error.GenerateErrorReport(); string errorMessage = string.Empty; switch (error.Error) { // Recognize and handle the error case PlayFabErrorCode.InvalidTitleId: // Handle invalid title id error errorMessage = "User already logged in"; break; case PlayFabErrorCode.AccountNotFound: // Handle account not found error errorMessage = "Email address not found, Do you need to register for an account?"; break; case PlayFabErrorCode.InvalidEmailOrPassword: // Handle invalid email or password error errorMessage = "Email address or Password is incorrect"; break; case PlayFabErrorCode.RequestViewConstraintParamsNotAllowed: // Handle not allowed view params error errorMessage = "Invalid login parameters"; break; default: // Handle unexpected error break; } // Show error message onLoginFail.Invoke(errorMessage); if (onSOLoginFail != null) { onSOLoginFail.Raise(errorMessage); } }
public void StartGame(string levelName) { //Load the given level levelChangeEvent.Raise(levelName); }
IEnumerator StateFinish() { if (debug) { Debug.Log("StateFinish"); } // notify channel if (gameEventChannel != null) { gameEventChannel.Raise(GameRecord.GameFinished()); } // declare game over if (bannerMessage != null) { bannerMessage.Raise("Game Over!!!"); } yield return(null); // disable bots for (var i = allBots.Items.Count - 1; i >= 0; i--) { allBots.Items[i].GetComponent <BotBrain>().DisableControls(); } // stop match music if (gameInfo.matchInfo.matchMusicTrack != null) { gameInfo.matchInfo.matchMusicTrack.Stop(AudioManager.GetInstance().GetEmitter(gameObject, gameInfo.matchInfo.matchMusicTrack)); } // add win/loss for player if (winningBot == spawnedPlayer) { // create score for win var scoreInfo = new MatchScoreInfo(); scoreInfo.matchID = gameInfo.matchInfo.id; scoreInfo.time = timerTick; scoreInfo.score = scoreKeeper.GetScore(); gameInfo.playerInfo.AddWin(scoreInfo); // update scoreboard var json = JsonStore.Load(JsonStore.SaveTag.Score, gameInfo.matchInfo.id); var scoreboard = MatchScoreboard.FromJson(json); if (scoreboard == null) { scoreboard = new MatchScoreboard(gameInfo.matchInfo.id); } scoreboard.AddScore(gameInfo.playerInfo.name, scoreInfo.score, scoreInfo.time); } else { gameInfo.playerInfo.AddLoss(); } // start win/loss music if (winLossTrack != null) { winLossTrack.Play(AudioManager.GetInstance().GetEmitter(gameObject, winLossTrack)); } // setup listener for doneConfirmed event var confirmed = false; var listener = gameObject.AddComponent <GameEventListener>(); listener.SetEvent(doneConfirmed); listener.Response.AddListener(() => { confirmed = true; }); // instantiate modal for confirmation var panelGo = Instantiate(donePanelPrefab, GetCanvas().gameObject.transform); yield return(null); // wait a frame for panel initialization // trigger event to notify player that match is complete, // causes confirmation modal to display message and wait for player to click ok var msg = System.String.Format("{0}:{1}", (winningBot == spawnedPlayer) ? "win" : "loss", gameInfo.playerInfo.name); wantDoneConfirm.Raise(msg); // wait for match info to be selected yield return(new WaitUntil(() => confirmed)); if (winLossTrack != null) { winLossTrack.Stop(AudioManager.GetInstance().GetEmitter(gameObject, winLossTrack)); } // clean up, remove listener Destroy(panelGo); Destroy(listener); // signal that the match is done if (matchFinished != null) { matchFinished.Raise(); } }
IEnumerator StatePlayerSelect() { if (debug) { Debug.Log("StatePlayerSelect"); } // load panel var panelGo = Instantiate(playerSelectPanelPrefab, GetCanvas().gameObject.transform); yield return(null); // wait a frame for panel initialization string selectedPlayer = ""; bool cancelled = false; // create string event listener to listen for callback event from player select modal var listener = panelGo.AddComponent <StringEventListener>(); listener.SetEvent(playerSelected); listener.Response.AddListener((msg) => { selectedPlayer = msg; }); var geListener = panelGo.AddComponent <GameEventListener>(); geListener.SetEvent(cancelSelected); geListener.Response.AddListener(() => { cancelled = true; }); // get list of player save files, then serialize to a single string var savedPlayerNames = JsonStore.ListByTag(JsonStore.SaveTag.Player); string serializedPlayerNames = ""; if (savedPlayerNames.Length > 0) { serializedPlayerNames = string.Join(":", savedPlayerNames); } // trigger event to ask for player to be selected wantPlayerSelect.Raise(serializedPlayerNames); // wait for player to be selected yield return(new WaitUntil(() => selectedPlayer != "" || cancelled)); // clean up Destroy(panelGo); // go back to main menu if cancelled if (cancelled) { StartCoroutine(StateMainMenu()); // otherwise, advance, based on game state } else { // if player is selected from existing saved players... load that player if (System.Array.Exists(savedPlayerNames, element => element == selectedPlayer)) { var json = JsonStore.Load(JsonStore.SaveTag.Player, selectedPlayer); playerInfo = PlayerInfo.FromJson(json); // otherwise create and save new player record } else { playerInfo = new PlayerInfo(); playerInfo.name = selectedPlayer; JsonStore.Save(JsonStore.SaveTag.Player, selectedPlayer, playerInfo.ToJson()); } // transition to match select StartCoroutine(StateMatchSelect()); } }
public void OnConcedeClick() { onSelection.Raise("concede"); Hide(); }
public void RestartMatch() { CurrentMatchReference.Value.ResetStats(); OnReloadScene.Raise(Properties.Scenes.Game); }
public void RiseOnChange() { onChange?.Raise(Value); m_CurrentValue = Value; }