Ejemplo n.º 1
0
    public void handleBtnClick(INotifyData obj)
    {
        NotifyData <int> msg = obj as NotifyData <int>;

        if (msg != null)
        {
            GameModel    gameModel    = GameModel.getInstance();
            GameNotifier gameNotifier = GameNotifier.getInstance();

            bool needResult = false;

            //如果现在已经有数字, 加上去
            if (gameModel.opNumber > 0)
            {
                gameModel.opNumber += msg.data;
                needResult          = true;
            }
            else
            {
                gameModel.opNumber = msg.data;
            }

            //通知炮上的数字发生改变
            gameNotifier.notifydata((int)NotifyId.CANNON_NUMBER_CHANGE, gameModel.opNumber);

            //如果需要结算
            if (needResult)
            {
                handleOpResult();
            }
        }
    }
Ejemplo n.º 2
0
 void _NotifyEvent(INotifyObserver observer, string eventName, INotifyData data)
 {
     if (_observers.Contains(observer))
     {
         observer.onNotify(eventName, data);
     }
 }
Ejemplo n.º 3
0
 //暂停游戏
 private void stopGame(INotifyData obj)
 {
     if (_stoneBallObj != null)
     {
         Destroy(_stoneBallObj);
         _stoneBallObj = null;
     }
 }
Ejemplo n.º 4
0
    private void handleGamePrepareOk(INotifyData obj)
    {
        //初始化数据
        GameModel gameModel = GameModel.getInstance();

        gameModel.level = 1;
        gameModel.score = 0;
        startRound();
    }
Ejemplo n.º 5
0
    private void playButonPressedSound(INotifyData obj)
    {
        int soundIndex = (int)E_SOUND_ID.E_BUTTON_PRESSED_SOUND;

        if (_audioResources.Count > soundIndex)
        {
            _audioResources[soundIndex].Play();
        }
    }
Ejemplo n.º 6
0
    private void showStopMenu(INotifyData obj)
    {
        GameObject menu  = showScene(1, SceneLayerType.E_MENU_LAYER_TYPE);
        StopMenu   logic = menu.GetComponent <StopMenu>();

        if (logic != null)
        {
            logic.setGameEndDisplay(obj.id == (int)NotifyId.NOTIFY_SHOW_GAME_END);
        }
    }
Ejemplo n.º 7
0
        public void onNotify(string eventName, INotifyData data)
        {
            EmitterData info = data as EmitterData;

            Console.WriteLine(_name + "::onNotify : " + eventName + " / " + info._data);

            // The default behavior of this test transmitter would be
            // to propagate the event to observers who are looking at you.
            NotifyEvent(eventName, data);
        }
Ejemplo n.º 8
0
        public void NotifyEvent(string eventName, INotifyData data)
        {
            var info = data as EmitterData;

            if (_emitter.HasObserver())
            {
                Console.WriteLine("NotifyEvent : " + eventName + " / " + info._data);

                _emitter.NotifyEvent(eventName, data);
            }
        }
Ejemplo n.º 9
0
    private void startRound(INotifyData obj)
    {
        NotifyData <NotifyRoundStartMsg> msg = obj as NotifyData <NotifyRoundStartMsg>;

        //创建一个石球
        resetStoneBall(msg.data.result);

        cannon.clearNumber();

        //刷新按键数字
        numberBtnArea.refreshNumbers(msg.data.numbers);
    }
Ejemplo n.º 10
0
    public void NotifyEvent(string eventName, INotifyData data)
    {
        Queue <INotifyObserver> queue = new Queue <INotifyObserver>();

        _observers.ForEach((observer) => {
            queue.Enqueue(observer);
        });

        while (queue.Count > 0)
        {
            _NotifyEvent(queue.Dequeue(), eventName, data);
        }
    }
Ejemplo n.º 11
0
    private void onOpNumberChanged(INotifyData obj)
    {
        NotifyData <int> msg = obj as NotifyData <int>;

        if (msg.data <= 0)
        {
            numberText.text = "";
        }
        else
        {
            numberText.text = msg.data.ToString();
        }
    }
Ejemplo n.º 12
0
    private void handleBulletHit(INotifyData obj)
    {
        GameModel    gameModel    = GameModel.getInstance();
        GameNotifier gameNotifier = GameNotifier.getInstance();

        gameModel.score += 1;
        gameNotifier.notifydata((int)NotifyId.NOTIFY_SOCRE_UPDATE, gameModel.score);

        //每5分升一级
        if (gameModel.score > 0 && gameModel.score % 5 == 0)
        {
            gameModel.level += 1;
            gameNotifier.notifydata((int)NotifyId.NOTIFY_LEVEL_UPDATE, gameModel.level);
        }

        startRound();
    }
Ejemplo n.º 13
0
    private void showOpResult(INotifyData obj)
    {
        NotifyData <bool> notifyData = obj as NotifyData <bool>;

        //算对了
        if (notifyData.data == true)
        {
            //将炮移到数字的位置
            if (_stoneBallObj != null)
            {
                float x = _stoneBallObj.transform.localPosition.x;
                cannon.moveToX(x);
            }
            else
            {
                Debug.LogError("GameScene.showOpResult: _stoneBallObj is null");
            }
        }
        else
        {
            cannon.shake();
        }
    }
Ejemplo n.º 14
0
 private void handleStopGame(INotifyData obj)
 {
     GameNotifier.getInstance().notifyStateChange((int)NotifyId.NOTIFY_SHOW_STOP_MENU);
 }
Ejemplo n.º 15
0
    private void onLevelUpdate(INotifyData obj)
    {
        NotifyData <int> data = obj as NotifyData <int>;

        levelText.text = "LVL:" + data.data.ToString();
    }
Ejemplo n.º 16
0
    private void onScroeUpdate(INotifyData obj)
    {
        NotifyData <int> data = obj as NotifyData <int>;

        scoreText.text = data.data.ToString();
    }
Ejemplo n.º 17
0
 private void onGameStop(INotifyData obj)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 18
0
 //球落到地上了,游戏结束
 public void handleStoneFallingEnd(INotifyData obj)
 {
     GameNotifier.getInstance().notifyStateChange((int)NotifyId.NOTIFY_SHOW_GAME_END);
 }
Ejemplo n.º 19
0
 private void handleRestartGame(INotifyData obj)
 {
     handleGamePrepareOk(obj);
 }
Ejemplo n.º 20
0
 private void handleContinuGame(INotifyData obj)
 {
     startRound();
 }