Ejemplo n.º 1
0
    /**
     * 结算处理
     * 结算:BalanceAction
     *      参数:1:Token 用户的seeion标示符
     *      返回:1:Result 结果(0表示成功,其他均是错误码,
     *      -1:用户异地登陆,须管理员先注销上次登陆ip,-2:Token不正确)
     *
     * */
    public void BalancAction(Action <object> callBack)
    {
        Dictionary <string, object> param = new Dictionary <string, object>();

        param.Add("token", UserModel.getInstance().UserVo.token);

        PopMaskMaskManager.show(0.5f);


        Action <object, object> action;

        action = (object data, object str) => {
            setVo = (SetVo)data;
            int result = setVo.result;            //System.Convert.ToInt32( data["Result"] );
            if (result == Config.CODE_SUCCESS)
            {
                UserModel.getInstance().UserVo.money = 0;
                if (callBack != null)
                {
                    callBack(result);
                }
            }

            PopMaskMaskManager.hide();
        };

        HttpLoadManager.getInstance.json <SetVo>("api/v1/users/balance", action, param);
    }
Ejemplo n.º 2
0
    /**
     * 充值:ChargeAction
     * 参数:1:Token 用户的seeion标示符
     * 2:Money 充值的金额
     * 返回:1:Result 结果(0表示成功,其他均是错误码,
     * -1:用户异地登陆,须管理员先注销上次登陆ip,-2:Token不正确)
     * 2:Money 返回用户充值完后,账户的总余额
     **/
    public void ChargeAction(int Money, Action <object> callBack)
    {
        Dictionary <string, object> param = new Dictionary <string, object>();

        param.Add("money", Money);
        param.Add("token", UserModel.getInstance().UserVo.token);

        PopMaskMaskManager.show(0.5f);
        //测试Action委托
        //Action<object> action;
        Action <object, object> action;

        action = (object data, object str) => {
            BaseVo baseVo = data as BaseVo;
            int    result = baseVo.result;         //System.Convert.ToInt32( data["Result"] );
            if (result == Config.CODE_SUCCESS)
            {
                //UserModel.getInstance().UserVo.money = UserModel.getInstance().UserVo.money + Money;
                JsonData json = JsonMapper.ToObject(str.ToString());
                UserModel.getInstance().UserVo.money = int.Parse(json["money"].ToString());

                if (callBack != null)
                {
                    callBack(result);
                }
            }

            PopMaskMaskManager.hide();
        };

        //Action action
        HttpLoadManager.getInstance.json <BaseVo>("api/v1/users/charge", action, param);
    }
Ejemplo n.º 3
0
    void betOkCallBack(object obj, object str)
    {
        int result = (int)obj;

        if (result == Config.CODE_SUCCESS)
        {
            int BenAmount = FightModel.getInstance().getBenAmount();


            //生产牌
            Dictionary <string, List <int> > CardsInfo = FightModel.getInstance().betVo.cardsInfo;
            List <int> MasterCards = CardsInfo["masterCards"]; MasterCards.Sort();          //默认List的排序是升序排序
            List <int> GuestCards  = CardsInfo["guestCards"]; GuestCards.Sort();

            //庄家的
            GameObject cardSpriteMaster = UITool.createUGUIImage("Sprite/sprite_CardSprite_" + MasterCards[0], Transform_CardSprite_MasterCards);
            cardSpriteMaster.transform.localPosition = new Vector3(-10, 0, 0);
            cardSpriteMaster.transform.localScale    = Vector3.one / 2;
            cardSpriteMaster = UITool.createUGUIImage("Sprite/sprite_CardSprite_" + MasterCards[1], Transform_CardSprite_MasterCards);
            cardSpriteMaster.transform.localPosition = new Vector3(10, 0, 0);
            cardSpriteMaster.transform.localScale    = Vector3.one / 2;
            //自己的
            GameObject cardSpriteGuest = UITool.createUGUIImage("Sprite/sprite_CardSprite_" + GuestCards[0], Transform_CardSprite_GuestCards);
            cardSpriteGuest.transform.localPosition = new Vector3(-10, 0, 0);
            cardSpriteGuest.transform.localScale    = Vector3.one / 2;
            cardSpriteGuest = UITool.createUGUIImage("Sprite/sprite_CardSprite_" + GuestCards[1], Transform_CardSprite_GuestCards);
            cardSpriteGuest.transform.localPosition = new Vector3(10, 0, 0);
            cardSpriteGuest.transform.localScale    = Vector3.one / 2;

            int[] compareResult = CardUtil.getCompareCards(MasterCards, GuestCards);
            Txt_Point_MasterCards.text = compareResult[0] + " 点";
            Txt_Point_GuestCards.text  = compareResult[1] + " 点";


            PopMaskMaskManager.show(0f);
            StartCoroutine(BetIEnumerator(compareResult[0], compareResult[1]));
        }
    }
