コード例 #1
0
    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();
        }
    }
コード例 #2
0
    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();
        }
    }
コード例 #3
0
 void OnGameStarted(ISignalParameters parameters)
 {
     if (connType == ConnectionType.SERVER)
     {
         CreateLocalGame();
     }
 }
コード例 #4
0
        private void OnPlaySFX(ISignalParameters parameters)
        {
            ESfx sfx = (ESfx)parameters.GetParameter(GameParams.AUDIO_ID);

            this.source.clip = this.audioMap[sfx];
            this.source.Play();
        }
コード例 #5
0
 private void OnEndGame(ISignalParameters @params)
 {
     this.StopAllCoroutines();
     this.started          = false;
     this.waveTotalTime    = 0.0f;
     this.waveTotalTimeInt = 0;
     this.wave             = 0;
 }
コード例 #6
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;
 }
コード例 #7
0
        void OnInputHostIP(ISignalParameters parameters)
        {
            if (connType != ConnectionType.CLIENT)
            {
                return;
            }

            hostIp = (string)parameters.GetParameter(GameParams.NETWORK_HOST_IP);
            JoinLocalGame(hostIp);
        }
コード例 #8
0
ファイル: UIRoot.cs プロジェクト: ariessanchezsulit/mad-monk
        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;
        }
コード例 #9
0
        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();
            }
        }
コード例 #10
0
ファイル: UIRoot.cs プロジェクト: ariessanchezsulit/mad-monk
        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);
        }
コード例 #11
0
    private void OnStartGame(ISignalParameters @params)
    {
        IsActive = true;

        // hide current monster if applicable
        HideCurrentMonster();

        // reset monster index
        CurrentMonsterIndex = -1;

        // show next monster
        ShowNextMonster();
    }
コード例 #12
0
        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);
            }
        }
コード例 #13
0
ファイル: UIRoot.cs プロジェクト: ariessanchezsulit/mad-monk
        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);
        }
コード例 #14
0
        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();
            }
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
ファイル: UIRoot.cs プロジェクト: ariessanchezsulit/mad-monk
 private void OnMonsterDead(ISignalParameters @params)
 {
     SetKillCount(KillCount + 1);
 }
コード例 #17
0
        void OnLogReceived(ISignalParameters parameters)
        {
            var text = (string)parameters.GetParameter(GameParams.DEBUG_TEXT);

            textDisplay.text += text + "\n";
        }
コード例 #18
0
 void OnGameEnded(ISignalParameters parameters)
 {
     DisableRecognizers();
 }
コード例 #19
0
 void OnGameStarted(ISignalParameters parameters)
 {
     InitializeRecognizers();
 }
コード例 #20
0
 private void OnPlayBGM(ISignalParameters parameters)
 {
     this.bgmSource.clip = this.bgm;
     this.bgmSource.loop = true;
     this.bgmSource.Play();
 }
コード例 #21
0
        void OnDisplayHostIp(ISignalParameters parameters)
        {
            var ip = (string)parameters.GetParameter(GameParams.NETWORK_HOST_IP);

            hostDisplay.text = "Host IP: " + ip;
        }