コード例 #1
0
        void Start()
        {
            rollBtn.interactable = false;
            rollBtn.onClick.AddListener(() =>
            {
                if (!TryToConnect())
                {
                    return;
                }
                _goldModule.CmdRollDice();
                _energyModule.CmdRollDice();
            });

            EventManager.StartListening(Constants.EVENT_REFEREE_CLIENT_ENDTURNED, new Action <uint>((turningCharacterNetId) => {
                if (!TryToConnect())
                {
                    return;
                }
                if (_character.netId.Value == turningCharacterNetId)
                {
                    rollBtn.interactable = true;
                }
                else
                {
                    rollBtn.interactable = false;
                }
            }));

            EventManager.StartListening(Constants.EVENT_GOLD_CHANGED, new Action <float, uint>((gold, ownNetId) =>
            {
                if (!TryToConnect())
                {
                    return;
                }
                if (_character.netId.Value != ownNetId)
                {
                    return;
                }
                goldTxt.text = Mathf.RoundToInt(gold).ToString();
            }));

            EventManager.StartListening(Constants.EVENT_ENERGY_CHANGED, new Action <float, uint>((energy, ownNetId) =>
            {
                if (!TryToConnect())
                {
                    return;
                }
                if (_character.netId.Value != ownNetId)
                {
                    return;
                }
                energyTxt.text = Mathf.RoundToInt(energy).ToString();
            }));

            EventManager.StartListening(Constants.EVENT_GOLD_DICE_ROLLED, new Action <int, uint>((dice, ownNetId) =>
            {
                if (!TryToConnect())
                {
                    return;
                }
                if (_character.netId.Value != ownNetId)
                {
                    return;
                }
                goldDiceTxt.text = dice.ToString();
            }));

            EventManager.StartListening(Constants.EVENT_ENERGY_DICE_ROLLED, new Action <int, uint>((dice, ownNetId) =>
            {
                if (!TryToConnect())
                {
                    return;
                }
                if (_character.netId.Value != ownNetId)
                {
                    return;
                }
                energyDiceTxt.text = dice.ToString();
            }));
        }
コード例 #2
0
ファイル: TabContent.cs プロジェクト: khiemnd777/Mob
 void Start()
 {
     EventManager.StartListening(Constants.EVENT_TAB_CONTENT_FIRED, new Action <string>(OnVisible));
 }