Example #1
0
    public void OnBuyRole(int index)
    {
        int id = roles[index];

        int cost = ConfigRoleManager.Instance().allDatas[id].cost;

        int price = cost - zhekou;

        if (playerModel.SetMoney(-price))
        {
            roles[index] = 0; //买了后 id 设置为0

            playerModel.AddRolePre(id);

            EventManager.ExecuteEvent(EventType.ShopDataUpdate);
        }
        else
        {
            WndTips.ShowTips("您的余额不足以购买该角色!");
        }
    }