Ejemplo n.º 4
0
    /**
     *      玩家下注:BetAction
     *      参数:1:Token 用户的seeion标示符
     *                2:GameId 游戏id,以后可能各种游戏集成
     *            3:BenAmount 当前下注的金额
     *      返回:1:Result 结果(0表示成功,其他均是错误码,
     *      -1:用户异地登陆,须管理员先注销上次登陆ip,-2:Token不正确
     *      1:用户当前下注金额超过设置最大金额
     *      )
     *                2:LoseAmount 该盘下注用户输赢多少钱
     *        2:CardsInfo 返回的游戏信息,不同游戏id,这个参数不一样
     *      {
     *      MasterCards:为数组,庄家的牌
     *      GuestCards:为数组,闲家即自己的牌
     *      }
     * */
    public void BetAction(Action <object, object> callBack)
    {
        Dictionary <string, object> param = new Dictionary <string, object>();

        param.Add("betAmount", BenAmount);
        param.Add("token", UserModel.getInstance().UserVo.token);
        param.Add("gameId", Config.GameId);

        PopMaskMaskManager.show(0.5f);
        //测试Action委托
        //Action<object> action;
        Action <object, object> action;

        action = (object data, object str) => {
            betVo = (BetVo)data;
            int result = betVo.result;            //System.Convert.ToInt32( data["Result"] );
            if (result == Config.CODE_SUCCESS)
            {
                UserModel.getInstance().UserVo.money = betVo.money;
                if (callBack != null)
                {
                    callBack(result, str);
                }
                return;
            }
            else if (result == 1)
            {
                PopMessageManager.show("current is max Bet");
            }

            PopMaskMaskManager.hide();
        };

        //Action action
        HttpLoadManager.getInstance.json <BetVo>("api/v1/users/bet", action, param);
    }
Ejemplo n.º 5
0
    /**
     * 登录
     * (一):
     *      登陆:LoginAction
     *      参数:1:UserName 用户名
     *            2:PassWaorld 密码(md5加密)
     *                3:MacAddress 用户的mac地址
     *            4:IPAddress  用户的ip地址(若服务器应该可以获取用户的ip地址,如果可以就
     *      不需要传输)
     *      返回:1:Result 结果(0表示成功,其他均是错误码,
     *      -1:用户异地登陆,须管理员先注销上次登陆ip,-2:Token不正确
     *      1:没有该用户,2:用户名错误)
     *        2:Token 用户的seeion标示符
     *                3:Money 如果上次用户还有钱没结算,吧剩余钱返回,否则为0即可
     * */
    public void LoginAction(string userName, string passWorld, Action <object, object> callBack)
    {
        PopMaskMaskManager.show(0.5f);

        Dictionary <string, object> param = new Dictionary <string, object>();

        //param.Add("Action","LoginAction");
        param.Add("username", userName);
        param.Add("password", passWorld);       //Util.getMD5CodeByString(passWorld));

        string ip = Util.getUserIp() + "";

        param.Add("macAddress", ip);
        param.Add("ipAddress", ip);

        //PopMessageManager.show ();
        //Echo.Log("mac:" + Util.getUserIp());
        //Echo.Log("passworld:" + Util.getMD5CodeByString(passWorld));

        /**
         * //测试Func委托
         * Func<Dictionary<string,string>, bool> fun;
         * fun = (Dictionary<string,string> data) => {
         *      int result = System.Convert.ToInt32( data["Result"] );
         *      if(result == Config.successCode){
         *              if(callBack != null ) callBack();
         *      }
         *
         *
         *      return false;
         * };
         **/


        //测试Action委托
        Action <object, object> actionFun;

        actionFun = (object data, object str) => {
            userVo = (UserVo)data;
            int result = userVo.result;             //System.Convert.ToInt32( data["Result"] );
            PopMaskMaskManager.hide();
            if (result == Config.CODE_SUCCESS)
            {
                userVo.nickName = "张三";
                userVo.userName = userName;
                PlayerPrefs.SetString("userName", userVo.userName);
                PlayerPrefs.SetString("nickName", userVo.nickName);
                if (callBack != null)
                {
                    callBack(result, str);
                }
            }
            else if (result == 1)
            {
                PopMessageManager.show("username is error");
            }
            else if (result == 2)
            {
                PopMessageManager.show("password is error");
            }
        };
        HttpLoadManager.getInstance.json <UserVo>("api/v1/login", actionFun, param);
    }