Ejemplo n.º 1
0
    public void OnSellClick()
    {
        int result = WebService1.service.DeleteCloth(GameDataUtil.playerInfo.account_id, GameDataUtil.session, clothId);

        if (result == -1)
        {
            WarningUtil.ShowWarningWindow("非法请求");
        }
        else if (result == -2)
        {
            WarningUtil.ShowWarningWindow("数据请求错误");
        }
        else if (result == -3)
        {
            WarningUtil.ShowWarningWindow("出售失败");
        }
        else if (result == 1)
        {
            Destroy(this.gameObject);
            uiGrid.repositionNow = true;
            uiGrid.Reposition();
            GameDataUtil.MyCloth.Remove(clothId);
            WarningUtil.ShowWarningWindow("出售成功");
        }
    }
Ejemplo n.º 2
0
    public void OnBuyClick()
    {
        //购买装备的操作,需要向缓存层添加,需要修改服务端的数据库;
        if (GameDataUtil.playerInfo.money < int.Parse(lbPrice.text))
        {
            WarningUtil.ShowWarningWindow("你的金钱不足!");
            return;
        }
        //GameDataUtil.NewClothList.Add ( );
        Cloth cloth = WebService1.service.AddCloth(GameDataUtil.playerInfo.account_id, GameDataUtil.session, clothType, 1);

        if (cloth == null)
        {
            WarningUtil.ShowWarningWindow("购买失败!");
            return;
        }
        GameDataUtil.NewClothList.Add(cloth.id, cloth);//将新添加的数据保存到newClothList,
        GameDataUtil.MyCloth.Add(cloth.id, cloth);
        WarningUtil.ShowWarningWindow("购买成功!");
    }
Ejemplo n.º 3
0
    //登录界面的方法
    public void OnLoginClick_login()
    {
        string account  = accountInput.value;
        string passward = passwardInput.value;

        if (account == string.Empty || passward == string.Empty)
        {
            WarningUtil.ShowWarningWindow("请输入正确的账号与密码!");
            return;
        }
        //向服务器发送信息;
        zhezhao.SetActive(true);
        try
        {
            //向服务器发出信息。。
            string result = WebService1.Instance.login(account, passward);//连接服务器,并且返回当前登录的密钥。
            if (result == string.Empty)
            {
                WarningUtil.ShowWarningWindow("账号不存在!");
            }
            else if (result == "-1")
            {
                WarningUtil.ShowWarningWindow("密码错误!");
            }
            else
            {
                GameDataUtil.session = result;
                getPlayer();
                // ShowWarningWindow("登陆成功!"+result);
            }
        }
        catch
        {
            WarningUtil.ShowWarningWindow("服务器连接失败!");
        }
        finally
        {
            zhezhao.SetActive(false);
        }
    }
Ejemplo n.º 4
0
    //注册界面方法

    public void OnRegClick_reg()
    {
        string account  = r_accountInput.value.Trim();
        string passward = r_passwardInput.value.Trim();

        if (account == string.Empty || passward == string.Empty)
        {
            // Debug.Log("请输入正确的账号与密码!");
            WarningUtil.ShowWarningWindow("请输入正确的账号与密码!");
            return;
        }
        if (passward != r_passwardsureInput.value)
        {
            //Debug.Log("与输入的密码不一致!");
            WarningUtil.ShowWarningWindow("与输入的密码不一致!");
            return;
        }
        //屏蔽界面;
        zhezhao.SetActive(true);
        try
        {
            //向服务器发出信息。。
            bool result = WebService1.Instance.register(account, passward);
            if (result)
            {
                WarningUtil.ShowWarningWindow("注册成功!");
            }
            else
            {
                WarningUtil.ShowWarningWindow("注册失败!");
            }
        }
        catch
        {
            WarningUtil.ShowWarningWindow("服务器连接失败!");
        }finally
        {
            zhezhao.SetActive(false);
        }
    }
Ejemplo n.º 5
0
 public void createPlayer()
 {
     try
     {
         if (selected == -1)
         {
             //未选择角色
             WarningUtil.ShowWarningWindow("未选择角色");
             return;
         }
         if (nameInput.value == string.Empty || nameInput.value.Length > 6)
         {
             //昵称不合法
             WarningUtil.ShowWarningWindow("昵称不合法");
             return;
         }
         zhezhao.SetActive(true);
         Player player = WebService1.Instance.createPlayer(GameDataUtil.session, nameInput.value, codes[selected]);
         if (player == null)
         {
             zhezhao.SetActive(false);
             WarningUtil.ShowWarningWindow("角色创建失败!");
         }
         else
         {
             GameDataUtil.playerInfo = player;//保存角色数据
             //跳转至主场景
             Application.LoadLevel(2);
         }
     }
     catch
     {
         WarningUtil.ShowWarningWindow("服务器连接失败!");
     }finally
     {
         zhezhao.SetActive(false);
     }
 }
Ejemplo n.º 6
0
 void Start()
 {
     grid = transform.parent.GetComponent <UIGrid>();
     EventDelegate.Set(tavernBtn.onClick, () =>
     {
         //招募英雄
         GameDataUtil.playerInfo = WebService1.service.getPlayer(GameDataUtil.session);
         if (GameDataUtil.playerInfo.gold < int.Parse(lbGold.text))
         {
             WarningUtil.ShowWarningWindow("元宝不足!");
             return;
         }
         Card c = WebService1.service.AddCard(GameDataUtil.playerInfo.account_id, GameDataUtil.session, cardcode);
         if (c == null)
         {
             WarningUtil.ShowWarningWindow("招募失败");
             return;
         }
         GameDataUtil.NewCardList.Add(c.id, c);
         GameDataUtil.MyCard.Add(c.id, c);
         WarningUtil.ShowWarningWindow("招募成功");
     });
 }