Ejemplo n.º 1
0
    private void OnFetchUserInfoHandler(NEvent evt)
    {
        SFSObject obj = evt.BaseEvt.Params["params"] as SFSObject;

        print(obj.GetUtfString("zone"));
        print(obj.GetInt("id"));
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 拿到底牌,加入手牌
    /// </summary>
    /// <param name="evt"></param>
    private void GetExtCardsHandler(NEvent evt)
    {
        print("GetExtCards");
        evt.Data.GetUtfStringArray("ExtCards");

        for (int i = evt.Data.GetUtfStringArray("ExtCards").Length - 1; i >= 0; i--)
        {
            Card go = Instantiate(M_card);

            go.Value = evt.Data.GetUtfStringArray("ExtCards")[i];
            //Debug.Log(go.Color + "," + go.Number);
            go.transform.SetParent(GameObject.Find("CardParent").transform);
            go.transform.localScale = Vector3.one;
            go.name = "Card_" + go.Value;

            go.gameObject.SetActive(false);

            go.OnClickHandler = OnCardSelectHandler;
            cards.Add(go);
        }

        cards.Sort();

        RepositionExtCard();
    }
Ejemplo n.º 3
0
 /// <summary>
 /// 游戏大区连接成功回调
 /// </summary>
 /// <param name="evt"></param>
 private void UserLogin(NEvent evt)
 {
     Global.Log("用户登录连接成功");
     //储存自己
     Global.me = evt.BaseEvt.Params["user"] as User;
     SceneManager.LoadScene("ModeSelect");
 }
Ejemplo n.º 4
0
    private void onFetchBoardListHandler(NEvent evt)
    {
        int count = evt.Data.GetInt("count");



        SFSArray list = (SFSArray)evt.Data.GetSFSArray("list");

        //获取数据容器
        RectTransform grid   = content.transform.Find("scrollRect/grid") as RectTransform;
        RectTransform prefab = content.transform.Find("scrollRect/templete") as RectTransform;

        while (grid.childCount > 0)
        {
            Destroy(grid.GetChild(0).gameObject);
        }


        grid.sizeDelta = new Vector2(grid.sizeDelta.x, (prefab.sizeDelta.y + 10) * count);
        for (int i = 0; i < count; i++)
        {
            RectTransform item = Instantiate <RectTransform>(prefab, grid);
            item.gameObject.SetActive(true);
        }
    }
Ejemplo n.º 5
0
    public void OnFoul(NEvent e)
    {
        Pawn p1 = ((Foul)e).player1;
        Pawn p2 = ((Foul)e).player2;

        Debug.Log($"Foul between {p1.name} and {p2.name}.");
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 从服务器拿到用户的信息
    /// </summary>
    /// <param name="evt"></param>
    private void UserInfoGet(NEvent evt)
    {
        SFSObject obj = evt.Data;


        Global.user_nick = obj.GetUtfString("usernick");
        Global.user_gold = int.Parse(obj.GetUtfString("gold"));
        Global.user_quan = int.Parse(obj.GetUtfString("quan"));

        print("金币数量为:" + Global.user_gold);
        print("用户昵称为:" + Global.user_nick);
        print("用户礼券数量为:" + Global.user_quan);

        gold.text = Global.user_gold.ToString();

        quan.text = Global.user_quan.ToString();

        usernick.text = Global.user_nick;

        m_gold.text     = gold.text;
        m_quan.text     = quan.text;
        m_usernick.text = usernick.text;

        signature.text = obj.GetUtfString("personalwords");
    }
Ejemplo n.º 7
0
    private void OnUserVariableHandler(NEvent evt)
    {
        User user = evt.BaseEvt.Params["user"] as User;

        try
        {
            if (!user.IsItMe && user.Name == this.name)
            {
                ///同步位移
                if (user.ContainsVariable("position"))
                {
                    SFSObject so = (SFSObject)user.GetVariable("position").Value;
                    this.transform.position = Vector3.Lerp(this.transform.position, new Vector3((float)so.GetDouble("x"), (float)so.GetDouble("y"), (float)so.GetDouble("z")), Time.deltaTime * 10);
                }

                ///同步旋转
                if (user.ContainsVariable("rotation"))
                {
                    SFSObject so = (SFSObject)user.GetVariable("rotation").Value;

                    this.transform.eulerAngles = new Vector3(0, (float)so.GetDouble("y"), 0);
                }
            }
        }
        catch (Exception e)
        {
            print("出错" + e.Message);
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// 自定义扩展事件
    /// </summary>
    /// <param name="evt">事件对象</param>
    private void OnExtensionHandler(BaseEvent evt)
    {
        string cmd = (string)evt.Params["cmd"];
        NEvent e   = new NEvent(evt.Target, cmd, evt);

        EventManager.GetInstance().DispatchEvent(e);
    }
        public async Task <RequestResult> Handle(CreateEventCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var nEvent = new NEvent
                {
                    Description = request.Description,
                    EndDate     = request.EndDate,
                    StartDate   = request.StartDate,
                    EventName   = request.EventName,
                    EventId     = request.EventId
                };
                var result = _unitOfWork.NEvent.Add(nEvent);

                await _unitOfWork.CompleteAsync();

                await _mediator.Publish(new NEventCreated {
                    NEventName = nEvent.EventName
                }
                                        );

                return(await RequestResult.Success());
            }
            catch (Exception ex)
            {
                return(RequestResult.Error(new Exception("There was an error creating the Event", ex)));
            }
        }
Ejemplo n.º 10
0
    private void CallBack(NEvent evt)
    {
        SFSObject obj  = evt.Data;
        string    info = obj.GetUtfString("info");

        Debug.Log(info);
    }
Ejemplo n.º 11
0
 public void DispatchEvent(NEvent note)
 {
     if (eventListeners.ContainsKey(note.Type))
     {
         eventListeners[note.Type](note);
     }
 }
Ejemplo n.º 12
0
 public void StartPlay(NEvent e)
 {
     HideUI();
     timeText.enabled      = true;
     redScoreText.enabled  = true;
     blueScoreText.enabled = true;
 }
Ejemplo n.º 13
0
    /// <summary>
    /// 服务器发给客户端任务内容
    /// </summary>
    /// <param name="evt"></param>
    private void MaskInfoHandler(NEvent evt)
    {
        print(evt.Data.GetUtfString("mask"));

        evt.Data.GetUtfStringArray("mask1");
        print(evt.Data.GetUtfStringArray("mask1")[1]);
        mask.SetActive(true);
    }
Ejemplo n.º 14
0
    /// <summary>
    /// 获取背包信息
    /// </summary>
    /// <param name="evt"></param>
    private void GetBackpackMessageHandler(NEvent evt)
    {
        print("拿到背包信息");

        string lv = evt.Data.GetUtfString("gamelv");

        print(lv);
    }
Ejemplo n.º 15
0
    /// <summary>
    /// 修改用户信息成功回调
    /// </summary>
    /// <param name="evt"></param>
    private void UserInfoChanged(NEvent evt)
    {
        print("!---------修改信息成功-----------!");

        m_usernick.text = evt.Data.GetUtfString("usernick");
        usernick.text   = evt.Data.GetUtfString("usernick");
        print(m_usernick.text);
    }
Ejemplo n.º 16
0
    /// <summary>
    /// SmartFoxServer系统事件
    /// </summary>
    /// <param name="evt"></param>
    private void OnSFSEventHandler(BaseEvent evt)
    {
        object target = evt.Target;
        string cmd    = evt.Type.ToString();
        NEvent e      = new NEvent(target, cmd, evt);

        EventManager.GetInstance().DispatchEvent(e);
    }
Ejemplo n.º 17
0
 public void Unpause(NEvent e)
 {
     foreach (Pawn pawn in pawns)
     {
         pawn.Unpause();
     }
     _referee.Unpause();
 }
Ejemplo n.º 18
0
 public void OnPause(NEvent e)
 {
     foreach (Pawn pawn in pawns)
     {
         pawn.Pause();
     }
     _referee.Pause();
 }
Ejemplo n.º 19
0
    private void RoomMassageHandler(NEvent evt)
    {
        Global.multi     = evt.Data.GetInt("Multi");
        Global.grade     = evt.Data.GetInt("Grade");
        Global.matchName = evt.Data.GetUtfString("MatchName");

        print(Global.matchName);
    }
Ejemplo n.º 20
0
    /// <summary>
    /// 扩展函数处理
    /// </summary>
    /// <param name="evt">事件类型</param>
    private void OnExtensionHandler(BaseEvent evt)
    {
        //通讯指令
        string    cmd  = (string)evt.Params["cmd"];
        SFSObject data = (SFSObject)evt.Params ["params"];
        NEvent    e    = new NEvent(evt.Target, cmd, data, evt);

        Global.EvtMgr.DispatchEvent(e);
    }
Ejemplo n.º 21
0
 private void OnJoinGameHandler(NEvent evt)
 {
     if (evt.Data.GetBool("success"))
     {
         Global.GetInstance().LoadScene("Game", (string sn) => {
             UIManager.GetInstance().SwitchUI("GameUI");
         });
     }
 }
Ejemplo n.º 22
0
    public void Fire(NEvent e)
    {
        var type = e.GetType();

        if (_registeredHandlers.TryGetValue(type, out var handlers))
        {
            handlers(e);
        }
    }
Ejemplo n.º 23
0
    /// <summary>
    /// GetUserInfo拓展的回调,获取到用户信息
    /// </summary>
    /// <param name="evt"></param>
    private void UserInfoGet(NEvent evt)
    {
        SFSObject obj = evt.Data;

        print("金币数量为:" + obj.GetUtfString("gold"));
        print("用户昵称为:" + obj.GetUtfString("usernick"));
        print("用户VIP等级为:" + obj.GetUtfString("viplv"));
        print("用户礼券数量为:" + obj.GetUtfString("quan"));
    }
Ejemplo n.º 24
0
    /// <summary>
    /// 系统事件监听
    /// </summary>
    /// <param name="evt"></param>
    private void OnSFSEventHandler(BaseEvent evt)
    {
        object    target = evt.Target;
        string    cmd    = evt.Type.ToString();
        SFSObject data   = evt.Params ["params"] as SFSObject;
        NEvent    e      = new NEvent(target, cmd, data, evt);

        ///派发系统事件
        Global.EvtMgr.DispatchEvent(e);
    }
Ejemplo n.º 25
0
    /// <summary>
    /// 游戏结束处理
    /// </summary>
    /// <param name="evt"></param>
    private void GameOverHandler(NEvent evt)
    {
        Destroy(GameObject.Find("DCardParent"));
        start_sign.gameObject.SetActive(false);
        print("本场游戏结束");
        gameoversign.SetActive(true);

        btn_send.gameObject.SetActive(false);
        btn_sendNo.gameObject.SetActive(false);
    }
Ejemplo n.º 26
0
    private void JoinRoom(NEvent evt)
    {
        print("进入房间成功");
        print("向服务器发送RoomExt");
        //Global.SendExtMessage("test", new SFSObject(), Global.SFS.LastJoinedRoom);
        //Global.NetMgr.SFS.Send(new ExtensionRequest("test",new SFSObject(),Global.NetMgr.SFS.LastJoinedRoom,true));

        print("我要跳啦!进入game场景");
        SceneManager.LoadScene("game");
    }
Ejemplo n.º 27
0
    /// <summary>
    /// 服务器开始游戏的回调,给玩家发牌
    /// </summary>
    /// <param name="evt"></param>
    private void GameStartHandler(NEvent evt)
    {
        O1.SetActive(true);
        O2.SetActive(true);

        other1nick.text = evt.Data.GetUtfString("other1");
        other2nick.text = evt.Data.GetUtfString("other2");
        evt.Data.GetUtfString("other1");
        print("Other1:" + evt.Data.GetUtfString("other1"));

        evt.Data.GetUtfString("other2");
        print("Other2:" + evt.Data.GetUtfString("other2"));

        print("游戏开始,发牌给各位玩家。");
        start_sign.SetActive(true);

        int cl = evt.Data.GetUtfStringArray("PlayersHandCard").Length;

        cards = new List <Card>();
        for (int i = evt.Data.GetUtfStringArray("PlayersHandCard").Length - 1; i >= 0; i--)
        {
            Card go = Instantiate(M_card);

            go.Value = evt.Data.GetUtfStringArray("PlayersHandCard")[i];
            //Debug.Log(go.Color + "," + go.Number);
            go.transform.SetParent(GameObject.Find("CardParent").transform);
            go.transform.localScale = Vector3.one;
            go.name = "Card_" + go.Value;

            go.gameObject.SetActive(false);

            go.OnClickHandler = OnCardSelectHandler;
            cards.Add(go);
        }
        cards.Sort();

        for (int i = 0; i < cards.Count; i++)
        {
            Card go = cards[i];

            go.GetComponent <UIPanel>().depth = i + cards.Count;
            go.transform.localPosition        = new Vector3(55 * i, go.transform.parent.position.y, go.transform.parent.position.z);
            go.gameObject.SetActive(true);
            if (Input.GetMouseButtonDown(0))
            {
                go.transform.localPosition += Vector3.up * 10;
            }
            else
            {
                go.transform.localPosition -= Vector3.up * 10;
            }
        }
        // CallLord.gameObject.SetActive(true);
        //CallLordNo.gameObject.SetActive(true);
    }
Ejemplo n.º 28
0
    /// <summary>
    /// 房间人数已满调用
    /// </summary>
    /// <param name="evt"></param>
    private void RoomIsFullHandler(NEvent evt)
    {
        //Room gameroom = (Room)evt.Data.GetSFSObject("GameRoom");
        //Global.NetMgr.SFS.LastJoinedRoom = gameroom;
        string gameroomname = evt.Data.GetUtfString("GameRoomName");

        Global.SendSFSMessage(new JoinRoomRequest(gameroomname));

        Global.isGameStart = true;
        IsGameOrWait();
    }
Ejemplo n.º 29
0
    public void Start(NEvent e)
    {
        SpawnTeam(Services.SceneObjectIndex.pawnStartPositionsRed, Services.SceneObjectIndex.pawnPrefabRed, false);
        SpawnTeam(Services.SceneObjectIndex.pawnStartPositionsBlue, Services.SceneObjectIndex.pawnPrefabBlue, true);

        _referee = SpawnPawn(Services.SceneObjectIndex.refereeSpawnTransform, Services.SceneObjectIndex.refereePrefab.GetComponent <Pawn>()).GetComponent <Referee>();

        Services.EventManager.Register <PauseEvent>(OnPause);
        Services.EventManager.Register <UnpauseEvent>(Unpause);
        Services.EventManager.Register <Foul>(OnFoul);
    }
Ejemplo n.º 30
0
    /// <summary>
    /// 用户推出房间
    /// </summary>
    /// <param name="evt"></param>
    private void OnUserExitRoomHandler(NEvent evt)
    {
        User u = evt.BaseEvt.Params["user"] as User;

        print("用户梨花开" + u.Name);
        if (mUsers.ContainsKey(u.Name))
        {
            GameObject go = mUsers[u.Name];
            mUsers.Remove(u.Name);
            Destroy(go);
        }
    }