private void OnBubbleMissed(ISignalParameters @params) { if (!IsActive) { return; } // raise monster CurrentMonster.Rise(); Signal monsterSummonedSignal = GameSignals.ON_MONSTER_SUMMONED; monsterSummonedSignal.ClearParameters(); monsterSummonedSignal.AddParameter(GameParams.MONSTER_HP, CurrentMonster.HitPoints); monsterSummonedSignal.AddParameter(GameParams.MONSTER_MAX_HP, CurrentMonster.MaxHitPoints); monsterSummonedSignal.Dispatch(); // check if monster has reached character bool isMonsterOnTop = CurrentMonster.YPosition >= CurrentMonster.TowerTopY; if (isMonsterOnTop) { IsActive = false; CurrentMonster.YPosition = CurrentMonster.MonkEatenY; // dispatch end game GameSignals.END_GAME.Dispatch(); } }
private void OnBubblePopped(ISignalParameters @params) { if (!IsActive) { return; } // lower monster CurrentMonster.Lower(); Signal monsterHitSignal = GameSignals.ON_MONSTER_HIT; monsterHitSignal.ClearParameters(); monsterHitSignal.AddParameter(GameParams.MONSTER_HP, CurrentMonster.HitPoints); monsterHitSignal.AddParameter(GameParams.MONSTER_MAX_HP, CurrentMonster.MaxHitPoints); monsterHitSignal.Dispatch(); // check if monster has been defeated bool monsterDefeated = CurrentMonster.YPosition < CurrentMonster.TowerBottomY; Debug.Log("monsterDefeated: " + monsterDefeated); if (monsterDefeated) { // kill current monster HideCurrentMonster(); // dispatch monster dead GameSignals.ON_MONSTER_DEAD.Dispatch(); // replace with new monster ShowNextMonster(); } }
void OnGameStarted(ISignalParameters parameters) { if (connType == ConnectionType.SERVER) { CreateLocalGame(); } }
private void OnPlaySFX(ISignalParameters parameters) { ESfx sfx = (ESfx)parameters.GetParameter(GameParams.AUDIO_ID); this.source.clip = this.audioMap[sfx]; this.source.Play(); }
private void OnEndGame(ISignalParameters @params) { this.StopAllCoroutines(); this.started = false; this.waveTotalTime = 0.0f; this.waveTotalTimeInt = 0; this.wave = 0; }
private void OnStartGame(ISignalParameters @params) { this.StopAllCoroutines(); this.StartCoroutine(this.GenerateBubble()); this.started = true; this.waveTotalTime = 0.0f; this.waveTotalTimeInt = 0; this.wave = 0; }
void OnInputHostIP(ISignalParameters parameters) { if (connType != ConnectionType.CLIENT) { return; } hostIp = (string)parameters.GetParameter(GameParams.NETWORK_HOST_IP); JoinLocalGame(hostIp); }
void UpdateGauge(ISignalParameters parameters) { float hp = (float)(int)parameters.GetParameter(GameParams.MONSTER_HP); float maxHp = (float)(int)parameters.GetParameter(GameParams.MONSTER_MAX_HP); float rectWidth = GaugeFillMaxWidth * Mathf.Clamp01(hp / maxHp); Vector2 sizeDelta = GaugeFillImage.rectTransform.sizeDelta; sizeDelta.x = rectWidth; GaugeFillImage.rectTransform.sizeDelta = sizeDelta; }
void OnGameEnded(ISignalParameters parameters) { if (connType == ConnectionType.SERVER) { this.StopHost(); Debug.Log("host stopped"); var networkSignal = GameSignals.NETWORK_STATUS_SIGNAL; networkSignal.AddParameter(GameParams.NETWORK_STATUS, "Host Stopped"); networkSignal.Dispatch(); networkSignal.ClearParameters(); } }
private void OnMonsterShown(ISignalParameters parameters) { if (GaugeIcon != null) { GaugeIcon.SetActive(false); } MonsterType monsterType = (MonsterType)parameters.GetParameter(GameParams.MONSTER_TYPE); GaugeIcon = MonsterIcons.Find(mi => mi.Type == monsterType).Icon; GaugeIcon.SetActive(true); UpdateGauge(parameters); }
private void OnStartGame(ISignalParameters @params) { IsActive = true; // hide current monster if applicable HideCurrentMonster(); // reset monster index CurrentMonsterIndex = -1; // show next monster ShowNextMonster(); }
private void ProcessInput(ISignalParameters parameters, bool isLocal) { GestureType gesture = (GestureType)parameters.GetParameter(GameParams.INPUT_TYPE); if (gesture == GestureType.SWIPE) { SwipePayload swipePayload = (SwipePayload)parameters.GetParameter(GameParams.INPUT_SWIPE_PAYLOAD); this.PopBubble(gesture, swipePayload.direction); } else { this.PopBubble(gesture); } }
private void OnGameEnd(ISignalParameters @params) { ResultsKillCountText.text = KillCount.ToString("N0"); int currHighScore = PlayerPrefs.GetInt("HighScore", 0); if (KillCount > currHighScore) { currHighScore = KillCount; PlayerPrefs.SetInt("HighScore", KillCount); } ResultsHighestKillCountText.text = string.Format("Best: {0}", currHighScore.ToString("N0")); ResultsScreen.SetActive(true); }
void OnNetworkStatusReceived(ISignalParameters parameters) { var status = (string)parameters.GetParameter(GameParams.NETWORK_STATUS); networkStatusDisplay.text = string.Format("Connection status: {0}", status); if (status.Contains("success")) { OnJoinSuccess(); } else if (status.Contains("Stopped")) { OnHostStopped(); } else { OnJoinFailed(); } }
void OnInputReceived(ISignalParameters parameters) { if (isLocalPlayer) { var type = (GestureType)parameters.GetParameter(GameParams.INPUT_TYPE); string textToDisplay = ""; switch (type) { case GestureType.TAP: var pos = (Vector2)parameters.GetParameter(GameParams.INPUT_TAP_POS); // server already dispatches this on its side if (!isServer) { CmdDispatchTap(pos); } CmdSpawnTapEffectToServer(pos); textToDisplay = string.Format("{0} Gesture detected!", type.ToString()); break; case GestureType.SWIPE: var payload = (SwipePayload)parameters.GetParameter(GameParams.INPUT_SWIPE_PAYLOAD); // server already dispatches this on its side if (!isServer) { CmdDispatchSwipe(payload); } CmdSpawnSwipeEffectToServer(payload); textToDisplay = string.Format("Swipe detected! direction: {0}, startPos: {1}, endPos: {2}, velocity: {3}", payload.direction.ToString(), payload.startScreenPos, payload.endScreenPos, payload.velocity); break; case GestureType.PINCH: if (!isServer) { CmdDispatchPinch(); } textToDisplay = string.Format("{0} Gesture detected!", type.ToString()); break; case GestureType.LONG_PRESS: if (!isServer) { CmdDispatchLongPress(); } textToDisplay = string.Format("{0} Gesture detected!", type.ToString()); break; default: textToDisplay = string.Format("{0} Gesture detected!", type.ToString()); break; } //display only to client screen if (!isServer) { DispatchText(textToDisplay); } //display only to server screen CmdDispatchTextToServer(textToDisplay); } }
private void OnMonsterDead(ISignalParameters @params) { SetKillCount(KillCount + 1); }
void OnLogReceived(ISignalParameters parameters) { var text = (string)parameters.GetParameter(GameParams.DEBUG_TEXT); textDisplay.text += text + "\n"; }
void OnGameEnded(ISignalParameters parameters) { DisableRecognizers(); }
void OnGameStarted(ISignalParameters parameters) { InitializeRecognizers(); }
private void OnPlayBGM(ISignalParameters parameters) { this.bgmSource.clip = this.bgm; this.bgmSource.loop = true; this.bgmSource.Play(); }
void OnDisplayHostIp(ISignalParameters parameters) { var ip = (string)parameters.GetParameter(GameParams.NETWORK_HOST_IP); hostDisplay.text = "Host IP: " + ip; }