コード例 #1
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();
        }
    }
コード例 #2
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();
        }
    }
コード例 #3
0
    private void ShowNextMonster()
    {
        // incremenet monster index
        CurrentMonsterIndex = (CurrentMonsterIndex == Monsters.Length - 1) ? 0 : ++CurrentMonsterIndex;

        // update current monster
        CurrentMonster = Monsters[CurrentMonsterIndex];

        // set monster speed
        float towerHeight     = CurrentMonster.TowerTopY - CurrentMonster.TowerBottomY;
        int   heightInBubbles = CurrentMonster.BubblesToReachTop + CurrentMonster.BubblesToReachBottom;
        float monsterSpeed    = towerHeight / ((float)heightInBubbles);

        CurrentMonster.SetSpeed(monsterSpeed);

        // show monster
        Vector3 initialPosition = Vector3.zero;

        initialPosition.y = CurrentMonster.TowerBottomY + (monsterSpeed * CurrentMonster.BubblesToReachBottom);
        CurrentMonster.Show(initialPosition);

        Signal monsterShownSignal = GameSignals.ON_MONSTER_SHOWN;

        monsterShownSignal.ClearParameters();
        monsterShownSignal.AddParameter(GameParams.MONSTER_TYPE, CurrentMonster.Type);
        monsterShownSignal.AddParameter(GameParams.MONSTER_HP, CurrentMonster.HitPoints);
        monsterShownSignal.AddParameter(GameParams.MONSTER_MAX_HP, CurrentMonster.MaxHitPoints);
        monsterShownSignal.Dispatch();
    }
コード例 #4
0
        public void OnClickedButton(object data)
        {
            Signal signal = GameSignals.ON_CLICKED_BUTTON;

            signal.ClearParameters();
            signal.AddParameter(GameParams.BUTTON_TYPE, this.button);
            signal.AddParameter(GameParams.BUTTON_DATA, data);
            signal.Dispatch();
        }
コード例 #5
0
ファイル: Bubble.cs プロジェクト: ariessanchezsulit/mad-monk
        private void OnEnable()
        {
            this.bubbleType  = (EBubbleType)(0x1 << URandom.Range(0, 6));
            this.bubbleColor = (EBubbleColor)(0x1 << URandom.Range(0, 8));

            // add to pool
            Signal signal = GameSignals.ON_BUBBLE_ADDED_TO_POOL;

            signal.AddParameter(GameParams.BUBBLE, this.gameObject);
            signal.Dispatch();
        }
コード例 #6
0
        private void LateUpdate()
        {
            if (this.transform.position.y >= this.capPositionY)
            {
                // dispatch bubble missed
                //Signal signal = GameSignals.ON_BUBBLE_MISSED;
                //signal.Dispatch();

                // remove to pool
                Signal signal = GameSignals.ON_BUBBLE_REMOVED_TO_POOL;
                signal.AddParameter(GameParams.BUBBLE, this.gameObject);
                signal.Dispatch();
            }
        }